diff options
Diffstat (limited to 'src/main')
23 files changed, 741 insertions, 1732 deletions
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<TE_TFFTMultiHatch> 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<FluidStack> 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<String> 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<GTMTE_TFFTMultiHatch> 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<FluidStack> 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_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. + 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; + } + } + } + } + } + + 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 (GTMTE_TFFTMultiHatch mh : sMultiHatches) { + mh.setMultiFluidHandler(mfh); + } + } + + return formationChecklist; + } + + public boolean addMultiHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } else if (aMetaTileEntity instanceof GTMTE_TFFTMultiHatch) { + ((GTMTE_TFFTMultiHatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.sMultiHatches.add((GTMTE_TFFTMultiHatch)aMetaTileEntity); + } else { + return false; + } + } + } + + @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<String> 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 (GTMTE_TFFTMultiHatch mh : sMultiHatches) { + 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; + } }
\ No newline at end of file diff --git a/src/main/java/common/tileentities/GTMTE_ItemServer.java b/src/main/java/common/tileentities/GTMTE_ItemServer.java deleted file mode 100644 index cfff360ce4..0000000000 --- a/src/main/java/common/tileentities/GTMTE_ItemServer.java +++ /dev/null @@ -1,393 +0,0 @@ -package common.tileentities; - -import java.util.ArrayList; -import java.util.HashSet; - -import org.lwjgl.input.Keyboard; - -import common.Blocks; -import common.blocks.Block_ItemServerDrive; -import common.blocks.Block_ItemServerIOPort; -import common.blocks.Block_ItemServerRackCasing; -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_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import kekztech.MultiItemHandler; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; -import util.MultiBlockTooltipBuilder; -import util.Vector3i; -import util.Vector3ic; - -public class GTMTE_ItemServer extends GT_MetaTileEntity_MultiBlockBase { - - private static final int BASE_SEGMENT_ENERGY_COST = 1; - private static final int BASE_PER_ITEM_CAPACITY = 1024; - private static final int BASE_ITEM_TYPES_PER_SEGMENT = 4; - - private final Block_ItemServerDrive DRIVE = (Block_ItemServerDrive) Blocks.itemServerDrive; - private final Block_ItemServerRackCasing CASING = (Block_ItemServerRackCasing) Blocks.itemServerRackCasing; - private final Block_ItemServerIOPort IO_PORT = (Block_ItemServerIOPort) Blocks.itemServerIOPort; - private final String ALU_FRAME_BOX_NAME = "gt.blockmachines"; - private final int ALU_FRAME_BOX_META = 6; - private final int CASING_TEXTURE_ID = 176; - - private MultiItemHandler mih; - private HashSet<TE_ItemServerIOPort> ioPorts = new HashSet<>(); - private int sliceCount = 0; - - public GTMTE_ItemServer(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GTMTE_ItemServer(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { - return new GTMTE_ItemServer(super.mName); - } - - @Override - public String[] getDescription() { - final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); - b.addInfo("[W.I.P - Probably doesn't work]") - .addInfo("High-Tech item storage!") - .addInfo("Variable length: Slices 2-4 can be repeated as long as the total length does not exceed 16 blocks.") - .addInfo("Each segment offers storage for 128 item types") - .addInfo("Storage capacity per item depends on the controller configuration.") - .addInfo("Insert an Integrated Circuit into the controller with your desired configuration.") - .addInfo("The base configuration (0) is 1024 items per type. For each higher level, the capacity quadruples.") - .addInfo("Each slice also adds 1EU/t of power consumption and doubles with rising configuration values.") - .addInfo("Valid config values are from zero to eight.") - .addSeparator() - .beginStructureBlock(3, 5, 4) - .addController("Front Bottom Center") - .addEnergyHatch("Any casing") - .addOtherStructurePart("Front slice", "3x5x1 Item Server Rack Casing") - .addOtherStructurePart("2nd and 3rd slice, center", "1x4x1 Aluminium Frame Box") - .addOtherStructurePart("2nd and 3rd slice, top", "3x1x1 Item Server Rack Casing") - .addOtherStructurePart("2nd and 3rd slice, sides", "2x 1x4x1 Item Server Drive") - .addOtherStructurePart("Back slice", "3x5x1 Item Server Rack Casing") - .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) { - final int config = (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) - ? Math.min(8, guiSlotItem.getItemDamage()) : 0; - - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - this.mEUt = (int) -(BASE_SEGMENT_ENERGY_COST * sliceCount * Math.pow(2, config)); - super.mMaxProgresstime = 20; - - mih.setPerTypeCapacity((int) (BASE_PER_ITEM_CAPACITY * Math.pow(4, config))); - - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if(mih != null) { - mih.setLock(!super.getBaseMetaTileEntity().isActive()); - } - } - - 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; - } - - 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 - ); - boolean formationChecklist = true; - - // Front slice - for(int X = -1; X <= 1; X++) { - for(int Y = 0; Y <= 4; Y++) { - if(X == 0 && Y == 0) { - continue; // is controller - } - - // Get next TE - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); - IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // Is casing or IO port? - if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Is casing, but there's no casing requirements - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) { - final TE_ItemServerIOPort port = - (TE_ItemServerIOPort) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - ioPorts.add(port); - } else { - formationChecklist = false; - } - } - } - } - - // Check slices - int segmentsFound = 0; - int zOffset = -1; // -1 is the first slice after the front one. It goes in negative direction. - - while(segmentsFound < 5) { - if(checkSegment(thisController, forgeDirection, zOffset)) { - segmentsFound++; - zOffset -= 3; // Each segment is 3 blocks long, so progress Z by -3 - - System.out.println("Item Server segment approved: " + segmentsFound); - } else { - System.out.println("Item Server segment rejected: " + (segmentsFound + 1)); - break; - } - } - - if(segmentsFound < 1) { - System.out.println("At least one slice required for storage"); - formationChecklist = false; - } - - if(this.mEnergyHatches.size() < 1) { - System.out.println("At least one energy hatch is required!"); - formationChecklist = false; - } - - if(this.mMaintenanceHatches.size() < 1) { - System.out.println("You need a maintenance hatch to do maintenance."); - formationChecklist = false; - } - - if(formationChecklist) { - sliceCount = segmentsFound; - - if(mih == null) { - mih = new MultiItemHandler(); - mih.setItemTypeCapacity(segmentsFound * BASE_ITEM_TYPES_PER_SEGMENT); - } - System.out.println("Configuring " + ioPorts.size() + " ports"); - for(TE_ItemServerIOPort port : ioPorts) { - port.setMultiItemHandler(mih); - } - } - - return formationChecklist; - } - - public boolean checkSegment(IGregTechTileEntity thisController, Vector3ic forgeDirection, int zOffset) { - boolean formationChecklist = true; - // Slice by slice - for(int Z = 0; Z >= -2; Z--) { - // Is not back slice - if(Z != -2) { - // Left to right - for(int X = -1; X <= 1; X++) { - // Bottom to top - for(int Y = 0; Y <= 4; Y++) { - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, zOffset + Z); - - // Server rack roof - if(Y == 4) { - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - // Is casing or IO port? - if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Is casing, but there's no casing requirements - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) { - final TE_ItemServerIOPort port = - (TE_ItemServerIOPort) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - ioPorts.add(port); - } else { - formationChecklist = false; - } - } - } - - // Middle wall is aluminium frame boxes - else if(Y <= 3 && X == 0) { - if(!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(ALU_FRAME_BOX_NAME)) - || !(thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == ALU_FRAME_BOX_META)) { - formationChecklist = false; - } - } - - // Side walls are item server drives - else if(Y <= 3 && X != 0) { - if(!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == DRIVE)) { - formationChecklist = false; - } - } - } - } - } else { - // Back slice - for(int X = -1; X <= 1; X++) { - for(int Y = 0; Y <= 4; Y++) { - - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, zOffset + Z); - IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - // Is casing or IO port? - if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Is casing, but there's no casing requirements - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) { - final TE_ItemServerIOPort port = - (TE_ItemServerIOPort) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - ioPorts.add(port); - } else { - formationChecklist = false; - } - } - } - } - } - } - - - return formationChecklist; - } - - @Override - public String[] getInfoData() { - final ArrayList<String> ll = new ArrayList<>();//mfh.getInfoData(); - - ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); - ll.add("Per-Item Capacity: " + mih.getPerTypeCapacity()); - ll.add("Item-Type Capacity: " + BASE_ITEM_TYPES_PER_SEGMENT * sliceCount); - 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; - - super.saveNBTData(nbt); - } - - @Override - public void loadNBTData(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - 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; - } -} diff --git a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java new file mode 100644 index 0000000000..529a948dbe --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java @@ -0,0 +1,196 @@ +package common.tileentities; + +import gregtech.api.GregTech_API; +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; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import kekztech.MultiFluidHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.HashMap; + +public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { + + private static final HashMap<Integer, Integer> vals = new HashMap<>(); + static { + vals.put(3, 2000); + vals.put(5, 20000); + vals.put(7, 200000); + } + private static final int INV_SLOT_COUNT = 2; + + private MultiFluidHandler mfh; + private boolean outputting = false; + + public GTMTE_TFFTMultiHatch(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, INV_SLOT_COUNT, new String[] { + "All-in-one access for the T.F.F.T", + "Right-click with a screwdriver to toggle auto-output", + "Throughput: " + vals.get(aTier) + "L/s per fluid"} + ); + } + + public GTMTE_TFFTMultiHatch(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, INV_SLOT_COUNT, aDescription, aTextures); + } + + public GTMTE_TFFTMultiHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, INV_SLOT_COUNT, aDescription, aTextures); + } + + public void setMultiFluidHandler(MultiFluidHandler mfh) { + this.mfh = mfh; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("outputting", outputting); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + outputting = aNBT.getBoolean("outputting"); + } + + @Override + public ITexture[] getTexturesActive(ITexture iTexture) { + return new ITexture[0]; + } + + @Override + public ITexture[] getTexturesInactive(ITexture iTexture) { + return new ITexture[0]; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GTMTE_TFFTMultiHatch(super.mName, super.mTier, super.mDescriptionArray, super.mTextures); + } + + @Override + public boolean isMachineBlockUpdateRecursive() { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (GT_Utility.isStackInList(aPlayer.getHeldItem(), GregTech_API.sScrewdriverList)) { + if (GT_ModHandler.damageOrDechargeItem(aPlayer.getHeldItem(), 1, 200, aPlayer)) { + outputting = !outputting; + GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(100), + 1.0F, -1.0F, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord() + ); + // Give chat feedback + GT_Utility.sendChatToPlayer(aPlayer, outputting ? "Auto-output enabled" : "Auto-output disabled"); + } + return true; + } + return false; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public int getCapacity() { + return (mfh != null) ? mfh.getCapacity() : 0; + } + + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && mfh != null) { + // Handle emptying containers + final FluidStack fluidFromCell = GT_Utility.getFluidForFilledItem(super.mInventory[super.getInputSlot()], true); + // Check if fluid is not null, could be inserted, and if there is space for the empty container + if (fluidFromCell != null && mfh.couldPush(fluidFromCell) + && aBaseMetaTileEntity.addStackToSlot(super.getOutputSlot(), GT_Utility.getContainerItem(super.mInventory[super.getInputSlot()], true), 1)) { + // Consume one filled container if it was emptied successfully + if(mfh.pushFluid(fluidFromCell, true) == fluidFromCell.amount) { + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + // Handle filling containers. This will use the selected T.F.F.T fluid + final ItemStack cellFromFluid = GT_Utility.fillFluidContainer( + mfh.getFluid(mfh.getSelectedFluid()), super.mInventory[super.getInputSlot()], false, true); + // Check if cell is not null and if there is space for the filled container + if (cellFromFluid != null && aBaseMetaTileEntity.addStackToSlot(super.getOutputSlot(), cellFromFluid, 1)) { + // Convert back to FluidStack to learn the container capacity... + final FluidStack fluidCapacityStack = GT_Utility.getFluidForFilledItem(cellFromFluid, true); + // Consume one empty container if it was filled successfully + if(mfh.pullFluid(fluidCapacityStack, true) == fluidCapacityStack.amount) { + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return (mfh != null) ? mfh.pushFluid(resource, doFill) : 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return (mfh != null) ? new FluidStack(resource.getFluid(), mfh.pullFluid(resource, doDrain)) : null; + } + + /** + * Drains fluid out of 0th internal tank. + * If the TFFT Controller contains an Integrated Circuit, drain fluid + * from the slot equal to the circuit configuration. + * + * @param from + * Orientation the fluid is drained to. + * @param maxDrain + * Maximum amount of fluid to drain. + * @param doDrain + * If false, drain will only be simulated. + * @return FluidStack representing the Fluid and amount that was (or would have been, if + * simulated) drained. + */ + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if(mfh != null) { + final FluidStack drain = mfh.getFluid(0); + if(drain != null) { + // If there's no integrated circuit in the T.F.F.T. controller, output slot 0 + final byte selectedSlot = (mfh.getSelectedFluid() == -1) ? 0 : mfh.getSelectedFluid(); + + return new FluidStack( + drain.getFluid(), + mfh.pullFluid(new FluidStack(drain.getFluid(), maxDrain), selectedSlot, doDrain) + ); + } + } + return null; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == super.getOutputSlot(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == super.getInputSlot(); + } + +} diff --git a/src/main/java/common/tileentities/TE_ItemServerIOPort.java b/src/main/java/common/tileentities/TE_ItemServerIOPort.java deleted file mode 100644 index 0e96ff75b9..0000000000 --- a/src/main/java/common/tileentities/TE_ItemServerIOPort.java +++ /dev/null @@ -1,145 +0,0 @@ -package common.tileentities; - -import kekztech.MultiItemHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -public class TE_ItemServerIOPort extends TileEntity implements ISidedInventory { - - private MultiItemHandler mih; - - private int tickCounter = 0; - - public void setMultiItemHandler(MultiItemHandler mih) { - this.mih = mih; - } - - @Override - public void updateEntity() { - if(mih != null) { - - tickCounter++; - if(tickCounter >= 40) { - mih.debugPrint(); - tickCounter = 0; - } - } - } - - @Override - public int getSizeInventory() { - return (mih != null) ? mih.getItemTypeCapacity() : 0; - } - - @Override - public ItemStack getStackInSlot(int slot) { - return (mih != null) ? mih.getStackInSlot(slot) : null; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - if(mih != null) { - if(mih.getStackInSlot(slot) != null) { - final ItemStack obtained = mih.getStackInSlot(slot).copy(); - obtained.stackSize = mih.reduceStackInSlot(slot, amount); - super.markDirty(); - return obtained; - } else { - return null; - } - } else { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemStack) { - System.out.println("Set slot: " + slot); - if(mih != null) { - if(itemStack == null) { - return; - } else { - if(!mih.insertStackInSlot(slot, itemStack)) { - final int delta = itemStack.stackSize - mih.getStackInSlot(slot).stackSize; - if(delta < 0) { - System.out.println("Set slot reduce: " + itemStack.getDisplayName()); - mih.reduceStackInSlot(slot, delta); - } else { - System.out.println("Set slot increase: " + itemStack.getDisplayName()); - mih.increaseStackInSlot(slot, delta); - } - - } else { - System.out.println("Allocated new slot for: " + itemStack.getDisplayName()); - } - super.markDirty(); - } - } - } - - @Override - public String getInventoryName() { - return "Item Server IO Port"; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public int getInventoryStackLimit() { - return (mih != null) ? mih.getPerTypeCapacity() : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return true; - } - - @Override - public void openInventory() { - - } - - @Override - public void closeInventory() { - - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemStack) { - return (mih != null) ? (mih.getStackInSlot(slot).isItemEqual(itemStack) || mih.getStackInSlot(slot) == null) : false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - if(mih != null) { - final int[] as = new int[mih.getItemTypeCapacity()]; - for(int i = 0; i < mih.getItemTypeCapacity(); i++) { - as[i] = i; - } - return as; - } else { - return new int[1]; - } - } - - @Override - public boolean canInsertItem(int slot, ItemStack itemStack, int side) { - return isItemValidForSlot(slot, itemStack); - } - - @Override - public boolean canExtractItem(int slot, ItemStack itemStack, int side) { - return (mih != null) ? true : false; - } - -} diff --git a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java index 161cad3110..823d456b56 100644 --- a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java @@ -14,6 +14,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; +@Deprecated public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { public static final int BASE_OUTPUT_PER_SECOND = 2000; // L/s diff --git a/src/main/java/kekztech/Items.java b/src/main/java/kekztech/Items.java index 66a8f996e3..59873f88a0 100644 --- a/src/main/java/kekztech/Items.java +++ b/src/main/java/kekztech/Items.java @@ -40,7 +40,6 @@ public enum Items { YSZCeramicDust(9,1), GDCCeramicDust(10,1), YttriaDust(11,1), ZirconiaDust(12,1), CeriaDust(13,1), YSZCeramicPlate(14,1), GDCCeramicPlate(15,1), - ItemServerBlade(16,1), // Error Item Error(0,1), // Configurator diff --git a/src/main/java/kekztech/MultiFluidHandler.java b/src/main/java/kekztech/MultiFluidHandler.java index f1a527b2c0..1d8f4c2fea 100644 --- a/src/main/java/kekztech/MultiFluidHandler.java +++ b/src/main/java/kekztech/MultiFluidHandler.java @@ -70,14 +70,15 @@ public class MultiFluidHandler { public int getCapacity() { return capacityPerFluid; } - + + // TODO return deep copy instead public List<FluidStack> getFluids(){ return (!locked) ? fluids : new ArrayList<>(); } public FluidStack getFluid(int slot) { return (!locked && fluids.size() > 0 && slot >= 0 && slot < MAX_DISTINCT_FLUIDS) - ? fluids.get(slot) : null; + ? fluids.get(slot).copy() : null; } public NBTTagCompound saveNBTData(NBTTagCompound nbt) { diff --git a/src/main/java/kekztech/MultiItemHandler.java b/src/main/java/kekztech/MultiItemHandler.java deleted file mode 100644 index 27d936efec..0000000000 --- a/src/main/java/kekztech/MultiItemHandler.java +++ /dev/null @@ -1,185 +0,0 @@ -package kekztech; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -public class MultiItemHandler { - - private int perTypeCapacity = 0; - - private boolean locked = true; - - private ItemStack[] items; - - public MultiItemHandler() { - - } - - public List<String> debugPrint() { - if(items == null) { - return new ArrayList<String>(); - } - final ArrayList<String> slots = new ArrayList<>(); - - for(int i = 0; i < items.length; i++) { - slots.add("Slot " + i + " contains " + items[i].stackSize + " " + items[i].getDisplayName()); - } - - return slots; - } - - /** - * Adapts the internal storage to structure changes. - * In the event of structure down-sizing, all excess items - * will be dropped on the ground. - * - * @param itemTypeCapacity - */ - public void setItemTypeCapacity(int itemTypeCapacity) { - System.out.println("Configuring type capacity"); - if(items.length > itemTypeCapacity) { - // Generate new smaller backing array - final ItemStack[] newItems = new ItemStack[itemTypeCapacity]; - for(int i = 0; i < newItems.length; i++) { - newItems[i] = items[i]; - } - // Sort out item overflow - final ItemStack[] toDrop = new ItemStack[items.length - itemTypeCapacity]; - for(int i = 0; i < toDrop.length; i++) { - toDrop[i] = items[i + newItems.length - 1]; - } - // TODO drop overflow items to the ground - - // Swap array - items = newItems; - } else { - // Generate new larger backing array - final ItemStack[] newItems = new ItemStack[itemTypeCapacity]; - for(int i = 0; i < items.length; i++) { - newItems[i] = items[i]; - } - - // Swap array - items = newItems; - } - } - - public void setPerTypeCapacity(int perTypeCapacity) { - this.perTypeCapacity = perTypeCapacity; - } - - /** - * Lock internal storage in case Item Server is not running. - * - * @param state - * Lock state. - */ - public void setLock(boolean state) { - locked = state; - } - - public int getItemTypeCapacity() { - return items != null ? items.length : 0; - } - - public int getPerTypeCapacity() { - return perTypeCapacity; - } - - /** - * Returns the ItemStack from the specified slot. - * - * @param slot - * Storage slot number. Zero indexed. - * @return - * ItemStack from storage or null if - * storage is locked or invalid slot parameter. - */ - public ItemStack getStackInSlot(int slot) { - System.out.println("Stack in slot " + slot + " requested"); - if(locked || slot >= items.length) { - return null; - } else { - return items[slot]; - } - } - - /** - * Inserts a new ItemStack into storage, - * but only if the slot is still unassigned. - * - * @param slot - * Storage slot number. Zero indexed. - * @param itemStack - * ItemStack to insert. - * @return - * Operation success state. - */ - public boolean insertStackInSlot(int slot, ItemStack itemStack) { - System.out.println("Inserting " + itemStack.getDisplayName() + " into " + slot); - if(itemStack == null - || items[slot] != null - || locked - || slot >= items.length) { - return false; - } else { - items[slot] = itemStack; - return true; - } - } - - /** - * Tries to increase the item amount in a specified slot. - * - * @param slot - * Storage slot number. Zero indexed. - * @param amount - * Amount to increase by. - * @return - * Actual amount the item amount was increased by. - */ - public int increaseStackInSlot(int slot, int amount) { - System.out.println("Increasing item in slot " + slot + " by " + amount); - if(slot >= items.length - || locked - || amount <= 0) { - return 0; - } else { - final int space = perTypeCapacity - items[slot].stackSize; - final int fit = Math.min(space, amount); - items[slot].stackSize += fit; - return fit; - } - } - - /** - * Tries to reduce the item amount in a specified slot. - * - * @param slot - * Storage slot number. Zero indexed. - * @param amount - * Amount to decrease by. - * @return - * Actual amount the item amount was decreased by. - */ - public int reduceStackInSlot(int slot, int amount) { - System.out.println("Reducing item in slot " + slot + " by " + amount); - if(slot >= items.length - || locked - || amount <= 0) { - return 0; - } else { - final int available = items[slot].stackSize; - final int take = Math.min(available, amount); - items[slot].stackSize -= take; - if(take == available) { - items[slot] = null; - } - return take; - } - } - - -} diff --git a/src/main/resources/assets/kekztech/lang/en_US.lang b/src/main/resources/assets/kekztech/lang/en_US.lang index 16f7233e17..9d201e442a 100644 --- a/src/main/resources/assets/kekztech/lang/en_US.lang +++ b/src/main/resources/assets/kekztech/lang/en_US.lang @@ -117,24 +117,10 @@ tile.kekztech_tfftstoragefieldblock2_block.name=T.F.F.T Storage Field Block (Tie tile.kekztech_tfftstoragefieldblock3_block.name=T.F.F.T Storage Field Block (Tier III) tile.kekztech_tfftstoragefieldblock4_block.name=T.F.F.T Storage Field Block (Tier IV) tile.kekztech_tfftstoragefieldblock5_block.name=T.F.F.T Storage Field Block (Tier V) -tile.kekztech_tfftmultihatch_block.0.name=T.F.F.T Multi-Fluid I/O Hatch (Tier I) -tile.kekztech_tfftmultihatch_block.1.name=T.F.F.T Multi-Fluid I/O Hatch (Tier II) -tile.kekztech_tfftmultihatch_block.2.name=T.F.F.T Multi-Fluid I/O Hatch (Tier III) -tile.kekztech_tfftmultihatch_block.0.desc=Special hatch for the T.F.F.T -tile.kekztech_tfftmultihatch_block.1.desc=Allows for automated interaction with all stored fluids in a single place -tile.kekztech_tfftmultihatch_block.2.desc=Right-click with screwdriver to activate auto-output -tile.kekztech_tfftmultihatch_block.3.desc=Auto-output will try to output fluids into adjacent tanks at a per fluid rate of - -# -------- Item Server: Structure Blocks -tile.kekztech_itemserverdrive_block.name=Item Server Drive -tile.kekztech_itemserverdrive_block.0.desc=Item Server Storage Drive -tile.kekztech_itemserverrackcasing_block.name=Item Server Rack Casing -tile.kekztech_itemserverrackcasing_block.0.desc=Shiny new server rack -tile.kekztech_itemserverioport_block.name=Item Server I/O Port -tile.kekztech_itemserverioport_block.0.desc=I/O Port for interfacing with an Item Server - -# -------- Item Server: Crafting Components -item.kekztech_crafting_item.16.name=Item Server Blade +tile.kekztech_tfftmultihatch_block.0.name=[DEPRECATED] T.F.F.T Multi-Fluid I/O Hatch (Tier I) +tile.kekztech_tfftmultihatch_block.1.name=[DEPRECATED] T.F.F.T Multi-Fluid I/O Hatch (Tier II) +tile.kekztech_tfftmultihatch_block.2.name=[DEPRECATED] T.F.F.T Multi-Fluid I/O Hatch (Tier III) +tile.kekztech_tfftmultihatch_block.0.desc=Put in crafting field to change to update # -------- Item Proxy: Structure Blocks tile.kekztech_itemproxycable_block.name=Item Proxy Network Cable |