From 752df423fba48d92fe4d032aab21b505426ea16f Mon Sep 17 00:00:00 2001 From: Boblet Date: Thu, 6 Aug 2020 11:26:27 +0200 Subject: [PATCH] made tank corrosion seamless --- .../hbm/blocks/machine/BlockFluidBarrel.java | 3 +-- .../tileentity/machine/TileEntityBarrel.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/BlockFluidBarrel.java b/src/main/java/com/hbm/blocks/machine/BlockFluidBarrel.java index 3e88d7997..cabf500a4 100644 --- a/src/main/java/com/hbm/blocks/machine/BlockFluidBarrel.java +++ b/src/main/java/com/hbm/blocks/machine/BlockFluidBarrel.java @@ -79,8 +79,7 @@ public class BlockFluidBarrel extends BlockContainer { } private final Random field_149933_a = new Random(); - private Random rand; - private static boolean keepInventory; + public static boolean keepInventory; @Spaghetti("stop doing that and make a base class for fuck's sake") @Override diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityBarrel.java b/src/main/java/com/hbm/tileentity/machine/TileEntityBarrel.java index caf24335e..3e13e1d59 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityBarrel.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityBarrel.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.machine.BlockFluidBarrel; import com.hbm.handler.FluidTypeHandler.FluidType; import com.hbm.interfaces.IFluidAcceptor; import com.hbm.interfaces.IFluidSource; @@ -59,28 +60,27 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc Block b = this.getBlockType(); + //for when you fill antimatter into a matter tank if(b != ModBlocks.barrel_antimatter && tank.getTankType().isAntimatter()) { worldObj.func_147480_a(xCoord, yCoord, zCoord, false); worldObj.newExplosion(null, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 5, true, true); } + //for when you fill hot or corrosive liquids into a plastic tank if(b == ModBlocks.barrel_plastic && (tank.getTankType().isCorrosive() || tank.getTankType().isHot())) { worldObj.func_147480_a(xCoord, yCoord, zCoord, false); worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.fizz", 1.0F, 1.0F); } - //TODO: rip off furnace code and make transition more seamless + //for when you fill corrosive liquid into an iron tank if(b == ModBlocks.barrel_iron && tank.getTankType().isCorrosive()) { - ItemStack[] copy = this.slots.clone(); - this.slots = new ItemStack[6]; - worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.barrel_corroded); - TileEntityBarrel barrel = (TileEntityBarrel)worldObj.getTileEntity(xCoord, yCoord, zCoord); - if(barrel != null) { - barrel.tank.setTankType(tank.getTankType()); - barrel.tank.setFill(Math.min(barrel.tank.getMaxFill(), tank.getFill())); - barrel.slots = copy; - } + BlockFluidBarrel.keepInventory = true; + worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.barrel_corroded); + worldObj.setTileEntity(xCoord, yCoord, zCoord, this); + this.validate(); + + BlockFluidBarrel.keepInventory = false; worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.fizz", 1.0F, 1.0F); }