placer works... the breaker tho...

This commit is contained in:
Flanks255 2022-04-03 15:18:46 -05:00
parent 327fdc5c3b
commit 30e8137c04
5 changed files with 27 additions and 9 deletions

View file

@ -34,9 +34,14 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
this.isPlacer = isPlacer;
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
//@Override
public TileEntity newBlockEntity(IBlockReader world) {
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return this.isPlacer
? new TileEntityPlacer()
: new TileEntityBreaker();
@ -45,7 +50,7 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) {
return ActionResultType.PASS;
return ActionResultType.CONSUME;
}
return this.openGui(world, player, pos, TileEntityBreaker.class);

View file

@ -132,7 +132,7 @@ public abstract class BlockContainerBase extends Block {
}
}
@Override
@Override //TODO do we need this?
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
this.neighborsChangedCustom(worldIn, pos);
}
@ -140,7 +140,7 @@ public abstract class BlockContainerBase extends Block {
@Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
super.onNeighborChange(state, world, pos, neighbor);
if (world instanceof World) {
if (world instanceof World) { //TODO what?
this.neighborsChangedCustom((World) world, pos);
}
}

View file

@ -15,6 +15,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
@ -36,6 +37,13 @@ public class GuiBreaker extends AAScreen<ContainerBreaker> {
this.imageHeight = 93 + 86;
}
@Override
public void init(Minecraft pMinecraft, int pWidth, int pHeight) {
super.init(pMinecraft, pWidth, pHeight);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override
protected void renderBg(@Nonnull MatrixStack matrices, float partialTicks, int x, int y) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -29,9 +29,11 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.fluids.IFluidBlock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
@ -125,9 +127,10 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements INamed
this.doWork();
}
@Nonnull
@Override
public ITextComponent getDisplayName() {
return StringTextComponent.EMPTY;
return new TranslationTextComponent(isPlacer ? "container.actuallyadditions.placer" : "container.actuallyadditions.breaker");
}
@Nullable

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.util;
import com.sun.javafx.geom.Vec3d;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditionsClient;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
@ -196,11 +197,12 @@ public final class WorldUtil {
if (fake.connection == null) {
fake.connection = new NetHandlerSpaghettiServer(fake);
}
ItemStack heldBefore = fake.getMainHandItem();
//ItemStack heldBefore = fake.getMainHandItem();
setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, stack.copy());
//fake.gameMode.useItemOn(fake, world, fake.getMainHandItem(), Hand.MAIN_HAND, offsetPos, side.getOpposite(), 0.5F, 0.5F, 0.5F); //TODO
BlockRayTraceResult ray = new BlockRayTraceResult(new Vector3d(0.5, 0.5, 0.5), side.getOpposite(), offsetPos, true);
fake.gameMode.useItemOn(fake, world, fake.getMainHandItem(), Hand.MAIN_HAND, ray);
ItemStack result = fake.getItemInHand(Hand.MAIN_HAND);
setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, heldBefore);
//setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, heldBefore);
return result;
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Something that places Blocks at " + offsetPos.getX() + ", " + offsetPos.getY() + ", " + offsetPos.getZ() + " in World " + world.dimension() + " threw an Exception! Don't let that happen again!", e);