From cf4206d981762fbcd00ab62f89034eb351559356 Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Tue, 2 Jun 2020 01:49:21 +0200 Subject: Refactored into sided proxies --- src/main/java/client/ClientProxy.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/client/ClientProxy.java (limited to 'src/main/java/client/ClientProxy.java') diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java new file mode 100644 index 0000000000..e50639b878 --- /dev/null +++ b/src/main/java/client/ClientProxy.java @@ -0,0 +1,29 @@ +package client; + +import client.renderer.TESR_SECapacitor; +import client.renderer.TESR_SETether; +import common.CommonProxy; +import common.tileentities.TE_SpaceElevatorCapacitor; +import common.tileentities.TE_SpaceElevatorTether; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy { + + @Override + public void preInit(final FMLPreInitializationEvent e) { + super.preInit(e); + // Register TESR + ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorTether.class, new TESR_SETether()); + ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorCapacitor.class, new TESR_SECapacitor()); + } + + @Override + public void init(final FMLInitializationEvent e) { + super.init(e); + // Register Simple Block Renderers + //RenderingRegistry.registerBlockHandler(ConduitRenderer.getInstance()); + } + +} -- cgit From c26c2895e7188c0d4cdeae0af104075efcc404f0 Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Sun, 7 Jun 2020 17:35:50 +0200 Subject: implemented correct item rendering for new multi hatches --- src/main/java/client/ClientProxy.java | 3 + src/main/java/client/renderer/HatchRenderer.java | 77 +++++++++++++++++++++ .../java/common/blocks/Block_TFFTMultiHatch.java | 41 ++++++++--- .../textures/blocks/TFFTMultiHatch0_off.png | Bin 0 -> 2022 bytes .../textures/blocks/TFFTMultiHatch0_on.png | Bin 0 -> 2022 bytes .../kekztech/textures/blocks/TFFTMultiHatch1.png | Bin 1840 -> 0 bytes .../textures/blocks/TFFTMultiHatch1_off.png | Bin 0 -> 2022 bytes .../textures/blocks/TFFTMultiHatch1_on.png | Bin 0 -> 2022 bytes .../kekztech/textures/blocks/TFFTMultiHatch2.png | Bin 1840 -> 0 bytes .../textures/blocks/TFFTMultiHatch2_off.png | Bin 0 -> 2022 bytes .../textures/blocks/TFFTMultiHatch2_on.png | Bin 0 -> 2022 bytes .../kekztech/textures/blocks/TFFTMultiHatch3.png | Bin 1839 -> 0 bytes 12 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 src/main/java/client/renderer/HatchRenderer.java create mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_off.png create mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_on.png delete mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1.png create mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_off.png create mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_on.png delete mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2.png create mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_off.png create mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_on.png delete mode 100755 src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch3.png (limited to 'src/main/java/client/ClientProxy.java') diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index e50639b878..c863198976 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -1,11 +1,13 @@ package client; +import client.renderer.HatchRenderer; import client.renderer.TESR_SECapacitor; import client.renderer.TESR_SETether; import common.CommonProxy; import common.tileentities.TE_SpaceElevatorCapacitor; import common.tileentities.TE_SpaceElevatorTether; import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -24,6 +26,7 @@ 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 new file mode 100644 index 0000000000..0a764b3118 --- /dev/null +++ b/src/main/java/client/renderer/HatchRenderer.java @@ -0,0 +1,77 @@ +package client.renderer; + +import common.tileentities.TE_ItemProxyCable; +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.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; +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) { + + + 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/Block_TFFTMultiHatch.java b/src/main/java/common/blocks/Block_TFFTMultiHatch.java index a70e983ed3..eda34c8ce3 100644 --- a/src/main/java/common/blocks/Block_TFFTMultiHatch.java +++ b/src/main/java/common/blocks/Block_TFFTMultiHatch.java @@ -1,9 +1,13 @@ package common.blocks; +import client.renderer.ConduitRenderer; +import client.renderer.HatchRenderer; import common.Blocks; 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; @@ -29,7 +33,8 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { private static final Block_TFFTMultiHatch INSTANCE = new Block_TFFTMultiHatch(); private IIcon casing; - private final IIcon[] tieredTexture = new IIcon[3]; + private final IIcon[] overlayOff = new IIcon[3]; + private final IIcon[] overlayOn = new IIcon[3]; private Block_TFFTMultiHatch() { super(Material.iron); @@ -39,7 +44,6 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { final String blockName = "kekztech_tfftmultihatch_block"; INSTANCE.setBlockName(blockName); INSTANCE.setCreativeTab(CreativeTabs.tabMisc); - INSTANCE.setBlockTextureName(KekzCore.MODID + ":" + "TFFTMultiHatch"); INSTANCE.setHardness(5.0f); INSTANCE.setResistance(6.0f); GameRegistry.registerBlock(INSTANCE, IB_TFFTMultiHatch.class, blockName); @@ -50,8 +54,9 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { @Override public void registerBlockIcons(IIconRegister ir) { casing = ir.registerIcon("kekztech:TFFTCasing"); - for(int i = 0; i < tieredTexture.length; i++) { - tieredTexture[i] = ir.registerIcon("kekztech:TFFTMultiHatch" + (i + 1)); + for(int i = 0; i < overlayOff.length; i++) { + overlayOff[i] = ir.registerIcon("kekztech:TFFTMultiHatch" + i + "_off"); + overlayOn[i] = ir.registerIcon("kekztech:TFFTMultiHatch" + i + "_on"); } } @@ -64,13 +69,33 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { par3List.add(new ItemStack(par1, 1, 2)); } + @Override + public IIcon getIcon(int side, int meta) { + if(side != 3) { + return casing; + } else { + return overlayOff[meta]; + } + } + @Override public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - final TileEntity te = blockAccess.getTileEntity(x, y, z); - if(te instanceof TE_TFFTMultiHatch && ((TE_TFFTMultiHatch) te).hasFacingOnSide((byte) side)){ - return tieredTexture[blockAccess.getBlockMetadata(x, y, z)]; + if(side != 3) { + return casing; + } else { + return overlayOff[blockAccess.getBlockMetadata(x, y, z)]; } - return casing; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 0; + } + + @Override + public int getRenderType() { + return HatchRenderer.RID; } @Override diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_off.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_off.png new file mode 100755 index 0000000000..96ced7f091 Binary files /dev/null and b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_off.png differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_on.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_on.png new file mode 100755 index 0000000000..149c7c847e Binary files /dev/null and b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch0_on.png differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1.png deleted file mode 100755 index 3b897857a6..0000000000 Binary files a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1.png and /dev/null differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_off.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_off.png new file mode 100755 index 0000000000..259826d921 Binary files /dev/null and b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_off.png differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_on.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_on.png new file mode 100755 index 0000000000..ed5dd7610b Binary files /dev/null and b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch1_on.png differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2.png deleted file mode 100755 index eb749ca0e8..0000000000 Binary files a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2.png and /dev/null differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_off.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_off.png new file mode 100755 index 0000000000..30fbb78f34 Binary files /dev/null and b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_off.png differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_on.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_on.png new file mode 100755 index 0000000000..be6c2a6856 Binary files /dev/null and b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch2_on.png differ diff --git a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch3.png b/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch3.png deleted file mode 100755 index 8d0c0d2fdc..0000000000 Binary files a/src/main/resources/assets/kekztech/textures/blocks/TFFTMultiHatch3.png and /dev/null differ -- cgit From 76b15123238ca2f01c1bf46db8a4ea20dc7ced2b Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Mon, 8 Jun 2020 02:50:03 +0200 Subject: Removed everything related to Item Server; Deprecated current TFFT Multi Hatch in favor of GTMTE version --- GregTech.lang | 10 + src/main/java/client/ClientProxy.java | 2 - src/main/java/client/renderer/HatchRenderer.java | 102 -- src/main/java/common/Blocks.java | 9 +- src/main/java/common/Recipes.java | 62 -- src/main/java/common/TileEntities.java | 15 +- .../java/common/blocks/Block_ItemServerDrive.java | 57 -- .../java/common/blocks/Block_ItemServerIOPort.java | 43 - .../common/blocks/Block_ItemServerRackCasing.java | 30 - .../java/common/blocks/Block_TFFTMultiHatch.java | 77 +- .../java/common/itemBlocks/IB_ItemServerDrive.java | 22 - .../common/itemBlocks/IB_ItemServerIOPort.java | 22 - .../common/itemBlocks/IB_ItemServerRackCasing.java | 22 - .../java/common/itemBlocks/IB_TFFTMultiHatch.java | 7 +- .../common/items/MetaItem_CraftingComponent.java | 3 +- .../tileentities/GTMTE_FluidMultiStorage.java | 1052 ++++++++++---------- .../java/common/tileentities/GTMTE_ItemServer.java | 393 -------- .../common/tileentities/GTMTE_TFFTMultiHatch.java | 196 ++++ .../common/tileentities/TE_ItemServerIOPort.java | 145 --- .../common/tileentities/TE_TFFTMultiHatch.java | 1 + src/main/java/kekztech/Items.java | 1 - src/main/java/kekztech/MultiFluidHandler.java | 5 +- src/main/java/kekztech/MultiItemHandler.java | 185 ---- src/main/resources/assets/kekztech/lang/en_US.lang | 22 +- 24 files changed, 751 insertions(+), 1732 deletions(-) delete mode 100644 src/main/java/client/renderer/HatchRenderer.java delete mode 100644 src/main/java/common/blocks/Block_ItemServerDrive.java delete mode 100644 src/main/java/common/blocks/Block_ItemServerIOPort.java delete mode 100644 src/main/java/common/blocks/Block_ItemServerRackCasing.java delete mode 100644 src/main/java/common/itemBlocks/IB_ItemServerDrive.java delete mode 100644 src/main/java/common/itemBlocks/IB_ItemServerIOPort.java delete mode 100644 src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java delete mode 100644 src/main/java/common/tileentities/GTMTE_ItemServer.java create mode 100644 src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java delete mode 100644 src/main/java/common/tileentities/TE_ItemServerIOPort.java delete mode 100644 src/main/java/kekztech/MultiItemHandler.java (limited to 'src/main/java/client/ClientProxy.java') diff --git a/GregTech.lang b/GregTech.lang index a0cbff982a..227be0de63 100644 --- a/GregTech.lang +++ b/GregTech.lang @@ -3578,9 +3578,18 @@ languagefile { S:TileEntity_DESCRIPTION_13107_Index_4=----------------------------------------- S:TileEntity_DESCRIPTION_13107_Index_5=Hold §l[LSHIFT]§r§7 to display structure guidelines S:TileEntity_DESCRIPTION_13107_Index_6=Created by Kekzdealer + S:TileEntity_DESCRIPTION_13108_Index_0=All-in-one access for the T.F.F.T + S:TileEntity_DESCRIPTION_13108_Index_1=Right-click with a screwdriver to toggle auto-output + S:TileEntity_DESCRIPTION_13108_Index_2=Throughput: 2000L/s per fluid + S:TileEntity_DESCRIPTION_13109_Index_0=All-in-one access for the T.F.F.T + S:TileEntity_DESCRIPTION_13109_Index_1=Right-click with a screwdriver to toggle auto-output + S:TileEntity_DESCRIPTION_13109_Index_2=Throughput: 20000L/s per fluid S:TileEntity_DESCRIPTION_1310_Index_0=Max Voltage: %s S:TileEntity_DESCRIPTION_1310_Index_1=Max Amperage: %s S:TileEntity_DESCRIPTION_1310_Index_2=Loss/Meter/Ampere: %s EU-Volt + S:TileEntity_DESCRIPTION_13110_Index_0=All-in-one access for the T.F.F.T + S:TileEntity_DESCRIPTION_13110_Index_1=Right-click with a screwdriver to toggle auto-output + S:TileEntity_DESCRIPTION_13110_Index_2=Throughput: 200000L/s per fluid S:TileEntity_DESCRIPTION_1311_Index_0=Max Voltage: %s S:TileEntity_DESCRIPTION_1311_Index_1=Max Amperage: %s S:TileEntity_DESCRIPTION_1311_Index_2=Loss/Meter/Ampere: %s EU-Volt @@ -13169,6 +13178,7 @@ languagefile { S:gt.blockmachines.machine.avr.tier.12.name=UMV AVR Micro-controller S:gt.blockmachines.machine.dehydrator.tier.00.name=Basic Dehydrator I S:gt.blockmachines.machine.dehydrator.tier.01.name=Basic Dehydrator II + S:gt.blockmachines.machine.multihatch.name=T.F.F.T Multi I/O Hatch [HV] S:gt.blockmachines.machine.tt.buck.05.name=Insane Buck Converter S:gt.blockmachines.machine.tt.buck.06.name=Ludicrous Buck Converter S:gt.blockmachines.machine.tt.buck.07.name=ZPM Voltage Buck Converter diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index c863198976..f608861c0d 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -1,6 +1,5 @@ package client; -import client.renderer.HatchRenderer; import client.renderer.TESR_SECapacitor; import client.renderer.TESR_SETether; import common.CommonProxy; @@ -26,7 +25,6 @@ public class ClientProxy extends CommonProxy { super.init(e); // Register Simple Block Renderers //RenderingRegistry.registerBlockHandler(ConduitRenderer.getInstance()); - RenderingRegistry.registerBlockHandler(HatchRenderer.getInstance()); } } diff --git a/src/main/java/client/renderer/HatchRenderer.java b/src/main/java/client/renderer/HatchRenderer.java deleted file mode 100644 index b2670af76b..0000000000 --- a/src/main/java/client/renderer/HatchRenderer.java +++ /dev/null @@ -1,102 +0,0 @@ -package client.renderer; - -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.client.registry.RenderingRegistry; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.world.IBlockAccess; -import org.lwjgl.opengl.GL11; - -public class HatchRenderer implements ISimpleBlockRenderingHandler { - - public static final int RID = RenderingRegistry.getNextAvailableRenderId(); - private static final HatchRenderer INSTANCE = new HatchRenderer(); - - private HatchRenderer() { - - } - - public static HatchRenderer getInstance() { - return INSTANCE; - } - - @Override - public void renderInventoryBlock(Block block, int meta, int modelId, RenderBlocks renderer) { - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - renderer.setRenderBoundsFromBlock(block); - final Tessellator t = Tessellator.instance; - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - t.startDrawingQuads(); - t.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); - t.draw(); - t.startDrawingQuads(); - t.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(6, meta)); - t.draw(); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, - RenderBlocks renderer) { - final Tessellator t = Tessellator.instance; - // Set colour - int mb = block.getMixedBrightnessForBlock(world, x, y, z); - t.setBrightness(mb); - - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - renderer.setRenderBoundsFromBlock(block); - - if (block.shouldSideBeRendered(world, x, y - 1, z, 6)) { - renderer.renderFaceYNeg(block, x, y, z, block.getIcon(world, x, y, z, 0)); - } - if (block.shouldSideBeRendered(world, x, y + 1, z, 6)) { - t.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, x, y, z, block.getIcon(world, x, y, z, 1)); - } - - if (block.shouldSideBeRendered(world, x, y, z - 1, 6)) { - renderer.renderFaceZNeg(block, x, y, z, block.getIcon(world, x, y, z, 2)); - } - if (block.shouldSideBeRendered(world, x, y, z + 1, 6)) { - renderer.renderFaceZPos(block, x, y, z, block.getIcon(world, x, y, z, 3)); - } - - if (block.shouldSideBeRendered(world, x - 1, y, z, 6)) { - renderer.renderFaceXNeg(block, x, y, z, block.getIcon(world, x, y, z, 4)); - } - if (block.shouldSideBeRendered(world, x + 1, y, z, 6)) { - renderer.renderFaceXPos(block, x, y, z, block.getIcon(world, x, y, z, 5)); - } - - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return HatchRenderer.RID; - } -} diff --git a/src/main/java/common/Blocks.java b/src/main/java/common/Blocks.java index 18725b6000..bc8b2ff573 100644 --- a/src/main/java/common/Blocks.java +++ b/src/main/java/common/Blocks.java @@ -44,7 +44,6 @@ public class Blocks { registerBlocks_SOFC(); registerBlocks_TFFT(); registerBlocks_Nuclear(); - //registerBlocks_ItemServer(); //registerBlocks_ItemProxy(); registerBlocks_Jars(); registerBlocks_LSC(); @@ -73,13 +72,7 @@ public class Blocks { reactorChamberON = Block_ReactorChamber_ON.registerBlock(); reactorControlRod = Block_ControlRod.registerBlock(); } - - private static void registerBlocks_ItemServer() { - itemServerDrive = Block_ItemServerDrive.registerBlock(); - itemServerRackCasing = Block_ItemServerRackCasing.registerBlock(); - itemServerIOPort = Block_ItemServerIOPort.registerBlock(); - } - + private static void registerBlocks_ItemProxy() { itemProxyCable = Block_ItemProxyCable.registerBlock(); itemProxySource = Block_ItemProxySource.registerBlock(); diff --git a/src/main/java/common/Recipes.java b/src/main/java/common/Recipes.java index eaaad88570..b694805c96 100644 --- a/src/main/java/common/Recipes.java +++ b/src/main/java/common/Recipes.java @@ -35,7 +35,6 @@ public class Recipes { registerRecipes_TFFT(); registerRecipes_SOFC(); registerRecipes_Nuclear(); - //registerRecipes_ItemServer(); registerRecipes_Jars(); registerRecipes_LSC(); registerRecipes_SpaceElevator(); @@ -329,67 +328,6 @@ public class Recipes { null, 1200, 7680); } - private static void registerRecipes_ItemServer() { - - final MetaItem_CraftingComponent craftingItem = MetaItem_CraftingComponent.getInstance(); - - // Controller - final Object[] is_recipe = { - "FRF", "CGC", "PZP", - 'F', GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.TungstenSteel, 1), - 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.TungstenSteel, 1), - 'C', ItemList.Conveyor_Module_LuV.get(1L), - 'G', ItemList.Field_Generator_EV.get(1L), - 'P', GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.VanadiumGallium, 1), - 'Z', GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 1) - }; - GT_ModHandler.addCraftingRecipe(TileEntities.is.getStackForm(1), is_recipe); - - // Blocks - final Object[] is_rack_recipe = { - "BRB", "CFC", "BRB", - 'B', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlueSteel, 1), - 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.Aluminium, 1), - 'C', GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Platinum, 1), - 'F', GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.TungstenSteel, 1), - }; - GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.itemServerRackCasing), is_rack_recipe); - final ItemStack[] is_ioport = { - GT_Utility.getIntegratedCircuit(6), - new ItemStack(Blocks.itemServerRackCasing), - GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.Platinum, 16), - GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Platinum, 2), - ItemList.Field_Generator_HV.get(1L), - ItemList.Robot_Arm_EV.get(4L) - }; - GT_Values.RA.addAssemblerRecipe( - is_ioport, - FluidRegistry.getFluidStack("molten.polytetrafluoroethylene", 144), - new ItemStack(Blocks.itemServerIOPort, 1), - 200, 7680); - final Object[] is_blade = { - "CRC", "CMC", "HPH", - 'C', GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1), - 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.Aluminium, 1), - 'P', GT_OreDictUnificator.get(OrePrefixes.cableGt08, Materials.Platinum, 1), - 'M', ItemList.Electric_Motor_EV.get(1L), - 'H', craftingItem.getStackFromDamage(Items.BoronArsenideHeatPipe.getMetaID()), - }; - GT_ModHandler.addCraftingRecipe(craftingItem.getStackOfAmountFromDamage(Items.ItemServerBlade.getMetaID(), 8), is_blade); - final ItemStack[] is_drive = { - GT_Utility.getIntegratedCircuit(6), - craftingItem.getStackOfAmountFromDamage(Items.ItemServerBlade.getMetaID(), 8), - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlueSteel, 4), - GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Aluminium, 1), - GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Aluminium, 16) - }; - GT_Values.RA.addAssemblerRecipe( - is_drive, - FluidRegistry.getFluidStack("molten.polyethylene", 1152), - new ItemStack(Blocks.itemServerDrive, 1), - 200, 7680); - } - private static void registerRecipes_Jars() { // Thaumium Reinforced Jar diff --git a/src/main/java/common/TileEntities.java b/src/main/java/common/TileEntities.java index 9e3a648667..35ac65d2e6 100644 --- a/src/main/java/common/TileEntities.java +++ b/src/main/java/common/TileEntities.java @@ -5,17 +5,20 @@ import cpw.mods.fml.common.registry.GameRegistry; public class TileEntities { + // Multiblock controllers public static GTMTE_SOFuelCellMK1 sofc1; public static GTMTE_SOFuelCellMK2 sofc2; public static GTMTE_ModularNuclearReactor mdr; public static GTMTE_FluidMultiStorage fms; - public static GTMTE_ItemServer is; public static GTMTE_LapotronicSuperCapacitor lsc; public static GTMTE_SpaceElevator se; - + // Singleblocks + public static GTMTE_TFFTMultiHatch mhHV; + public static GTMTE_TFFTMultiHatch mhIV; + public static GTMTE_TFFTMultiHatch mhZPM; + public static void preInit() { GameRegistry.registerTileEntity(TE_TFFTMultiHatch.class, "kekztech_tfftmultihatch_tile"); - //GameRegistry.registerTileEntity(TE_ItemServerIOPort.class, "kekztech_itemserverioport_tile"); GameRegistry.registerTileEntity(TE_ItemProxyCable.class, "kekztech_itemproxycable_tile"); GameRegistry.registerTileEntity(TE_ItemProxySource.class, "kekztech_itemproxysource_tile"); GameRegistry.registerTileEntity(TE_ItemProxyEndpoint.class, "kekztech_itemproxyendpoint_tile"); @@ -25,13 +28,17 @@ public class TileEntities { } public static void init() { + // Multiblock controllers sofc1 = new GTMTE_SOFuelCellMK1(13101, "multimachine.fuelcellmk1", "Solid-Oxide Fuel Cell Mk I"); sofc2 = new GTMTE_SOFuelCellMK2(13102, "multimachine.fuelcellmk2", "Solid-Oxide Fuel Cell Mk II"); mdr = new GTMTE_ModularNuclearReactor(13103, "multimachine.nuclearreactor", "Nuclear Reactor"); fms = new GTMTE_FluidMultiStorage(13104, "multimachine.tf_fluidtank", "T.F.F.T"); - //is = new GTMTE_ItemServer(13105, "multimachine.itemserver", "Item Server"); lsc = new GTMTE_LapotronicSuperCapacitor(13106, "multimachine.supercapacitor", "Lapotronic Supercapacitor"); se = new GTMTE_SpaceElevator(13107, "multimachine.spaceelevator", "Space Elevator"); + // Singleblocks + mhHV = new GTMTE_TFFTMultiHatch(13108, "machine.multihatch", "T.F.F.T Multi I/O Hatch [HV]", 3); + mhIV = new GTMTE_TFFTMultiHatch(13109, "machine.multihatch", "T.F.F.T Multi I/O Hatch [IV]", 5); + mhZPM = new GTMTE_TFFTMultiHatch(13110, "machine.multihatch", "T.F.F.T Multi I/O Hatch [ZPM]", 7); } } diff --git a/src/main/java/common/blocks/Block_ItemServerDrive.java b/src/main/java/common/blocks/Block_ItemServerDrive.java deleted file mode 100644 index 63747a8598..0000000000 --- a/src/main/java/common/blocks/Block_ItemServerDrive.java +++ /dev/null @@ -1,57 +0,0 @@ -package common.blocks; - -import common.itemBlocks.IB_ItemServerDrive; -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.KekzCore; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.util.IIcon; - -public class Block_ItemServerDrive extends BaseGTUpdateableBlock{ - - private static Block_ItemServerDrive instance = new Block_ItemServerDrive(); - - private IIcon[] faces = new IIcon[6]; - - private Block_ItemServerDrive() { - super(Material.iron); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemserverdrive_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setHardness(5.0f); - instance.setResistance(6.0f); - GameRegistry.registerBlock(instance, IB_ItemServerDrive.class, blockName); - - return instance; - } - - @Override - public void registerBlockIcons(IIconRegister reg) { - for(int i = 0; i < 6; i++) { - if(i == 0) { - faces[i] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerDrive_BOTTOM"); - } else if(i == 1) { - faces[i] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerDrive_TOP"); - } else { - faces[i] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerDrive"); - } - - } - } - - @Override - public IIcon getIcon(int side, int meta) { - return faces[side]; - } - - @Override - public int getLightValue() { - return 7; - } - -} diff --git a/src/main/java/common/blocks/Block_ItemServerIOPort.java b/src/main/java/common/blocks/Block_ItemServerIOPort.java deleted file mode 100644 index 6af90b6e42..0000000000 --- a/src/main/java/common/blocks/Block_ItemServerIOPort.java +++ /dev/null @@ -1,43 +0,0 @@ -package common.blocks; - -import common.itemBlocks.IB_ItemServerIOPort; -import common.tileentities.TE_ItemServerIOPort; -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.KekzCore; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class Block_ItemServerIOPort extends BaseGTUpdateableBlock { - - private static Block_ItemServerIOPort instance = new Block_ItemServerIOPort(); - - private Block_ItemServerIOPort() { - super(Material.iron); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemserverioport_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemServerIOPort"); - instance.setHardness(5.0f); - instance.setResistance(6.0f); - GameRegistry.registerBlock(instance, IB_ItemServerIOPort.class, blockName); - - return instance; - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } - - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TE_ItemServerIOPort(); - } - -} diff --git a/src/main/java/common/blocks/Block_ItemServerRackCasing.java b/src/main/java/common/blocks/Block_ItemServerRackCasing.java deleted file mode 100644 index db0ec9c3e6..0000000000 --- a/src/main/java/common/blocks/Block_ItemServerRackCasing.java +++ /dev/null @@ -1,30 +0,0 @@ -package common.blocks; - -import common.itemBlocks.IB_ItemServerRackCasing; -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.KekzCore; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; - -public class Block_ItemServerRackCasing extends BaseGTUpdateableBlock { - - private static Block_ItemServerRackCasing instance = new Block_ItemServerRackCasing(); - - private Block_ItemServerRackCasing() { - super(Material.iron); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemserverrackcasing_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemServerRackCasing"); - instance.setHardness(5.0f); - instance.setResistance(6.0f); - GameRegistry.registerBlock(instance, IB_ItemServerRackCasing.class, blockName); - - return instance; - } - -} diff --git a/src/main/java/common/blocks/Block_TFFTMultiHatch.java b/src/main/java/common/blocks/Block_TFFTMultiHatch.java index d2780c8c4b..37f9e47bcc 100644 --- a/src/main/java/common/blocks/Block_TFFTMultiHatch.java +++ b/src/main/java/common/blocks/Block_TFFTMultiHatch.java @@ -1,11 +1,8 @@ package common.blocks; -import client.renderer.HatchRenderer; import common.itemBlocks.IB_TFFTMultiHatch; import common.tileentities.TE_TFFTMultiHatch; import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; @@ -13,20 +10,17 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import thaumcraft.common.tiles.TileJarFillable; import java.util.List; +@Deprecated public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { private static final Block_TFFTMultiHatch INSTANCE = new Block_TFFTMultiHatch(); @@ -96,43 +90,6 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { return casing; } } - // ========= Leagris stuff - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return true; - } - - @Override - public int getLightOpacity(IBlockAccess world, int x, int y, int z) { - return 255; - } - - @Override - public int getLightValue() { - return 0; - } - - @Override - public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { - return false; - } - - //============== Leagris over - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() { - return 0; - } - - @Override - public int getRenderType() { - return HatchRenderer.RID; - } @Override public TileEntity createTileEntity(World world, int meta) { @@ -172,36 +129,4 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { return false; } - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) { - final int yaw = MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - final int pitch = MathHelper.floor_double((double)(placer.rotationPitch * 4.0F / 360.0F) + 0.5D) & 3; - final TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TE_TFFTMultiHatch) { - if(pitch == 0 || pitch == 2) { - if (yaw == 0) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 2); - } - - if (yaw == 1) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 5); - } - - if (yaw == 2) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 3); - } - - if (yaw == 3) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 4); - } - } else { - if(pitch == 1) { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 1); - } else { - ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 0); - } - } - } - - } - } diff --git a/src/main/java/common/itemBlocks/IB_ItemServerDrive.java b/src/main/java/common/itemBlocks/IB_ItemServerDrive.java deleted file mode 100644 index a937230da5..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemServerDrive.java +++ /dev/null @@ -1,22 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemServerDrive extends ItemBlock { - - public IB_ItemServerDrive(Block block) { - super(block); - } - - @SuppressWarnings({"unchecked"}) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemserverdrive_block.0.desc")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_ItemServerIOPort.java b/src/main/java/common/itemBlocks/IB_ItemServerIOPort.java deleted file mode 100644 index 10803af14c..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemServerIOPort.java +++ /dev/null @@ -1,22 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemServerIOPort extends ItemBlock { - - public IB_ItemServerIOPort(Block block) { - super(block); - } - - @SuppressWarnings({"unchecked"}) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemserverioport_block.0.desc")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java b/src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java deleted file mode 100644 index f1da1fcb5e..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java +++ /dev/null @@ -1,22 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemServerRackCasing extends ItemBlock { - - public IB_ItemServerRackCasing(Block block) { - super(block); - } - - @SuppressWarnings({"unchecked"}) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemserverrackcasing_block.0.desc=")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java index c5ecdca46d..f00c5ef0c2 100644 --- a/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java +++ b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java @@ -9,6 +9,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; +@Deprecated public class IB_TFFTMultiHatch extends ItemBlock { public IB_TFFTMultiHatch(Block block) { @@ -33,12 +34,6 @@ public class IB_TFFTMultiHatch extends ItemBlock { @SuppressWarnings({"unchecked"}) @Override public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - final int outputPerSecond = (int) (TE_TFFTMultiHatch.BASE_OUTPUT_PER_SECOND * Math.pow(10, stack.getItemDamage())); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.0.desc")); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.1.desc")); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.2.desc")); - lines.add(StatCollector.translateToLocal("tile.kekztech_tfftmultihatch_block.3.desc" ) - + " " + outputPerSecond + "L/s"); } } diff --git a/src/main/java/common/items/MetaItem_CraftingComponent.java b/src/main/java/common/items/MetaItem_CraftingComponent.java index ac57222b79..2b1c989831 100644 --- a/src/main/java/common/items/MetaItem_CraftingComponent.java +++ b/src/main/java/common/items/MetaItem_CraftingComponent.java @@ -14,7 +14,7 @@ import net.minecraft.util.IIcon; public class MetaItem_CraftingComponent extends Item { private static final MetaItem_CraftingComponent INSTANCE = new MetaItem_CraftingComponent(); - private final IIcon[] icons = new IIcon[17]; + private final IIcon[] icons = new IIcon[16]; private MetaItem_CraftingComponent() { } @@ -54,7 +54,6 @@ public class MetaItem_CraftingComponent extends Item { icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "CeriaDust"); icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "YSZCeramicPlate"); icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "GDCCeramicPlate"); - icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "ItemServerBlade"); } @Override diff --git a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java index 1c32525c4e..e06d1cc4a6 100644 --- a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java +++ b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java @@ -1,531 +1,523 @@ -package common.tileentities; - -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import kekztech.MultiFluidHandler; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; - -import common.Blocks; -import common.blocks.*; -import util.MultiBlockTooltipBuilder; -import util.Vector3i; -import util.Vector3ic; - -import java.util.ArrayList; -import java.util.HashSet; - -public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { - - private final static String glassNameIC2Reinforced = "blockAlloyGlass"; - private final static Block CASING = Blocks.tfftCasing; - private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1; - private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2; - private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3; - private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4; - private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5; - private final static Block MULTI_HATCH = Blocks.tfftMultiHatch; - private final static int CASING_TEXTURE_ID = 176; - - private MultiFluidHandler mfh; - private HashSet multiHatches = new HashSet<>(); - - private int runningCost = 0; - private boolean doVoidExcess = false; - private byte fluidSelector = 0; - - public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GTMTE_FluidMultiStorage(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { - return new GTMTE_FluidMultiStorage(super.mName); - } - - @Override - public String[] getDescription() { - final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); - b.addInfo("High-Tech fluid tank that can hold up to 25 different fluids!") - .addInfo("Has 1/25th of the total capacity as capacity for each fluid.") - .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.") - .addInfo("Fluid storage amount and running cost depends on the storage field blocks used.") - .addSeparator() - .addInfo("Note on hatch locking:") - .addInfo("Use an Integrated Circuit in the GUI slot to limit which fluid is output.") - .addInfo("The index of a stored fluid can be obtained through the Tricorder.") - .addSeparator() - .beginStructureBlock(5, 9, 5) - .addController("Top Center") - .addEnergyHatch("Any top or bottom casing") - .addOtherStructurePart("Inner 3x7x3 solid pillar", "Storage Field Blocks") - .addOtherStructurePart("Outer 5x7x5 glass shell", "IC2 Reinforced Glass") - .addMaintenanceHatch("Any top or bottom casing") - .addIOHatches("Instead of any casing or glass, have to touch storage field.") - .signAndFinalize("Kekzdealer"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return b.getInformation(); - } else { - return b.getStructureInformation(); - } - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return aSide == aFacing - ? new ITexture[]{BlockIcons.casingTexturePages[1][48], - new GT_RenderedTexture(aActive - ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE - : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)} - : new ITexture[]{BlockIcons.casingTexturePages[1][48]}; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "MultiblockDisplay.png"); - } - - @Override - public boolean isCorrectMachinePart(ItemStack var1) { - return true; - } - - @Override - public boolean checkRecipe(ItemStack guiSlotItem) { - - super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000; - super.mEfficiencyIncrease = 10000; - super.mEUt = runningCost; - super.mMaxProgresstime = 10; - - if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { - this.fluidSelector = (byte) guiSlotItem.getItemDamage(); - } - - // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code! - if (multiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) { - return true; - } - - // Suck in fluids - final ArrayList inputHatchFluids = super.getStoredFluids(); - if (inputHatchFluids.size() > 0) { - - for (FluidStack fluidStack : inputHatchFluids) { - - final int pushed = mfh.pushFluid(fluidStack, true); - final FluidStack toDeplete = fluidStack.copy(); - toDeplete.amount = pushed; - super.depleteInput(toDeplete); - } - } - - // Push out fluids - if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { - final FluidStack storedFluid = mfh.getFluid(fluidSelector); - // Sum available output capacity - int possibleOutput = 0; - for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { - if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() == null) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } - } - // Output as much as possible - final FluidStack tempStack = storedFluid.copy(); - tempStack.amount = possibleOutput; - tempStack.amount = mfh.pullFluid(tempStack, fluidSelector, true); - super.addOutput(tempStack); - - } else { - for (FluidStack storedFluid : mfh.getFluids()) { - // Sum available output capacity - int possibleOutput = 0; - for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { - if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } else if (outputHatch.getFluid() == null) { - possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); - } - } - // output as much as possible - final FluidStack tempStack = storedFluid.copy(); - tempStack.amount = possibleOutput; - // TODO possible concurrent modification exception as pullFluid calls remove() without an iterator - tempStack.amount = mfh.pullFluid(tempStack, true); - super.addOutput(tempStack); - } - } - - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (mfh != null) { - mfh.setLock(!super.getBaseMetaTileEntity().isActive()); - mfh.setFluidSelector(fluidSelector); - mfh.setDoVoidExcess(doVoidExcess); - } - } - - public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) { - final Vector3i offset = new Vector3i(); - - // either direction on z-axis - if (forgeDirection.x() == 0 && forgeDirection.z() == -1) { - offset.x = x; - offset.y = y; - offset.z = z; - } - if (forgeDirection.x() == 0 && forgeDirection.z() == 1) { - offset.x = -x; - offset.y = y; - offset.z = -z; - } - // either direction on x-axis - if (forgeDirection.x() == -1 && forgeDirection.z() == 0) { - offset.x = z; - offset.y = y; - offset.z = -x; - } - if (forgeDirection.x() == 1 && forgeDirection.z() == 0) { - offset.x = -z; - offset.y = y; - offset.z = x; - } - // either direction on y-axis - if (forgeDirection.y() == -1) { - offset.x = x; - offset.y = z; - offset.z = y; - } - - return offset; - } - - @Override - public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) { - // Figure out the vector for the direction the back face of the controller is facing - final Vector3ic forgeDirection = new Vector3i( - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX, - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY, - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ - ); - int minCasingAmount = 20; - boolean formationChecklist = true; // If this is still true at the end, machine is good to go :) - float runningCostAcc = 0; - double fluidCapacityAcc = 0; - - multiHatches.clear(); - - // Front segment - for (int X = -2; X <= 2; X++) { - for (int Y = -2; Y <= 2; Y++) { - if (X == 0 && Y == 0) { - continue; // Skip controller - } - - // Get next TE - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - // Fluid hatches should touch the storage field. - // Maintenance/Energy hatch can go anywhere - if (X > -2 && X < 2 && Y > -2 && Y < 2) { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - final Block b = thisController.getBlockOffset(offset.x(), offset.y(), offset.z()); - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - // Also check for multi hatch - if (b == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else if (b == MULTI_HATCH) { - final TE_TFFTMultiHatch mh = - (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - multiHatches.add(mh); - } else { - formationChecklist = false; - } - } - } else { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else { - formationChecklist = false; - } - } - } - } - } - - // Middle seven long segment - for (int X = -2; X <= 2; X++) { - for (int Y = -2; Y <= 2; Y++) { - for (int Z = -1; Z >= -7; Z--) { - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z); - if (X > -2 && X < 2 && Y > -2 && Y < 2) { - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD1.getUnlocalizedName())) { - runningCostAcc += 0.5f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT1.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD2.getUnlocalizedName())) { - runningCostAcc += 1.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT2.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD3.getUnlocalizedName())) { - runningCostAcc += 2.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT3.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD4.getUnlocalizedName())) { - runningCostAcc += 4.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT4.getCapacity(); - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD5.getUnlocalizedName())) { - runningCostAcc += 8.0f; - fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT5.getCapacity(); - } else { - formationChecklist = false; - } - continue; - } - - // Get next TE - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - // Corner allows only glass - if (X == -2 && Y == -2 || X == 2 && Y == 2 || X == -2 && Y == 2 || X == 2 && Y == -2) { - if (!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced))) { - formationChecklist = false; - } - } else { - // Tries to add TE as either of those kinds of hatches. - // The number is the texture index number for the texture that needs to be painted over the hatch texture (TAE for GT++) - if (!super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - // Also check for multi hatch - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) { - final TE_TFFTMultiHatch mh = - (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - multiHatches.add(mh); - } else if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced)) { - formationChecklist = false; - } - } - } - } - } - } - - // Back segment - for (int X = -2; X <= 2; X++) { - for (int Y = -2; Y <= 2; Y++) { - // Get next TE - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8); - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - // Fluid hatches should touch the storage field. - // Maintenance/Energy hatch can go anywhere - if (X > -2 && X < 2 && Y > -2 && Y < 2) { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) { - final TE_TFFTMultiHatch mh = - (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - multiHatches.add(mh); - } else { - formationChecklist = false; - } - } - } else { - if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // If it's not a hatch, is it the right casing for this machine? Check block and block meta. - if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Seems to be valid casing. Decrement counter. - minCasingAmount--; - } else { - formationChecklist = false; - } - } - } - } - } - - if (this.mEnergyHatches.size() < 1) { - formationChecklist = false; - } - - if (this.mMaintenanceHatches.size() < 1) { - formationChecklist = false; - } - - if (minCasingAmount > 0) { - formationChecklist = false; - } - - if (formationChecklist) { - runningCost = Math.round(-runningCostAcc); - // Update MultiFluidHandler in case storage cells have been changed - final int capacityPerFluid = (int) Math.round(fluidCapacityAcc / 25.0f); - if (mfh == null) { - mfh = new MultiFluidHandler(capacityPerFluid); - } else { - if (mfh.getCapacity() != capacityPerFluid) { - mfh = new MultiFluidHandler(capacityPerFluid, mfh.getFluids()); - } - } - for (TE_TFFTMultiHatch mh : multiHatches) { - mh.setMultiFluidHandler(mfh); - } - } - - return formationChecklist; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (doVoidExcess) { - doVoidExcess = false; - aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned off")); - } else { - doVoidExcess = true; - aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned on")); - } - } - - @Override - public String[] getInfoData() { - final ArrayList ll = mfh.getInfoData(); - - ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); - ll.add("Auto-voiding: " + doVoidExcess); - ll.add("Per-Fluid Capacity: " + mfh.getCapacity() + "L"); - ll.add("Running Cost: " - // mEUt does not naturally reflect efficiency status. Do that here. - + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t"); - ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus()) - ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET - : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET)); - ll.add("---------------------------------------------"); - - final String[] a = new String[ll.size()]; - return ll.toArray(a); - } - - @Override - public void saveNBTData(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - nbt.setInteger("runningCost", runningCost); - nbt.setBoolean("doVoidExcess", doVoidExcess); - - nbt.setInteger("capacityPerFluid", mfh.getCapacity()); - nbt.setTag("fluids", mfh.saveNBTData(new NBTTagCompound())); - - super.saveNBTData(nbt); - } - - @Override - public void loadNBTData(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - runningCost = nbt.getInteger("runningCost"); - doVoidExcess = nbt.getBoolean("doVoidExcess"); - - mfh = new MultiFluidHandler(); - mfh.loadNBTData(nbt); - for (TE_TFFTMultiHatch mh : multiHatches) { - mh.setMultiFluidHandler(mfh); - } - super.loadNBTData(nbt); - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack var1) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack var1) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack var1) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack var1) { - return false; - } +package common.tileentities; + +import common.Blocks; +import common.blocks.*; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import kekztech.MultiFluidHandler; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.input.Keyboard; +import util.MultiBlockTooltipBuilder; +import util.Vector3i; +import util.Vector3ic; + +import java.util.ArrayList; +import java.util.HashSet; + +public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { + + private final static String glassNameIC2Reinforced = "blockAlloyGlass"; + private final static Block CASING = Blocks.tfftCasing; + private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1; + private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2; + private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3; + private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4; + private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5; + private final static int CASING_TEXTURE_ID = 176; + + private MultiFluidHandler mfh; + private final HashSet sMultiHatches = new HashSet<>(); + + private int runningCost = 0; + private boolean doVoidExcess = false; + private byte fluidSelector = 0; + + public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GTMTE_FluidMultiStorage(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { + return new GTMTE_FluidMultiStorage(super.mName); + } + + @Override + public String[] getDescription() { + final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); + b.addInfo("High-Tech fluid tank that can hold up to 25 different fluids!") + .addInfo("Has 1/25th of the total capacity as capacity for each fluid.") + .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.") + .addInfo("Fluid storage amount and running cost depends on the storage field blocks used.") + .addSeparator() + .addInfo("Note on hatch locking:") + .addInfo("Use an Integrated Circuit in the GUI slot to limit which fluid is output.") + .addInfo("The index of a stored fluid can be obtained through the Tricorder.") + .addSeparator() + .beginStructureBlock(5, 9, 5) + .addController("Top Center") + .addEnergyHatch("Any top or bottom casing") + .addOtherStructurePart("Inner 3x7x3 solid pillar", "Storage Field Blocks") + .addOtherStructurePart("Outer 5x7x5 glass shell", "IC2 Reinforced Glass") + .addMaintenanceHatch("Any top or bottom casing") + .addIOHatches("Instead of any casing or glass, have to touch storage field.") + .signAndFinalize("Kekzdealer"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return b.getInformation(); + } else { + return b.getStructureInformation(); + } + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return aSide == aFacing + ? new ITexture[]{BlockIcons.casingTexturePages[1][48], + new GT_RenderedTexture(aActive + ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE + : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)} + : new ITexture[]{BlockIcons.casingTexturePages[1][48]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + "MultiblockDisplay.png"); + } + + @Override + public boolean isCorrectMachinePart(ItemStack var1) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack guiSlotItem) { + + super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000; + super.mEfficiencyIncrease = 10000; + super.mEUt = runningCost; + super.mMaxProgresstime = 10; + + if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { + this.fluidSelector = (byte) guiSlotItem.getItemDamage(); + } + + // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code! + if (sMultiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) { + return true; + } + + // Suck in fluids + final ArrayList inputHatchFluids = super.getStoredFluids(); + if (inputHatchFluids.size() > 0) { + + for (FluidStack fluidStack : inputHatchFluids) { + + final int pushed = mfh.pushFluid(fluidStack, true); + final FluidStack toDeplete = fluidStack.copy(); + toDeplete.amount = pushed; + super.depleteInput(toDeplete); + } + } + + // Push out fluids + if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { + final FluidStack storedFluid = mfh.getFluid(fluidSelector); + // Sum available output capacity + int possibleOutput = 0; + for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { + if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() == null) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } + } + // Output as much as possible + final FluidStack tempStack = storedFluid.copy(); + tempStack.amount = possibleOutput; + tempStack.amount = mfh.pullFluid(tempStack, fluidSelector, true); + super.addOutput(tempStack); + + } else { + for (FluidStack storedFluid : mfh.getFluids()) { + // Sum available output capacity + int possibleOutput = 0; + for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { + if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } else if (outputHatch.getFluid() == null) { + possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + } + } + // output as much as possible + final FluidStack tempStack = storedFluid.copy(); + tempStack.amount = possibleOutput; + // TODO possible concurrent modification exception as pullFluid calls remove() without an iterator + tempStack.amount = mfh.pullFluid(tempStack, true); + super.addOutput(tempStack); + } + } + + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (mfh != null) { + mfh.setLock(!super.getBaseMetaTileEntity().isActive()); + mfh.setFluidSelector(fluidSelector); + mfh.setDoVoidExcess(doVoidExcess); + } + } + + public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) { + final Vector3i offset = new Vector3i(); + + // either direction on z-axis + if (forgeDirection.x() == 0 && forgeDirection.z() == -1) { + offset.x = x; + offset.y = y; + offset.z = z; + } + if (forgeDirection.x() == 0 && forgeDirection.z() == 1) { + offset.x = -x; + offset.y = y; + offset.z = -z; + } + // either direction on x-axis + if (forgeDirection.x() == -1 && forgeDirection.z() == 0) { + offset.x = z; + offset.y = y; + offset.z = -x; + } + if (forgeDirection.x() == 1 && forgeDirection.z() == 0) { + offset.x = -z; + offset.y = y; + offset.z = x; + } + // either direction on y-axis + if (forgeDirection.y() == -1) { + offset.x = x; + offset.y = z; + offset.z = y; + } + + return offset; + } + + @Override + public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) { + // Figure out the vector for the direction the back face of the controller is facing + final Vector3ic forgeDirection = new Vector3i( + ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX, + ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY, + ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ + ); + int minCasingAmount = 20; + boolean formationChecklist = true; // If this is still true at the end, machine is good to go :) + float runningCostAcc = 0; + double fluidCapacityAcc = 0; + + sMultiHatches.clear(); + + // Front segment + for (int X = -2; X <= 2; X++) { + for (int Y = -2; Y <= 2; Y++) { + if (X == 0 && Y == 0) { + continue; // Skip controller + } + + // Get next TE + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); + final IGregTechTileEntity currentTE = + thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + + // Fluid hatches should touch the storage field. + // Maintenance/Energy hatch can go anywhere + if (X > -2 && X < 2 && Y > -2 && Y < 2) { + if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID) + && !addMultiHatchToMachineList(currentTE, CASING_TEXTURE_ID)) { + + // If it's not a hatch, is it the right casing for this machine? Check block and block meta. + // Also check for multi hatch + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else { + formationChecklist = false; + } + } + } else { + if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { + + // If it's not a hatch, is it the right casing for this machine? Check block and block meta. + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else { + formationChecklist = false; + } + } + } + } + } + + // Middle seven long segment + for (int X = -2; X <= 2; X++) { + for (int Y = -2; Y <= 2; Y++) { + for (int Z = -1; Z >= -7; Z--) { + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z); + if (X > -2 && X < 2 && Y > -2 && Y < 2) { + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD1.getUnlocalizedName())) { + runningCostAcc += 0.5f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT1.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD2.getUnlocalizedName())) { + runningCostAcc += 1.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT2.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD3.getUnlocalizedName())) { + runningCostAcc += 2.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT3.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD4.getUnlocalizedName())) { + runningCostAcc += 4.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT4.getCapacity(); + } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD5.getUnlocalizedName())) { + runningCostAcc += 8.0f; + fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT5.getCapacity(); + } else { + formationChecklist = false; + } + continue; + } + + // Get next TE + final IGregTechTileEntity currentTE = + thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + + // Corner allows only glass + if (X == -2 && Y == -2 || X == 2 && Y == 2 || X == -2 && Y == 2 || X == 2 && Y == -2) { + if (!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced))) { + formationChecklist = false; + } + } else { + // Tries to add TE as either of those kinds of hatches. + // The number is the texture index number for the texture that needs to be painted over the hatch texture (TAE for GT++) + if (!super.addInputToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID) + && !addMultiHatchToMachineList(currentTE, CASING_TEXTURE_ID)) { + + // If it's not a hatch, is it the right casing for this machine? Check block and block meta. + // Also check for multi hatch + if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced)) { + formationChecklist = false; + } + } + } + } + } + } + + // Back segment + for (int X = -2; X <= 2; X++) { + for (int Y = -2; Y <= 2; Y++) { + // Get next TE + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8); + final IGregTechTileEntity currentTE = + thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + + // Fluid hatches should touch the storage field. + // Maintenance/Energy hatch can go anywhere + if (X > -2 && X < 2 && Y > -2 && Y < 2) { + if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_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 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 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 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 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 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 debugPrint() { - if(items == null) { - return new ArrayList(); - } - final ArrayList 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 -- cgit From 258d5b9be22d3aad2c27a2b57d22b907b3284248 Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Thu, 11 Jun 2020 20:29:50 +0200 Subject: Implemented new class for GT rendered textures! --- src/main/java/client/ClientProxy.java | 2 + src/main/java/client/GTTexture.java | 63 ++++++++++++++++++++++ .../common/tileentities/GTMTE_TFFTMultiHatch.java | 10 ++-- 3 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 src/main/java/client/GTTexture.java (limited to 'src/main/java/client/ClientProxy.java') diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index f608861c0d..b4eb51f369 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -18,6 +18,8 @@ public class ClientProxy extends CommonProxy { // Register TESR ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorTether.class, new TESR_SETether()); ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorCapacitor.class, new TESR_SECapacitor()); + // Register GTTextures + GTTexture.init(); } @Override diff --git a/src/main/java/client/GTTexture.java b/src/main/java/client/GTTexture.java new file mode 100644 index 0000000000..98795e6585 --- /dev/null +++ b/src/main/java/client/GTTexture.java @@ -0,0 +1,63 @@ +package client; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import kekztech.KekzCore; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import java.util.HashMap; + +public class GTTexture implements IIconContainer { + + public static final String MULTI_HATCH_OFF = "multi_hatch_off"; + public static final String MULTI_HATCH_ON = "multi_hatch_on"; + + private static final HashMap icons = new HashMap<>(); + + private final IIcon icon; + private final IIcon overlayIcon; + + private GTTexture(String iconName) { + icon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + iconName); + overlayIcon = null; + } + + private GTTexture(String iconName, String overlayIconName) { + icon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + iconName); + overlayIcon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + overlayIconName); + } + + public static void registerTexture(String iconName) { + icons.put(iconName, new GTTexture(iconName)); + } + + public static void registerTexture(String iconName, String overlayIconName) { + icons.put(iconName, new GTTexture(iconName, overlayIconName)); + } + + public static void init() { + registerTexture(MULTI_HATCH_ON); + registerTexture(MULTI_HATCH_OFF); + } + + public static IIconContainer getIconContainer(String iconName) { + return icons.get(iconName); + } + + @Override + public IIcon getIcon() { + return icon; + } + + @Override + public IIcon getOverlayIcon() { + return overlayIcon; + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } +} diff --git a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java index f93bafbead..024ffdc135 100644 --- a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java @@ -1,10 +1,12 @@ package common.tileentities; +import client.GTTexture; 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.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import kekztech.MultiFluidHandler; @@ -64,13 +66,13 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { } @Override - public ITexture[] getTexturesActive(ITexture iTexture) { - return new ITexture[0]; + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.getIconContainer(GTTexture.MULTI_HATCH_ON))}; } @Override - public ITexture[] getTexturesInactive(ITexture iTexture) { - return new ITexture[0]; + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.getIconContainer(GTTexture.MULTI_HATCH_OFF))}; } @Override -- cgit From 9692e77efa9d74014738753d1c6eb0f259733476 Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Thu, 18 Jun 2020 16:59:39 +0200 Subject: changed multi hatch to use some default texture from GT so I can test the actual functionality --- src/main/java/client/ClientProxy.java | 2 - src/main/java/client/GTTexture.java | 49 +++++++++++++++------- .../common/tileentities/GTMTE_TFFTMultiHatch.java | 7 +++- 3 files changed, 38 insertions(+), 20 deletions(-) (limited to 'src/main/java/client/ClientProxy.java') diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index b4eb51f369..f608861c0d 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -18,8 +18,6 @@ public class ClientProxy extends CommonProxy { // Register TESR ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorTether.class, new TESR_SETether()); ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorCapacitor.class, new TESR_SECapacitor()); - // Register GTTextures - GTTexture.init(); } @Override diff --git a/src/main/java/client/GTTexture.java b/src/main/java/client/GTTexture.java index 98795e6585..76539adaab 100644 --- a/src/main/java/client/GTTexture.java +++ b/src/main/java/client/GTTexture.java @@ -9,37 +9,44 @@ import net.minecraft.util.ResourceLocation; import java.util.HashMap; -public class GTTexture implements IIconContainer { +public class GTTexture implements IIconContainer, Runnable { + public static final String TFFT_CASING = "TFFTCasing"; public static final String MULTI_HATCH_OFF = "multi_hatch_off"; public static final String MULTI_HATCH_ON = "multi_hatch_on"; private static final HashMap icons = new HashMap<>(); + private static final String REL_PATH = "blocks/"; - private final IIcon icon; - private final IIcon overlayIcon; + static { + registerTexture(TFFT_CASING); + registerTexture(MULTI_HATCH_OFF); + registerTexture(MULTI_HATCH_ON); + } + + private IIcon icon; + private IIcon iconOverlay; + private final String iconName; + private final String iconOverlayName; private GTTexture(String iconName) { - icon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + iconName); - overlayIcon = null; + this.iconName = iconName; + this.iconOverlayName = ""; + GregTech_API.sGTBlockIconload.add(this); } - private GTTexture(String iconName, String overlayIconName) { - icon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + iconName); - overlayIcon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + overlayIconName); + private GTTexture(String iconName, String iconOverlayName) { + this.iconName = iconName; + this.iconOverlayName = iconOverlayName; + GregTech_API.sGTBlockIconload.add(this); } public static void registerTexture(String iconName) { icons.put(iconName, new GTTexture(iconName)); } - public static void registerTexture(String iconName, String overlayIconName) { - icons.put(iconName, new GTTexture(iconName, overlayIconName)); - } - - public static void init() { - registerTexture(MULTI_HATCH_ON); - registerTexture(MULTI_HATCH_OFF); + public static void registerTexture(String iconName, String iconOverlayName) { + icons.put(iconName, new GTTexture(iconName, iconOverlayName)); } public static IIconContainer getIconContainer(String iconName) { @@ -53,11 +60,21 @@ public class GTTexture implements IIconContainer { @Override public IIcon getOverlayIcon() { - return overlayIcon; + return iconOverlay; } @Override public ResourceLocation getTextureFile() { return TextureMap.locationBlocksTexture; } + + @Override + public void run() { + icon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + REL_PATH + iconName); + if(!iconOverlayName.equals("")) { + iconOverlay = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + REL_PATH + iconOverlayName); + } else { + KekzCore.LOGGER.info("No overlay texture specified for icon: " + iconName + "; This is fine."); + } + } } diff --git a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java index 024ffdc135..0ad9e5c7a9 100644 --- a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java @@ -2,6 +2,7 @@ package common.tileentities; import client.GTTexture; import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -67,12 +68,14 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.getIconContainer(GTTexture.MULTI_HATCH_ON))}; + // TODO return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.getIconContainer(GTTexture.MULTI_HATCH_ON))}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.getIconContainer(GTTexture.MULTI_HATCH_OFF))}; + // TODO return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.getIconContainer(GTTexture.MULTI_HATCH_OFF))}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN)}; } @Override -- cgit From 2178a42eca603aba98ca4e181c2c46597e638597 Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Tue, 23 Jun 2020 02:17:11 +0200 Subject: Started to imlements BeamTransmitter --- src/main/java/client/ClientProxy.java | 3 + src/main/java/client/GTTexture.java | 6 +- .../java/client/renderer/TESR_BeamTransmitter.java | 65 +++++++++++++++++++++ src/main/java/common/Blocks.java | 2 + src/main/java/common/TileEntities.java | 1 + .../java/common/blocks/Block_BeamTransmitter.java | 55 +++++++++++++++++ .../common/tileentities/GTMTE_TFFTMultiHatch.java | 68 +++++----------------- .../common/tileentities/TE_BeamTransmitter.java | 47 +++++++++++++++ src/main/resources/assets/kekztech/lang/en_US.lang | 5 +- 9 files changed, 195 insertions(+), 57 deletions(-) create mode 100644 src/main/java/client/renderer/TESR_BeamTransmitter.java create mode 100644 src/main/java/common/blocks/Block_BeamTransmitter.java create mode 100644 src/main/java/common/tileentities/TE_BeamTransmitter.java (limited to 'src/main/java/client/ClientProxy.java') diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index f608861c0d..5ed713f827 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -1,8 +1,10 @@ package client; +import client.renderer.TESR_BeamTransmitter; import client.renderer.TESR_SECapacitor; import client.renderer.TESR_SETether; import common.CommonProxy; +import common.tileentities.TE_BeamTransmitter; import common.tileentities.TE_SpaceElevatorCapacitor; import common.tileentities.TE_SpaceElevatorTether; import cpw.mods.fml.client.registry.ClientRegistry; @@ -18,6 +20,7 @@ public class ClientProxy extends CommonProxy { // Register TESR ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorTether.class, new TESR_SETether()); ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorCapacitor.class, new TESR_SECapacitor()); + ClientRegistry.bindTileEntitySpecialRenderer(TE_BeamTransmitter.class, new TESR_BeamTransmitter()); } @Override diff --git a/src/main/java/client/GTTexture.java b/src/main/java/client/GTTexture.java index a449dc257b..2ede4976fb 100644 --- a/src/main/java/client/GTTexture.java +++ b/src/main/java/client/GTTexture.java @@ -12,9 +12,9 @@ import java.util.HashMap; public class GTTexture implements IIconContainer, Runnable { - public static final GTTexture TFFT_CASING = new GTTexture("textures/blocks/TFFTCasing"); - public static final GTTexture MULTI_HATCH_OFF = new GTTexture("textures/blocks/multi_hatch_off"); - public static final GTTexture MULTI_HATCH_ON = new GTTexture("textures/blocks/multi_hatch_on"); + public static final GTTexture TFFT_CASING = new GTTexture("blocks/TFFTCasing"); + public static final GTTexture MULTI_HATCH_OFF = new GTTexture("blocks/multi_hatch_off"); + public static final GTTexture MULTI_HATCH_ON = new GTTexture("blocks/multi_hatch_on"); private IIcon icon; private final String iconName; diff --git a/src/main/java/client/renderer/TESR_BeamTransmitter.java b/src/main/java/client/renderer/TESR_BeamTransmitter.java new file mode 100644 index 0000000000..3c48dab264 --- /dev/null +++ b/src/main/java/client/renderer/TESR_BeamTransmitter.java @@ -0,0 +1,65 @@ +package client.renderer; + +import common.tileentities.TE_BeamTransmitter; +import kekztech.KekzCore; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class TESR_BeamTransmitter extends TileEntitySpecialRenderer { + + private static final ResourceLocation beamTexture = new ResourceLocation(KekzCore.MODID, "textures/effects/Tether_beam.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) { + final TE_BeamTransmitter beamTransmitter = (TE_BeamTransmitter) te; + + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + // Get Tessellator instance + final Tessellator tessellator = Tessellator.instance; + // Bind beam texture and set texture params + super.bindTexture(beamTexture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + // Set render flags for inner beam + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + // Prepare Tessellator + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(255, 255, 255, 32); + // Variables stuff II + final float exactTime = (float)beamTransmitter.getWorldObj().getTotalWorldTime() + partialTick; + final float streamTextureOffset = -exactTime * 0.2F - (float) MathHelper.floor_float(-exactTime * 0.1F); + + final double halfBeamWidth = 0.1D; + final double height = beamTransmitter.getDistanceFromTarget(); + final double uv_x1 = 0.0D; + final double uv_x2 = 1.0D; + final double uv_y1 = -1.0D - streamTextureOffset; // This makes the beam stream upwards if you add a time sensitive number to it + final double uv_y2 = (double)beamTransmitter.getDistanceFromTarget() * (0.5D / (halfBeamWidth * 2)) + uv_y1; + // Construct mesh with texture + tessellator.addVertexWithUV(x + 0.5 + halfBeamWidth, y + 0.5, z + 0.5, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + 0.5 + halfBeamWidth, y + height, z + 0.5, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + 0.5 - halfBeamWidth, y + height, z + 0.5, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + 0.5 - halfBeamWidth, y + 0.5, z + 0.5, uv_x1, uv_y2); + + tessellator.addVertexWithUV(x + 0.5, y + 0.5, z + 0.5 + halfBeamWidth, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + 0.5, y + height, z + 0.5 + halfBeamWidth, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + 0.5, y + height, z + 0.5 - halfBeamWidth, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + 0.5, y + 0.5, z + 0.5 - halfBeamWidth, uv_x1, uv_y2); + // Draw! + tessellator.draw(); + + // Reset render flags + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } +} diff --git a/src/main/java/common/Blocks.java b/src/main/java/common/Blocks.java index efb5146137..304af71460 100644 --- a/src/main/java/common/Blocks.java +++ b/src/main/java/common/Blocks.java @@ -33,6 +33,7 @@ public class Blocks { public static Block jarIchor; public static Block lscLapotronicEnergyUnit; + public static Block beamTransmitter; public static Block spaceElevatorStructure; public static Block spaceElevatorCapacitor; @@ -89,6 +90,7 @@ public class Blocks { private static void registerBlocks_LSC() { lscLapotronicEnergyUnit = Block_LapotronicEnergyUnit.registerBlock(); + beamTransmitter = Block_BeamTransmitter.registerBlock(); } private static void registerBlocks_SpaceElevator() { diff --git a/src/main/java/common/TileEntities.java b/src/main/java/common/TileEntities.java index 963dd81e9f..9bb839feda 100644 --- a/src/main/java/common/TileEntities.java +++ b/src/main/java/common/TileEntities.java @@ -25,6 +25,7 @@ public class TileEntities { GameRegistry.registerTileEntity(TE_ThaumiumReinforcedJar.class, "kekztech_thaumiumreinforcedjar"); GameRegistry.registerTileEntity(TE_IchorJar.class, "kekztech_ichorjar"); //GameRegistry.registerTileEntity(TE_SpaceElevatorCapacitor.class, "kekztech_secapacitor"); + GameRegistry.registerTileEntity(TE_BeamTransmitter.class, "kekztech_beamtransmitter"); } public static void init() { diff --git a/src/main/java/common/blocks/Block_BeamTransmitter.java b/src/main/java/common/blocks/Block_BeamTransmitter.java new file mode 100644 index 0000000000..af7a837fdd --- /dev/null +++ b/src/main/java/common/blocks/Block_BeamTransmitter.java @@ -0,0 +1,55 @@ +package common.blocks; + +import common.tileentities.TE_BeamTransmitter; +import common.tileentities.TE_SpaceElevatorTether; +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_BeamTransmitter extends Block { + + private static final Block_BeamTransmitter INSTANCE = new Block_BeamTransmitter(); + + private Block_BeamTransmitter() { + super(Material.glass); + } + + public static Block registerBlock() { + final String blockName = "kekztech_beamtransmitter_block"; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(5.0f); + INSTANCE.setResistance(5.0f); + INSTANCE.setBlockTextureName(KekzCore.MODID + ":" + "Tether_top"); + GameRegistry.registerBlock(INSTANCE, blockName); + + return INSTANCE; + } + + @Override + public TileEntity createTileEntity(World world, int meta) { + return new TE_BeamTransmitter(); + } + + @Override + public boolean hasTileEntity(int meta) { + return true; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + +} diff --git a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java index ba523ab090..c8c987d7dc 100644 --- a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java @@ -66,12 +66,14 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_ON)}; + //return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_ON)}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_PIPE_STEEL)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_OFF)}; + //return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_OFF)}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE)}; } @Override @@ -90,16 +92,6 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { GT_Utility.sendChatToPlayer(aPlayer, outputting ? "Auto-output enabled" : "Auto-output disabled"); } - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - @Override public int getCapacity() { return (mfh != null) ? mfh.getCapacity() : 0; @@ -108,51 +100,12 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide() && mfh != null) { - emptyContainers(aBaseMetaTileEntity); - fillContainers(aBaseMetaTileEntity); if(outputting && (aTick % 20 == 0)) { doAutoOutputPerSecond(aBaseMetaTileEntity); } } } - /** - * Empty containers (cells, buckets, etc) from the GUI into the T.F.F.T - * @param aBaseMetaTileEntity - * this MetaTileEntity - */ - private void emptyContainers(IGregTechTileEntity aBaseMetaTileEntity) { - 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); - } - } - } - - /** - * Fill containers (cells, buckets, etc) in the GUI. The fluid used to fill containers will be the one that is - * selected through an Integrated Circuit in the T.F.F.T's controller GUI. - * @param aBaseMetaTileEntity - * this MetaTileEntity - */ - private void fillContainers(IGregTechTileEntity aBaseMetaTileEntity) { - final ItemStack cellFromFluid = GT_Utility.fillFluidContainer( - mfh.getFluidCopy(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); - } - } - } - /** * Handle the Multi Hatch's auto-output feature. Should be called once per second only. * @param aBaseMetaTileEntity @@ -229,12 +182,21 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == super.getOutputSlot(); + return false; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == super.getInputSlot(); + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; } + @Override + public boolean canTankBeEmptied() { + return true; + } } diff --git a/src/main/java/common/tileentities/TE_BeamTransmitter.java b/src/main/java/common/tileentities/TE_BeamTransmitter.java new file mode 100644 index 0000000000..74cb845fc4 --- /dev/null +++ b/src/main/java/common/tileentities/TE_BeamTransmitter.java @@ -0,0 +1,47 @@ +package common.tileentities; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import org.joml.Vector3i; +import org.joml.Vector3ic; + +public class TE_BeamTransmitter extends TileEntity { + + private final Vector3ic position; + + private Vector3ic target = new Vector3i(10, 20, 10); + private double distanceCache; + private boolean distanceCacheValid = false; + + public TE_BeamTransmitter() { + position = new Vector3i(super.xCoord, super.yCoord, super.zCoord); + } + + public Vector3ic getTargetPosition() { + return target; + } + + public double getDistanceFromTarget() { + if (!distanceCacheValid) { + distanceCache = position.distance(target); + distanceCacheValid = true; + } + return distanceCache; + } + + @SideOnly(Side.CLIENT) + @Override + public double getMaxRenderDistanceSquared() { + // 4k is standard, 65k is what the vanilla beacon uses + return 65536.0D; + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + // Make it so the beam is still rendered even when the source block is out of sight + return INFINITE_EXTENT_AABB; + } +} diff --git a/src/main/resources/assets/kekztech/lang/en_US.lang b/src/main/resources/assets/kekztech/lang/en_US.lang index f4a97bd101..3c8ec42ce8 100644 --- a/src/main/resources/assets/kekztech/lang/en_US.lang +++ b/src/main/resources/assets/kekztech/lang/en_US.lang @@ -173,4 +173,7 @@ tile.kekztech_spaceelevatorcapacitor_block.desc=The see-through is good for your tile.kekztech_spaceelevatortether_block.name=Space Elevator Tether # -------- Cosmetic Blocks -tile.kekztech_largehextile_block=Large Hex Tile \ No newline at end of file +tile.kekztech_largehextile_block=Large Hex Tile + +# -------- Beam Transmitter +tile.kekztech_beamtransmitter_block=Beam Transmitter \ No newline at end of file -- cgit