From d871e46b9f689970021d1414b6809f15751f7d05 Mon Sep 17 00:00:00 2001 From: Vaern Date: Tue, 16 May 2023 19:58:15 -0700 Subject: [PATCH] Fixes o'plenty, nearing completion --- .../hbm/blocks/machine/PistonInserter.java | 19 ++++++++++++++++--- .../pile/BlockGraphiteDrilledBase.java | 4 +++- .../machine/pile/BlockGraphiteFuel.java | 10 +++++++--- .../machine/pile/TileEntityPileFuel.java | 8 +++----- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java index 70defcb86..8dd6114df 100644 --- a/src/main/java/com/hbm/blocks/machine/PistonInserter.java +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -16,6 +16,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -179,7 +180,7 @@ public class PistonInserter extends BlockContainerBase { @SideOnly(Side.CLIENT) public double renderExtend; @SideOnly(Side.CLIENT) public double lastExtend; @SideOnly(Side.CLIENT) private int syncExtend; //what are these for? - @SideOnly(Side.CLIENT) private int turnProgress; //idk man, i can't find the convo bob had about them + @SideOnly(Side.CLIENT) private int turnProgress; public TileEntityPistonInserter() { } @@ -271,7 +272,7 @@ public class PistonInserter extends BlockContainerBase { this.extend = nbt.getInteger("extend"); this.isRetracting = nbt.getBoolean("retract"); this.lastState = nbt.getBoolean("state"); - if(nbt.hasKey("stack")) { //TODO double check that these work + if(nbt.hasKey("stack")) { NBTTagCompound stack = nbt.getCompoundTag("stack"); this.slot = ItemStack.loadItemStackFromNBT(stack); } else { @@ -279,7 +280,19 @@ public class PistonInserter extends BlockContainerBase { } } - //TODO: render AABB that extends out in direction of piston so it will render + @SideOnly(Side.CLIENT) + private AxisAlignedBB aabb; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + + if(aabb != null) + return aabb; + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); + aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).addCoord(dir.offsetX, dir.offsetY, dir.offsetZ); + return aabb; + } /* BS inventory stuff */ diff --git a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java index 19adfb63e..58ec7bce2 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java @@ -201,13 +201,15 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements newTag.setInteger("z", te.zCoord + dir.offsetZ); } - world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 2); + world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 0); if(oldBlock instanceof BlockGraphiteDrilledTE && !oldTag.hasNoTags()) { //safety first TileEntity te = world.getTileEntity(ix, iy, iz); te.readFromNBT(oldTag); } + world.markAndNotifyBlock(ix, iy, iz, world.getChunkFromBlockCoords(ix, iz), newBlock, oldBlock, 3); //in case setBlock returns false due to = meta / block + oldMeta = newMeta; oldBlock = newBlock; oldTag = newTag; diff --git a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java index 74281a5e3..cc98534da 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java @@ -24,8 +24,12 @@ import net.minecraftforge.common.util.ForgeDirection; public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolable, IBlowable { @Override - public TileEntity createNewTileEntity(World world, int mets) { - return new TileEntityPileFuel(); + public TileEntity createNewTileEntity(World world, int meta) { + TileEntityPileFuel pile = new TileEntityPileFuel(); + if((meta & 8) != 0) + pile.progress = pile.maxProgress - 1000; // pu239 rods cringe :( + + return pile; } @Override @@ -41,7 +45,7 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab } @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { //serverside? maybe + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { TileEntityPileFuel pile = (TileEntityPileFuel)world.getTileEntity(x, y, z); return MathHelper.clamp_int((pile.progress * 16) / pile.maxProgress, 0, 15); //potentially wip } diff --git a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java index 7b00d14e2..15233ad0c 100644 --- a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java +++ b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java @@ -18,7 +18,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr public int neutrons; public int lastNeutrons; public int progress; - public static final int maxProgress = GeneralConfig.enable528 ? 75000 : 50000; + public static final int maxProgress = GeneralConfig.enable528 ? 75000 : 50000; //might double to reduce compact setup's effectiveness @Override public void updateEntity() { @@ -79,10 +79,8 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr private void checkRedstone(int lastProgress) { int lastLevel = MathHelper.clamp_int((lastProgress * 16) / maxProgress, 0, 15); int newLevel = MathHelper.clamp_int((progress * 16) / maxProgress, 0, 15); - if(lastLevel != newLevel) //TODO TEST - System.out.println(lastLevel + ", " + newLevel + "; " + lastProgress + ", " + progress); - if(lastLevel != newLevel) //the block update doesn't seem to update the comparators... need to troubleshoot and fix - worldObj.scheduleBlockUpdate(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1); //TODO test + if(lastLevel != newLevel) + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType()); } private void transmute() {