From 76b15123238ca2f01c1bf46db8a4ea20dc7ced2b Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Mon, 8 Jun 2020 02:50:03 +0200 Subject: Removed everything related to Item Server; Deprecated current TFFT Multi Hatch in favor of GTMTE version --- src/main/java/client/ClientProxy.java | 2 - src/main/java/client/renderer/HatchRenderer.java | 102 -- src/main/java/common/Blocks.java | 9 +- src/main/java/common/Recipes.java | 62 -- src/main/java/common/TileEntities.java | 15 +- .../java/common/blocks/Block_ItemServerDrive.java | 57 -- .../java/common/blocks/Block_ItemServerIOPort.java | 43 - .../common/blocks/Block_ItemServerRackCasing.java | 30 - .../java/common/blocks/Block_TFFTMultiHatch.java | 77 +- .../java/common/itemBlocks/IB_ItemServerDrive.java | 22 - .../common/itemBlocks/IB_ItemServerIOPort.java | 22 - .../common/itemBlocks/IB_ItemServerRackCasing.java | 22 - .../java/common/itemBlocks/IB_TFFTMultiHatch.java | 7 +- .../common/items/MetaItem_CraftingComponent.java | 3 +- .../tileentities/GTMTE_FluidMultiStorage.java | 1052 ++++++++++---------- .../java/common/tileentities/GTMTE_ItemServer.java | 393 -------- .../common/tileentities/GTMTE_TFFTMultiHatch.java | 196 ++++ .../common/tileentities/TE_ItemServerIOPort.java | 145 --- .../common/tileentities/TE_TFFTMultiHatch.java | 1 + src/main/java/kekztech/Items.java | 1 - src/main/java/kekztech/MultiFluidHandler.java | 5 +- src/main/java/kekztech/MultiItemHandler.java | 185 ---- src/main/resources/assets/kekztech/lang/en_US.lang | 22 +- 23 files changed, 741 insertions(+), 1732 deletions(-) delete mode 100644 src/main/java/client/renderer/HatchRenderer.java delete mode 100644 src/main/java/common/blocks/Block_ItemServerDrive.java delete mode 100644 src/main/java/common/blocks/Block_ItemServerIOPort.java delete mode 100644 src/main/java/common/blocks/Block_ItemServerRackCasing.java delete mode 100644 src/main/java/common/itemBlocks/IB_ItemServerDrive.java delete mode 100644 src/main/java/common/itemBlocks/IB_ItemServerIOPort.java delete mode 100644 src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java delete mode 100644 src/main/java/common/tileentities/GTMTE_ItemServer.java create mode 100644 src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java delete mode 100644 src/main/java/common/tileentities/TE_ItemServerIOPort.java delete mode 100644 src/main/java/kekztech/MultiItemHandler.java (limited to 'src/main') diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index c863198976..f608861c0d 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -1,6 +1,5 @@ package client; -import client.renderer.HatchRenderer; import client.renderer.TESR_SECapacitor; import client.renderer.TESR_SETether; import common.CommonProxy; @@ -26,7 +25,6 @@ public class ClientProxy extends CommonProxy { super.init(e); // Register Simple Block Renderers //RenderingRegistry.registerBlockHandler(ConduitRenderer.getInstance()); - RenderingRegistry.registerBlockHandler(HatchRenderer.getInstance()); } } diff --git a/src/main/java/client/renderer/HatchRenderer.java b/src/main/java/client/renderer/HatchRenderer.java deleted file mode 100644 index b2670af76b..0000000000 --- a/src/main/java/client/renderer/HatchRenderer.java +++ /dev/null @@ -1,102 +0,0 @@ -package client.renderer; - -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.client.registry.RenderingRegistry; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.world.IBlockAccess; -import org.lwjgl.opengl.GL11; - -public class HatchRenderer implements ISimpleBlockRenderingHandler { - - public static final int RID = RenderingRegistry.getNextAvailableRenderId(); - private static final HatchRenderer INSTANCE = new HatchRenderer(); - - private HatchRenderer() { - - } - - public static HatchRenderer getInstance() { - return INSTANCE; - } - - @Override - public void renderInventoryBlock(Block block, int meta, int modelId, RenderBlocks renderer) { - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - renderer.setRenderBoundsFromBlock(block); - final Tessellator t = Tessellator.instance; - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - t.startDrawingQuads(); - t.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(6, meta)); - t.draw(); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, - RenderBlocks renderer) { - final Tessellator t = Tessellator.instance; - // Set colour - int mb = block.getMixedBrightnessForBlock(world, x, y, z); - t.setBrightness(mb); - - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - renderer.setRenderBoundsFromBlock(block); - - if (block.shouldSideBeRendered(world, x, y - 1, z, 6)) { - renderer.renderFaceYNeg(block, x, y, z, block.getIcon(world, x, y, z, 0)); - } - if (block.shouldSideBeRendered(world, x, y + 1, z, 6)) { - t.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, x, y, z, block.getIcon(world, x, y, z, 1)); - } - - if (block.shouldSideBeRendered(world, x, y, z - 1, 6)) { - renderer.renderFaceZNeg(block, x, y, z, block.getIcon(world, x, y, z, 2)); - } - if (block.shouldSideBeRendered(world, x, y, z + 1, 6)) { - renderer.renderFaceZPos(block, x, y, z, block.getIcon(world, x, y, z, 3)); - } - - if (block.shouldSideBeRendered(world, x - 1, y, z, 6)) { - renderer.renderFaceXNeg(block, x, y, z, block.getIcon(world, x, y, z, 4)); - } - if (block.shouldSideBeRendered(world, x + 1, y, z, 6)) { - renderer.renderFaceXPos(block, x, y, z, block.getIcon(world, x, y, z, 5)); - } - - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return HatchRenderer.RID; - } -} diff --git a/src/main/java/common/Blocks.java b/src/main/java/common/Blocks.java index 18725b6000..bc8b2ff573 100644 --- a/src/main/java/common/Blocks.java +++ b/src/main/java/common/Blocks.java @@ -44,7 +44,6 @@ public class Blocks { registerBlocks_SOFC(); registerBlocks_TFFT(); registerBlocks_Nuclear(); - //registerBlocks_ItemServer(); //registerBlocks_ItemProxy(); registerBlocks_Jars(); registerBlocks_LSC(); @@ -73,13 +72,7 @@ public class Blocks { reactorChamberON = Block_ReactorChamber_ON.registerBlock(); reactorControlRod = Block_ControlRod.registerBlock(); } - - private static void registerBlocks_ItemServer() { - itemServerDrive = Block_ItemServerDrive.registerBlock(); - itemServerRackCasing = Block_ItemServerRackCasing.registerBlock(); - itemServerIOPort = Block_ItemServerIOPort.registerBlock(); - } - + private static void registerBlocks_ItemProxy() { itemProxyCable = Block_ItemProxyCable.registerBlock(); itemProxySource = Block_ItemProxySource.registerBlock(); diff --git a/src/main/java/common/Recipes.java b/src/main/java/common/Recipes.java index eaaad88570..b694805c96 100644 --- a/src/main/java/common/Recipes.java +++ b/src/main/java/common/Recipes.java @@ -35,7 +35,6 @@ public class Recipes { registerRecipes_TFFT(); registerRecipes_SOFC(); registerRecipes_Nuclear(); - //registerRecipes_ItemServer(); registerRecipes_Jars(); registerRecipes_LSC(); registerRecipes_SpaceElevator(); @@ -329,67 +328,6 @@ public class Recipes { null, 1200, 7680); } - private static void registerRecipes_ItemServer() { - - final MetaItem_CraftingComponent craftingItem = MetaItem_CraftingComponent.getInstance(); - - // Controller - final Object[] is_recipe = { - "FRF", "CGC", "PZP", - 'F', GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.TungstenSteel, 1), - 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.TungstenSteel, 1), - 'C', ItemList.Conveyor_Module_LuV.get(1L), - 'G', ItemList.Field_Generator_EV.get(1L), - 'P', GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.VanadiumGallium, 1), - 'Z', GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 1) - }; - GT_ModHandler.addCraftingRecipe(TileEntities.is.getStackForm(1), is_recipe); - - // Blocks - final Object[] is_rack_recipe = { - "BRB", "CFC", "BRB", - 'B', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlueSteel, 1), - 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.Aluminium, 1), - 'C', GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Platinum, 1), - 'F', GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.TungstenSteel, 1), - }; - GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.itemServerRackCasing), is_rack_recipe); - final ItemStack[] is_ioport = { - GT_Utility.getIntegratedCircuit(6), - new ItemStack(Blocks.itemServerRackCasing), - GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.Platinum, 16), - GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Platinum, 2), - ItemList.Field_Generator_HV.get(1L), - ItemList.Robot_Arm_EV.get(4L) - }; - GT_Values.RA.addAssemblerRecipe( - is_ioport, - FluidRegistry.getFluidStack("molten.polytetrafluoroethylene", 144), - new ItemStack(Blocks.itemServerIOPort, 1), - 200, 7680); - final Object[] is_blade = { - "CRC", "CMC", "HPH", - 'C', GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1), - 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.Aluminium, 1), - 'P', GT_OreDictUnificator.get(OrePrefixes.cableGt08, Materials.Platinum, 1), - 'M', ItemList.Electric_Motor_EV.get(1L), - 'H', craftingItem.getStackFromDamage(Items.BoronArsenideHeatPipe.getMetaID()), - }; - GT_ModHandler.addCraftingRecipe(craftingItem.getStackOfAmountFromDamage(Items.ItemServerBlade.getMetaID(), 8), is_blade); - final ItemStack[] is_drive = { - GT_Utility.getIntegratedCircuit(6), - craftingItem.getStackOfAmountFromDamage(Items.ItemServerBlade.getMetaID(), 8), - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlueSteel, 4), - GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Aluminium, 1), - GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Aluminium, 16) - }; - GT_Values.RA.addAssemblerRecipe( - is_drive, - FluidRegistry.getFluidStack("molten.polyethylene", 1152), - new ItemStack(Blocks.itemServerDrive, 1), - 200, 7680); - } - private static void registerRecipes_Jars() { // Thaumium Reinforced Jar diff --git a/src/main/java/common/TileEntities.java b/src/main/java/common/TileEntities.java index 9e3a648667..35ac65d2e6 100644 --- a/src/main/java/common/TileEntities.java +++ b/src/main/java/common/TileEntities.java @@ -5,17 +5,20 @@ import cpw.mods.fml.common.registry.GameRegistry; public class TileEntities { + // Multiblock controllers public static GTMTE_SOFuelCellMK1 sofc1; public static GTMTE_SOFuelCellMK2 sofc2; public static GTMTE_ModularNuclearReactor mdr; public static GTMTE_FluidMultiStorage fms; - public static GTMTE_ItemServer is; public static GTMTE_LapotronicSuperCapacitor lsc; public static GTMTE_SpaceElevator se; - + // Singleblocks + public static GTMTE_TFFTMultiHatch mhHV; + public static GTMTE_TFFTMultiHatch mhIV; + public static GTMTE_TFFTMultiHatch mhZPM; + public static void preInit() { GameRegistry.registerTileEntity(TE_TFFTMultiHatch.class, "kekztech_tfftmultihatch_tile"); - //GameRegistry.registerTileEntity(TE_ItemServerIOPort.class, "kekztech_itemserverioport_tile"); GameRegistry.registerTileEntity(TE_ItemProxyCable.class, "kekztech_itemproxycable_tile"); GameRegistry.registerTileEntity(TE_ItemProxySource.class, "kekztech_itemproxysource_tile"); GameRegistry.registerTileEntity(TE_ItemProxyEndpoint.class, "kekztech_itemproxyendpoint_tile"); @@ -25,13 +28,17 @@ public class TileEntities { } public static void init() { + // Multiblock controllers sofc1 = new GTMTE_SOFuelCellMK1(13101, "multimachine.fuelcellmk1", "Solid-Oxide Fuel Cell Mk I"); sofc2 = new GTMTE_SOFuelCellMK2(13102, "multimachine.fuelcellmk2", "Solid-Oxide Fuel Cell Mk II"); mdr = new GTMTE_ModularNuclearReactor(13103, "multimachine.nuclearreactor", "Nuclear Reactor"); fms = new GTMTE_FluidMultiStorage(13104, "multimachine.tf_fluidtank", "T.F.F.T"); - //is = new GTMTE_ItemServer(13105, "multimachine.itemserver", "Item Server"); lsc = new GTMTE_LapotronicSuperCapacitor(13106, "multimachine.supercapacitor", "Lapotronic Supercapacitor"); se = new GTMTE_SpaceElevator(13107, "multimachine.spaceelevator", "Space Elevator"); + // Singleblocks + mhHV = new GTMTE_TFFTMultiHatch(13108, "machine.multihatch", "T.F.F.T Multi I/O Hatch [HV]", 3); + mhIV = new GTMTE_TFFTMultiHatch(13109, "machine.multihatch", "T.F.F.T Multi I/O Hatch [IV]", 5); + mhZPM = new GTMTE_TFFTMultiHatch(13110, "machine.multihatch", "T.F.F.T Multi I/O Hatch [ZPM]", 7); } } diff --git a/src/main/java/common/blocks/Block_ItemServerDrive.java b/src/main/java/common/blocks/Block_ItemServerDrive.java deleted file mode 100644 index 63747a8598..0000000000 --- a/src/main/java/common/blocks/Block_ItemServerDrive.java +++ /dev/null @@ -1,57 +0,0 @@ -package common.blocks; - -import common.itemBlocks.IB_ItemServerDrive; -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.KekzCore; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.util.IIcon; - -public class Block_ItemServerDrive extends BaseGTUpdateableBlock{ - - private static Block_ItemServerDrive instance = new Block_ItemServerDrive(); - - private IIcon[] faces = new IIcon[6]; - - private Block_ItemServerDrive() { - super(Material.iron); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemserverdrive_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setHardness(5.0f); - instance.setResistance(6.0f); - GameRegistry.registerBlock(instance, IB_ItemServerDrive.class, blockName); - - return instance; - } - - @Override - public void registerBlockIcons(IIconRegister reg) { - for(int i = 0; i < 6; i++) { - if(i == 0) { - faces[i] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerDrive_BOTTOM"); - } else if(i == 1) { - faces[i] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerDrive_TOP"); - } else { - faces[i] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerDrive"); - } - - } - } - - @Override - public IIcon getIcon(int side, int meta) { - return faces[side]; - } - - @Override - public int getLightValue() { - return 7; - } - -} diff --git a/src/main/java/common/blocks/Block_ItemServerIOPort.java b/src/main/java/common/blocks/Block_ItemServerIOPort.java deleted file mode 100644 index 6af90b6e42..0000000000 --- a/src/main/java/common/blocks/Block_ItemServerIOPort.java +++ /dev/null @@ -1,43 +0,0 @@ -package common.blocks; - -import common.itemBlocks.IB_ItemServerIOPort; -import common.tileentities.TE_ItemServerIOPort; -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.KekzCore; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class Block_ItemServerIOPort extends BaseGTUpdateableBlock { - - private static Block_ItemServerIOPort instance = new Block_ItemServerIOPort(); - - private Block_ItemServerIOPort() { - super(Material.iron); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemserverioport_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemServerIOPort"); - instance.setHardness(5.0f); - instance.setResistance(6.0f); - GameRegistry.registerBlock(instance, IB_ItemServerIOPort.class, blockName); - - return instance; - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } - - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TE_ItemServerIOPort(); - } - -} diff --git a/src/main/java/common/blocks/Block_ItemServerRackCasing.java b/src/main/java/common/blocks/Block_ItemServerRackCasing.java deleted file mode 100644 index db0ec9c3e6..0000000000 --- a/src/main/java/common/blocks/Block_ItemServerRackCasing.java +++ /dev/null @@ -1,30 +0,0 @@ -package common.blocks; - -import common.itemBlocks.IB_ItemServerRackCasing; -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.KekzCore; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; - -public class Block_ItemServerRackCasing extends BaseGTUpdateableBlock { - - private static Block_ItemServerRackCasing instance = new Block_ItemServerRackCasing(); - - private Block_ItemServerRackCasing() { - super(Material.iron); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemserverrackcasing_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemServerRackCasing"); - instance.setHardness(5.0f); - instance.setResistance(6.0f); - GameRegistry.registerBlock(instance, IB_ItemServerRackCasing.class, blockName); - - return instance; - } - -} diff --git a/src/main/java/common/blocks/Block_TFFTMultiHatch.java b/src/main/java/common/blocks/Block_TFFTMultiHatch.java index d2780c8c4b..37f9e47bcc 100644 --- a/src/main/java/common/blocks/Block_TFFTMultiHatch.java +++ b/src/main/java/common/blocks/Block_TFFTMultiHatch.java @@ -1,11 +1,8 @@ package common.blocks; -import client.renderer.HatchRenderer; import common.itemBlocks.IB_TFFTMultiHatch; import common.tileentities.TE_TFFTMultiHatch; import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; @@ -13,20 +10,17 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import thaumcraft.common.tiles.TileJarFillable; import java.util.List; +@Deprecated public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { private static final Block_TFFTMultiHatch INSTANCE = new Block_TFFTMultiHatch(); @@ -96,43 +90,6 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { return casing; } } - // ========= Leagris stuff - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return true; - } - - @Override - public int getLightOpacity(IBlockAccess world, int x, int y, int z) { - return 255; - } - - @Override - public int getLightValue() { - return 0; - } - - @Override - public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { - return false; - } - - //============== Leagris over - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() { - return 0; - } - - @Override - public int getRenderType() { - return HatchRenderer.RID; - } @Override public TileEntity createTileEntity(World world, int meta) { @@ -172,36 +129,4 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { return false; } - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) { - final int yaw = MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - final int pitch = MathHelper.floor_double((double)(placer.rotationPitch * 4.0F / 360.0F) + 0.5D) & 3; - final TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TE_TFFTMultiHatch) { - if(pitch == 0 || pitch == 2) { - if (yaw == 0) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 2); - } - - if (yaw == 1) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 5); - } - - if (yaw == 2) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 3); - } - - if (yaw == 3) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 4); - } - } else { - if(pitch == 1) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 1); - } else { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 0); - } - } - } - - } - } diff --git a/src/main/java/common/itemBlocks/IB_ItemServerDrive.java b/src/main/java/common/itemBlocks/IB_ItemServerDrive.java deleted file mode 100644 index a937230da5..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemServerDrive.java +++ /dev/null @@ -1,22 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemServerDrive extends ItemBlock { - - public IB_ItemServerDrive(Block block) { - super(block); - } - - @SuppressWarnings({"unchecked"}) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemserverdrive_block.0.desc")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_ItemServerIOPort.java b/src/main/java/common/itemBlocks/IB_ItemServerIOPort.java deleted file mode 100644 index 10803af14c..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemServerIOPort.java +++ /dev/null @@ -1,22 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemServerIOPort extends ItemBlock { - - public IB_ItemServerIOPort(Block block) { - super(block); - } - - @SuppressWarnings({"unchecked"}) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemserverioport_block.0.desc")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java b/src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java deleted file mode 100644 index f1da1fcb5e..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java +++ /dev/null @@ -1,22 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemServerRackCasing extends ItemBlock { - - public IB_ItemServerRackCasing(Block block) { - super(block); - } - - @SuppressWarnings({"unchecked"}) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemserverrackcasing_block.0.desc=")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java index c5ecdca46d..f00c5ef0c2 100644 --- a/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java +++ b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java @@ -9,6 +9,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; +@Deprecated public class IB_TFFTMultiHatch extends ItemBlock { public IB_TFFTMultiHatch(Block block) { @@ -33,12 +34,6 @@ public class IB_TFFTMultiHatch extends ItemBlock { @SuppressWarnings({"unchecked"}) @Override public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - final int outputPerSecond = (int) (TE_TFFTMultiHatch.BASE_OUTPUT_PER_SECOND * Math.pow(10, stack.getItemDamage())); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.0.desc")); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.1.desc")); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.2.desc")); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.3.desc" ) - + " " + outputPerSecond + "L/s"); } } diff --git a/src/main/java/common/items/MetaItem_CraftingComponent.java b/src/main/java/common/items/MetaItem_CraftingComponent.java index ac57222b79..2b1c989831 100644 --- a/src/main/java/common/items/MetaItem_CraftingComponent.java +++ b/src/main/java/common/items/MetaItem_CraftingComponent.java @@ -14,7 +14,7 @@ import net.minecraft.util.IIcon; public class MetaItem_CraftingComponent extends Item { private static final MetaItem_CraftingComponent INSTANCE = new MetaItem_CraftingComponent(); - private final IIcon[] icons = new IIcon[17]; + private final IIcon[] icons = new IIcon[16]; private MetaItem_CraftingComponent() { } @@ -54,7 +54,6 @@ public class MetaItem_CraftingComponent extends Item { icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "CeriaDust"); icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "YSZCeramicPlate"); icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "GDCCeramicPlate"); - icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerBlade"); } @Override diff --git a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java index 1c32525c4e..e06d1cc4a6 100644 --- a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java +++ b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java @@ -1,531 +1,523 @@ -package common.tileentities; - -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import kekztech.MultiFluidHandler; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; - -import common.Blocks; -import common.blocks.*; -import util.MultiBlockTooltipBuilder; -import util.Vector3i; -import util.Vector3ic; - -import java.util.ArrayList; -import java.util.HashSet; - -public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { - - private final static String glassNameIC2Reinforced = "blockAlloyGlass"; - private final static Block CASING = Blocks.tfftCasing; - private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1; - private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2; - private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3; - private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4; - private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5; - private final static Block MULTI_HATCH = Blocks.tfftMultiHatch; - private final static int CASING_TEXTURE_ID = 176; - - private MultiFluidHandler mfh; - private HashSet multiHatches = new HashSet<>(); - - private int runningCost = 0; - private boolean doVoidExcess = false; - private byte fluidSelector = 0; - - public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GTMTE_FluidMultiStorage(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { - return new GTMTE_FluidMultiStorage(super.mName); - } - - @Override - public String[] getDescription() { - final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); - b.addInfo("High-Tech fluid tank that can hold up to 25 different fluids!") - .addInfo("Has 1/25th of the total capacity as capacity for each fluid.") - .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.") - .addInfo("Fluid storage amount and running cost depends on the storage field blocks used.") - .addSeparator() - .addInfo("Note on hatch locking:") - .addInfo("Use an Integrated Circuit in the GUI slot to limit which fluid is output.") - .addInfo("The index of a stored fluid can be obtained through the Tricorder.") - .addSeparator() - .beginStructureBlock(5, 9, 5) - .addController("Top Center") - .addEnergyHatch("Any top or bottom casing") - .addOtherStructurePart("Inner 3x7x3 solid pillar", "Storage Field Blocks") - .addOtherStructurePart("Outer 5x7x5 glass shell", "IC2 Reinforced Glass") - .addMaintenanceHatch("Any top or bottom casing") - .addIOHatches("Instead of any casing or glass, have to touch storage field.") - .signAndFinalize("Kekzdealer"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return b.getInformation(); - } else { - return b.getStructureInformation(); - } - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return aSide == aFacing - ? new ITexture[]{BlockIcons.casingTexturePages[1][48], - new GT_RenderedTexture(aActive - ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE - : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)} - : new ITexture[]{BlockIcons.casingTexturePages[1][48]}; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "MultiblockDisplay.png"); - } - - @Override - public boolean isCorrectMachinePart(ItemStack var1) { - return true; - } - - @Override - public boolean checkRecipe(ItemStack guiSlotItem) { - - super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000; - super.mEfficiencyIncrease = 10000; - super.mEUt = runningCost; - super.mMaxProgresstime = 10; - - if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { - this.fluidSelector = (byte) guiSlotItem.getItemDamage(); - } - - // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code! - if (multiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) { - return true; - } - - // Suck in fluids - final ArrayList inputHatchFluids = super.getStoredFluids(); - if (inputHatchFluids.size() > 0) { - - for (FluidStack fluidStack : inputHatchFluids) { - - final int pushed = mfh.pushFluid(fluidStack, true); - final FluidStack toDeplete = fluidStack.copy(); - toDeplete.amount = pushed; - super.depleteInput(toDeplete); - } - } - - // Push out fluids - if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { - final FluidStack storedFluid = mfh.getFluid(fluidSelector); - // Sum available output capacity - int possibleOutput = 0; - for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { - if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() == null) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } - } - // Output as much as possible - final FluidStack tempStack = storedFluid.copy(); - tempStack.amount = possibleOutput; - tempStack.amount = mfh.pullFluid(tempStack, fluidSelector, true); - super.addOutput(tempStack); - - } else { - for (FluidStack storedFluid : mfh.getFluids()) { - // Sum available output capacity - int possibleOutput = 0; - for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { - if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() == null) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } - } - // output as much as possible - final FluidStack tempStack = storedFluid.copy(); - tempStack.amount = possibleOutput; - // TODO possible concurrent modification exception as pullFluid calls remove() without an iterator - tempStack.amount = mfh.pullFluid(tempStack, true); - super.addOutput(tempStack); - } - } - - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (mfh != null) { - mfh.setLock(!super.getBaseMetaTileEntity().isActive()); - mfh.setFluidSelector(fluidSelector); - mfh.setDoVoidExcess(doVoidExcess); - } - } - - public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) { - final Vector3i offset = new Vector3i(); - - // either direction on z-axis - if (forgeDirection.x() == 0 && forgeDirection.z() == -1) { - offset.x = x; - offset.y = y; - offset.z = z; - } - if (forgeDirection.x() == 0 && forgeDirection.z() == 1) { - offset.x = -x; - offset.y = y; - offset.z = -z; - } - // either direction on x-axis - if (forgeDirection.x() == -1 && forgeDirection.z() == 0) { - offset.x = z; - offset.y = y; - offset.z = -x; - } - if (forgeDirection.x() == 1 && forgeDirection.z() == 0) { - offset.x = -z; - offset.y = y; - offset.z = x; - } - // either direction on y-axis - if (forgeDirection.y() == -1) { - offset.x = x; - offset.y = z; - offset.z = y; - } - - return offset; - } - - @Override - public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) { - // Figure out the vector for the direction the back face of the controller is facing - final Vector3ic forgeDirection = new Vector3i( - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX, - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY, - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ - ); - int minCasingAmount = 20; - boolean formationChecklist = true; // If this is still true at the end, machine is good to go :) - float runningCostAcc = 0; - double fluidCapacityAcc = 0; - - multiHatches.clear(); - - // Front segment - for (int X = -2; X <= 2; X++) { - for (int Y = -2; Y <= 2; Y++) { - if (X == 0 && Y == 0) { - continue; // Skip controller - } - - // Get next TE - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - // Fluid hatches should touch the storage field. - // Maintenance/Energy hatch can go anywhere - if (X > -2 && X < 2 && Y > -2 && Y < 2) { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - final Block b = thisController.getBlockOffset(offset.x(), offset.y(), offset.z()); - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - // Also check for multi hatch - if (b == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else if (b == MULTI_HATCH) { - final TE_TFFTMultiHatch mh = - (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - multiHatches.add(mh); - } else { - formationChecklist = false; - } - } - } else { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else { - formationChecklist = false; - } - } - } - } - } - - // Middle seven long segment - for (int X = -2; X <= 2; X++) { - for (int Y = -2; Y <= 2; Y++) { - for (int Z = -1; Z >= -7; Z--) { - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z); - if (X > -2 && X < 2 && Y > -2 && Y < 2) { - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD1.getUnlocalizedName())) { - runningCostAcc += 0.5f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT1.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD2.getUnlocalizedName())) { - runningCostAcc += 1.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT2.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD3.getUnlocalizedName())) { - runningCostAcc += 2.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT3.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD4.getUnlocalizedName())) { - runningCostAcc += 4.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT4.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD5.getUnlocalizedName())) { - runningCostAcc += 8.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT5.getCapacity(); - } else { - formationChecklist = false; - } - continue; - } - - // Get next TE - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - // Corner allows only glass - if (X == -2 && Y == -2 || X == 2 && Y == 2 || X == -2 && Y == 2 || X == 2 && Y == -2) { - if (!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced))) { - formationChecklist = false; - } - } else { - // Tries to add TE as either of those kinds of hatches. - // The number is the texture index number for the texture that needs to be painted over the hatch texture (TAE for GT++) - if (!super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - // Also check for multi hatch - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) { - final TE_TFFTMultiHatch mh = - (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - multiHatches.add(mh); - } else if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced)) { - formationChecklist = false; - } - } - } - } - } - } - - // Back segment - for (int X = -2; X <= 2; X++) { - for (int Y = -2; Y <= 2; Y++) { - // Get next TE - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8); - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - // Fluid hatches should touch the storage field. - // Maintenance/Energy hatch can go anywhere - if (X > -2 && X < 2 && Y > -2 && Y < 2) { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) { - final TE_TFFTMultiHatch mh = - (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - multiHatches.add(mh); - } else { - formationChecklist = false; - } - } - } else { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else { - formationChecklist = false; - } - } - } - } - } - - if (this.mEnergyHatches.size() < 1) { - formationChecklist = false; - } - - if (this.mMaintenanceHatches.size() < 1) { - formationChecklist = false; - } - - if (minCasingAmount > 0) { - formationChecklist = false; - } - - if (formationChecklist) { - runningCost = Math.round(-runningCostAcc); - // Update MultiFluidHandler in case storage cells have been changed - final int capacityPerFluid = (int) Math.round(fluidCapacityAcc / 25.0f); - if (mfh == null) { - mfh = new MultiFluidHandler(capacityPerFluid); - } else { - if (mfh.getCapacity() != capacityPerFluid) { - mfh = new MultiFluidHandler(capacityPerFluid, mfh.getFluids()); - } - } - for (TE_TFFTMultiHatch mh : multiHatches) { - mh.setMultiFluidHandler(mfh); - } - } - - return formationChecklist; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (doVoidExcess) { - doVoidExcess = false; - aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned off")); - } else { - doVoidExcess = true; - aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned on")); - } - } - - @Override - public String[] getInfoData() { - final ArrayList ll = mfh.getInfoData(); - - ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); - ll.add("Auto-voiding: " + doVoidExcess); - ll.add("Per-Fluid Capacity: " + mfh.getCapacity() + "L"); - ll.add("Running Cost: " - // mEUt does not naturally reflect efficiency status. Do that here. - + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t"); - ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus()) - ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET - : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET)); - ll.add("---------------------------------------------"); - - final String[] a = new String[ll.size()]; - return ll.toArray(a); - } - - @Override - public void saveNBTData(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - nbt.setInteger("runningCost", runningCost); - nbt.setBoolean("doVoidExcess", doVoidExcess); - - nbt.setInteger("capacityPerFluid", mfh.getCapacity()); - nbt.setTag("fluids", mfh.saveNBTData(new NBTTagCompound())); - - super.saveNBTData(nbt); - } - - @Override - public void loadNBTData(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - runningCost = nbt.getInteger("runningCost"); - doVoidExcess = nbt.getBoolean("doVoidExcess"); - - mfh = new MultiFluidHandler(); - mfh.loadNBTData(nbt); - for (TE_TFFTMultiHatch mh : multiHatches) { - mh.setMultiFluidHandler(mfh); - } - super.loadNBTData(nbt); - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack var1) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack var1) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack var1) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack var1) { - return false; - } +package common.tileentities; + +import common.Blocks; +import common.blocks.*; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import kekztech.MultiFluidHandler; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.input.Keyboard; +import util.MultiBlockTooltipBuilder; +import util.Vector3i; +import util.Vector3ic; + +import java.util.ArrayList; +import java.util.HashSet; + +public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { + + private final static String glassNameIC2Reinforced = "blockAlloyGlass"; + private final static Block CASING = Blocks.tfftCasing; + private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1; + private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2; + private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3; + private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4; + private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5; + private final static int CASING_TEXTURE_ID = 176; + + private MultiFluidHandler mfh; + private final HashSet sMultiHatches = new HashSet<>(); + + private int runningCost = 0; + private boolean doVoidExcess = false; + private byte fluidSelector = 0; + + public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GTMTE_FluidMultiStorage(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { + return new GTMTE_FluidMultiStorage(super.mName); + } + + @Override + public String[] getDescription() { + final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); + b.addInfo("High-Tech fluid tank that can hold up to 25 different fluids!") + .addInfo("Has 1/25th of the total capacity as capacity for each fluid.") + .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.") + .addInfo("Fluid storage amount and running cost depends on the storage field blocks used.") + .addSeparator() + .addInfo("Note on hatch locking:") + .addInfo("Use an Integrated Circuit in the GUI slot to limit which fluid is output.") + .addInfo("The index of a stored fluid can be obtained through the Tricorder.") + .addSeparator() + .beginStructureBlock(5, 9, 5) + .addController("Top Center") + .addEnergyHatch("Any top or bottom casing") + .addOtherStructurePart("Inner 3x7x3 solid pillar", "Storage Field Blocks") + .addOtherStructurePart("Outer 5x7x5 glass shell", "IC2 Reinforced Glass") + .addMaintenanceHatch("Any top or bottom casing") + .addIOHatches("Instead of any casing or glass, have to touch storage field.") + .signAndFinalize("Kekzdealer"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return b.getInformation(); + } else { + return b.getStructureInformation(); + } + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return aSide == aFacing + ? new ITexture[]{BlockIcons.casingTexturePages[1][48], + new GT_RenderedTexture(aActive + ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE + : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)} + : new ITexture[]{BlockIcons.casingTexturePages[1][48]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + "MultiblockDisplay.png"); + } + + @Override + public boolean isCorrectMachinePart(ItemStack var1) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack guiSlotItem) { + + super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000; + super.mEfficiencyIncrease = 10000; + super.mEUt = runningCost; + super.mMaxProgresstime = 10; + + if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { + this.fluidSelector = (byte) guiSlotItem.getItemDamage(); + } + + // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code! + if (sMultiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) { + return true; + } + + // Suck in fluids + final ArrayList inputHatchFluids = super.getStoredFluids(); + if (inputHatchFluids.size() > 0) { + + for (FluidStack fluidStack : inputHatchFluids) { + + final int pushed = mfh.pushFluid(fluidStack, true); + final FluidStack toDeplete = fluidStack.copy(); + toDeplete.amount = pushed; + super.depleteInput(toDeplete); + } + } + + // Push out fluids + if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { + final FluidStack storedFluid = mfh.getFluid(fluidSelector); + // Sum available output capacity + int possibleOutput = 0; + for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { + if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() == null) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } + } + // Output as much as possible + final FluidStack tempStack = storedFluid.copy(); + tempStack.amount = possibleOutput; + tempStack.amount = mfh.pullFluid(tempStack, fluidSelector, true); + super.addOutput(tempStack); + + } else { + for (FluidStack storedFluid : mfh.getFluids()) { + // Sum available output capacity + int possibleOutput = 0; + for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { + if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() == null) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } + } + // output as much as possible + final FluidStack tempStack = storedFluid.copy(); + tempStack.amount = possibleOutput; + // TODO possible concurrent modification exception as pullFluid calls remove() without an iterator + tempStack.amount = mfh.pullFluid(tempStack, true); + super.addOutput(tempStack); + } + } + + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (mfh != null) { + mfh.setLock(!super.getBaseMetaTileEntity().isActive()); + mfh.setFluidSelector(fluidSelector); + mfh.setDoVoidExcess(doVoidExcess); + } + } + + public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) { + final Vector3i offset = new Vector3i(); + + // either direction on z-axis + if (forgeDirection.x() == 0 && forgeDirection.z() == -1) { + offset.x = x; + offset.y = y; + offset.z = z; + } + if (forgeDirection.x() == 0 && forgeDirection.z() == 1) { + offset.x = -x; + offset.y = y; + offset.z = -z; + } + // either direction on x-axis + if (forgeDirection.x() == -1 && forgeDirection.z() == 0) { + offset.x = z; + offset.y = y; + offset.z = -x; + } + if (forgeDirection.x() == 1 && forgeDirection.z() == 0) { + offset.x = -z; + offset.y = y; + offset.z = x; + } + // either direction on y-axis + if (forgeDirection.y() == -1) { + offset.x = x; + offset.y = z; + offset.z = y; + } + + return offset; + } + + @Override + public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) { + // Figure out the vector for the direction the back face of the controller is facing + final Vector3ic forgeDirection = new Vector3i( + ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX, + ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY, + ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ + ); + int minCasingAmount = 20; + boolean formationChecklist = true; // If this is still true at the end, machine is good to go :) + float runningCostAcc = 0; + double fluidCapacityAcc = 0; + + sMultiHatches.clear(); + + // Front segment + for (int X = -2; X <= 2; X++) { + for (int Y = -2; Y <= 2; Y++) { + if (X == 0 && Y == 0) { + continue; // Skip controller + } + + // Get next TE + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); + final IGregTechTileEntity currentTE = + thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + + // Fluid hatches should touch the storage field. + // Maintenance/Energy hatch can go anywhere + if (X > -2 && X < 2 && Y > -2 && Y < 2) { + if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID) + && !addMultiHatchToMachineList(currentTE, CASING_TEXTURE_ID)) { + + // If it's not a hatch, is it the right casing for this machine? Check block and block meta. + // Also check for multi hatch + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else { + formationChecklist = false; + } + } + } else { + if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { + + // If it's not a hatch, is it the right casing for this machine? Check block and block meta. + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else { + formationChecklist = false; + } + } + } + } + } + + // Middle seven long segment + for (int X = -2; X <= 2; X++) { + for (int Y = -2; Y <= 2; Y++) { + for (int Z = -1; Z >= -7; Z--) { + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z); + if (X > -2 && X < 2 && Y > -2 && Y < 2) { + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD1.getUnlocalizedName())) { + runningCostAcc += 0.5f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT1.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD2.getUnlocalizedName())) { + runningCostAcc += 1.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT2.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD3.getUnlocalizedName())) { + runningCostAcc += 2.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT3.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD4.getUnlocalizedName())) { + runningCostAcc += 4.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT4.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD5.getUnlocalizedName())) { + runningCostAcc += 8.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT5.getCapacity(); + } else { + formationChecklist = false; + } + continue; + } + + // Get next TE + final IGregTechTileEntity currentTE = + thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + + // Corner allows only glass + if (X == -2 && Y == -2 || X == 2 && Y == 2 || X == -2 && Y == 2 || X == 2 && Y == -2) { + if (!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced))) { + formationChecklist = false; + } + } else { + // Tries to add TE as either of those kinds of hatches. + // The number is the texture index number for the texture that needs to be painted over the hatch texture (TAE for GT++) + if (!super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) + && !addMultiHatchToMachineList(currentTE, CASING_TEXTURE_ID)) { + + // If it's not a hatch, is it the right casing for this machine? Check block and block meta. + // Also check for multi hatch + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced)) { + formationChecklist = false; + } + } + } + } + } + } + + // Back segment + for (int X = -2; X <= 2; X++) { + for (int Y = -2; Y <= 2; Y++) { + // Get next TE + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8); + final IGregTechTileEntity currentTE = + thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + + // Fluid hatches should touch the storage field. + // Maintenance/Energy hatch can go anywhere + if (X > -2 && X < 2 && Y > -2 && Y < 2) { + if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE