From f6f1c1c380e35c6acefeaf52677631210fb5ae59 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sat, 28 Jun 2025 23:50:45 +0300 Subject: [PATCH 01/12] Turn presses into pseudomultiblocks Affects burner and electrical press. They seem to have been implemented largely based on copy-pasted furnace code, and seemingly predate BlockDummyable. That meant the top two blocks of a press were intangible. Now they're in line with the rest of the machines, including the conveyor press. --- .../com/hbm/blocks/machine/MachineEPress.java | 91 +++++-------------- .../com/hbm/blocks/machine/MachinePress.java | 81 +++-------------- 2 files changed, 38 insertions(+), 134 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index 465ea6c69..42cb7713f 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -2,6 +2,7 @@ package com.hbm.blocks.machine; import java.util.Random; +import com.hbm.blocks.BlockDummyable; import com.hbm.main.MainRegistry; import com.hbm.tileentity.machine.TileEntityMachineEPress; import com.hbm.world.gen.INBTTransformable; @@ -20,10 +21,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -public class MachineEPress extends BlockContainer implements INBTTransformable { - - private final Random field_149933_a = new Random(); - private static boolean keepInventory; +public class MachineEPress extends BlockDummyable implements INBTTransformable { public MachineEPress(Material p_i45386_1_) { super(p_i45386_1_); @@ -35,75 +33,27 @@ public class MachineEPress extends BlockContainer implements INBTTransformable { } @Override - public int getRenderType() { - return -1; + public int[] getDimensions() { + return new int[] {2, 0, 0, 0, 0, 0}; } @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { - if(!keepInventory) { - ISidedInventory tileentityfurnace = (ISidedInventory) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); - - if(tileentityfurnace != null) { - for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) { - ItemStack itemstack = tileentityfurnace.getStackInSlot(i1); - - if(itemstack != null) { - float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - - while(itemstack.stackSize > 0) { - int j1 = this.field_149933_a.nextInt(21) + 10; - - if(j1 > itemstack.stackSize) { - j1 = itemstack.stackSize; - } - - itemstack.stackSize -= j1; - EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - - if(itemstack.hasTagCompound()) { - entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3; - entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3; - p_149749_1_.spawnEntityInWorld(entityitem); - } - } - } - - p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); - } - } - - super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + public int getOffset() { + return 0; } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { - int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - - if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2); - if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2); - if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2); - if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2); + super.onBlockPlacedBy(world, x, y, z, player, itemStack); if(itemStack.hasDisplayName()) { - ((TileEntityMachineEPress) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName()); + int[] pos = this.findCore(world, x, y, z); + if(pos != null) { + TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(pos[0], pos[1], pos[2]); + if(entity != null) { + entity.setCustomName(itemStack.getDisplayName()); + } + } } } @@ -112,10 +62,15 @@ public class MachineEPress extends BlockContainer implements INBTTransformable { if(world.isRemote) { return true; } else if(!player.isSneaking()) { - TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(x, y, z); - if(entity != null) { - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); - } + int[] pos = this.findCore(world, x, y, z); + if(pos == null) + return false; + + TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(pos[0], pos[1], pos[2]); + if(entity == null) + return false; + + FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); return true; } else { return false; diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index a28d22172..ddf7782b7 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -2,23 +2,16 @@ package com.hbm.blocks.machine; import java.util.Random; +import com.hbm.blocks.BlockDummyable; import com.hbm.main.MainRegistry; import com.hbm.tileentity.machine.TileEntityMachinePress; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class MachinePress extends BlockContainer { - - private final Random field_149933_a = new Random(); - private static boolean keepInventory; +public class MachinePress extends BlockDummyable { public MachinePress(Material p_i45386_1_) { super(p_i45386_1_); @@ -30,62 +23,13 @@ public class MachinePress extends BlockContainer { } @Override - public int getRenderType() { - return -1; + public int[] getDimensions() { + return new int[] {2, 0, 0, 0, 0, 0}; } @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { - if(!keepInventory) { - TileEntityMachinePress tileentityfurnace = (TileEntityMachinePress) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); - - if(tileentityfurnace != null) { - for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) { - ItemStack itemstack = tileentityfurnace.getStackInSlot(i1); - - if(itemstack != null) { - float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; - - while(itemstack.stackSize > 0) { - int j1 = this.field_149933_a.nextInt(21) + 10; - - if(j1 > itemstack.stackSize) { - j1 = itemstack.stackSize; - } - - itemstack.stackSize -= j1; - EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - - if(itemstack.hasTagCompound()) { - entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3; - entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3; - p_149749_1_.spawnEntityInWorld(entityitem); - } - } - } - - p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); - } - } - - super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + public int getOffset() { + return 0; } @Override @@ -93,10 +37,15 @@ public class MachinePress extends BlockContainer { if(world.isRemote) { return true; } else if(!player.isSneaking()) { - TileEntityMachinePress entity = (TileEntityMachinePress) world.getTileEntity(x, y, z); - if(entity != null) { - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); - } + int[] pos = this.findCore(world, x, y, z); + if(pos == null) + return false; + + TileEntityMachinePress entity = (TileEntityMachinePress) world.getTileEntity(pos[0], pos[1], pos[2]); + if(entity == null) + return false; + + FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); return true; } else { return false; From 1f073d570cece2b650a6fb43676a3d2db805b597 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sat, 28 Jun 2025 23:52:39 +0300 Subject: [PATCH 02/12] Fix createNewTileEntity and clean up a bit --- .../com/hbm/blocks/machine/MachineEPress.java | 15 +++++---------- .../java/com/hbm/blocks/machine/MachinePress.java | 9 +++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index 42cb7713f..3f33886f3 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -8,28 +8,23 @@ import com.hbm.tileentity.machine.TileEntityMachineEPress; import com.hbm.world.gen.INBTTransformable; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class MachineEPress extends BlockDummyable implements INBTTransformable { - public MachineEPress(Material p_i45386_1_) { - super(p_i45386_1_); + public MachineEPress(Material mat) { + super(mat); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileEntityMachineEPress(); + public TileEntity createNewTileEntity(World world, int meta) { + if(meta >= 12) return new TileEntityMachineEPress(); + return null; } @Override diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index ddf7782b7..6633c9e76 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -13,13 +13,14 @@ import net.minecraft.world.World; public class MachinePress extends BlockDummyable { - public MachinePress(Material p_i45386_1_) { - super(p_i45386_1_); + public MachinePress(Material mat) { + super(mat); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileEntityMachinePress(); + public TileEntity createNewTileEntity(World world, int meta) { + if(meta >= 12) return new TileEntityMachinePress(); + return null; } @Override From 1bb88b176a7231932f2b2875e4a9ddf2f6f70de4 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sun, 29 Jun 2025 00:10:25 +0300 Subject: [PATCH 03/12] More fixes Turns out, pseudomultiblocks are pretty complicated --- src/main/java/com/hbm/blocks/machine/MachineEPress.java | 4 +++- src/main/java/com/hbm/blocks/machine/MachinePress.java | 4 +++- src/main/java/com/hbm/render/tileentity/RenderEPress.java | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index 3f33886f3..d52898b60 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -4,6 +4,7 @@ import java.util.Random; import com.hbm.blocks.BlockDummyable; import com.hbm.main.MainRegistry; +import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachineEPress; import com.hbm.world.gen.INBTTransformable; @@ -24,6 +25,7 @@ public class MachineEPress extends BlockDummyable implements INBTTransformable { @Override public TileEntity createNewTileEntity(World world, int meta) { if(meta >= 12) return new TileEntityMachineEPress(); + if(meta >= 6) return new TileEntityProxyCombo(true, false, false); return null; } @@ -65,7 +67,7 @@ public class MachineEPress extends BlockDummyable implements INBTTransformable { if(entity == null) return false; - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); + FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]); return true; } else { return false; diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index 6633c9e76..22ecffa26 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -4,6 +4,7 @@ import java.util.Random; import com.hbm.blocks.BlockDummyable; import com.hbm.main.MainRegistry; +import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachinePress; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import net.minecraft.block.material.Material; @@ -20,6 +21,7 @@ public class MachinePress extends BlockDummyable { @Override public TileEntity createNewTileEntity(World world, int meta) { if(meta >= 12) return new TileEntityMachinePress(); + if(meta >= 6) return new TileEntityProxyCombo(true, false, false); return null; } @@ -46,7 +48,7 @@ public class MachinePress extends BlockDummyable { if(entity == null) return false; - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); + FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]); return true; } else { return false; diff --git a/src/main/java/com/hbm/render/tileentity/RenderEPress.java b/src/main/java/com/hbm/render/tileentity/RenderEPress.java index 987ab9a0a..cf8915ef8 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderEPress.java +++ b/src/main/java/com/hbm/render/tileentity/RenderEPress.java @@ -2,6 +2,7 @@ package com.hbm.render.tileentity; import org.lwjgl.opengl.GL11; +import com.hbm.blocks.BlockDummyable; import com.hbm.main.ResourceManager; import com.hbm.render.util.RenderDecoItem; import com.hbm.tileentity.machine.TileEntityMachineEPress; @@ -28,7 +29,7 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); - switch(tileentity.getBlockMetadata()) { + switch(tileentity.getBlockMetadata() - BlockDummyable.offset) { case 2: GL11.glRotatef(270, 0F, 1F, 0F); break; case 4: GL11.glRotatef(0, 0F, 1F, 0F); break; case 3: GL11.glRotatef(90, 0F, 1F, 0F); break; @@ -50,7 +51,7 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); - switch(tileentity.getBlockMetadata()) { + switch(tileentity.getBlockMetadata() - BlockDummyable.offset) { case 2: GL11.glRotatef(270, 0F, 1F, 0F); break; case 4: GL11.glRotatef(0, 0F, 1F, 0F); break; case 3: GL11.glRotatef(90, 0F, 1F, 0F); break; @@ -78,7 +79,7 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); - switch(tileentity.getBlockMetadata()) { + switch(tileentity.getBlockMetadata() - BlockDummyable.offset) { case 2: GL11.glRotatef(270, 0F, 1F, 0F); break; case 4: From 41d62c49db9e1fa3704c0c10eb59123ef7f2281f Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sun, 29 Jun 2025 00:24:32 +0300 Subject: [PATCH 04/12] Remove broken & redundant transformMeta --- .../java/com/hbm/blocks/machine/MachineEPress.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index d52898b60..12a7f91ff 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -1,12 +1,9 @@ package com.hbm.blocks.machine; -import java.util.Random; - import com.hbm.blocks.BlockDummyable; import com.hbm.main.MainRegistry; import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachineEPress; -import com.hbm.world.gen.INBTTransformable; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import net.minecraft.block.material.Material; @@ -16,7 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class MachineEPress extends BlockDummyable implements INBTTransformable { +public class MachineEPress extends BlockDummyable { public MachineEPress(Material mat) { super(mat); @@ -73,9 +70,4 @@ public class MachineEPress extends BlockDummyable implements INBTTransformable { return false; } } - - @Override - public int transformMeta(int meta, int coordBaseMode) { - return INBTTransformable.transformMetaDeco(meta, coordBaseMode); - } } \ No newline at end of file From 4a869ae2ea3a5926508b5f8936aa93e9cff2479d Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sun, 29 Jun 2025 01:02:43 +0300 Subject: [PATCH 05/12] Add automatic migration API to BlockDummyable --- .../java/com/hbm/blocks/BlockDummyable.java | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/hbm/blocks/BlockDummyable.java b/src/main/java/com/hbm/blocks/BlockDummyable.java index 9508350b5..0d7fa08b4 100644 --- a/src/main/java/com/hbm/blocks/BlockDummyable.java +++ b/src/main/java/com/hbm/blocks/BlockDummyable.java @@ -77,27 +77,20 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl super.onNeighborBlockChange(world, x, y, z, block); - if(world.isRemote || safeRem) + if(safeRem) return; - int metadata = world.getBlockMetadata(x, y, z); - - // if it's an extra, remove the extra-ness - if(metadata >= extra) - metadata -= extra; - - ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite(); - Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); - - if(b != this) { - world.setBlockToAir(x, y, z); - } + destroyIfOrphan(world, x, y, z); } public void updateTick(World world, int x, int y, int z, Random rand) { super.updateTick(world, x, y, z, rand); + destroyIfOrphan(world, x, y, z); + } + + private void destroyIfOrphan(World world, int x, int y, int z) { if(world.isRemote) return; @@ -111,9 +104,26 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); if(b != this) { - world.setBlockToAir(x, y, z); + if (isLegacyMonoblock(world, x, y, z)) { + fixLegacyMonoblock(world, x, y, z); + } else { + world.setBlockToAir(x, y, z); + } } + } + // Override this when turning a single block into a pseudo-multiblock. + // If this returns true, instead of being deleted as an orphan, the block + // will be promoted to a core of a dummyable, however without any dummies. + // This is only called if the block is presumed an orphan, so you don't + // need to check that here. + protected boolean isLegacyMonoblock(World world, int x, int y, int z) { + return false; + } + + protected void fixLegacyMonoblock(World world, int x, int y, int z) { + // Promote to a lone core block with the same effective rotation as before the change + world.setBlockMetadataWithNotify(x, y, z, offset + world.getBlockMetadata(x, y, z), 3); } public int[] findCore(World world, int x, int y, int z) { From 0eb87524ab832567d48a3a48b901f6df1305d0d0 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sun, 29 Jun 2025 01:03:16 +0300 Subject: [PATCH 06/12] Make new press implementation savegame-compatible --- src/main/java/com/hbm/blocks/machine/MachineEPress.java | 6 ++++++ src/main/java/com/hbm/blocks/machine/MachinePress.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index 12a7f91ff..add331ba3 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -36,6 +36,12 @@ public class MachineEPress extends BlockDummyable { return 0; } + @Override + protected boolean isLegacyMonoblock(World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + return te != null && te instanceof TileEntityMachineEPress; + } + @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { super.onBlockPlacedBy(world, x, y, z, player, itemStack); diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index 22ecffa26..6f4cf5808 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -34,6 +34,12 @@ public class MachinePress extends BlockDummyable { public int getOffset() { return 0; } + + @Override + protected boolean isLegacyMonoblock(World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + return te != null && te instanceof TileEntityMachinePress; + } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { From 3b36807242fa24ef3b9673a9b9e3ff86d92f114f Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sun, 29 Jun 2025 01:44:31 +0300 Subject: [PATCH 07/12] Trigger the press fix automatically --- .../tileentity/machine/TileEntityMachineEPress.java | 12 ++++++++++++ .../tileentity/machine/TileEntityMachinePress.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java index b2afe4309..90896b626 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java @@ -3,6 +3,7 @@ package com.hbm.tileentity.machine; import java.util.HashMap; import java.util.List; +import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.UpgradeManagerNT; import com.hbm.inventory.container.ContainerMachineEPress; @@ -64,6 +65,17 @@ public class TileEntityMachineEPress extends TileEntityMachineBase implements IE if(!worldObj.isRemote) { + // Triggers the legacy monoblock fix + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < BlockDummyable.offset) { + // Does nothing + // worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + + BlockDummyable block = (BlockDummyable)worldObj.getBlock(xCoord, yCoord, zCoord); + if (block != null) { + block.onNeighborBlockChange(worldObj, xCoord, yCoord, zCoord, null); + } + } + this.updateConnections(); power = Library.chargeTEFromItems(slots, 0, power, maxPower); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java index c927edc0a..0684ef87e 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java @@ -1,5 +1,6 @@ package com.hbm.tileentity.machine; +import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.container.ContainerMachinePress; import com.hbm.inventory.gui.GUIMachinePress; @@ -53,6 +54,17 @@ public class TileEntityMachinePress extends TileEntityMachineBase implements IGU if(!worldObj.isRemote) { + // Triggers the legacy monoblock fix + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < BlockDummyable.offset) { + // Does nothing + // worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + + BlockDummyable block = (BlockDummyable)worldObj.getBlock(xCoord, yCoord, zCoord); + if (block != null) { + block.onNeighborBlockChange(worldObj, xCoord, yCoord, zCoord, null); + } + } + boolean preheated = false; for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { From d1f50a8eb4419057c17dbc9faabdf87b225be10a Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sun, 29 Jun 2025 15:45:30 +0300 Subject: [PATCH 08/12] Fix press auto-migration --- .../tileentity/machine/TileEntityMachineEPress.java | 11 ++--------- .../tileentity/machine/TileEntityMachinePress.java | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java index 90896b626..4dc4df595 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineEPress.java @@ -3,7 +3,6 @@ package com.hbm.tileentity.machine; import java.util.HashMap; import java.util.List; -import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.UpgradeManagerNT; import com.hbm.inventory.container.ContainerMachineEPress; @@ -66,14 +65,8 @@ public class TileEntityMachineEPress extends TileEntityMachineBase implements IE if(!worldObj.isRemote) { // Triggers the legacy monoblock fix - if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < BlockDummyable.offset) { - // Does nothing - // worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - - BlockDummyable block = (BlockDummyable)worldObj.getBlock(xCoord, yCoord, zCoord); - if (block != null) { - block.onNeighborBlockChange(worldObj, xCoord, yCoord, zCoord, null); - } + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < 12) { + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1); } this.updateConnections(); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java index 0684ef87e..a0d1e5b8a 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java @@ -1,6 +1,5 @@ package com.hbm.tileentity.machine; -import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.container.ContainerMachinePress; import com.hbm.inventory.gui.GUIMachinePress; @@ -55,14 +54,8 @@ public class TileEntityMachinePress extends TileEntityMachineBase implements IGU if(!worldObj.isRemote) { // Triggers the legacy monoblock fix - if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < BlockDummyable.offset) { - // Does nothing - // worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - - BlockDummyable block = (BlockDummyable)worldObj.getBlock(xCoord, yCoord, zCoord); - if (block != null) { - block.onNeighborBlockChange(worldObj, xCoord, yCoord, zCoord, null); - } + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) < 12) { + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1); } boolean preheated = false; From d1497abd1e16ada4812c6c077db2aa6f9973cbcf Mon Sep 17 00:00:00 2001 From: abel1502 Date: Sun, 29 Jun 2025 23:40:51 +0300 Subject: [PATCH 09/12] Simplify press click handling Turns out there is already a function for doing just that --- .../com/hbm/blocks/machine/MachineEPress.java | 17 +---------------- .../com/hbm/blocks/machine/MachinePress.java | 17 +---------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index add331ba3..c44a8e575 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -59,21 +59,6 @@ public class MachineEPress extends BlockDummyable { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if(world.isRemote) { - return true; - } else if(!player.isSneaking()) { - int[] pos = this.findCore(world, x, y, z); - if(pos == null) - return false; - - TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(pos[0], pos[1], pos[2]); - if(entity == null) - return false; - - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]); - return true; - } else { - return false; - } + return this.standardOpenBehavior(world, x, y, z, player, 0); } } \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index 6f4cf5808..1e6c51ca3 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -43,21 +43,6 @@ public class MachinePress extends BlockDummyable { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if(world.isRemote) { - return true; - } else if(!player.isSneaking()) { - int[] pos = this.findCore(world, x, y, z); - if(pos == null) - return false; - - TileEntityMachinePress entity = (TileEntityMachinePress) world.getTileEntity(pos[0], pos[1], pos[2]); - if(entity == null) - return false; - - FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]); - return true; - } else { - return false; - } + return this.standardOpenBehavior(world, x, y, z, player, 0); } } From 18a310ba3a0e210d38125ac52a7a74926ef1527b Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 30 Jun 2025 00:24:55 +0300 Subject: [PATCH 10/12] Prevent pseudomultiblocks disappearing on chunk boundaries If this was indeed a problem, it must've been one before my PR... I suspect maybe some of my intermediate implementations allowed this to have an effect. Regardless, this is definitely a useful fix --- src/main/java/com/hbm/blocks/BlockDummyable.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/blocks/BlockDummyable.java b/src/main/java/com/hbm/blocks/BlockDummyable.java index 0d7fa08b4..19c33db65 100644 --- a/src/main/java/com/hbm/blocks/BlockDummyable.java +++ b/src/main/java/com/hbm/blocks/BlockDummyable.java @@ -103,7 +103,12 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite(); Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); - if(b != this) { + // An extra precaution against multiblocks on chunk borders being erroneously deleted. + // Technically, this might be used to persist ghost dummy blocks by manipulating + // loaded chunks and block destruction, but this gives no benefit to the player, + // cannot be done accidentally, and is definitely preferable to multiblocks + // just vanishing when their chunks are unloaded in an unlucky way. + if(b != this && world.checkChunksExist(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)) { if (isLegacyMonoblock(world, x, y, z)) { fixLegacyMonoblock(world, x, y, z); } else { From f792fdebe38ff319ae808147cb4136714cb22ac3 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 30 Jun 2025 09:11:51 +0300 Subject: [PATCH 11/12] Make presses un-multiblockable with a hand drill As per @MellowArpeggiation 's request. Meant for schenanigans with visually squishing things --- .../com/hbm/blocks/machine/MachineEPress.java | 20 +++++++++++++--- .../com/hbm/blocks/machine/MachinePress.java | 24 +++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index c44a8e575..d269c253c 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -1,11 +1,10 @@ package com.hbm.blocks.machine; import com.hbm.blocks.BlockDummyable; -import com.hbm.main.MainRegistry; import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachineEPress; -import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import api.hbm.block.IToolable; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -13,7 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class MachineEPress extends BlockDummyable { +public class MachineEPress extends BlockDummyable implements IToolable { public MachineEPress(Material mat) { super(mat); @@ -61,4 +60,19 @@ public class MachineEPress extends BlockDummyable { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { return this.standardOpenBehavior(world, x, y, z, player, 0); } + + // Un-multiblickable with a hand drill for schenanigans + @Override + public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { + + if (tool != ToolType.HAND_DRILL) + return false; + + int meta = world.getBlockMetadata(x, y, z); + if (meta >= 12) + return false; + + world.setBlockToAir(x, y, z); + return true; + } } \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index 1e6c51ca3..44415589f 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -1,18 +1,16 @@ package com.hbm.blocks.machine; -import java.util.Random; - import com.hbm.blocks.BlockDummyable; -import com.hbm.main.MainRegistry; import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachinePress; -import cpw.mods.fml.common.network.internal.FMLNetworkHandler; + +import api.hbm.block.IToolable; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class MachinePress extends BlockDummyable { +public class MachinePress extends BlockDummyable implements IToolable { public MachinePress(Material mat) { super(mat); @@ -45,4 +43,20 @@ public class MachinePress extends BlockDummyable { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { return this.standardOpenBehavior(world, x, y, z, player, 0); } + + // Un-multiblickable with a hand drill for schenanigans + @Override + public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { + + if (tool != ToolType.HAND_DRILL) + return false; + + int meta = world.getBlockMetadata(x, y, z); + if (meta >= 12) + return false; + + world.setBlockToAir(x, y, z); + return true; + } + } From 2e5882df606b88eea588fd7719132b0dd2051216 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 30 Jun 2025 09:14:49 +0300 Subject: [PATCH 12/12] Don't break the whole thing --- src/main/java/com/hbm/blocks/machine/MachineEPress.java | 2 ++ src/main/java/com/hbm/blocks/machine/MachinePress.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/hbm/blocks/machine/MachineEPress.java b/src/main/java/com/hbm/blocks/machine/MachineEPress.java index d269c253c..82eb6d89f 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineEPress.java +++ b/src/main/java/com/hbm/blocks/machine/MachineEPress.java @@ -72,7 +72,9 @@ public class MachineEPress extends BlockDummyable implements IToolable { if (meta >= 12) return false; + safeRem = true; world.setBlockToAir(x, y, z); + safeRem = false; return true; } } \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/machine/MachinePress.java b/src/main/java/com/hbm/blocks/machine/MachinePress.java index 44415589f..b02f3dab8 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePress.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePress.java @@ -55,7 +55,9 @@ public class MachinePress extends BlockDummyable implements IToolable { if (meta >= 12) return false; + safeRem = true; world.setBlockToAir(x, y, z); + safeRem = false; return true; }