diff options
Diffstat (limited to 'src/main/java')
47 files changed, 2646 insertions, 2844 deletions
diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java new file mode 100644 index 0000000000..5ed713f827 --- /dev/null +++ b/src/main/java/client/ClientProxy.java @@ -0,0 +1,33 @@ +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; +import cpw.mods.fml.client.registry.RenderingRegistry; +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()); + ClientRegistry.bindTileEntitySpecialRenderer(TE_BeamTransmitter.class, new TESR_BeamTransmitter()); + } + + @Override + public void init(final FMLInitializationEvent e) { + super.init(e); + // Register Simple Block Renderers + //RenderingRegistry.registerBlockHandler(ConduitRenderer.getInstance()); + } + +} diff --git a/src/main/java/client/GTTexture.java b/src/main/java/client/GTTexture.java new file mode 100644 index 0000000000..2ede4976fb --- /dev/null +++ b/src/main/java/client/GTTexture.java @@ -0,0 +1,46 @@ +package client; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.objects.GT_CopiedBlockTexture; +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, Runnable { + + 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; + + private GTTexture(String iconName) { + this.iconName = iconName; + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return icon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + + @Override + public void run() { + icon = GregTech_API.sBlockIcons.registerIcon(KekzCore.MODID + ":" + 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..81ab52654b --- /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 subtract a time sensitive number from it + final double uv_y2 = height * (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 18725b6000..8c145bd634 100644 --- a/src/main/java/common/Blocks.java +++ b/src/main/java/common/Blocks.java @@ -33,22 +33,25 @@ public class Blocks { public static Block jarIchor; public static Block lscLapotronicEnergyUnit; + public static Block beamTransmitter; public static Block spaceElevatorStructure; public static Block spaceElevatorCapacitor; public static Block spaceElevatorTether; + + public static Block largeHexPlate; public static void preInit() { KekzCore.LOGGER.info("Registering blocks..."); registerBlocks_SOFC(); registerBlocks_TFFT(); - registerBlocks_Nuclear(); - //registerBlocks_ItemServer(); + //registerBlocks_Nuclear(); //registerBlocks_ItemProxy(); registerBlocks_Jars(); registerBlocks_LSC(); - registerBlocks_SpaceElevator(); + //registerBlocks_SpaceElevator(); + registerBlocks_Cosmetics(); KekzCore.LOGGER.info("Finished registering blocks"); } @@ -68,23 +71,17 @@ public class Blocks { tfftMultiHatch = Block_TFFTMultiHatch.registerBlock(); } - private static void registerBlocks_Nuclear() { + /*private static void registerBlocks_Nuclear() { reactorChamberOFF = Block_ReactorChamber_OFF.registerBlock(); 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(); itemProxyEndpoint = Block_ItemProxyEndpoint.registerBlock(); - } + }*/ private static void registerBlocks_Jars() { jarThaumiumReinforced = Block_ThaumiumReinforcedJar.registerBlock(); @@ -93,12 +90,17 @@ public class Blocks { private static void registerBlocks_LSC() { lscLapotronicEnergyUnit = Block_LapotronicEnergyUnit.registerBlock(); + //beamTransmitter = Block_BeamTransmitter.registerBlock(); } - private static void registerBlocks_SpaceElevator() { + /*private static void registerBlocks_SpaceElevator() { spaceElevatorStructure = Block_SpaceElevator.registerBlock(); spaceElevatorCapacitor = Block_SpaceElevatorCapacitor.registerBlock(); spaceElevatorTether = Block_SpaceElevatorTether.registerBlock(); + }*/ + + private static void registerBlocks_Cosmetics() { + largeHexPlate = Block_LargeHexPlate.registerBlock(); } } diff --git a/src/main/java/common/CommonProxy.java b/src/main/java/common/CommonProxy.java new file mode 100644 index 0000000000..1e577148fb --- /dev/null +++ b/src/main/java/common/CommonProxy.java @@ -0,0 +1,44 @@ +package common; + +import common.items.ErrorItem; +import common.items.MetaItem_CraftingComponent; +import common.items.MetaItem_ReactorComponent; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import kekztech.GuiHandler; +import kekztech.Items; +import kekztech.KekzCore; + +public class CommonProxy { + + public void preInit(final FMLPreInitializationEvent e) { + // Items + ErrorItem.getInstance().registerItem(); + MetaItem_ReactorComponent.getInstance().registerItem(); + MetaItem_CraftingComponent.getInstance().registerItem(); + Items.registerOreDictNames(); + // Blocks + Blocks.preInit(); + // TileEntities + TileEntities.preInit(); + // TC Research + Researches.preInit(); + // GUI Handler + NetworkRegistry.INSTANCE.registerGuiHandler(KekzCore.instance, new GuiHandler()); + } + + public void init(final FMLInitializationEvent e) { + // GregTech Meta TileEntities + TileEntities.init(); + } + + public void postInit(final FMLPostInitializationEvent e) { + // Recipes + Recipes.postInit(); + // Research + Researches.postInit(); + } + +} diff --git a/src/main/java/common/Recipes.java b/src/main/java/common/Recipes.java index 0e3fdfc41f..d93b40b47f 100644 --- a/src/main/java/common/Recipes.java +++ b/src/main/java/common/Recipes.java @@ -1,5 +1,7 @@ package common; +import common.items.ErrorItem; +import common.items.MetaItem_CraftingComponent; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.GT_Values; @@ -8,10 +10,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import items.ErrorItem; -import items.MetaItem_CraftingComponent; import kekztech.Items; import kekztech.KekzCore; import net.minecraft.item.ItemStack; @@ -24,8 +23,6 @@ import thaumcraft.api.aspects.AspectList; import thaumcraft.api.crafting.InfusionRecipe; import util.Util; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; public class Recipes { @@ -37,32 +34,15 @@ public class Recipes { registerRecipes_TFFT(); registerRecipes_SOFC(); - registerRecipes_Nuclear(); - //registerRecipes_ItemServer(); + //registerRecipes_Nuclear(); registerRecipes_Jars(); registerRecipes_LSC(); - registerRecipes_SpaceElevator(); + //registerRecipes_SpaceElevator(); + registerRecipes_Cosmetics(); KekzCore.LOGGER.info("Finished registering recipes"); } - private static void lapoCapacitorRecipeAdder(GT_Recipe.GT_Recipe_AssemblyLine baseRecipe, Materials boxMaterial, ItemStack newResearchTrigger, ItemStack result) { - if(baseRecipe != null) { - final ArrayList<ItemStack> baseInputs = new ArrayList<>(Arrays.asList(baseRecipe.mInputs)); - if(baseInputs.size() <= 14){ - baseInputs.add(GT_OreDictUnificator.get(OrePrefixes.frameGt, boxMaterial, 4)); - baseInputs.add(GT_OreDictUnificator.get(OrePrefixes.screw, boxMaterial, 24)); - - GT_Values.RA.addAssemblylineRecipe(newResearchTrigger, baseRecipe.mResearchTime, - Util.toItemStackArray(baseInputs), baseRecipe.mFluidInputs, result, - baseRecipe.mDuration * 2, baseRecipe.mEUt); - KekzCore.LOGGER.info("Successfully extended Lapotronic Battery recipe for Lapotronic Capacitor of tier " + result.getItemDamage()); - } - } else { - KekzCore.LOGGER.info("Base recipe was NULL. Failed to extended Lapotronic Battery recipe for Lapotronic Capacitor of tier " + result.getItemDamage()); - } - } - private static void registerRecipes_TFFT() { // Controller @@ -74,7 +54,7 @@ public class Recipes { 'V', OrePrefixes.rotor.get(Materials.VibrantAlloy), 'C', OrePrefixes.circuit.get(Materials.Data) }; - GT_ModHandler.addCraftingRecipe(KekzCore.fms.getStackForm(1), tfft_recipe); + GT_ModHandler.addCraftingRecipe(TileEntities.fms.getStackForm(1), tfft_recipe); // Blocks final ItemStack[] tfftcasing = { @@ -83,82 +63,103 @@ public class Recipes { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.EnderPearl, 3), GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.StainlessSteel, 1), }; - GT_Values.RA.addAssemblerRecipe( - tfftcasing, - FluidRegistry.getFluidStack("molten.polytetrafluoroethylene", 144), - new ItemStack(Blocks.tfftCasing, 1), - 200, 256); - final ItemStack[] tfftstoragefield1 = { + GT_Values.RA.addAssemblerRecipe( + tfftcasing, + FluidRegistry.getFluidStack("molten.polytetrafluoroethylene", 144), + new ItemStack(Blocks.tfftCasing, 1), + 200, 256); + final ItemStack[] tfftstoragefield1 = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.PulsatingIron, 1), + GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Steel, 1), + ItemList.Electric_Pump_LV.get(1L) + }; + GT_Values.RA.addAssemblerRecipe( + tfftstoragefield1, + FluidRegistry.getFluidStack("molten.glass", 144), + new ItemStack(Blocks.tfftStorageField1, 1), + 200, 256); + final ItemStack[] tfftstoragefield2 = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.PulsatingIron, 4), + GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.StainlessSteel, 1), + ItemList.Electric_Pump_MV.get(1L) + }; + GT_Values.RA.addAssemblerRecipe( + tfftstoragefield2, + FluidRegistry.getFluidStack("molten.plastic", 576), + new ItemStack(Blocks.tfftStorageField2, 1), + 200, 480); + final ItemStack[] tfftstoragefield3 = { GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1), - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.PulsatingIron, 1), - GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Steel, 1), - ItemList.Electric_Pump_LV.get(1L) + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.VibrantAlloy, 2), + GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Titanium, 1), + ItemList.Field_Generator_MV.get(1L), + ItemList.Electric_Pump_HV.get(2L) }; - GT_Values.RA.addAssemblerRecipe( - tfftstoragefield1, - FluidRegistry.getFluidStack("molten.glass", 144), - new ItemStack(Blocks.tfftStorageField1, 1), - 200, 256); - final ItemStack[] tfftstoragefield2 = { - GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2), - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.PulsatingIron, 4), - GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.StainlessSteel, 1), - ItemList.Electric_Pump_MV.get(1L) - }; - GT_Values.RA.addAssemblerRecipe( - tfftstoragefield2, - FluidRegistry.getFluidStack("molten.plastic", 576), - new ItemStack(Blocks.tfftStorageField2, 1), - 200, 480); - final ItemStack[] tfftstoragefield3 = { - GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 2), - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.VibrantAlloy, 2), - GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Titanium, 1), - ItemList.Field_Generator_MV.get(1L), - ItemList.Electric_Pump_HV.get(2L) - }; - GT_Values.RA.addAssemblerRecipe( - tfftstoragefield3, - FluidRegistry.getFluidStack("molten.epoxid", 576), - new ItemStack(Blocks.tfftStorageField3, 1), - 300, 1920); - final ItemStack[] tfftstoragefield4 = { - GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 4), - GT_OreDictUnificator.get(OrePrefixes.plateTriple, Materials.NiobiumTitanium, 1), - GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.TungstenSteel, 1), - ItemList.Field_Generator_HV.get(1L), - ItemList.Electric_Pump_EV.get(1L) - }; - GT_Values.RA.addAssemblerRecipe( - tfftstoragefield4, - FluidRegistry.getFluidStack("molten.epoxid", 1152), - new ItemStack(Blocks.tfftStorageField4, 1), - 400, 4098); - final ItemStack[] tfftstoragefield5 = { - GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 4), - GT_OreDictUnificator.get(OrePrefixes.plateTriple, Materials.HSSS, 1), - GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.Enderium, 1), - ItemList.Field_Generator_EV.get(1L), - ItemList.Electric_Pump_IV.get(1L) - }; - GT_Values.RA.addAssemblerRecipe( - tfftstoragefield5, - FluidRegistry.getFluidStack("molten.epoxid", 1152), - new ItemStack(Blocks.tfftStorageField5, 1), - 400, 6147); - final Object[] multi_hatch = { - "PRP", "UFU", "PRP", - 'P', GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.NiobiumTitanium, 1), - 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.StainlessSteel, 1), - 'U', ItemList.Electric_Pump_IV.get(1L), - 'F', ItemList.Field_Generator_HV.get(1L) - }; - GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.tfftMultiHatch), multi_hatch); + GT_Values.RA.addAssemblerRecipe( + tfftstoragefield3, + FluidRegistry.getFluidStack("molten.epoxid", 576), + new ItemStack(Blocks.tfftStorageField3, 1), + 300, 1920); + final ItemStack[] tfftstoragefield4 = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 4), + GT_OreDictUnificator.get(OrePrefixes.plateTriple, Materials.NiobiumTitanium, 1), + GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.TungstenSteel, 1), + ItemList.Field_Generator_HV.get(1L), + ItemList.Electric_Pump_EV.get(1L) + }; + GT_Values.RA.addAssemblerRecipe( + tfftstoragefield4, + FluidRegistry.getFluidStack("molten.epoxid", 1152), + new ItemStack(Blocks.tfftStorageField4, 1), + 400, 4098); + final ItemStack[] tfftstoragefield5 = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 4), + GT_OreDictUnificator.get(OrePrefixes.plateTriple, Materials.HSSS, 1), + GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.Enderium, 1), + ItemList.Field_Generator_EV.get(1L), + ItemList.Electric_Pump_IV.get(1L) + }; + GT_Values.RA.addAssemblerRecipe( + tfftstoragefield5, + FluidRegistry.getFluidStack("molten.epoxid", 1152), + new ItemStack(Blocks.tfftStorageField5, 1), + 400, 6147); + // Multi Hatch + final Object[] multi_hatch_HV = { + "PRP", "UFU", "PRP", + 'P', GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.StainlessSteel, 1), + 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.StainlessSteel, 1), + 'U', ItemList.Electric_Pump_HV.get(1L), + 'F', ItemList.Field_Generator_LV.get(1L) + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.tfftMultiHatch), multi_hatch_HV); + final Object[] multi_hatch_IV = { + "PRP", "UFU", "PRP", + 'P', GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.TungstenSteel, 1), + 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.TungstenSteel, 1), + 'U', ItemList.Electric_Pump_IV.get(1L), + 'F', ItemList.Field_Generator_HV.get(1L) + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.tfftMultiHatch), multi_hatch_IV); + final Object[] multi_hatch_ZPM = { + "PRP", "UFU", "PRP", + 'P', GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.NaquadahAlloy, 1), + 'R', GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.NaquadahAlloy, 1), + 'U', ItemList.Electric_Pump_ZPM.get(1L), + 'F', ItemList.Field_Generator_IV.get(1L) + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.tfftMultiHatch), multi_hatch_ZPM); + + // Conversion recipe from deprecated hatch to new one (old hatch is equal to new IV hatch) + GT_ModHandler.addShapelessCraftingRecipe(TileEntities.mhIV.getStackForm(1), + new ItemStack[]{new ItemStack(Blocks.tfftMultiHatch, 1)}); } private static void registerRecipes_SOFC() { @@ -175,7 +176,7 @@ public class Recipes { 'B', GT_OreDictUnificator.get(OrePrefixes.cableGt02, Materials.Gold, 1), 'L', GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.StainlessSteel, 1) }; - GT_ModHandler.addCraftingRecipe(KekzCore.sofc1.getStackForm(1), mk1_recipe); + GT_ModHandler.addCraftingRecipe(TileEntities.sofc1.getStackForm(1), mk1_recipe); final Object[] mk2_recipe = { "CCC", "PHP", "FBL", 'C', OrePrefixes.circuit.get(Materials.Master), @@ -185,7 +186,7 @@ public class Recipes { 'B', Util.getStackofAmountFromOreDict("wireGt04SuperconductorEV", 1), 'L', GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Ultimate, 1) }; - GT_ModHandler.addCraftingRecipe(KekzCore.sofc2.getStackForm(1), mk2_recipe); + GT_ModHandler.addCraftingRecipe(TileEntities.sofc2.getStackForm(1), mk2_recipe); // Blocks final ItemStack[] yszUnit = { @@ -254,7 +255,7 @@ public class Recipes { 400, 1920); } - private static void registerRecipes_Nuclear() { + /*private static void registerRecipes_Nuclear() { final MetaItem_CraftingComponent craftingItem = MetaItem_CraftingComponent.getInstance(); @@ -330,68 +331,7 @@ public class Recipes { craftingItem.getStackOfAmountFromDamage(Items.IsotopicallyPureDiamondCrystal.getMetaID(), 4), craftingItem.getStackFromDamage(Items.DiamondHeatPipe.getMetaID()), 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(KekzCore.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() { @@ -419,15 +359,11 @@ public class Recipes { ThaumcraftApi.addInfusionCraftingRecipe("THAUMIUMREINFORCEDJAR", new ItemStack(Blocks.jarThaumiumReinforced, 1, 0), 5, aspects_jarthaumiumreinforced, ItemApi.getBlock("blockJar", 0), recipe_jarthaumiumreinforced)); // Thaumium Reinforced Void Jar - final ItemStack n1 = GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Obsidian, 1); - final ItemStack n2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Blaze, 1); - final ItemStack n3 = GT_OreDictUnificator.get(OrePrefixes.plate, Materials.EnderEye, 1); - final ItemStack n4 = ItemApi.getItem("itemNugget", 5); final ItemStack[] recipe_voidjarupgrade = { - n1, - n2, - n3, - n4 + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Obsidian, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Blaze, 1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.EnderEye, 1), + ItemApi.getItem("itemNugget", 5) }; final AspectList aspects_voidjarupgrade = new AspectList() .add(Aspect.VOID, 14) @@ -480,7 +416,7 @@ public class Recipes { 'C', OrePrefixes.circuit.get(Materials.Master), 'B', new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 0), }; - GT_ModHandler.addCraftingRecipe(KekzCore.lsc.getStackForm(1), lsc_recipe); + GT_ModHandler.addCraftingRecipe(TileEntities.lsc.getStackForm(1), lsc_recipe); // Blocks final Object[] lcBase_recipe = { @@ -491,6 +427,28 @@ public class Recipes { 'L', OrePrefixes.block.get(Materials.Lapis) }; GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 0), lcBase_recipe); + + // Empty Capacitor + final Object[] lcEmpty_recipe = { + "SLS", "L L", "SLS", + 'S', OrePrefixes.screw.get(Materials.Lapis), + 'L', OrePrefixes.plate.get(Materials.Lapis) + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 6), lcEmpty_recipe); + + // EV Capacitor + final Object[] lcEV_recipe = { + "SLS", "LCL", "SLS", + 'S', OrePrefixes.screw.get(Materials.Lapis), + 'L', OrePrefixes.plate.get(Materials.Lapis), + 'C', GT_ModHandler.getIC2Item("lapotronCrystal", 1L, GT_Values.W) + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 7), lcEV_recipe); + + //EV cap alt recipe + GT_Values.RA.addAssemblerRecipe(new ItemStack[] {(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 6)), GT_ModHandler.getIC2Item("lapotronCrystal", 1L, GT_Values.W), GT_Utility.getIntegratedCircuit(7)}, null, new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 7), 200, 480); + + // IV Capacitor final Object[] lcIV_recipe = { "SLS", "LOL", "SLS", 'S', OrePrefixes.screw.get(Materials.Lapis), @@ -499,82 +457,118 @@ public class Recipes { }; GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 1), lcIV_recipe); - KekzCore.LOGGER.info("Reading Assembly Line recipes from GregTech recipe map"); - GT_Recipe.GT_Recipe_AssemblyLine arLuV = null; - // Next two are hardcoded because my code can't find them - GT_Recipe.GT_Recipe_AssemblyLine arZPM = new GT_Recipe.GT_Recipe_AssemblyLine( - ItemList.Energy_LapotronicOrb2.get(1L), 288000, new ItemStack[] { - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Europium, 16L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), - ItemList.Energy_LapotronicOrb2.get(8L), - ItemList.Field_Generator_LuV.get(2), - ItemList.Circuit_Wafer_SoC2.get(64), - ItemList.Circuit_Wafer_SoC2.get(64), - ItemList.Circuit_Parts_DiodeASMD.get(8), - GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Naquadah, 32) + //IV cap alt recipe + GT_Values.RA.addAssemblerRecipe(new ItemStack[] {(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 6)), ItemList.Energy_LapotronicOrb.get(1L), GT_Utility.getIntegratedCircuit(1)}, null, new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 1), 200, 1920); + + // LuV Capacitor + GT_Values.RA.addAssemblylineRecipe( + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 1), 288000, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Osmiridium, 4), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Osmiridium, 24), + ItemList.Circuit_Board_Elite.get(1), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.NaquadahAlloy, 64), + new Object[]{OrePrefixes.circuit.get(Materials.Master), 4}, + ItemList.Circuit_Parts_Crystal_Chip_Master.get(36), + ItemList.Circuit_Parts_Crystal_Chip_Master.get(36), + ItemList.Circuit_Chip_HPIC.get(64), + ItemList.Circuit_Parts_DiodeASMD.get(8), + ItemList.Circuit_Parts_CapacitorASMD.get(8), + ItemList.Circuit_Parts_ResistorASMD.get(8), + ItemList.Circuit_Parts_TransistorASMD.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Platinum, 64) + }, + new FluidStack[] { + Materials.SolderingAlloy.getMolten(720) + }, + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 2), 2000, 100000 + ); + + // ZPM Capacitor + GT_Values.RA.addAssemblylineRecipe( + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 2), 288000, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.NaquadahAlloy, 4), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.NaquadahAlloy, 24), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Europium, 16L), + new Object[]{OrePrefixes.circuit.get(Materials.Ultimate), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Ultimate), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Ultimate), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Ultimate), 1}, + ItemList.Energy_LapotronicOrb2.get(8L), + ItemList.Field_Generator_LuV.get(2), + ItemList.Circuit_Wafer_SoC2.get(64), + ItemList.Circuit_Wafer_SoC2.get(64), + ItemList.Circuit_Parts_DiodeASMD.get(8), + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Naquadah, 32) }, new FluidStack[] { Materials.SolderingAlloy.getMolten(2880), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 16000) }, - ItemList.Energy_Module.get(1), 2000, 100000 + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 3), 2000, 100000 ); - GT_Recipe.GT_Recipe_AssemblyLine arUV = new GT_Recipe.GT_Recipe_AssemblyLine( - ItemList.Energy_Module.get(1L), 288000, new ItemStack[] { - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Americium, 32L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Superconductor, 1), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Superconductor, 1), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Superconductor, 1), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Superconductor, 1), - ItemList.Energy_Module.get(8L), - ItemList.Field_Generator_ZPM.get(2), - ItemList.Circuit_Wafer_HPIC.get(64), - ItemList.Circuit_Wafer_HPIC.get(64), - ItemList.Circuit_Parts_DiodeASMD.get(16), - GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.NaquadahAlloy, 32) + + // UV Capacitor + GT_Values.RA.addAssemblylineRecipe( + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 3), 288000, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Neutronium, 4), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Neutronium, 24), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Americium, 32L), + new Object[]{OrePrefixes.circuit.get(Materials.Superconductor), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Superconductor), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Superconductor), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Superconductor), 1}, + ItemList.Energy_Module.get(8L), + ItemList.Field_Generator_ZPM.get(2), + ItemList.Circuit_Wafer_HPIC.get(64), + ItemList.Circuit_Wafer_HPIC.get(64), + ItemList.Circuit_Parts_DiodeASMD.get(16), + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.NaquadahAlloy, 32) }, new FluidStack[] { Materials.SolderingAlloy.getMolten(2880), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 16000) }, - ItemList.Energy_Cluster.get(1), 2000, 200000 + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 4), 2000, 200000 + ); + + // Ultimate Capacitor + GT_Values.RA.addAssemblylineRecipe( + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 4), 288000, + new Object[] { + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 4), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.CosmicNeutronium, 24), + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Neutronium, 32L), + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Neutronium, 32L), + new Object[]{OrePrefixes.circuit.get(Materials.Bio), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Bio), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Bio), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Bio), 1}, + ItemList.ZPM2.get(8L), + ItemList.Field_Generator_UHV.get(4), + ItemList.Circuit_Wafer_UHPIC.get(64), + ItemList.Circuit_Wafer_UHPIC.get(64), + ItemList.Circuit_Wafer_SoC2.get(32), + ItemList.Circuit_Parts_DiodeASMD.get(64) + }, + new FluidStack[] { + Materials.SolderingAlloy.getMolten(3760), + Materials.Naquadria.getMolten(9216), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 32000) + }, + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 5), 2000, 200000 ); - GT_Recipe.GT_Recipe_AssemblyLine arU = null; - for(GT_Recipe.GT_Recipe_AssemblyLine ar : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { - if(GT_Utility.areStacksEqual(ar.mOutput, ItemList.Energy_LapotronicOrb2.get(1L), true)) { - // LuV Lapo Orb - arLuV = ar; - } else if(GT_Utility.areStacksEqual(ar.mOutput, ItemList.Energy_Module.get(1L), true)) { - // ZPM Lapo Orb - KekzCore.LOGGER.info("Found matching recipe for Energy Module?"); - } else if(GT_Utility.areStacksEqual(ar.mOutput, ItemList.Energy_Cluster.get(1L), true)) { - // UV Lapo Orb - KekzCore.LOGGER.info("Found matching recipe for Energy Cluster?"); - } else if(GT_Utility.areStacksEqual(ar.mOutput, ItemList.ZPM2.get(1L), true)) { - // Ultimate Battery - arU = ar; - } - } - lapoCapacitorRecipeAdder(arLuV, Materials.Osmiridium, - GT_OreDictUnificator.get(OrePrefixes.block, Materials.Lapis, 1), - new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 2)); - lapoCapacitorRecipeAdder(arZPM, Materials.NaquadahAlloy, - new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 2), - new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 3)); - lapoCapacitorRecipeAdder(arUV, Materials.Neutronium, - new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 3), - new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 4)); - lapoCapacitorRecipeAdder(arU, Materials.CosmicNeutronium, - new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 4), - new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 5)); // Capacitor recycling + GT_Values.RA.addUnboxingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 7), + GT_ModHandler.getIC2Item("lapotronCrystal", 1L, 26), + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 6), + 1200, 32); GT_Values.RA.addUnboxingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 1), ItemList.Energy_LapotronicOrb.get(1L), - GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Lapis, 4), + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 6), 1200, 32); GT_Values.RA.addUnboxingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 2), ItemList.Energy_LapotronicOrb2.get(1L), @@ -592,9 +586,22 @@ public class Recipes { ItemList.ZPM2.get(1L), GT_OreDictUnificator.get(OrePrefixes.screw, Materials.CosmicNeutronium, 24), 1200, 32); + + // For the people that already made the Really Ultimate Battery but want to use the LSC + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { + ItemList.ZPM3.get(1), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 4), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.CosmicNeutronium, 24), + GT_Utility.getIntegratedCircuit(6) + }, + null, + new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 5), + 12000, 200000 + ); } - private static void registerRecipes_SpaceElevator() { + /*private static void registerRecipes_SpaceElevator() { // Controller final Object[] se_recipe = { "BCB", "CPC", "BCB", @@ -602,7 +609,7 @@ public class Recipes { 'C', OrePrefixes.cableGt16.get(Materials.Aluminium), 'P', OrePrefixes.circuit.get(Materials.Master) }; - GT_ModHandler.addCraftingRecipe(KekzCore.se.getStackForm(1), se_recipe); + GT_ModHandler.addCraftingRecipe(TileEntities.se.getStackForm(1), se_recipe); // Blocks final Object[] seBase_recipe = { "DRD", "RCR", "DRD", @@ -618,5 +625,20 @@ public class Recipes { 'C', OrePrefixes.cableGt01.get(Materials.Aluminium) }; GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.spaceElevatorStructure, 1, 1), seCoilHolder_recipe); + }*/ + + private static void registerRecipes_Cosmetics() { + // Hex Tiles + final ItemStack[] hexTiles = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.stone, Materials.Concrete, 1), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Steel, 1), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.DarkSteel, 2) + }; + GT_Values.RA.addAssemblerRecipe( + hexTiles, + FluidRegistry.getFluidStack("molten.plastic", 36), + new ItemStack(Blocks.largeHexPlate, 2), + 600, 120); } } diff --git a/src/main/java/common/TileEntities.java b/src/main/java/common/TileEntities.java new file mode 100644 index 0000000000..740b985b00 --- /dev/null +++ b/src/main/java/common/TileEntities.java @@ -0,0 +1,45 @@ +package common; + +import common.tileentities.*; +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_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_ItemProxyCable.class, "kekztech_itemproxycable_tile"); + //GameRegistry.registerTileEntity(TE_ItemProxySource.class, "kekztech_itemproxysource_tile"); + //GameRegistry.registerTileEntity(TE_ItemProxyEndpoint.class, "kekztech_itemproxyendpoint_tile"); + 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() { + // 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"); + 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.0", "T.F.F.T Multi I/O Hatch [HV]", 3); + mhIV = new GTMTE_TFFTMultiHatch(13109, "machine.multihatch.1", "T.F.F.T Multi I/O Hatch [IV]", 5); + mhZPM = new GTMTE_TFFTMultiHatch(13110, "machine.multihatch.2", "T.F.F.T Multi I/O Hatch [ZPM]", 7); + } + +} 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/blocks/Block_IchorJar.java b/src/main/java/common/blocks/Block_IchorJar.java index 560fd0c37b..0c2417b2f1 100644 --- a/src/main/java/common/blocks/Block_IchorJar.java +++ b/src/main/java/common/blocks/Block_IchorJar.java @@ -42,6 +42,7 @@ public class Block_IchorJar extends BlockJar { public static Block registerBlock() { final String blockName = "kekztech_ichorjar_block"; INSTANCE.setBlockName(blockName); + INSTANCE.setHarvestLevel("pickaxe", 3); GameRegistry.registerBlock(INSTANCE, IB_IchorJar.class, blockName); return INSTANCE; 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_LapotronicEnergyUnit.java b/src/main/java/common/blocks/Block_LapotronicEnergyUnit.java index 9a6aad0b5b..75de60a308 100644 --- a/src/main/java/common/blocks/Block_LapotronicEnergyUnit.java +++ b/src/main/java/common/blocks/Block_LapotronicEnergyUnit.java @@ -14,11 +14,15 @@ import net.minecraft.util.IIcon; public class Block_LapotronicEnergyUnit extends BaseGTUpdateableBlock { - private static final Block_LapotronicEnergyUnit instance = new Block_LapotronicEnergyUnit(); + private static final Block_LapotronicEnergyUnit INSTANCE = new Block_LapotronicEnergyUnit(); private IIcon iconBaseSide; private IIcon iconBaseTop; + private IIcon iconLapoEmptySide; + private IIcon iconLapoEmptyTop; + private IIcon iconLapoEVSide; + private IIcon iconLapoEVTop; private IIcon iconLapoIVSide; private IIcon iconLapoIVTop; private IIcon iconLapoLuVSide; @@ -36,13 +40,13 @@ public class Block_LapotronicEnergyUnit extends BaseGTUpdateableBlock { public static Block registerBlock() { final String blockName = "kekztech_lapotronicenergyunit_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setHardness(5.0f); - instance.setResistance(6.0f); - GameRegistry.registerBlock(instance, IB_LapotronicEnergyUnit.class, blockName); - - return instance; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(5.0f); + INSTANCE.setResistance(6.0f); + GameRegistry.registerBlock(INSTANCE, IB_LapotronicEnergyUnit.class, blockName); + + return INSTANCE; } @Override @@ -50,6 +54,11 @@ public class Block_LapotronicEnergyUnit extends BaseGTUpdateableBlock { iconBaseSide = ir.registerIcon("kekztech:LSCBase_side"); iconBaseTop = ir.registerIcon("kekztech:LSCBase_top"); + + iconLapoEmptySide = ir.registerIcon("kekztech:LapotronicEnergyUnit6_side"); + iconLapoEmptyTop = ir.registerIcon("kekztech:LapotronicEnergyUnit6_top"); + iconLapoEVSide = ir.registerIcon("kekztech:LapotronicEnergyUnit7_side"); + iconLapoEVTop = ir.registerIcon("kekztech:LapotronicEnergyUnit7_top"); iconLapoIVSide = ir.registerIcon("kekztech:LapotronicEnergyUnit1_side"); iconLapoIVTop = ir.registerIcon("kekztech:LapotronicEnergyUnit1_top"); iconLapoLuVSide = ir.registerIcon("kekztech:LapotronicEnergyUnit2_side"); @@ -68,7 +77,10 @@ public class Block_LapotronicEnergyUnit extends BaseGTUpdateableBlock { public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { // Multi casing par3List.add(new ItemStack(par1, 1, 0)); - // Lapo units IV - UV + // Empty capacitor + par3List.add(new ItemStack(par1, 1, 6)); + // Lapo capacitors EV - UV + par3List.add(new ItemStack(par1, 1, 7)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); par3List.add(new ItemStack(par1, 1, 3)); @@ -86,6 +98,8 @@ public class Block_LapotronicEnergyUnit extends BaseGTUpdateableBlock { case 3: return (side < 2) ? iconLapoZPMTop : iconLapoZPMSide; case 4: return (side < 2) ? iconLapoUVTop : iconLapoUVSide; case 5: return (side < 2) ? iconUltimateTop : iconUltimateSide; + case 6: return (side < 2) ? iconLapoEmptyTop : iconLapoEmptySide; + case 7: return (side < 2) ? iconLapoEVTop : iconLapoEVSide; default: return iconUltimateTop; } } diff --git a/src/main/java/common/blocks/Block_LargeHexPlate.java b/src/main/java/common/blocks/Block_LargeHexPlate.java new file mode 100644 index 0000000000..8bdad56323 --- /dev/null +++ b/src/main/java/common/blocks/Block_LargeHexPlate.java @@ -0,0 +1,61 @@ +package common.blocks; + +import cpw.mods.fml.common.registry.GameRegistry; +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; +import net.minecraft.world.IBlockAccess; + +public class Block_LargeHexPlate extends Block { + + private static final Block_LargeHexPlate INSTANCE = new Block_LargeHexPlate(); + private static final int BATCH_SIZE = 4; + + private final IIcon[][] parts = new IIcon[BATCH_SIZE][BATCH_SIZE]; + + private Block_LargeHexPlate() { + super(Material.rock); + } + + public static Block registerBlock() { + final String blockName = "kekztech_largehextile_block"; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(6.0f); + INSTANCE.setResistance(10.0f); + GameRegistry.registerBlock(INSTANCE, blockName); + + return INSTANCE; + } + + @Override + public void registerBlockIcons(IIconRegister ir) { + for(int x = 0; x < BATCH_SIZE; x++) { + for(int z = 0; z < BATCH_SIZE; z++) { + parts[x][z] = ir.registerIcon("kekztech:LargeHexTile_" + x + "_" + z); + } + } + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + final int xMod = x >= 0 ? Math.abs(x % BATCH_SIZE) : Math.abs((Math.abs(x) % BATCH_SIZE) - BATCH_SIZE) % BATCH_SIZE; + final int yMod = y >= 0 ? Math.abs(y % BATCH_SIZE) : Math.abs((Math.abs(y) % BATCH_SIZE) - BATCH_SIZE) % BATCH_SIZE; + final int zMod = z >= 0 ? Math.abs(z % BATCH_SIZE) : Math.abs((Math.abs(z) % BATCH_SIZE) - BATCH_SIZE) % BATCH_SIZE; + + if(side == 0 || side == 1) { + return parts[xMod][zMod]; + } else if(side == 2 || side == 3) { + return parts[xMod][yMod]; + } else { + return parts[zMod][yMod]; + } + } + + @Override + public IIcon getIcon(int side, int meta) { + return parts[(int) Math.ceil(BATCH_SIZE / 2)][(int) Math.ceil(BATCH_SIZE / 2)]; + } +} diff --git a/src/main/java/common/blocks/Block_TFFTMultiHatch.java b/src/main/java/common/blocks/Block_TFFTMultiHatch.java index be7b588fa5..564113efe5 100644 --- a/src/main/java/common/blocks/Block_TFFTMultiHatch.java +++ b/src/main/java/common/blocks/Block_TFFTMultiHatch.java @@ -6,60 +6,60 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; -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.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.world.IBlockAccess; import net.minecraft.world.World; +import java.util.List; + +@Deprecated public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { - private static Block_TFFTMultiHatch instance = new Block_TFFTMultiHatch(); - + private static final Block_TFFTMultiHatch INSTANCE = new Block_TFFTMultiHatch(); + + private IIcon casing; + private Block_TFFTMultiHatch() { super(Material.iron); } public static Block registerBlock() { 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); - - return instance; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(5.0f); + INSTANCE.setResistance(6.0f); + GameRegistry.registerBlock(INSTANCE, IB_TFFTMultiHatch.class, blockName); + + return INSTANCE; } @Override - public TileEntity createTileEntity(World world, int p_149915_2_) { - return new TE_TFFTMultiHatch(); + public void registerBlockIcons(IIconRegister ir) { + casing = ir.registerIcon("kekztech:TFFTCasing"); } @Override - public boolean hasTileEntity(int metadata) { - return true; + public IIcon getIcon(int side, int meta) { + return casing; } - + @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - // Code block taken from GregTech's BaseMetaTileEntity.class - if (GT_Utility.isStackInList(player.getHeldItem(), GregTech_API.sScrewdriverList)) { - if (GT_ModHandler.damageOrDechargeItem(player.getHeldItem(), 1, 200, player)) { - final TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TE_TFFTMultiHatch) { - ((TE_TFFTMultiHatch) te).toggleAutoOutput(); - GT_Utility.sendSoundToPlayers(world, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, x, y, z); - // Give chat feedback - GT_Utility.sendChatToPlayer(player, ((TE_TFFTMultiHatch) te).isOutputting() ? "Auto-output enabled" : "Auto-output disabled"); - - } - } - return true; - } - return false; + public TileEntity createTileEntity(World world, int meta) { + return new TE_TFFTMultiHatch(); } + + @Override + public boolean hasTileEntity(int meta) { + return true; + } + } diff --git a/src/main/java/common/blocks/Block_ThaumiumReinforcedJar.java b/src/main/java/common/blocks/Block_ThaumiumReinforcedJar.java index 61ca0e2390..cce03b0236 100644 --- a/src/main/java/common/blocks/Block_ThaumiumReinforcedJar.java +++ b/src/main/java/common/blocks/Block_ThaumiumReinforcedJar.java @@ -30,7 +30,7 @@ import java.util.List; public class Block_ThaumiumReinforcedJar extends BlockJar { - private static final Block_ThaumiumReinforcedJar instance = new Block_ThaumiumReinforcedJar(); + private static final Block_ThaumiumReinforcedJar INSTANCE = new Block_ThaumiumReinforcedJar(); private Block_ThaumiumReinforcedJar() { super(); @@ -41,10 +41,11 @@ public class Block_ThaumiumReinforcedJar extends BlockJar { public static Block registerBlock() { final String blockName = "kekztech_thaumiumreinforcedjar_block"; - instance.setBlockName(blockName); - GameRegistry.registerBlock(instance, IB_ThaumiumReinforcedJar.class, blockName); + INSTANCE.setBlockName(blockName); + INSTANCE.setHarvestLevel("pickaxe", 2); + GameRegistry.registerBlock(INSTANCE, IB_ThaumiumReinforcedJar.class, blockName); - return instance; + return INSTANCE; } @Override 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_LapotronicEnergyUnit.java b/src/main/java/common/itemBlocks/IB_LapotronicEnergyUnit.java index 7891be8ea1..b6a8fc2468 100644 --- a/src/main/java/common/itemBlocks/IB_LapotronicEnergyUnit.java +++ b/src/main/java/common/itemBlocks/IB_LapotronicEnergyUnit.java @@ -39,6 +39,8 @@ public class IB_LapotronicEnergyUnit extends ItemBlock { case 3: lines.add("Capacity: 10,000,000,000 EU"); break; case 4: lines.add("Capacity: 100,000,000,000 EU"); break; case 5: lines.add("Capacity: 9,223,372,036,854,775,807 EU"); break; + case 6: lines.add("Capacity: None"); break; + case 7: lines.add("Capacity: 10,000,000 EU"); break; } } } diff --git a/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java index 38b8997f0f..f00c5ef0c2 100644 --- a/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java +++ b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java @@ -2,24 +2,38 @@ package common.itemBlocks; import java.util.List; +import common.tileentities.TE_TFFTMultiHatch; 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; +@Deprecated public class IB_TFFTMultiHatch extends ItemBlock { public IB_TFFTMultiHatch(Block block) { super(block); } - + + @Override + public int getMetadata(int meta) { + return meta; + } + + @Override + public boolean getHasSubtypes() { + return true; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + @SuppressWarnings({"unchecked"}) @Override public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { 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")); } } diff --git a/src/main/java/items/ErrorItem.java b/src/main/java/common/items/ErrorItem.java index f0dbc9e600..4b79e5fbd8 100644 --- a/src/main/java/items/ErrorItem.java +++ b/src/main/java/common/items/ErrorItem.java @@ -1,50 +1,48 @@ -package items;
-
-import java.util.List;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import kekztech.KekzCore;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
-
-public class ErrorItem extends Item {
-
- private static final ErrorItem instance = new ErrorItem();
-
- private ErrorItem() {
- // I am a singleton
- }
-
- public static ErrorItem getInstance() {
- return instance;
- }
-
- public void registerItem() {
- super.setHasSubtypes(false);
- final String unlocalizedName = "kekztech_error_item";
- super.setUnlocalizedName(unlocalizedName);
- super.setCreativeTab(CreativeTabs.tabMisc);
- super.setMaxStackSize(64);
- super.setTextureName(KekzCore.MODID + ":" + "Error");
- GameRegistry.registerItem(getInstance(), unlocalizedName);
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
- list.add("REMINDER: KekzTech recipes are only tested to work in GTNH!");
- list.add("Placeholder item in case something went wrong");
- list.add("If this item shows up in GTNH, you may report it to:");
- list.add("https://github.com/kekzdealer/KekzTech");
- }
-
- @Override
- public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) {
- player.swingItem();
- return item;
- }
-
-}
+package common.items; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import kekztech.KekzCore; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ErrorItem extends Item { + + private static final ErrorItem INSTANCE = new ErrorItem(); + + private ErrorItem() { } + + public static ErrorItem getInstance() { + return INSTANCE; + } + + public void registerItem() { + super.setHasSubtypes(false); + final String unlocalizedName = "kekztech_error_item"; + super.setUnlocalizedName(unlocalizedName); + super.setCreativeTab(CreativeTabs.tabMisc); + super.setMaxStackSize(64); + super.setTextureName(KekzCore.MODID + ":" + "Error"); + GameRegistry.registerItem(getInstance(), unlocalizedName); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) { + list.add("REMINDER: KekzTech recipes are only tested to work in GTNH!"); + list.add("Placeholder item in case something went wrong"); + list.add("If this item shows up in GTNH, you may report it to:"); + list.add("https://github.com/kekzdealer/KekzTech"); + } + + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + player.swingItem(); + return item; + } + +} diff --git a/src/main/java/items/MetaItem_CraftingComponent.java b/src/main/java/common/items/MetaItem_CraftingComponent.java index ae5bedad91..ca1c3dee7b 100644 --- a/src/main/java/items/MetaItem_CraftingComponent.java +++ b/src/main/java/common/items/MetaItem_CraftingComponent.java @@ -1,104 +1,101 @@ -package items;
-
-import java.util.List;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import kekztech.KekzCore;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.IIcon;
-
-public class MetaItem_CraftingComponent extends Item {
-
- private static MetaItem_CraftingComponent instance = new MetaItem_CraftingComponent();
- private final IIcon[] icons = new IIcon[17];
-
- private MetaItem_CraftingComponent() {
- // I am a singleton
- }
-
- public static MetaItem_CraftingComponent getInstance() {
- return instance;
- }
-
- public void registerItem() {
- super.setHasSubtypes(true);
- final String unlocalizedName = "kekztech_crafting_item";
- super.setUnlocalizedName(unlocalizedName);
- super.setCreativeTab(CreativeTabs.tabMisc);
- super.setMaxStackSize(64);
- GameRegistry.registerItem(getInstance(), unlocalizedName);
- }
-
- @Override
- public void registerIcons(IIconRegister reg) {
- int counter = 0;
- // Raw heat pipes
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "CopperHeatPipe");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "SilverHeatPipe");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "BoronArsenideHeatPipe");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "DiamondHeatPipe");
- // Dust
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "BoronArsenideDust");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "IsotopicallyPureDiamondDust");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "AmineCarbamateDust");
- // Crystal
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "BoronArsenideCrystal");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "IsotopicallyPureDiamondCrystal");
- // Ceramics
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "YSZCeramicDust");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "GDCCeramicDust");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "YttriaDust");
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "ZirconiaDust");
- 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
- public IIcon getIconFromDamage(int meta) {
- return icons[meta];
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public void getSubItems(Item item, CreativeTabs tab, List list) {
- for(int i = 0; i < icons.length; i++) {
- list.add(new ItemStack(item, 1, i));
- }
- }
-
- @Override
- public String getUnlocalizedName(ItemStack stack) {
- return super.getUnlocalizedName() + "." + stack.getItemDamage();
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
- list.add("Crafting component for KekzTech things");
- }
-
- @Override
- public double getDurabilityForDisplay(ItemStack stack) {
- return 0.0d;
- }
-
- @Override
- public boolean showDurabilityBar(ItemStack stack) {
- return false;
- }
-
- public ItemStack getStackFromDamage(int meta) {
- return new ItemStack(getInstance(), 1, meta);
- }
-
- public ItemStack getStackOfAmountFromDamage(int meta, int amount) {
- return new ItemStack(getInstance(), amount, meta);
- }
-
-}
+package common.items; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import kekztech.KekzCore; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +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[16]; + + private MetaItem_CraftingComponent() { } + + public static MetaItem_CraftingComponent getInstance() { + return INSTANCE; + } + + public void registerItem() { + super.setHasSubtypes(true); + final String unlocalizedName = "kekztech_crafting_item"; + super.setUnlocalizedName(unlocalizedName); + super.setCreativeTab(CreativeTabs.tabMisc); + super.setMaxStackSize(64); + GameRegistry.registerItem(getInstance(), unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + int counter = 9; + // Raw heat pipes + /*icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "CopperHeatPipe"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "SilverHeatPipe"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "BoronArsenideHeatPipe"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "DiamondHeatPipe"); + // Dust + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "BoronArsenideDust"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "IsotopicallyPureDiamondDust"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "AmineCarbamateDust"); + // Crystal + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "BoronArsenideCrystal"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "IsotopicallyPureDiamondCrystal");*/ + // Ceramics + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "YSZCeramicDust"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "GDCCeramicDust"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "YttriaDust"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "ZirconiaDust"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "CeriaDust"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "YSZCeramicPlate"); + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + "GDCCeramicPlate"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } + + @SuppressWarnings({"unchecked"}) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 9; i < icons.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) { + list.add("Crafting component for KekzTech things"); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0.0d; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + public ItemStack getStackFromDamage(int meta) { + return new ItemStack(getInstance(), 1, meta); + } + + public ItemStack getStackOfAmountFromDamage(int meta, int amount) { + return new ItemStack(getInstance(), amount, meta); + } + +} diff --git a/src/main/java/items/MetaItem_ReactorComponent.java b/src/main/java/common/items/MetaItem_ReactorComponent.java index 13a19dbc7c..9d364e7585 100644 --- a/src/main/java/items/MetaItem_ReactorComponent.java +++ b/src/main/java/common/items/MetaItem_ReactorComponent.java @@ -1,148 +1,142 @@ -package items;
-
-import java.util.List;
-
-import org.lwjgl.input.Keyboard;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import kekztech.KekzCore;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.IIcon;
-import reactor.items.CoolantCell;
-import reactor.items.FuelRod;
-import reactor.items.HeatExchanger;
-import reactor.items.HeatVent;
-import reactor.items.NeutronReflector;
-
-public class MetaItem_ReactorComponent extends Item {
-
- private static MetaItem_ReactorComponent instance = new MetaItem_ReactorComponent();
- private final IIcon[] icons = new IIcon[50];
-
- private MetaItem_ReactorComponent() {
- // I am a singleton
- }
-
- public static MetaItem_ReactorComponent getInstance() {
- return instance;
- }
-
- public void registerItem() {
- super.setHasSubtypes(true);
- final String unlocalizedName = "kekztech_reactor_item";
- super.setUnlocalizedName(unlocalizedName);
- super.setCreativeTab(CreativeTabs.tabMisc);
- super.setMaxStackSize(1);
- GameRegistry.registerItem(getInstance(), unlocalizedName);
- }
-
- @Override
- public void registerIcons(IIconRegister reg) {
- int counter = 0;
- for(String s : HeatVent.RESOURCE_NAMES) {
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s);
- }
- for(String s : HeatExchanger.RESOURCE_NAME) {
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s);
- }
- for(String s : FuelRod.RESOURCE_NAME) {
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s);
- }
- for(String s : FuelRod.RESOURCE_NAME_DEPLETED) {
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s);
- }
- for(String s : NeutronReflector.RESOURCE_NAME) {
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s);
- }
- for(String s : CoolantCell.RESOURCE_NAME) {
- icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s);
- }
- }
-
- @Override
- public IIcon getIconFromDamage(int meta) {
- return icons[meta];
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public void getSubItems(Item item, CreativeTabs tab, List list) {
- for(int i = 0; i < icons.length; i++) {
- list.add(new ItemStack(item, 1, i));
- }
- }
-
- @Override
- public String getUnlocalizedName(ItemStack stack) {
- return super.getUnlocalizedName() + "." + stack.getItemDamage();
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
- if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- list.add("Property = 1");
- } else {
- list.add("Part for the Modular Nuclear Reactor");
- list.add("Hold " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " to display properties");
- }
- }
-
- @Override
- public double getDurabilityForDisplay(ItemStack stack) {
- NBTTagCompound nbt = (stack.getTagCompound() == null) ? new NBTTagCompound() : stack.getTagCompound();
- if(nbt.getInteger("HEALTH") != 0 && nbt.getInteger("MAXHEALTH") != 0) {
- return 1 - (double) (nbt.getInteger("HEALTH") / nbt.getInteger("MAXHEALTH"));
- } else {
- return 0.0d;
- }
- }
-
- @Override
- public boolean showDurabilityBar(ItemStack stack) {
- final int meta = stack.getItemDamage();
- if(meta >= 31 && meta <= 45) {
- return false;
- } else {
- return true;
- }
- }
-
- public ItemStack getStackFromDamage(int meta) {
- return new ItemStack(getInstance(), 1, meta);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-}
+package common.items; + +import java.util.List; + +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.common.registry.GameRegistry; +import kekztech.KekzCore; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import reactor.items.CoolantCell; +import reactor.items.FuelRod; +import reactor.items.HeatExchanger; +import reactor.items.HeatVent; +import reactor.items.NeutronReflector; + +public class MetaItem_ReactorComponent extends Item { + + private static final MetaItem_ReactorComponent INSTANCE = new MetaItem_ReactorComponent(); + private final IIcon[] icons = new IIcon[50]; + + private MetaItem_ReactorComponent() { } + + public static MetaItem_ReactorComponent getInstance() { + return INSTANCE; + } + + public void registerItem() { + super.setHasSubtypes(true); + final String unlocalizedName = "kekztech_reactor_item"; + super.setUnlocalizedName(unlocalizedName); + super.setCreativeTab(CreativeTabs.tabMisc); + super.setMaxStackSize(1); + //GameRegistry.registerItem(getInstance(), unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + int counter = 0; + for(String s : HeatVent.RESOURCE_NAMES) { + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s); + } + for(String s : HeatExchanger.RESOURCE_NAME) { + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s); + } + for(String s : FuelRod.RESOURCE_NAME) { + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s); + } + for(String s : FuelRod.RESOURCE_NAME_DEPLETED) { + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s); + } + for(String s : NeutronReflector.RESOURCE_NAME) { + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s); + } + for(String s : CoolantCell.RESOURCE_NAME) { + icons[counter++] = reg.registerIcon(KekzCore.MODID + ":" + s); + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } + + @SuppressWarnings({"unchecked"}) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < icons.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) { + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + list.add("Property = 1"); + } else { + list.add("Part for the Modular Nuclear Reactor"); + list.add("Hold " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " to display properties"); + } + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + NBTTagCompound nbt = (stack.getTagCompound() == null) ? new NBTTagCompound() : stack.getTagCompound(); + if(nbt.getInteger("HEALTH") != 0 && nbt.getInteger("MAXHEALTH") != 0) { + return 1 - (double) (nbt.getInteger("HEALTH") / nbt.getInteger("MAXHEALTH")); + } else { + return 0.0d; + } + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + final int meta = stack.getItemDamage(); + return meta < 31 || meta > 45; + } + + public ItemStack getStackFromDamage(int meta) { + return new ItemStack(getInstance(), 1, meta); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/src/main/java/common/reactorItem/AbstractReactorItem.java b/src/main/java/common/reactorItem/AbstractReactorItem.java new file mode 100644 index 0000000000..e78889b57f --- /dev/null +++ b/src/main/java/common/reactorItem/AbstractReactorItem.java @@ -0,0 +1,29 @@ +package common.reactorItem; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public abstract class AbstractReactorItem extends Item { + + private final int[] behaviourID; + + protected AbstractReactorItem(int...behaviourID) { + this.behaviourID = behaviourID; + } + + @Override + public abstract double getDurabilityForDisplay(ItemStack stack); + + @Override + public abstract boolean showDurabilityBar(ItemStack stack); + + @Override + public final String getUnlocalizedName(ItemStack stack) { + return super.hasSubtypes ? (super.getUnlocalizedName() + "." + stack.getItemDamage()) + : super.getUnlocalizedName(); + } + + public final int getBehaviourID(int meta) { + return behaviourID[meta]; + } +} diff --git a/src/main/java/common/reactorItem/ReactorItem.java b/src/main/java/common/reactorItem/ReactorItem.java new file mode 100644 index 0000000000..e8dfbef21e --- /dev/null +++ b/src/main/java/common/reactorItem/ReactorItem.java @@ -0,0 +1,48 @@ +package common.reactorItem; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class ReactorItem extends AbstractReactorItem { + + private static final ReactorItem INSTANCE = new ReactorItem(); + + private final IIcon[] icons = new IIcon[50]; + + private ReactorItem() { + super(); + } + + public static ReactorItem registerItem() { + INSTANCE.setHasSubtypes(true); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setMaxStackSize(1); + final String unloc = "kekztech_reactor_item"; + INSTANCE.setUnlocalizedName(unloc); + GameRegistry.registerItem(INSTANCE, unloc); + return INSTANCE; + } + + @Override + public void registerIcons(IIconRegister reg) { + + } + + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } +} diff --git a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java index 1c32525c4e..a12f4130cb 100644 --- a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java +++ b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java @@ -1,531 +1,534 @@ -package common.tileentities;
-
-import gregtech.api.enums.Textures.BlockIcons;
-import gregtech.api.gui.GT_GUIContainer_MultiMachine;
-import gregtech.api.interfaces.ITexture;
-import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gregtech.api.objects.GT_RenderedTexture;
-import kekztech.MultiFluidHandler;
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.fluids.FluidStack;
-import org.lwjgl.input.Keyboard;
-
-import common.Blocks;
-import common.blocks.*;
-import util.MultiBlockTooltipBuilder;
-import util.Vector3i;
-import util.Vector3ic;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase {
-
- private final static String glassNameIC2Reinforced = "blockAlloyGlass";
- private final static Block CASING = Blocks.tfftCasing;
- private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1;
- private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2;
- private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3;
- private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4;
- private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5;
- private final static Block MULTI_HATCH = Blocks.tfftMultiHatch;
- private final static int CASING_TEXTURE_ID = 176;
-
- private MultiFluidHandler mfh;
- private HashSet<TE_TFFTMultiHatch> multiHatches = new HashSet<>();
-
- private int runningCost = 0;
- private boolean doVoidExcess = false;
- private byte fluidSelector = 0;
-
- public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) {
- super(aID, aName, aNameRegional);
- }
-
- public GTMTE_FluidMultiStorage(String aName) {
- super(aName);
- }
-
- @Override
- public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
- return new GTMTE_FluidMultiStorage(super.mName);
- }
-
- @Override
- public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("High-Tech fluid tank that can hold up to 25 different fluids!")
- .addInfo("Has 1/25th of the total capacity as capacity for each fluid.")
- .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.")
- .addInfo("Fluid storage amount and running cost depends on the storage field blocks used.")
- .addSeparator()
- .addInfo("Note on hatch locking:")
- .addInfo("Use an Integrated Circuit in the GUI slot to limit which fluid is output.")
- .addInfo("The index of a stored fluid can be obtained through the Tricorder.")
- .addSeparator()
- .beginStructureBlock(5, 9, 5)
- .addController("Top Center")
- .addEnergyHatch("Any top or bottom casing")
- .addOtherStructurePart("Inner 3x7x3 solid pillar", "Storage Field Blocks")
- .addOtherStructurePart("Outer 5x7x5 glass shell", "IC2 Reinforced Glass")
- .addMaintenanceHatch("Any top or bottom casing")
- .addIOHatches("Instead of any casing or glass, have to touch storage field.")
- .signAndFinalize("Kekzdealer");
- if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
- } else {
- return b.getStructureInformation();
- }
- }
-
- @Override
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex,
- boolean aActive, boolean aRedstone) {
- return aSide == aFacing
- ? new ITexture[]{BlockIcons.casingTexturePages[1][48],
- new GT_RenderedTexture(aActive
- ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE
- : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)}
- : new ITexture[]{BlockIcons.casingTexturePages[1][48]};
- }
-
- public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(),
- "MultiblockDisplay.png");
- }
-
- @Override
- public boolean isCorrectMachinePart(ItemStack var1) {
- return true;
- }
-
- @Override
- public boolean checkRecipe(ItemStack guiSlotItem) {
-
- super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000;
- super.mEfficiencyIncrease = 10000;
- super.mEUt = runningCost;
- super.mMaxProgresstime = 10;
-
- if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) {
- this.fluidSelector = (byte) guiSlotItem.getItemDamage();
- }
-
- // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code!
- if (multiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) {
- return true;
- }
-
- // Suck in fluids
- final ArrayList<FluidStack> inputHatchFluids = super.getStoredFluids();
- if (inputHatchFluids.size() > 0) {
-
- for (FluidStack fluidStack : inputHatchFluids) {
-
- final int pushed = mfh.pushFluid(fluidStack, true);
- final FluidStack toDeplete = fluidStack.copy();
- toDeplete.amount = pushed;
- super.depleteInput(toDeplete);
- }
- }
-
- // Push out fluids
- if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) {
- final FluidStack storedFluid = mfh.getFluid(fluidSelector);
- // Sum available output capacity
- int possibleOutput = 0;
- for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) {
- if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() == null) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- }
- }
- // Output as much as possible
- final FluidStack tempStack = storedFluid.copy();
- tempStack.amount = possibleOutput;
- tempStack.amount = mfh.pullFluid(tempStack, fluidSelector, true);
- super.addOutput(tempStack);
-
- } else {
- for (FluidStack storedFluid : mfh.getFluids()) {
- // Sum available output capacity
- int possibleOutput = 0;
- for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) {
- if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() == null) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- }
- }
- // output as much as possible
- final FluidStack tempStack = storedFluid.copy();
- tempStack.amount = possibleOutput;
- // TODO possible concurrent modification exception as pullFluid calls remove() without an iterator
- tempStack.amount = mfh.pullFluid(tempStack, true);
- super.addOutput(tempStack);
- }
- }
-
- return true;
- }
-
- @Override
- public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- super.onPostTick(aBaseMetaTileEntity, aTick);
-
- if (mfh != null) {
- mfh.setLock(!super.getBaseMetaTileEntity().isActive());
- mfh.setFluidSelector(fluidSelector);
- mfh.setDoVoidExcess(doVoidExcess);
- }
- }
-
- public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) {
- final Vector3i offset = new Vector3i();
-
- // either direction on z-axis
- if (forgeDirection.x() == 0 && forgeDirection.z() == -1) {
- offset.x = x;
- offset.y = y;
- offset.z = z;
- }
- if (forgeDirection.x() == 0 && forgeDirection.z() == 1) {
- offset.x = -x;
- offset.y = y;
- offset.z = -z;
- }
- // either direction on x-axis
- if (forgeDirection.x() == -1 && forgeDirection.z() == 0) {
- offset.x = z;
- offset.y = y;
- offset.z = -x;
- }
- if (forgeDirection.x() == 1 && forgeDirection.z() == 0) {
- offset.x = -z;
- offset.y = y;
- offset.z = x;
- }
- // either direction on y-axis
- if (forgeDirection.y() == -1) {
- offset.x = x;
- offset.y = z;
- offset.z = y;
- }
-
- return offset;
- }
-
- @Override
- public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) {
- // Figure out the vector for the direction the back face of the controller is facing
- final Vector3ic forgeDirection = new Vector3i(
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX,
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY,
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ
- );
- int minCasingAmount = 20;
- boolean formationChecklist = true; // If this is still true at the end, machine is good to go :)
- float runningCostAcc = 0;
- double fluidCapacityAcc = 0;
-
- multiHatches.clear();
-
- // Front segment
- for (int X = -2; X <= 2; X++) {
- for (int Y = -2; Y <= 2; Y++) {
- if (X == 0 && Y == 0) {
- continue; // Skip controller
- }
-
- // Get next TE
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0);
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- // Fluid hatches should touch the storage field.
- // Maintenance/Energy hatch can go anywhere
- if (X > -2 && X < 2 && Y > -2 && Y < 2) {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- final Block b = thisController.getBlockOffset(offset.x(), offset.y(), offset.z());
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- // Also check for multi hatch
- if (b == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else if (b == MULTI_HATCH) {
- final TE_TFFTMultiHatch mh =
- (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- multiHatches.add(mh);
- } else {
- formationChecklist = false;
- }
- }
- } else {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else {
- formationChecklist = false;
- }
- }
- }
- }
- }
-
- // Middle seven long segment
- for (int X = -2; X <= 2; X++) {
- for (int Y = -2; Y <= 2; Y++) {
- for (int Z = -1; Z >= -7; Z--) {
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z);
- if (X > -2 && X < 2 && Y > -2 && Y < 2) {
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD1.getUnlocalizedName())) {
- runningCostAcc += 0.5f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT1.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD2.getUnlocalizedName())) {
- runningCostAcc += 1.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT2.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD3.getUnlocalizedName())) {
- runningCostAcc += 2.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT3.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD4.getUnlocalizedName())) {
- runningCostAcc += 4.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT4.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD5.getUnlocalizedName())) {
- runningCostAcc += 8.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT5.getCapacity();
- } else {
- formationChecklist = false;
- }
- continue;
- }
-
- // Get next TE
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- // Corner allows only glass
- if (X == -2 && Y == -2 || X == 2 && Y == 2 || X == -2 && Y == 2 || X == 2 && Y == -2) {
- if (!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced))) {
- formationChecklist = false;
- }
- } else {
- // Tries to add TE as either of those kinds of hatches.
- // The number is the texture index number for the texture that needs to be painted over the hatch texture (TAE for GT++)
- if (!super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- // Also check for multi hatch
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) {
- final TE_TFFTMultiHatch mh =
- (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- multiHatches.add(mh);
- } else if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced)) {
- formationChecklist = false;
- }
- }
- }
- }
- }
- }
-
- // Back segment
- for (int X = -2; X <= 2; X++) {
- for (int Y = -2; Y <= 2; Y++) {
- // Get next TE
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8);
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- // Fluid hatches should touch the storage field.
- // Maintenance/Energy hatch can go anywhere
- if (X > -2 && X < 2 && Y > -2 && Y < 2) {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) {
- final TE_TFFTMultiHatch mh =
- (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- multiHatches.add(mh);
- } else {
- formationChecklist = false;
- }
- }
- } else {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else {
- formationChecklist = false;
- }
- }
- }
- }
- }
-
- if (this.mEnergyHatches.size() < 1) {
- formationChecklist = false;
- }
-
- if (this.mMaintenanceHatches.size() < 1) {
- formationChecklist = false;
- }
-
- if (minCasingAmount > 0) {
- formationChecklist = false;
- }
-
- if (formationChecklist) {
- runningCost = Math.round(-runningCostAcc);
- // Update MultiFluidHandler in case storage cells have been changed
- final int capacityPerFluid = (int) Math.round(fluidCapacityAcc / 25.0f);
- if (mfh == null) {
- mfh = new MultiFluidHandler(capacityPerFluid);
- } else {
- if (mfh.getCapacity() != capacityPerFluid) {
- mfh = new MultiFluidHandler(capacityPerFluid, mfh.getFluids());
- }
- }
- for (TE_TFFTMultiHatch mh : multiHatches) {
- mh.setMultiFluidHandler(mfh);
- }
- }
-
- return formationChecklist;
- }
-
- @Override
- public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (doVoidExcess) {
- doVoidExcess = false;
- aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned off"));
- } else {
- doVoidExcess = true;
- aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned on"));
- }
- }
-
- @Override
- public String[] getInfoData() {
- final ArrayList<String> ll = mfh.getInfoData();
-
- ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET);
- ll.add("Auto-voiding: " + doVoidExcess);
- ll.add("Per-Fluid Capacity: " + mfh.getCapacity() + "L");
- ll.add("Running Cost: "
- // mEUt does not naturally reflect efficiency status. Do that here.
- + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t");
- ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus())
- ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET
- : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET));
- ll.add("---------------------------------------------");
-
- final String[] a = new String[ll.size()];
- return ll.toArray(a);
- }
-
- @Override
- public void saveNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- nbt.setInteger("runningCost", runningCost);
- nbt.setBoolean("doVoidExcess", doVoidExcess);
-
- nbt.setInteger("capacityPerFluid", mfh.getCapacity());
- nbt.setTag("fluids", mfh.saveNBTData(new NBTTagCompound()));
-
- super.saveNBTData(nbt);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- runningCost = nbt.getInteger("runningCost");
- doVoidExcess = nbt.getBoolean("doVoidExcess");
-
- mfh = new MultiFluidHandler();
- mfh.loadNBTData(nbt);
- for (TE_TFFTMultiHatch mh : multiHatches) {
- mh.setMultiFluidHandler(mfh);
- }
- super.loadNBTData(nbt);
- }
-
- @Override
- public boolean isGivingInformation() {
- return true;
- }
-
- @Override
- public int getMaxEfficiency(ItemStack var1) {
- return 10000;
- }
-
- @Override
- public int getPollutionPerTick(ItemStack var1) {
- return 0;
- }
-
- @Override
- public int getDamageToComponent(ItemStack var1) {
- return 0;
- }
-
- @Override
- public boolean explodesOnComponentBreak(ItemStack var1) {
- return false;
- }
+package common.tileentities; + +import common.Blocks; +import common.blocks.*; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +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.Vector3i; +import util.Vector3ic; + +import java.util.ArrayList; +import java.util.HashSet; + +public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { + + private final static String glassNameIC2Reinforced = "blockAlloyGlass"; + private final static Block CASING = Blocks.tfftCasing; + private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1; + private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2; + private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3; + private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4; + private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5; + private final static int CASING_TEXTURE_ID = 176; + + private MultiFluidHandler mfh; + private final HashSet<GTMTE_TFFTMultiHatch> sMultiHatches = new HashSet<>(); + + private int runningCost = 0; + private boolean doVoidExcess = false; + private byte fluidSelector = 0; + + public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GTMTE_FluidMultiStorage(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { + return new GTMTE_FluidMultiStorage(super.mName); + } + + @Override + public String[] getDescription() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Fluid Tank") + .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, false) + .addController("Top Center") + .addCasingInfo("T.F.F.T. Casing", 20) + .addOtherStructurePart("Storage Field Blocks (Tier I-V)", "Inner 3x7x3 solid pillar") + .addOtherStructurePart("IC2 Reinforced Glass", "Outer 5x7x5 glass shell") + .addMaintenanceHatch("Any top or bottom casing") + .addEnergyHatch("Any top or bottom casing") + .addInputHatch("Instead of any casing or glass, has to touch storage field block") + .addOutputHatch("Instead of any casing or glass, has to touch storage field block") + .addStructureInfo("You can have a bunch of hatches") + .addOtherStructurePart("Multi I/O Hatches", "Instead of any casing or glass, has to touch storage field block") + .addStructureInfo("Use MIOH with conduits or fluid storage busses to see all fluids at once. If it's fixed.") + .addStructureInfo("Ask someone else why there's 4 versions, with 2 uncraftable ones") + .toolTipFinisher("KekzTech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return aSide == aFacing + ? new ITexture[]{BlockIcons.casingTexturePages[1][48], + new GT_RenderedTexture(aActive + ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE + : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)} + : new ITexture[]{BlockIcons.casingTexturePages[1][48]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + "MultiblockDisplay.png"); + } + + @Override + public boolean isCorrectMachinePart(ItemStack var1) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack guiSlotItem) { + + super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000; + super.mEfficiencyIncrease = 10000; + super.mEUt = runningCost; + super.mMaxProgresstime = 10; + + if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { + this.fluidSelector = (byte) guiSlotItem.getItemDamage(); + } + + // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code! + if (sMultiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) { + return true; + } + + // Suck in fluids + final ArrayList<FluidStack> inputHatchFluids = super.getStoredFluids(); + if (inputHatchFluids.size() > 0) { + + for (FluidStack fluidStack : inputHatchFluids) { + + final int pushed = mfh.pushFluid(fluidStack, true); + final FluidStack toDeplete = fluidStack.copy(); + toDeplete.amount = pushed; + super.depleteInput(toDeplete); + } + } + + // Push out fluids + if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { + final FluidStack storedFluid = mfh.getFluidCopy(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 { + int tDistinct = mfh.getDistinctFluids(); + int tDistinctCount = 0; + int tMaxDistinct = mfh.getMaxDistinctFluids(); + for(int i = 0; i < tMaxDistinct && tDistinctCount< tDistinct;i++) { + final FluidStack storedFluidCopy = mfh.getFluidCopy(i); + if (storedFluidCopy == null) + continue; + tDistinctCount++; + storedFluidCopy.amount = 0; + // Calculate how much capacity all available Output Hatches offer + for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) { + if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluidCopy.getUnlocalizedName())) { + storedFluidCopy.amount += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + addFluidToHatch(storedFluidCopy,outputHatch); + } else if (outputHatch.getFluid() != null && outputHatch.getFluid().isFluidEqual(storedFluidCopy)) { + storedFluidCopy.amount += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + addFluidToHatch(storedFluidCopy,outputHatch); + } else if (!outputHatch.isFluidLocked() && outputHatch.getFluid() == null) { + storedFluidCopy.amount += outputHatch.getCapacity() - outputHatch.getFluidAmount(); + addFluidToHatch(storedFluidCopy,outputHatch); + } + } + } + } + + return true; + } + + public void addFluidToHatch(FluidStack aFluid, GT_MetaTileEntity_Hatch_Output aHatch) { + aFluid.amount = mfh.pullFluid(aFluid, true); + aHatch.fill(aFluid,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 = MultiFluidHandler.newInstance(25, capacityPerFluid); + } else { + if (mfh.getCapacity() != capacityPerFluid) { + mfh = MultiFluidHandler.newAdjustedInstance(mfh, capacityPerFluid); + } + } + 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) { + doVoidExcess = !doVoidExcess; + GT_Utility.sendChatToPlayer(aPlayer, doVoidExcess ? "Auto-voiding enabled" : "Auto-voiding disabled"); + } + + @Override + public String[] getInfoData() { + final ArrayList<String> ll = mfh.getInfoData(); + + ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); + ll.add("Auto-voiding: " + doVoidExcess); + ll.add("Per-Fluid Capacity: " + mfh.getCapacity() + "L"); + ll.add("Running Cost: " + // mEUt does not naturally reflect efficiency status. Do that here. + + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t"); + ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus()) + ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET + : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET)); + ll.add("---------------------------------------------"); + + final String[] a = new String[ll.size()]; + return ll.toArray(a); + } + + @Override + public void saveNBTData(NBTTagCompound nbt) { + nbt = (nbt == null) ? new NBTTagCompound() : nbt; + + nbt.setInteger("runningCost", runningCost); + nbt.setBoolean("doVoidExcess", doVoidExcess); + + nbt.setInteger("capacityPerFluid", mfh.getCapacity()); + nbt.setTag("fluids", mfh.saveNBTData(new NBTTagCompound())); + + super.saveNBTData(nbt); + } + + @Override + public void loadNBTData(NBTTagCompound nbt) { + nbt = (nbt == null) ? new NBTTagCompound() : nbt; + + runningCost = nbt.getInteger("runningCost"); + doVoidExcess = nbt.getBoolean("doVoidExcess"); + + mfh = MultiFluidHandler.loadNBTData(nbt); + for (GTMTE_TFFTMultiHatch mh : sMultiHatches) { + mh.setMultiFluidHandler(mfh); + } + super.loadNBTData(nbt); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack var1) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack var1) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack var1) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack var1) { + return false; + } }
\ No newline at end of file diff --git a/src/main/java/common/tileentities/GTMTE_ItemServer.java b/src/main/java/common/tileentities/GTMTE_ItemServer.java deleted file mode 100644 index cfff360ce4..0000000000 --- a/src/main/java/common/tileentities/GTMTE_ItemServer.java +++ /dev/null @@ -1,393 +0,0 @@ -package common.tileentities; - -import java.util.ArrayList; -import java.util.HashSet; - -import org.lwjgl.input.Keyboard; - -import common.Blocks; -import common.blocks.Block_ItemServerDrive; -import common.blocks.Block_ItemServerIOPort; -import common.blocks.Block_ItemServerRackCasing; -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.objects.GT_RenderedTexture; -import kekztech.MultiItemHandler; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; -import util.MultiBlockTooltipBuilder; -import util.Vector3i; -import util.Vector3ic; - -public class GTMTE_ItemServer extends GT_MetaTileEntity_MultiBlockBase { - - private static final int BASE_SEGMENT_ENERGY_COST = 1; - private static final int BASE_PER_ITEM_CAPACITY = 1024; - private static final int BASE_ITEM_TYPES_PER_SEGMENT = 4; - - private final Block_ItemServerDrive DRIVE = (Block_ItemServerDrive) Blocks.itemServerDrive; - private final Block_ItemServerRackCasing CASING = (Block_ItemServerRackCasing) Blocks.itemServerRackCasing; - private final Block_ItemServerIOPort IO_PORT = (Block_ItemServerIOPort) Blocks.itemServerIOPort; - private final String ALU_FRAME_BOX_NAME = "gt.blockmachines"; - private final int ALU_FRAME_BOX_META = 6; - private final int CASING_TEXTURE_ID = 176; - - private MultiItemHandler mih; - private HashSet<TE_ItemServerIOPort> ioPorts = new HashSet<>(); - private int sliceCount = 0; - - public GTMTE_ItemServer(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GTMTE_ItemServer(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { - return new GTMTE_ItemServer(super.mName); - } - - @Override - public String[] getDescription() { - final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); - b.addInfo("[W.I.P - Probably doesn't work]") - .addInfo("High-Tech item storage!") - .addInfo("Variable length: Slices 2-4 can be repeated as long as the total length does not exceed 16 blocks.") - .addInfo("Each segment offers storage for 128 item types") - .addInfo("Storage capacity per item depends on the controller configuration.") - .addInfo("Insert an Integrated Circuit into the controller with your desired configuration.") - .addInfo("The base configuration (0) is 1024 items per type. For each higher level, the capacity quadruples.") - .addInfo("Each slice also adds 1EU/t of power consumption and doubles with rising configuration values.") - .addInfo("Valid config values are from zero to eight.") - .addSeparator() - .beginStructureBlock(3, 5, 4) - .addController("Front Bottom Center") - .addEnergyHatch("Any casing") - .addOtherStructurePart("Front slice", "3x5x1 Item Server Rack Casing") - .addOtherStructurePart("2nd and 3rd slice, center", "1x4x1 Aluminium Frame Box") - .addOtherStructurePart("2nd and 3rd slice, top", "3x1x1 Item Server Rack Casing") - .addOtherStructurePart("2nd and 3rd slice, sides", "2x 1x4x1 Item Server Drive") - .addOtherStructurePart("Back slice", "3x5x1 Item Server Rack Casing") - .signAndFinalize("Kekzdealer"); - if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return b.getInformation(); - } else { - return b.getStructureInformation(); - } - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return aSide == aFacing - ? new ITexture[]{BlockIcons.casingTexturePages[1][48], - new GT_RenderedTexture(aActive - ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE - : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)} - : new ITexture[]{BlockIcons.casingTexturePages[1][48]}; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "MultiblockDisplay.png"); - } - - @Override - public boolean isCorrectMachinePart(ItemStack var1) { - return true; - } - - @Override - public boolean checkRecipe(ItemStack guiSlotItem) { - final int config = (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) - ? Math.min(8, guiSlotItem.getItemDamage()) : 0; - - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - this.mEUt = (int) -(BASE_SEGMENT_ENERGY_COST * sliceCount * Math.pow(2, config)); - super.mMaxProgresstime = 20; - - mih.setPerTypeCapacity((int) (BASE_PER_ITEM_CAPACITY * Math.pow(4, config))); - - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if(mih != null) { - mih.setLock(!super.getBaseMetaTileEntity().isActive()); - } - } - - public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) { - final Vector3i offset = new Vector3i(); - - // either direction on z-axis - if(forgeDirection.x() == 0 && forgeDirection.z() == -1) { - offset.x = x; - offset.y = y; - offset.z = z; - } - if(forgeDirection.x() == 0 && forgeDirection.z() == 1) { - offset.x = -x; - offset.y = y; - offset.z = -z; - } - // either direction on x-axis - if(forgeDirection.x() == -1 && forgeDirection.z() == 0) { - offset.x = z; - offset.y = y; - offset.z = -x; - } - if(forgeDirection.x() == 1 && forgeDirection.z() == 0) { - offset.x = -z; - offset.y = y; - offset.z = x; - } - - return offset; - } - - @Override - public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) { - // Figure out the vector for the direction the back face of the controller is facing - final Vector3ic forgeDirection = new Vector3i( - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX, - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY, - ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ - ); - boolean formationChecklist = true; - - // Front slice - for(int X = -1; X <= 1; X++) { - for(int Y = 0; Y <= 4; Y++) { - if(X == 0 && Y == 0) { - continue; // is controller - } - - // Get next TE - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); - IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - - // Is casing or IO port? - if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Is casing, but there's no casing requirements - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) { - final TE_ItemServerIOPort port = - (TE_ItemServerIOPort) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - ioPorts.add(port); - } else { - formationChecklist = false; - } - } - } - } - - // Check slices - int segmentsFound = 0; - int zOffset = -1; // -1 is the first slice after the front one. It goes in negative direction. - - while(segmentsFound < 5) { - if(checkSegment(thisController, forgeDirection, zOffset)) { - segmentsFound++; - zOffset -= 3; // Each segment is 3 blocks long, so progress Z by -3 - - System.out.println("Item Server segment approved: " + segmentsFound); - } else { - System.out.println("Item Server segment rejected: " + (segmentsFound + 1)); - break; - } - } - - if(segmentsFound < 1) { - System.out.println("At least one slice required for storage"); - formationChecklist = false; - } - - if(this.mEnergyHatches.size() < 1) { - System.out.println("At least one energy hatch is required!"); - formationChecklist = false; - } - - if(this.mMaintenanceHatches.size() < 1) { - System.out.println("You need a maintenance hatch to do maintenance."); - formationChecklist = false; - } - - if(formationChecklist) { - sliceCount = segmentsFound; - - if(mih == null) { - mih = new MultiItemHandler(); - mih.setItemTypeCapacity(segmentsFound * BASE_ITEM_TYPES_PER_SEGMENT); - } - System.out.println("Configuring " + ioPorts.size() + " ports"); - for(TE_ItemServerIOPort port : ioPorts) { - port.setMultiItemHandler(mih); - } - } - - return formationChecklist; - } - - public boolean checkSegment(IGregTechTileEntity thisController, Vector3ic forgeDirection, int zOffset) { - boolean formationChecklist = true; - // Slice by slice - for(int Z = 0; Z >= -2; Z--) { - // Is not back slice - if(Z != -2) { - // Left to right - for(int X = -1; X <= 1; X++) { - // Bottom to top - for(int Y = 0; Y <= 4; Y++) { - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, zOffset + Z); - - // Server rack roof - if(Y == 4) { - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - // Is casing or IO port? - if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Is casing, but there's no casing requirements - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) { - final TE_ItemServerIOPort port = - (TE_ItemServerIOPort) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - ioPorts.add(port); - } else { - formationChecklist = false; - } - } - } - - // Middle wall is aluminium frame boxes - else if(Y <= 3 && X == 0) { - if(!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(ALU_FRAME_BOX_NAME)) - || !(thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == ALU_FRAME_BOX_META)) { - formationChecklist = false; - } - } - - // Side walls are item server drives - else if(Y <= 3 && X != 0) { - if(!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == DRIVE)) { - formationChecklist = false; - } - } - } - } - } else { - // Back slice - for(int X = -1; X <= 1; X++) { - for(int Y = 0; Y <= 4; Y++) { - - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, zOffset + Z); - IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); - - if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) - && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - // Is casing or IO port? - if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) { - // Is casing, but there's no casing requirements - } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) { - final TE_ItemServerIOPort port = - (TE_ItemServerIOPort) thisController.getWorld().getTileEntity( - thisController.getXCoord() + offset.x(), - thisController.getYCoord() + offset.y(), - thisController.getZCoord() + offset.z()); - ioPorts.add(port); - } else { - formationChecklist = false; - } - } - } - } - } - } - - - return formationChecklist; - } - - @Override - public String[] getInfoData() { - final ArrayList<String> ll = new ArrayList<>();//mfh.getInfoData(); - - ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); - ll.add("Per-Item Capacity: " + mih.getPerTypeCapacity()); - ll.add("Item-Type Capacity: " + BASE_ITEM_TYPES_PER_SEGMENT * sliceCount); - ll.add("Running Cost: " - // mEUt does not naturally reflect efficiency status. Do that here. - + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t"); - ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus()) - ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET - : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET)); - ll.add("---------------------------------------------"); - - final String[] a = new String[ll.size()]; - return ll.toArray(a); - } - - @Override - public void saveNBTData(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - super.saveNBTData(nbt); - } - - @Override - public void loadNBTData(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - super.loadNBTData(nbt); - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack var1) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack var1) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack var1) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack var1) { - return false; - } -} diff --git a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java index fc743a56d3..b3d2c9fea3 100644 --- a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java +++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java @@ -11,11 +11,12 @@ 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; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -23,7 +24,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.input.Keyboard; -import util.MultiBlockTooltipBuilder; import util.Vector3i; import util.Vector3ic; @@ -51,14 +51,17 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock private final Set<GT_MetaTileEntity_Hatch_EnergyTunnel> mEnergyTunnelsTT = new HashSet<>(); private final Set<GT_MetaTileEntity_Hatch_DynamoTunnel> mDynamoTunnelsTT = new HashSet<>(); // Count the amount of capacitors of each tier in each slot (translate with meta - 1) - private final int[] capacitors = new int[5]; + private final int[] capacitors = new int[7]; private BigInteger capacity = BigInteger.ZERO; private BigInteger stored = BigInteger.ZERO; private BigInteger passiveDischargeAmount = BigInteger.ZERO; - private BigInteger intputLastTick = BigInteger.ZERO; + private BigInteger inputLastTick = BigInteger.ZERO; private BigInteger outputLastTick = BigInteger.ZERO; private int repairStatusCache = 0; + private long mMaxEUIn = 0; + private long mMaxEUOut = 0; + public GTMTE_LapotronicSuperCapacitor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -74,29 +77,34 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock @Override public String[] getDescription() { - final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); - b.addInfo("Power storage structure!") - .addInfo("Looses energy equal to 1% of the total capacity every 24 hours.") - .addInfo("EXCEPTION: Ultimate Capacitors only count as Lapotronic Capacitors (UV) for the") - .addInfo("purpose of passive loss calculation. The full capacity is counted towards the actual power capacity.") - .addSeparator() - .addInfo("Glass shell has to be Tier - 2 of the highest capacitor tier") - .addInfo("UV-Tier glass required for TecTech Laser Hatches") - .addInfo("Modular height of 4 to 18 blocks.") - .addSeparator() - .beginStructureBlock(5, 4, 5) - .addController("Front Bottom Center") - .addDynamoHatch("Instead of any casing") - .addEnergyHatch("Instead of any casing") - .addOtherStructurePart("Lapotronic Capacitor Base", "5x2x5 base (at least 17x)") - .addOtherStructurePart("Lapotronic Capacitor, (Really) Ultimate Capacitor", "Center 3x(1-15)x3 above base (9-135 blocks)") - .addOtherStructurePart("Borosilicate Glass", "41-265x, Encase capacitor pillar") - .addMaintenanceHatch("Instead of any casing") - .signAndFinalize("Kekzdealer"); + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Battery Buffer") + .addInfo("Power storage structure. Does not charge batteries or tools, however.") + .addInfo("Loses energy equal to 1% of the total capacity every 24 hours.") + .addInfo("Exception: Ultimate Capacitors only count as Lapotronic Capacitors (UV) for the") + .addInfo("purposes of passive loss calculation. The full capacity is counted towards the actual power capacity.") + .addSeparator() + .addInfo("Glass shell has to be Tier - 2 of the highest capacitor tier") + .addInfo("UV-tier glass required for TecTech Laser Hatches") + .addInfo("Add more or better capacitors to increase capacity") + .addSeparator() + .beginStructureBlock(5, 4, 5, false) + .addStructureInfo("Modular height of 4-18 blocks.") + .addController("Front center bottom") + .addOtherStructurePart("Lapotronic Super Capacitor Casing", "5x2x5 base (at least 17x)") + .addOtherStructurePart("Lapotronic Capacitor (EV-UV), Ultimate Capacitor (UHV)", "Center 3x(1-15)x3 above base (9-135 blocks)") + .addStructureInfo("You can also use the Empty Capacitor to save materials if you use it for less than half the blocks") + .addOtherStructurePart("Borosilicate Glass (any)", "41-265x, Encase capacitor pillar") + .addEnergyHatch("Any casing") + .addDynamoHatch("Any casing") + .addOtherStructurePart("Laser Target/Source Hatches", "Any casing, must be using UV-tier glass") + .addStructureInfo("You can have several I/O Hatches") + .addMaintenanceHatch("Any casing") + .toolTipFinisher("KekzTech"); if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return b.getInformation(); + return tt.getInformation(); } else { - return b.getStructureInformation(); + return tt.getStructureInformation(); } } @@ -184,6 +192,9 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock mDynamoHatchesTT.clear(); mEnergyTunnelsTT.clear(); mDynamoTunnelsTT.clear(); + + mMaxEUIn = 0; + mMaxEUOut = 0; // Temp var for loss calculation BigInteger tempCapacity = BigInteger.ZERO; @@ -196,8 +207,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock } final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z); - final IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + final IGregTechTileEntity currentTE = thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); // 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 @@ -229,14 +239,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock final int meta = thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()); if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == LSC_PART && (meta > 0)) { // Add capacity - if(meta <= 4){ - final long c = (long) (100000000L * Math.pow(10, meta - 1)); - tempCapacity = tempCapacity.add(BigInteger.valueOf(c)); - capacity = capacity.add(BigInteger.valueOf(c)); - } else if(meta <= 5){ - tempCapacity = tempCapacity.add(BigInteger.valueOf((long) (100000000L * Math.pow(10, 3)))); - capacity = capacity.add(MAX_LONG); - } + tempCapacity = calculateTempCapacity(tempCapacity, meta); capacitors[meta - 1]++; } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameBorosilicate)){ firstGlassHeight = Y; @@ -281,7 +284,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock } } - if(minCasingAmount > 0){ + if(minCasingAmount > 0) { formationChecklist = false; } @@ -290,11 +293,8 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock // Borosilicate glass after 5 are just recolours of 0 final int colourCorrectedMeta = firstGlassMeta > 5 ? 0 : firstGlassMeta; for(int highestCapacitor = capacitors.length - 1; highestCapacitor >= 0; highestCapacitor--){ - if(capacitors[highestCapacitor] > 0){ - if(colourCorrectedMeta < highestCapacitor){ - formationChecklist = false; - } - break; + if(capacitors[highestCapacitor] > 0 && formationChecklist == true) { + formationChecklist = checkGlassTier(colourCorrectedMeta, highestCapacitor); } } @@ -305,44 +305,115 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock } mEnergyTunnelsTT.clear(); mDynamoTunnelsTT.clear(); - } + //Check if enough (more than 50%) non-empty caps + double emptyCheck = ((double) capacitors[5]) / (double) (capacitors[0] + capacitors[1] + capacitors[2] + capacitors[3] + capacitors[4] + capacitors[6]); + if (emptyCheck > 0.5) + formationChecklist = false; + // Calculate total capacity - capacity = BigInteger.ZERO; - for(int i = 0; i < capacitors.length; i++){ - if(i <= 3){ - final long c = (long) (100000000L * Math.pow(10, i)); - capacity = capacity.add( - BigInteger.valueOf(c).multiply(BigInteger.valueOf(capacitors[i]))); - } else { - capacity = capacity.add( - MAX_LONG.multiply(BigInteger.valueOf(capacitors[i]))); - } - } + calculateCapacity(); + // Calculate how much energy to void each tick passiveDischargeAmount = new BigDecimal(tempCapacity).multiply(PASSIVE_DISCHARGE_FACTOR_PER_TICK).toBigInteger(); passiveDischargeAmount = recalculateLossWithMaintenance(super.getRepairStatus()); return formationChecklist; } + public BigInteger calculateTempCapacity(BigInteger tempCapacity, int meta) { + switch(meta) { + case 1: tempCapacity = tempCapacity.add(BigInteger.valueOf(100000000L)); capacity = capacity.add(BigInteger.valueOf(100000000L)); break; + case 2: tempCapacity = tempCapacity.add(BigInteger.valueOf(1000000000L)); capacity = capacity.add(BigInteger.valueOf(1000000000L)); break; + case 3: tempCapacity = tempCapacity.add(BigInteger.valueOf(10000000000L)); capacity = capacity.add(BigInteger.valueOf(10000000000L)); break; + case 4: tempCapacity = tempCapacity.add(BigInteger.valueOf(100000000000L)); capacity = capacity.add(BigInteger.valueOf(100000000000L)); break; + case 5: tempCapacity = tempCapacity.add(BigInteger.valueOf(100000000000L)); capacity = capacity.add(MAX_LONG); break; + case 6: break; + case 7: tempCapacity = tempCapacity.add(BigInteger.valueOf(10000000L)); capacity = capacity.add(BigInteger.valueOf(10000000L)); break; + default: break; + } + return tempCapacity; + } + + public boolean checkGlassTier(int colourCorrectedMeta, int highestCapacitor) { + Boolean check = true; + switch (highestCapacitor) { + case 0://For the empty/EV/IV caps, any BS glass works. The case is meta - 1 + break; + case 1: + if(colourCorrectedMeta < highestCapacitor) { + check = false; + } + break; + case 2: + if(colourCorrectedMeta < highestCapacitor) { + check = false; + } + break; + case 3: + if(colourCorrectedMeta < highestCapacitor) { + check = false; + } + break; + case 4: + if(colourCorrectedMeta < highestCapacitor) { + check = false; + } + break; + case 5: + break; + case 6: + break; + default: + check = false; + } + return check; //Return false if it fails the check, otherwise true + } + + public void calculateCapacity() { + capacity = BigInteger.ZERO; + for(int i = 0; i < capacitors.length; i++) { + switch(i) { + case 0: capacity = capacity.add(BigInteger.valueOf(100000000L).multiply(BigInteger.valueOf(capacitors[i]))); break; + case 1: capacity = capacity.add(BigInteger.valueOf(1000000000L).multiply(BigInteger.valueOf(capacitors[i]))); break; + case 2: capacity = capacity.add(BigInteger.valueOf(10000000000L).multiply(BigInteger.valueOf(capacitors[i]))); break; + case 3: capacity = capacity.add(BigInteger.valueOf(100000000000L).multiply(BigInteger.valueOf(capacitors[i]))); break; + case 4: capacity = capacity.add(MAX_LONG.multiply(BigInteger.valueOf(capacitors[i]))); break; + case 5: break; + case 6: capacity = capacity.add(BigInteger.valueOf(10000000L).multiply(BigInteger.valueOf(capacitors[i]))); break; + default: break; + } + } + } + @Override public boolean addEnergyInputToMachineList(IGregTechTileEntity te, int aBaseCasingIndex) { if (te == null) { return false; } else { final IMetaTileEntity mte = te.getMetaTileEntity(); + + if (mte instanceof MetaTileEntity) { + mMaxEUIn += ((MetaTileEntity) mte).maxEUInput() * ((MetaTileEntity) mte).maxAmperesIn(); + } + if (mte instanceof GT_MetaTileEntity_Hatch_Energy) { // Add GT hatches - ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex); - return super.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) mte); + final GT_MetaTileEntity_Hatch_Energy tHatch = ((GT_MetaTileEntity_Hatch_Energy) mte); + tHatch.updateTexture(aBaseCasingIndex); + + return super.mEnergyHatches.add(tHatch); } else if(mte instanceof GT_MetaTileEntity_Hatch_EnergyTunnel) { // Add TT Laser hatches + final GT_MetaTileEntity_Hatch_EnergyTunnel tHatch = ((GT_MetaTileEntity_Hatch_EnergyTunnel) mte); + return mEnergyTunnelsTT.add((GT_MetaTileEntity_Hatch_EnergyTunnel) mte); } else if(mte instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { // Add TT hatches - ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex); - return mEnergyHatchesTT.add((GT_MetaTileEntity_Hatch_EnergyMulti) mte); + final GT_MetaTileEntity_Hatch_EnergyMulti tHatch = (GT_MetaTileEntity_Hatch_EnergyMulti) mte; + tHatch.updateTexture(aBaseCasingIndex); + + return mEnergyHatchesTT.add(tHatch); } else { return false; } @@ -355,17 +426,28 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock return false; } else { final IMetaTileEntity mte = te.getMetaTileEntity(); + + if (mte instanceof MetaTileEntity) { + mMaxEUOut += ((MetaTileEntity) mte).maxEUOutput() * ((MetaTileEntity) mte).maxAmperesOut(); + } + if (mte instanceof GT_MetaTileEntity_Hatch_Dynamo) { // Add GT hatches - ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex); - return super.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) mte); + final GT_MetaTileEntity_Hatch_Dynamo tDynamo = (GT_MetaTileEntity_Hatch_Dynamo) mte; + tDynamo.updateTexture(aBaseCasingIndex); + + return super.mDynamoHatches.add(tDynamo); } else if(mte instanceof GT_MetaTileEntity_Hatch_DynamoTunnel) { // Add TT Laser hatches - return mDynamoTunnelsTT.add((GT_MetaTileEntity_Hatch_DynamoTunnel) mte); + final GT_MetaTileEntity_Hatch_DynamoTunnel tDynamo = (GT_MetaTileEntity_Hatch_DynamoTunnel) mte; + + return mDynamoTunnelsTT.add(tDynamo); } else if(mte instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { // Add TT hatches - ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex); - return mDynamoHatchesTT.add((GT_MetaTileEntity_Hatch_DynamoMulti) mte); + final GT_MetaTileEntity_Hatch_DynamoMulti tDynamo = (GT_MetaTileEntity_Hatch_DynamoMulti) mte; + tDynamo.updateTexture(aBaseCasingIndex); + + return mDynamoHatchesTT.add(tDynamo); } else { return false; } @@ -375,9 +457,11 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock @Override public boolean onRunningTick(ItemStack stack){ // Reset I/O cache - intputLastTick = BigInteger.ZERO; + inputLastTick = BigInteger.ZERO; outputLastTick = BigInteger.ZERO; + //System.out.println(getBaseMetaTileEntity().) + // Draw energy from GT hatches for(GT_MetaTileEntity_Hatch_Energy eHatch : super.mEnergyHatches) { if(eHatch == null || eHatch.getBaseMetaTileEntity().isInvalidTileEntity()) { @@ -387,7 +471,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock if(eHatch.getEUVar() >= power) { eHatch.setEUVar(eHatch.getEUVar() - power); stored = stored.add(BigInteger.valueOf(power)); - intputLastTick = intputLastTick.add(BigInteger.valueOf(power)); + inputLastTick = inputLastTick.add(BigInteger.valueOf(power)); } } // Output energy to GT hatches @@ -411,7 +495,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock if(eHatch.getEUVar() >= power) { eHatch.setEUVar(eHatch.getEUVar() - power); stored = stored.add(BigInteger.valueOf(power)); - intputLastTick = intputLastTick.add(BigInteger.valueOf(power)); + inputLastTick = inputLastTick.add(BigInteger.valueOf(power)); } } // Output energy to TT hatches @@ -436,7 +520,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock if(eHatch.getEUVar() >= power) { eHatch.setEUVar(eHatch.getEUVar() - power); stored = stored.add(BigInteger.valueOf(power)); - intputLastTick = intputLastTick.add(BigInteger.valueOf(power)); + inputLastTick = inputLastTick.add(BigInteger.valueOf(power)); } } // Output energy to TT Laser hatches @@ -460,6 +544,11 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock stored = stored.subtract(passiveDischargeAmount); stored = (stored.compareTo(BigInteger.ZERO) <= 0) ? BigInteger.ZERO : stored; + IGregTechTileEntity tBMTE = this.getBaseMetaTileEntity(); + + tBMTE.injectEnergyUnits((byte)ForgeDirection.UNKNOWN.ordinal(), inputLastTick.longValue(), 1L); + tBMTE.drainEnergyUnits((byte)ForgeDirection.UNKNOWN.ordinal(), outputLastTick.longValue(), 1L); + return true; } @@ -500,13 +589,17 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock @Override public String[] getInfoData() { + final IGregTechTileEntity tGTTE = getBaseMetaTileEntity(); + final ArrayList<String> ll = new ArrayList<>(); ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); ll.add("Used Capacity: " + NumberFormat.getNumberInstance().format(stored) + "EU"); ll.add("Total Capacity: " + NumberFormat.getNumberInstance().format(capacity) + "EU"); ll.add("Passive Loss: " + NumberFormat.getNumberInstance().format(passiveDischargeAmount) + "EU/t"); - ll.add("EU IN: " + NumberFormat.getNumberInstance().format(intputLastTick) + "EU/t"); + ll.add("EU IN: " + NumberFormat.getNumberInstance().format(inputLastTick) + "EU/t"); ll.add("EU OUT: " + NumberFormat.getNumberInstance().format(outputLastTick) + "EU/t"); + ll.add("Avg EU IN: " + NumberFormat.getNumberInstance().format(tGTTE.getAverageElectricInput())); + ll.add("Avg EU OUT: " + NumberFormat.getNumberInstance().format(tGTTE.getAverageElectricOutput())); ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus()) ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET)); @@ -554,5 +647,57 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock @Override public boolean explodesOnComponentBreak(ItemStack stack) { return false; } - + + //called by the getEUCapacity() function in BaseMetaTileEntity + @Override + public long maxEUStore() + { + return capacity.longValue(); + } + + //called by the getEUStored() function in BaseMetaTileEntity + @Override + public long getEUVar() + { + return stored.longValue(); + } + + /* all of these are needed for the injectEnergyUnits() and drainEnergyUnits() + in IGregTechTileEntity + */ + @Override + public long maxEUInput() + { + return mMaxEUIn; + } + + @Override + public long maxAmperesIn() + { + return 1L; + } + + @Override + public long maxEUOutput() + { + return mMaxEUOut; + } + + @Override + public long maxAmperesOut() + { + return 1L; + } + + @Override + public boolean isEnetInput() + { + return true; + } + + @Override + public boolean isEnetOutput() + { + return true; + } } diff --git a/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java b/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java index 5e0b86ed69..ec720b9354 100644 --- a/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java +++ b/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java @@ -16,7 +16,6 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
-import util.MultiBlockTooltipBuilder;
public class GTMTE_ModularNuclearReactor extends GT_MetaTileEntity_MultiBlockBase {
@@ -47,6 +46,8 @@ public class GTMTE_ModularNuclearReactor extends GT_MetaTileEntity_MultiBlockBas @Override
public String[] getDescription() {
+ return new String[]{"Disabled"};
+ /*
final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
b.addInfo("Can be built, BUT DOES NOT WORK")
.addInfo("Converts fissile material and outputs power or heat")
@@ -75,18 +76,18 @@ public class GTMTE_ModularNuclearReactor extends GT_MetaTileEntity_MultiBlockBas return b.getInformation();
} else {
return b.getStructureInformation();
- }
+ }*/
}
@Override
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
return aSide == aFacing
- ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID],
+ ? new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID),
new GT_RenderedTexture(aActive ?
Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE
: Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)}
- : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]};
+ : new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)};
}
// TODO: Opening UI crashes server. Controller isn't craftable right now.
diff --git a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java index 76536f0e50..0bc05927aa 100644 --- a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java +++ b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java @@ -17,6 +17,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
@@ -25,7 +26,6 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
-import util.MultiBlockTooltipBuilder;
import util.Vector3i;
import util.Vector3ic;
@@ -56,26 +56,29 @@ public class GTMTE_SOFuelCellMK1 extends GT_MetaTileEntity_MultiBlockBase { @Override
public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
- .addInfo("Consumes 29,480EU worth of fuel with up to 97% efficiency each second")
- .addInfo("Steam production requires the SOFC to heat up completely first")
- .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
- .addInfo("Additionally requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
- .addSeparator()
- .beginStructureBlock(3, 3, 5)
- .addController("Front Center")
- .addDynamoHatch("Back Center")
- .addOtherStructurePart("YSZ Ceramic Electrolyte Unit", "3x, Center 1x1x3")
- .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
- .addCasingInfo("Clean Stainless Steel Casing", 12)
- .addMaintenanceHatch("Instead of any casing")
- .addIOHatches("Instead of any casing")
- .signAndFinalize("Kekzdealer");
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Gas Turbine")
+ .addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
+ .addInfo("Consumes 29,480EU worth of fuel with up to 97% efficiency each second")
+ .addInfo("Steam production requires the SOFC to heat up completely first")
+ .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
+ .addInfo("Additionally, requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
+ .addSeparator()
+ .beginStructureBlock(3, 3, 5, false)
+ .addController("Front center")
+ .addCasingInfo("Clean Stainless Steel Casing", 12)
+ .addOtherStructurePart("YSZ Ceramic Electrolyte Unit", "3x, Center 1x1x3")
+ .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
+ .addDynamoHatch("Back center")
+ .addMaintenanceHatch("Any casing")
+ .addInputHatch("Fuel, any casing")
+ .addInputHatch("Oxygen, any casing")
+ .addOutputHatch("Steam, any casing")
+ .toolTipFinisher("KekzTech");
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
+ return tt.getInformation();
} else {
- return b.getStructureInformation();
+ return tt.getStructureInformation();
}
}
@@ -83,11 +86,11 @@ public class GTMTE_SOFuelCellMK1 extends GT_MetaTileEntity_MultiBlockBase { public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
return aSide == aFacing
- ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID],
+ ? new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID),
new GT_RenderedTexture(aActive ?
Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE
: Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)}
- : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]};
+ : new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
diff --git a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java index fb3fb7e9c7..a015887350 100644 --- a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java +++ b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java @@ -16,6 +16,7 @@ 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 gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
@@ -25,7 +26,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
-import util.MultiBlockTooltipBuilder;
+
import util.Vector3i;
import util.Vector3ic;
@@ -56,26 +57,29 @@ public class GTMTE_SOFuelCellMK2 extends GT_MetaTileEntity_MultiBlockBase { @Override
public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
- .addInfo("Consumes 442,200EU worth of fuel with up to 97% efficiency each second")
- .addInfo("Steam production requires the SOFC to heat up completely first")
- .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
- .addInfo("Additionally requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
- .addSeparator()
- .beginStructureBlock(3, 3, 5)
- .addController("Front Center")
- .addDynamoHatch("Back Center")
- .addOtherStructurePart("GDC Ceramic Electrolyte Unit", "3x, Center 1x1x3")
- .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
- .addCasingInfo("Robust Tungstensteel Machine Casing", 12)
- .addMaintenanceHatch("Instead of any casing")
- .addIOHatches("Instead of any casing")
- .signAndFinalize("Kekzdealer");
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Gas Turbine")
+ .addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
+ .addInfo("Consumes 442,200EU worth of fuel with up to 97% efficiency each second")
+ .addInfo("Steam production requires the SOFC to heat up completely first")
+ .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
+ .addInfo("Additionally, requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
+ .addSeparator()
+ .beginStructureBlock(3, 3, 5, false)
+ .addController("Front center")
+ .addCasingInfo("Robust Tungstensteel Machine Casing", 12)
+ .addOtherStructurePart("GDC Ceramic Electrolyte Unit", "3x, Center 1x1x3")
+ .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
+ .addDynamoHatch("Back center")
+ .addMaintenanceHatch("Any casing")
+ .addInputHatch("Fuel, any casing")
+ .addInputHatch("Oxygen, any casing")
+ .addOutputHatch("Superheated Steam, any casing")
+ .toolTipFinisher("KekzTech");
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
+ return tt.getInformation();
} else {
- return b.getStructureInformation();
+ return tt.getStructureInformation();
}
}
@@ -83,11 +87,11 @@ public class GTMTE_SOFuelCellMK2 extends GT_MetaTileEntity_MultiBlockBase { public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
return aSide == aFacing
- ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID],
+ ? new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID),
new GT_RenderedTexture(aActive ?
Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE
: Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)}
- : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]};
+ : new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
diff --git a/src/main/java/common/tileentities/GTMTE_SpaceElevator.java b/src/main/java/common/tileentities/GTMTE_SpaceElevator.java index 8f7827f4be..3469528f78 100644 --- a/src/main/java/common/tileentities/GTMTE_SpaceElevator.java +++ b/src/main/java/common/tileentities/GTMTE_SpaceElevator.java @@ -12,12 +12,10 @@ import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.input.Keyboard; -import util.MultiBlockTooltipBuilder; import util.Vector3i; import util.Vector3ic; @@ -58,6 +56,8 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase { @Override public String[] getDescription() { + return new String[]{"Disabled"}; + /* final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder(); b.addInfo("Access for your Space Station!") .addInfo("Check out the wiki on my github if you are having trouble with the structure") @@ -78,7 +78,7 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase { return b.getInformation(); } else { return b.getStructureInformation(); - } + }*/ } @Override @@ -140,6 +140,7 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase { boolean formationChecklist = true; int minCasingAmount = 320; int firstCoilMeta = -1; + capacitors.clear(); // Base floor for(int X = -7; X <= 7; X++){ @@ -215,6 +216,10 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase { formationChecklist = false; } + for(TE_SpaceElevatorCapacitor cap : capacitors){ + cap.setIsDamaged(false); + } + return formationChecklist; } @@ -233,20 +238,6 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase { } @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; } 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..fc2579604a --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java @@ -0,0 +1,217 @@ +package common.tileentities; + +import client.GTTexture; +import gregtech.api.enums.Textures; +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_Utility; +import kekztech.MultiFluidHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +import java.util.HashMap; + +public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { + + private static final HashMap<Integer, Integer> vals = new HashMap<>(); + static { + vals.put(3, 2000); + vals.put(5, 20000); + vals.put(7, 200000); + } + private static final int INV_SLOT_COUNT = 2; + + private MultiFluidHandler mfh; + private boolean outputting = false; + + public GTMTE_TFFTMultiHatch(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, INV_SLOT_COUNT, new String[] { + "All-in-one access for the T.F.F.T", + "Right-click with a screwdriver to toggle auto-output", + "Throughput: " + vals.get(aTier) + "L/s per fluid"} + ); + } + + public GTMTE_TFFTMultiHatch(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, INV_SLOT_COUNT, aDescription, aTextures); + } + + public GTMTE_TFFTMultiHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, INV_SLOT_COUNT, aDescription, aTextures); + } + + public void setMultiFluidHandler(MultiFluidHandler mfh) { + this.mfh = mfh; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("outputting", outputting); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + outputting = aNBT.getBoolean("outputting"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + //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(Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE)}; + } + + @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 void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + outputting = !outputting; + GT_Utility.sendChatToPlayer(aPlayer, outputting ? "Auto-output enabled" : "Auto-output disabled"); + } + + @Override + public int getCapacity() { + return (mfh != null) ? mfh.getCapacity() : 0; + } + + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && mfh != null) { + if(outputting && (aTick % 20 == 0)) { + doAutoOutputPerSecond(aBaseMetaTileEntity); + } + } + } + + /** + * Handle the Multi Hatch's auto-output feature. Should be called once per second only. + * @param aBaseMetaTileEntity + * this MetaTileEntity + */ + private void doAutoOutputPerSecond(IGregTechTileEntity aBaseMetaTileEntity) { + final ForgeDirection outSide = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()); + final TileEntity adjacentTE = aBaseMetaTileEntity.getTileEntityOffset(outSide.offsetX, outSide.offsetY, outSide.offsetZ); + if(adjacentTE instanceof IFluidHandler) { + final IFluidHandler adjFH = (IFluidHandler) adjacentTE; + // Cycle through fluids + for(int i = 0; i < mfh.getDistinctFluids(); i++) { + final FluidStack fluidCopy = mfh.getFluidCopy(i); + // Make sure the adjacent IFluidHandler can accept this fluid + if(adjFH.canFill(outSide.getOpposite(), fluidCopy.getFluid())) { + + // Limit to output rate + fluidCopy.amount = Math.min(fluidCopy.amount, vals.get(super.mTier)); + + // Test how much can be drawn + fluidCopy.amount = mfh.pullFluid(fluidCopy, false); + + // Test how much can be filled (and fill if possible) + fluidCopy.amount = adjFH.fill(outSide.getOpposite(), fluidCopy, true); + + // Actually deplete storage + mfh.pullFluid(fluidCopy, true); + } + } + + } + } + + @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.getFluidCopy(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 FluidTankInfo[] getTankInfo(ForgeDirection from) { + if (mfh == null) + return null; + FluidStack[] fluids = mfh.getAllFluids(); + int length = fluids.length; + int maxCapcity = mfh.getCapacity(); + FluidTankInfo[] tankInfo = new FluidTankInfo[length]; + for (int i = 0; i < length; i++) { + tankInfo[i] = new FluidTankInfo(fluids[i],maxCapcity); + } + return tankInfo; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + 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/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 c4f9451478..de274bb15e 100644 --- a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java @@ -1,11 +1,6 @@ package common.tileentities; -import java.util.Iterator; -import java.util.List; - -import common.Blocks; import kekztech.MultiFluidHandler; -import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -14,14 +9,26 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; +@Deprecated public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { - private static final int OUTPUT_PER_SECOND = 1000; // L/s - + public static final int BASE_OUTPUT_PER_SECOND = 2000; // L/s + + private byte facings = 0x0; + private MultiFluidHandler mfh; private int tickCounter = 0; private boolean autoOutput = false; - + + public boolean hasFacingOnSide(byte side) { + final byte key = (byte) Math.pow(0x2, side); + return (facings & key) == key; + } + + public void setFacingToSide(byte side) { + facings = (byte) Math.pow(0x2, side); + } + public void setMultiFluidHandler(MultiFluidHandler mfh) { this.mfh = mfh; } @@ -36,90 +43,19 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { @Override public void updateEntity() { - if(!autoOutput || mfh == null) { - return; - } - - tickCounter++; - if(tickCounter >= 20) { - - final ForgeDirection d = getOutwardsFacingDirection(); - if(d == ForgeDirection.UNKNOWN) { - return; - } - final TileEntity t = this.getWorldObj().getTileEntity( - this.xCoord + d.offsetX, - this.yCoord + d.offsetY, - this.zCoord + d.offsetZ); - - if(t instanceof IFluidHandler) { - - final IFluidHandler fh = (IFluidHandler) t; - - // Cycle through fluids - final Iterator<FluidStack> volumes = mfh.getFluids().iterator(); - while(volumes.hasNext()) { - final FluidStack volume = volumes.next(); - - // Remember for later - final int oVolume = volume.amount; - - // Use API methods - if(fh.canFill(d.getOpposite(), volume.getFluid())) { - - // Test how much can be output - final FluidStack copy = volume.copy(); - copy.amount = Math.min(copy.amount, OUTPUT_PER_SECOND); - - // How much is drawn - copy.amount = mfh.pullFluid(copy, false); - - // Test how much can be filled (and fill if possible) - copy.amount = fh.fill(d.getOpposite(), copy, true); - - // Actually deplete storage - mfh.pullFluid(copy, true); - - // Prevent ConcurrentModificationException - if(copy.amount >= oVolume) { - break; - } - } - } - } - - tickCounter = 0; - } - } - - private ForgeDirection getOutwardsFacingDirection() { - // TODO Revisit this once the hatch has a facing side - // Look up which side has the storage field block and choose the other side. - // This is important so the tank doesn't output into itself in case - // there is another hatch next to this one. - for(ForgeDirection direction : ForgeDirection.values()) { - - final Block b = this.getWorldObj().getBlock(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ); - if(b != null && ( - b.equals(Blocks.tfftStorageField1) - || b.equals(Blocks.tfftStorageField2) - || b.equals(Blocks.tfftStorageField3) - || b.equals(Blocks.tfftStorageField4) - || b.equals(Blocks.tfftStorageField5))) { - return direction.getOpposite(); - } - } - return ForgeDirection.UNKNOWN; + // Removed deprecated code } @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - return (mfh != null) ? mfh.pushFluid(resource, doFill) : 0; + // Removed deprecated code + return 0; } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - return (mfh != null) ? new FluidStack(resource.getFluid(), mfh.pullFluid(resource, doDrain)) : null; + // Removed deprecated code + return null; } /** @@ -138,60 +74,40 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { */ @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) - ); - } - } + // Removed deprecated code return null; } @Override public boolean canFill(ForgeDirection from, Fluid fluid) { - return (mfh != null) && mfh.couldPush(new FluidStack(fluid, 1)); + // Removed deprecated code + return false; } @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { - return (mfh != null) && mfh.contains(new FluidStack(fluid, 1)); + // Removed deprecated code + return false; } @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { - if(mfh == null) { - return null; - } - final List<FluidStack> fluids = mfh.getFluids(); - final FluidTankInfo[] tankInfo = new FluidTankInfo[fluids.size()]; - for(int i = 0; i < tankInfo.length; i++) { - tankInfo[i] = new FluidTankInfo(fluids.get(i), mfh.getCapacity()); - } - return tankInfo; + // Removed deprecated code + return null; } @Override public void writeToNBT(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - nbt.setBoolean("autoOutput", autoOutput); - super.writeToNBT(nbt); + nbt.setBoolean("autoOutput", autoOutput); + nbt.setByte("facings", facings); } @Override public void readFromNBT(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - - autoOutput = nbt.getBoolean("autoOutput"); - super.readFromNBT(nbt); + autoOutput = nbt.getBoolean("autoOutput"); + facings = nbt.getByte("facings"); } diff --git a/src/main/java/config/ConfigIO.java b/src/main/java/config/ConfigIO.java deleted file mode 100644 index 4898c9b58d..0000000000 --- a/src/main/java/config/ConfigIO.java +++ /dev/null @@ -1,49 +0,0 @@ -package config; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Properties; - -public class ConfigIO { - - private static final String CONFIG_PATH = "main/java/config/config.properties"; - private static final int CONFIG_SIZE = 0; - - private static Properties config; - - private ConfigIO() { - - } - - public static void load() { - config = new Properties(); - try { - config.load(new FileInputStream(CONFIG_PATH)); - } catch (IOException e) { - throw new IllegalStateException("Failed to load KekzTech config!"); - } - if(config.size() != CONFIG_SIZE) { - throw new IllegalStateException("KekzTech config is not expected size!"); - } - } - - @SuppressWarnings("unchecked") - public <T> T get(String key, T valueType) { - if(config.size() != CONFIG_SIZE) { - throw new IllegalStateException("Tried to access config without loading it first"); - } - return (T) config.get((Object) key); - } - - public static void saveConfig() { - try { - config = (config == null) ? new Properties() : config; - config.setProperty("key", "value"); - config.store(new FileOutputStream(CONFIG_PATH), "Welcome to KekzTech's config file :)"); - } catch (IOException e) { - System.err.println("Failed to save changes to KekzTech config. Settings may be lost."); - } - } - -} diff --git a/src/main/java/kekztech/Items.java b/src/main/java/kekztech/Items.java index cb79d01947..50e56ced00 100644 --- a/src/main/java/kekztech/Items.java +++ b/src/main/java/kekztech/Items.java @@ -1,94 +1,95 @@ -package kekztech;
-
-import items.MetaItem_CraftingComponent;
-import items.MetaItem_ReactorComponent;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.oredict.OreDictionary;
-import util.Util;
-
-import java.util.Arrays;
-
-public enum Items {
- // Heat Vents
- T1HeatVent(0,0), T2HeatVent(1,0), T3HeatVent(2,0), T4HeatVent(3,0),
- T1ComponentHeatVent(4,0), T2ComponentHeatVent(5,0), T3ComponentHeatVent(6,0), T4ComponentHeatVent(7,0),
- T1OverclockedHeatVent(8,0), T2OverclockedHeatVent(9,0), T3OverclockedHeatVent(10,0), T4OverclockedHeatVent(11,0),
- // Heat Exchanger
- T1HeatExchanger(12,0), T2HeatExchanger(13,0), T3HeatExchanger(14,0), T4HeatExchanger(15,0),
- // Fuel Rods
- UraniumFuelRod(16,0), UraniumDualFuelRod(17,0), UraniumQuadFuelRod(18,0),
- ThoriumFuelRod(19,0), ThoriumDualFuelRod(20,0), ThoriumQuadFuelRod(21,0),
- MOXFuelRod(22,0), MOXDualFuelRod(23,0), MOXQuadFuelRod(24,0),
- NaquadahFuelRod(25,0), NaquadahDualFuelRod(26,0), NaquadahQuadFuelRod(27,0),
- Th_MOXFuelRod(28,0), Th_MOXDualFuelRod(29,0), Th_MOXQuadFuelRod(30,0),
- // Depleted Fuel Rods
- DepletedUraniumFuelRod(31,0), DepletedUraniumDualFuelRod(32,0), DepletedUraniumQuadFuelRod(33,0),
- DepletedThoriumFuelRod(34,0), DepletedThoriumDualFuelRod(35,0), DepletedThoriumQuadFuelRod(36,0),
- DepletedMOXFuelRod(37,0), DepletedMOXDualFuelRod(38,0), DepletedMOXQuadFuelRod(39,0),
- DepletedNaquadahFuelRod(40,0), DepletedNaquadahDualFuelRod(41,0), DepletedNaquadahQuadFuelRod(42,0),
- Th_DepletedMOXFuelRod(43,0), Th_DepletedMOXDualFuelRod(44,0), Th_DepletedMOXQuadFuelRod(45,0),
- // Neutron Reflectors
- T1NeutronReflector(46,0), T2NeutronReflector(47,0),
- // Coolant Cells
- HeliumCoolantCell360k(48,0), NaKCoolantCell360k(49,0),
-
- // Heat Pipes
- CopperHeatPipe(0,1), SilverHeatPipe(1,1), BoronArsenideHeatPipe(2,1), DiamondHeatPipe(3,1),
- BoronArsenideDust(4,1), IsotopicallyPureDiamondDust(5,1), AmineCarbamiteDust(6,1),
- BoronArsenideCrystal(7,1), IsotopicallyPureDiamondCrystal(8,1),
- // Ceramics
- 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
- Configurator(0, 1);
-
- static {
- YttriaDust.setOreDictName("dustYttriumOxide");
- ZirconiaDust.setOreDictName("dustCubicZirconia");
- }
-
- private final int metaID;
- private final int identifier;
-
- private Items(int metaID, int identifier) {
- this.metaID = metaID;
- this.identifier = identifier;
- }
-
- public int getMetaID() {
- return metaID;
- }
-
- String OreDictName;
-
- private void registerOreDict(){
- OreDictionary.registerOre(getOreDictName(),getNonOreDictedItemStack(1));
- }
-
- public static void registerOreDictNames(){
- Arrays.stream(Items.values()).filter(e -> e.getOreDictName() != null).forEach(Items::registerOreDict);
- }
-
- public ItemStack getNonOreDictedItemStack(int amount){
- return identifier == 0 ? new ItemStack(MetaItem_ReactorComponent.getInstance(),amount,this.getMetaID()) :
- new ItemStack(MetaItem_CraftingComponent.getInstance(),amount,this.getMetaID());
- }
-
- public ItemStack getOreDictedItemStack(int amount){
- return this.getOreDictName() != null ? Util.getStackofAmountFromOreDict(this.getOreDictName(),amount) :
- identifier == 0 ? new ItemStack(MetaItem_ReactorComponent.getInstance(),amount,this.getMetaID()) :
- new ItemStack(MetaItem_CraftingComponent.getInstance(),amount,this.getMetaID());
- }
-
- public String getOreDictName() {
- return OreDictName;
- }
-
- public void setOreDictName(String oreDictName) {
- OreDictName = oreDictName;
- }
-}
+package kekztech; + +import common.items.MetaItem_CraftingComponent; +import common.items.MetaItem_ReactorComponent; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import util.Util; + +import java.util.Arrays; + +public enum Items { + /* + // Heat Vents + T1HeatVent(0,0), T2HeatVent(1,0), T3HeatVent(2,0), T4HeatVent(3,0), + T1ComponentHeatVent(4,0), T2ComponentHeatVent(5,0), T3ComponentHeatVent(6,0), T4ComponentHeatVent(7,0), + T1OverclockedHeatVent(8,0), T2OverclockedHeatVent(9,0), T3OverclockedHeatVent(10,0), T4OverclockedHeatVent(11,0), + // Heat Exchanger + T1HeatExchanger(12,0), T2HeatExchanger(13,0), T3HeatExchanger(14,0), T4HeatExchanger(15,0), + // Fuel Rods + UraniumFuelRod(16,0), UraniumDualFuelRod(17,0), UraniumQuadFuelRod(18,0), + ThoriumFuelRod(19,0), ThoriumDualFuelRod(20,0), ThoriumQuadFuelRod(21,0), + MOXFuelRod(22,0), MOXDualFuelRod(23,0), MOXQuadFuelRod(24,0), + NaquadahFuelRod(25,0), NaquadahDualFuelRod(26,0), NaquadahQuadFuelRod(27,0), + Th_MOXFuelRod(28,0), Th_MOXDualFuelRod(29,0), Th_MOXQuadFuelRod(30,0), + // Depleted Fuel Rods + DepletedUraniumFuelRod(31,0), DepletedUraniumDualFuelRod(32,0), DepletedUraniumQuadFuelRod(33,0), + DepletedThoriumFuelRod(34,0), DepletedThoriumDualFuelRod(35,0), DepletedThoriumQuadFuelRod(36,0), + DepletedMOXFuelRod(37,0), DepletedMOXDualFuelRod(38,0), DepletedMOXQuadFuelRod(39,0), + DepletedNaquadahFuelRod(40,0), DepletedNaquadahDualFuelRod(41,0), DepletedNaquadahQuadFuelRod(42,0), + Th_DepletedMOXFuelRod(43,0), Th_DepletedMOXDualFuelRod(44,0), Th_DepletedMOXQuadFuelRod(45,0), + // Neutron Reflectors + T1NeutronReflector(46,0), T2NeutronReflector(47,0), + // Coolant Cells + HeliumCoolantCell360k(48,0), NaKCoolantCell360k(49,0), + + // Heat Pipes + CopperHeatPipe(0,1), SilverHeatPipe(1,1), BoronArsenideHeatPipe(2,1), DiamondHeatPipe(3,1), + BoronArsenideDust(4,1), IsotopicallyPureDiamondDust(5,1), AmineCarbamiteDust(6,1), + BoronArsenideCrystal(7,1), IsotopicallyPureDiamondCrystal(8,1), + */ + // Ceramics + YSZCeramicDust(9,1), GDCCeramicDust(10,1), + YttriaDust(11,1), ZirconiaDust(12,1), CeriaDust(13,1), + YSZCeramicPlate(14,1), GDCCeramicPlate(15,1), + // Error Item + Error(0,1), + // Configurator + Configurator(0, 1); + + static { + YttriaDust.setOreDictName("dustYttriumOxide"); + ZirconiaDust.setOreDictName("dustCubicZirconia"); + } + + private final int metaID; + private final int identifier; + + Items(int metaID, int identifier) { + this.metaID = metaID; + this.identifier = identifier; + } + + public int getMetaID() { + return metaID; + } + + String OreDictName; + + private void registerOreDict(){ + OreDictionary.registerOre(getOreDictName(),getNonOreDictedItemStack(1)); + } + + public static void registerOreDictNames(){ + Arrays.stream(Items.values()).filter(e -> e.getOreDictName() != null).forEach(Items::registerOreDict); + } + + public ItemStack getNonOreDictedItemStack(int amount){ + return identifier == 0 ? new ItemStack(MetaItem_ReactorComponent.getInstance(),amount,this.getMetaID()) : + new ItemStack(MetaItem_CraftingComponent.getInstance(),amount,this.getMetaID()); + } + + public ItemStack getOreDictedItemStack(int amount){ + return this.getOreDictName() != null ? Util.getStackofAmountFromOreDict(this.getOreDictName(),amount) : + identifier == 0 ? new ItemStack(MetaItem_ReactorComponent.getInstance(),amount,this.getMetaID()) : + new ItemStack(MetaItem_CraftingComponent.getInstance(),amount,this.getMetaID()); + } + + public String getOreDictName() { + return OreDictName; + } + + public void setOreDictName(String oreDictName) { + OreDictName = oreDictName; + } +} diff --git a/src/main/java/kekztech/KekzCore.java b/src/main/java/kekztech/KekzCore.java index 7574c1f399..1aed8315ce 100644 --- a/src/main/java/kekztech/KekzCore.java +++ b/src/main/java/kekztech/KekzCore.java @@ -1,105 +1,68 @@ -package kekztech;
-
-import client.renderer.TESR_SECapacitor;
-import client.renderer.TESR_SETether;
-import common.Blocks;
-import common.Recipes;
-import common.Researches;
-import common.tileentities.*;
-import cpw.mods.fml.client.registry.ClientRegistry;
-import cpw.mods.fml.common.Mod;
-import cpw.mods.fml.common.event.FMLInitializationEvent;
-import cpw.mods.fml.common.event.FMLPostInitializationEvent;
-import cpw.mods.fml.common.event.FMLPreInitializationEvent;
-import cpw.mods.fml.common.network.NetworkRegistry;
-import cpw.mods.fml.common.registry.GameRegistry;
-import items.ErrorItem;
-import items.MetaItem_CraftingComponent;
-import items.MetaItem_ReactorComponent;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- * My GT-Meta-IDs are: 13101 - 13500
- *
- * @author kekzdealer
- *
- */
-@Mod(modid = KekzCore.MODID, name = KekzCore.NAME, version = KekzCore.VERSION,
- dependencies =
- "required-after:IC2;"
- + "required-after:gregtech;"
- + "required-after:tectech;"
- + "required-after:Thaumcraft;"
- + "required-after:ThaumicTinkerer;"
- + "after:bartworks;"
- + "after:dreamcraft"
- )
-public class KekzCore {
-
- public static final String NAME = "KekzTech";
- public static final String MODID = "kekztech";
- public static final String VERSION = "0.4.5";
-
- public static final Logger LOGGER = LogManager.getLogger(NAME);
-
- @Mod.Instance("kekztech")
- public static KekzCore instance;
-
- 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;
-
- @Mod.EventHandler
- public void preInit(FMLPreInitializationEvent event) {
- // Items
- ErrorItem.getInstance().registerItem();
- MetaItem_ReactorComponent.getInstance().registerItem();
- MetaItem_CraftingComponent.getInstance().registerItem();
- Items.registerOreDictNames();
-
- Blocks.preInit();
-
- // Register TileEntities
- 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");
- GameRegistry.registerTileEntity(TE_ThaumiumReinforcedJar.class, "kekztech_thaumiumreinforcedjar");
- GameRegistry.registerTileEntity(TE_IchorJar.class, "kekztech_ichorjar");
-
- // Register guis
- NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
-
- // Register TESR
- ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorTether.class, new TESR_SETether());
- ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorCapacitor.class, new TESR_SECapacitor());
-
- Researches.preInit();
- }
-
- @Mod.EventHandler
- public void init(FMLInitializationEvent event) {
- // 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");
- // Register renderer
- //RenderingRegistry.registerBlockHandler(ConduitRenderer.getInstance());
- }
-
- @Mod.EventHandler
- public void postInit(FMLPostInitializationEvent event) {
- Recipes.postInit();
- Researches.postInit();
- }
-}
+package kekztech; + +import client.renderer.TESR_SECapacitor; +import client.renderer.TESR_SETether; +import common.Blocks; +import common.CommonProxy; +import common.Recipes; +import common.Researches; +import common.tileentities.*; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import common.items.ErrorItem; +import common.items.MetaItem_CraftingComponent; +import common.items.MetaItem_ReactorComponent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * My GT-Meta-IDs are: 13101 - 13500 + * + * @author kekzdealer + * + */ +@Mod(modid = KekzCore.MODID, name = KekzCore.NAME, version = KekzCore.VERSION, + dependencies = + "required-after:IC2;" + + "required-after:gregtech;" + + "required-after:tectech;" + + "required-after:Thaumcraft;" + + "required-after:ThaumicTinkerer;" + + "after:bartworks;" + + "after:dreamcraft" + ) +public class KekzCore { + + public static final String NAME = "KekzTech"; + public static final String MODID = "kekztech"; + public static final String VERSION = "0.5"; + + public static final Logger LOGGER = LogManager.getLogger(NAME); + + @Mod.Instance("kekztech") + public static KekzCore instance; + + @SidedProxy(clientSide = "client.ClientProxy", serverSide = "kekztech.ServerProxy") + public static CommonProxy proxy; + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) { + proxy.preInit(event); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + proxy.init(event); + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent event) { + proxy.postInit(event); + } +} diff --git a/src/main/java/kekztech/MultiFluidHandler.java b/src/main/java/kekztech/MultiFluidHandler.java index f1a527b2c0..399f9faa8b 100644 --- a/src/main/java/kekztech/MultiFluidHandler.java +++ b/src/main/java/kekztech/MultiFluidHandler.java @@ -1,34 +1,61 @@ package kekztech; -import java.util.ArrayList; -import java.util.List; - import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class MultiFluidHandler { - - public static final int MAX_DISTINCT_FLUIDS = 25; - - private final List<FluidStack> fluids = new ArrayList<>(MAX_DISTINCT_FLUIDS); - private int capacityPerFluid; + + private final FluidStack[] fluids; + private final int maxDistinctFluids; + private final int capacityPerFluid; private boolean locked = true; private boolean doVoidExcess = false; private byte fluidSelector = -1; - public MultiFluidHandler() { - - } - - public MultiFluidHandler(int capacityPerFluid) { + public MultiFluidHandler(int maxDistinctFluids, int capacityPerFluid, FluidStack[] fluidsToAdd) { + this.maxDistinctFluids = maxDistinctFluids; + this.fluids = new FluidStack[maxDistinctFluids]; + if(fluidsToAdd != null) { + int tFluidLengt = (maxDistinctFluids <fluidsToAdd.length) ? maxDistinctFluids:fluidsToAdd.length; + for (int i = 0; i < tFluidLengt; i++) { + this.fluids[i] = fluidsToAdd[i]; + } + } this.capacityPerFluid = capacityPerFluid; } - - public MultiFluidHandler(int capacityPerFluid, List<FluidStack> fluids) { - this.capacityPerFluid = capacityPerFluid; - this.fluids.addAll(fluids); + + /** + * Initialize a new MultiFluidHandler object with the given parameters + * @param maxDistinctFluids + * How many different fluids can be stored + * @param capacityPerFluid + * How much capacity each fluid should have + * @param fluidsToAdd + * Fluids to add immediately + * @return + * A new instance + */ + public static MultiFluidHandler newInstance(int maxDistinctFluids, int capacityPerFluid, FluidStack...fluidsToAdd) { + return new MultiFluidHandler(maxDistinctFluids, capacityPerFluid, fluidsToAdd); + } + + /** + * Deep copy a MultiFluidHandler instance with a new capacity + * @param toCopy + * The MultiFluidHandler that should be copied + * @param capacityPerFluid + * How much capacity each fluid should have + * @return + * A new instance + */ + public static MultiFluidHandler newAdjustedInstance(MultiFluidHandler toCopy, int capacityPerFluid) { + return new MultiFluidHandler(toCopy.maxDistinctFluids, capacityPerFluid, toCopy.fluids); } /** @@ -46,12 +73,14 @@ public class MultiFluidHandler { /** * Used to tell the MFH if a fluid is selected by * an Integrated Circuit in the controller. + * If the Integrate Circuit configuration exceeds + * the number of stored fluid, the configuration will be ignored. * * @param fluidSelector * Selected fluid or -1 if no fluid is selected */ public void setFluidSelector(byte fluidSelector) { - this.fluidSelector = fluidSelector; + this.fluidSelector = fluidSelector < fluids.length ? fluidSelector : -1; } /** @@ -62,59 +91,152 @@ public class MultiFluidHandler { public byte getSelectedFluid() { return fluidSelector; } - - public boolean contains(FluidStack fluid) { - return !locked && fluids.contains(fluid); + + public FluidStack[] getAllFluids() { + return fluids; } + + public int getFluidPosistion(FluidStack aFluid) { + + for (int i = 0; i < fluids.length; i++) + { + FluidStack tFluid = fluids[i]; + if (tFluid != null && tFluid.isFluidEqual(aFluid)) + return i; + } + return -1; + } + + public boolean contains(FluidStack aFluid) { + if (locked) + return false; + return getFluidPosistion(aFluid)>=0; + } + + public int countFluids() + { + int tCount = 0; + for (int i = 0; i < fluids.length; i++) { + if (fluids[i] != null) + tCount++; + } + return tCount; + } + public int getCapacity() { return capacityPerFluid; } - - public List<FluidStack> getFluids(){ - return (!locked) ? fluids : new ArrayList<>(); + public int getMaxDistinctFluids() { + return maxDistinctFluids; } - - public FluidStack getFluid(int slot) { - return (!locked && fluids.size() > 0 && slot >= 0 && slot < MAX_DISTINCT_FLUIDS) - ? fluids.get(slot) : null; + + /** + * Returns a deep copy of the the FluidStack in the requested slot + * @param slot + * requested slot + * @return + * deep copy of the requested FluidStack + */ + public FluidStack getFluidCopy(int slot) { + if (slot >= fluids.length) + return null; + if (!locked + && fluids.length > 0 + && slot >= 0 + && slot < maxDistinctFluids) + { + FluidStack tFluid = fluids[slot]; + if (tFluid != null) + return tFluid.copy(); + } + return null; } - + + /** + * Returns the amount of different fluids currently stored. + * @return + * amount of different fluids currently stored (0-25) + */ + public int getDistinctFluids() { + int distinctFluids = 0; + for (FluidStack f : fluids) { + if (f != null) + distinctFluids++; + } + return distinctFluids; + } + + /** + * Helper method to save a MultiFluidHandler to NBT data + * @param nbt + * The NBT Tag to write to + * @return + * Updated NBT Tag + */ public NBTTagCompound saveNBTData(NBTTagCompound nbt) { nbt = (nbt == null) ? new NBTTagCompound() : nbt; nbt.setInteger("capacityPerFluid", getCapacity()); + nbt.setInteger("maxDistinctFluids",this.maxDistinctFluids); int c = 0; for(FluidStack f : fluids) { - nbt.setTag("" + c, f.writeToNBT(new NBTTagCompound())); + if (f == null) + { + c++; + continue; + } + nbt.setTag( String.valueOf(c), f.writeToNBT(new NBTTagCompound())); c++; } return nbt; } - - public void loadNBTData(NBTTagCompound nbt) { + + /** + * Helper method to initialize a MultiFluidHandler from NBT data + * @param nbt + * The NBT Tag to read from + * @return + * A new Instance + */ + static public MultiFluidHandler loadNBTData(NBTTagCompound nbt) { nbt = (nbt == null) ? new NBTTagCompound() : nbt; - capacityPerFluid = nbt.getInteger("capacityPerFluid"); - - fluids.clear(); + final int capacityPerFluid = nbt.getInteger("capacityPerFluid"); final NBTTagCompound fluidsTag = (NBTTagCompound) nbt.getTag("fluids"); - for(int i = 0; i < MultiFluidHandler.MAX_DISTINCT_FLUIDS; i++) { - final NBTTagCompound fnbt = (NBTTagCompound) fluidsTag.getTag("" + i); - if(fnbt == null) { - break; + int distinctFluids = nbt.getInteger("maxDistinctFluids"); + if (!nbt.hasKey("maxDistinctFluids")) + distinctFluids = 25;// adding it so it doesent break on upgrading + final FluidStack[] loadedFluids = new FluidStack[distinctFluids]; + + if (fluidsTag != null) + { + for (int i = 0; i < distinctFluids; i++) { + final NBTTagCompound fluidNBT = (NBTTagCompound) fluidsTag.getTag("" + i); + if(fluidNBT == null) { + loadedFluids[i] = null; + } else { + loadedFluids[i] = FluidStack.loadFluidStackFromNBT(fluidNBT); + } } - fluids.add(FluidStack.loadFluidStackFromNBT(fnbt)); } + return new MultiFluidHandler(distinctFluids, capacityPerFluid, loadedFluids); } public ArrayList<String> getInfoData() { - final ArrayList<String> lines = new ArrayList<>(fluids.size()); + final ArrayList<String> lines = new ArrayList<>(fluids.length); lines.add(EnumChatFormatting.YELLOW + "Stored Fluids:" + EnumChatFormatting.RESET); - for(int i = 0; i < fluids.size(); i++) { - lines.add(i + " - " + fluids.get(i).getLocalizedName() + ": " - + fluids.get(i).amount + "L (" - + (Math.round(100.0f * fluids.get(i).amount / getCapacity())) + "%)"); + for(int i = 0; i < fluids.length; i++) { + FluidStack tFluid = fluids[i]; + if (tFluid == null) { + lines.add(i + " - " + "null" + ": " + + "0" + "L (" + + "0" + "%)"); + } else { + lines.add(i + " - " + tFluid.getLocalizedName() + ": " + + tFluid.amount + "L (" + + (Math.round(100.0f * tFluid.amount / getCapacity())) + "%)"); + } } return lines; @@ -133,20 +255,28 @@ public class MultiFluidHandler { if(locked) { return 0; } - if(fluids.size() == MAX_DISTINCT_FLUIDS && !contains(push)) { + int empty = getNullSlot(); + int fluidCount = countFluids(); + if(fluidCount >= maxDistinctFluids && !contains(push)) { // Already contains 25 fluids and this isn't one of them return 0; - } else if (fluids.size() < MAX_DISTINCT_FLUIDS && !contains(push)) { + } else if (empty < maxDistinctFluids && !contains(push)) { // Add new fluid final int fit = Math.min(getCapacity(), push.amount); if(doPush) { - fluids.add(new FluidStack(push.getFluid(), fit)); + if (empty == -1) + return 0; + else + fluids[empty] = new FluidStack(push.getFluid(), fit); } // If doVoidExcess, pretend all of it fit return doVoidExcess ? push.amount : fit; } else { - // Add to existing fluid - final FluidStack existing = fluids.get(fluids.indexOf(push)); + // Add to existing fluids + int index = getFluidPosistion(push); + if (index < 0) + return 0; + final FluidStack existing = fluids[index]; final int fit = Math.min(getCapacity() - existing.amount, push.amount); if(doPush) { existing.amount += fit; @@ -155,6 +285,16 @@ public class MultiFluidHandler { return doVoidExcess ? push.amount : fit; } } + + + public int getNullSlot() + { + for (int i = 0; i < fluids.length; i++) { + if (fluids[i] == null) + return i; + } + return -1; + } /** * Fill fluid into the specified tank. @@ -171,19 +311,25 @@ public class MultiFluidHandler { if(locked) { return 0; } - if(slot < 0 || slot >= MAX_DISTINCT_FLUIDS) { + FluidStack tFluid = fluids[slot]; + if(slot < 0 || slot >= maxDistinctFluids) { // Invalid slot return 0; } - if((fluids.get(slot) != null) && !fluids.get(slot).equals(push)) { + if((tFluid != null) && !tFluid.equals(push)) { // Selected slot is taken by a non-matching fluid return 0; } else { + int fit = 0; // Add to existing fluid - final FluidStack existing = fluids.get(slot); - final int fit = Math.min(getCapacity() - existing.amount, push.amount); - if(doPush) { - existing.amount += fit; + if (tFluid == null) { + fit = Math.min(getCapacity(),push.amount); + fluids[slot] = new FluidStack(push.getFluid(), fit); + } else { + fit = Math.min(getCapacity() - tFluid.amount, push.amount); + if(doPush) { + tFluid.amount += fit; + } } // If doVoidExcess, pretend all of it fit return doVoidExcess ? push.amount : fit; @@ -200,16 +346,19 @@ public class MultiFluidHandler { * @return Amount of fluid that was (or would have been, if simulated) pulled. */ public int pullFluid(FluidStack pull, boolean doPull) { - if (locked || !contains(pull)) { + if (locked) { return 0; } else { - final FluidStack src = fluids.get(fluids.indexOf(pull)); + int tIndex = getFluidPosistion(pull); + if (tIndex < 0) + return 0; + FluidStack src = fluids[tIndex]; final int rec = Math.min(pull.amount, src.amount); if (doPull) { src.amount -= rec; } if (src.amount == 0) { - fluids.remove(src); + fluids[tIndex]= null; } return rec; } @@ -227,22 +376,22 @@ public class MultiFluidHandler { * @return Amount of fluid that was (or would have been, if simulated) pulled. */ public int pullFluid(FluidStack pull, int slot, boolean doPull) { - if(locked) { + if(locked || slot >= fluids.length) { return 0; } - if(slot < 0 || slot >= MAX_DISTINCT_FLUIDS) { + if(slot < 0 || slot >= maxDistinctFluids) { return 0; } - if(!fluids.get(slot).equals(pull)) { + FluidStack tFluid = fluids[slot]; + if(tFluid == null || !tFluid.equals(pull)) { return 0; } else { - final FluidStack src = fluids.get(slot); - final int rec = Math.min(pull.amount, src.amount); + final int rec = Math.min(pull.amount, tFluid.amount); if(doPull) { - src.amount -= rec; + tFluid.amount -= rec; } - if(src.amount == 0) { - fluids.remove(src); + if(tFluid.amount == 0) { + fluids[slot] = null; } return rec; } @@ -258,13 +407,15 @@ public class MultiFluidHandler { if(locked) { return false; } - if(fluids.size() == MAX_DISTINCT_FLUIDS && !contains(push)) { + int tFluidIndex = getFluidPosistion(push); + int fluidCount = countFluids(); + if(fluidCount >= maxDistinctFluids && !contains(push)) { return false; - } else if (fluids.size() < MAX_DISTINCT_FLUIDS && !contains(push)) { + } else if (fluidCount < maxDistinctFluids && !contains(push)) { return Math.min(getCapacity(), push.amount) > 0; } else { - final int remcap = getCapacity() - fluids.get(fluids.indexOf(push)).amount; - return doVoidExcess ? true : (Math.min(remcap, push.amount) > 0); + final int remcap = getCapacity() - fluids[tFluidIndex].amount; + return doVoidExcess || (Math.min(remcap, push.amount) > 0); } } } diff --git a/src/main/java/kekztech/MultiItemHandler.java b/src/main/java/kekztech/MultiItemHandler.java deleted file mode 100644 index 27d936efec..0000000000 --- a/src/main/java/kekztech/MultiItemHandler.java +++ /dev/null @@ -1,185 +0,0 @@ -package kekztech; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -public class MultiItemHandler { - - private int perTypeCapacity = 0; - - private boolean locked = true; - - private ItemStack[] items; - - public MultiItemHandler() { - - } - - public List<String> debugPrint() { - if(items == null) { - return new ArrayList<String>(); - } - final ArrayList<String> slots = new ArrayList<>(); - - for(int i = 0; i < items.length; i++) { - slots.add("Slot " + i + " contains " + items[i].stackSize + " " + items[i].getDisplayName()); - } - - return slots; - } - - /** - * Adapts the internal storage to structure changes. - * In the event of structure down-sizing, all excess items - * will be dropped on the ground. - * - * @param itemTypeCapacity - */ - public void setItemTypeCapacity(int itemTypeCapacity) { - System.out.println("Configuring type capacity"); - if(items.length > itemTypeCapacity) { - // Generate new smaller backing array - final ItemStack[] newItems = new ItemStack[itemTypeCapacity]; - for(int i = 0; i < newItems.length; i++) { - newItems[i] = items[i]; - } - // Sort out item overflow - final ItemStack[] toDrop = new ItemStack[items.length - itemTypeCapacity]; - for(int i = 0; i < toDrop.length; i++) { - toDrop[i] = items[i + newItems.length - 1]; - } - // TODO drop overflow items to the ground - - // Swap array - items = newItems; - } else { - // Generate new larger backing array - final ItemStack[] newItems = new ItemStack[itemTypeCapacity]; - for(int i = 0; i < items.length; i++) { - newItems[i] = items[i]; - } - - // Swap array - items = newItems; - } - } - - public void setPerTypeCapacity(int perTypeCapacity) { - this.perTypeCapacity = perTypeCapacity; - } - - /** - * Lock internal storage in case Item Server is not running. - * - * @param state - * Lock state. - */ - public void setLock(boolean state) { - locked = state; - } - - public int getItemTypeCapacity() { - return items != null ? items.length : 0; - } - - public int getPerTypeCapacity() { - return perTypeCapacity; - } - - /** - * Returns the ItemStack from the specified slot. - * - * @param slot - * Storage slot number. Zero indexed. - * @return - * ItemStack from storage or null if - * storage is locked or invalid slot parameter. - */ - public ItemStack getStackInSlot(int slot) { - System.out.println("Stack in slot " + slot + " requested"); - if(locked || slot >= items.length) { - return null; - } else { - return items[slot]; - } - } - - /** - * Inserts a new ItemStack into storage, - * but only if the slot is still unassigned. - * - * @param slot - * Storage slot number. Zero indexed. - * @param itemStack - * ItemStack to insert. - * @return - * Operation success state. - */ - public boolean insertStackInSlot(int slot, ItemStack itemStack) { - System.out.println("Inserting " + itemStack.getDisplayName() + " into " + slot); - if(itemStack == null - || items[slot] != null - || locked - || slot >= items.length) { - return false; - } else { - items[slot] = itemStack; - return true; - } - } - - /** - * Tries to increase the item amount in a specified slot. - * - * @param slot - * Storage slot number. Zero indexed. - * @param amount - * Amount to increase by. - * @return - * Actual amount the item amount was increased by. - */ - public int increaseStackInSlot(int slot, int amount) { - System.out.println("Increasing item in slot " + slot + " by " + amount); - if(slot >= items.length - || locked - || amount <= 0) { - return 0; - } else { - final int space = perTypeCapacity - items[slot].stackSize; - final int fit = Math.min(space, amount); - items[slot].stackSize += fit; - return fit; - } - } - - /** - * Tries to reduce the item amount in a specified slot. - * - * @param slot - * Storage slot number. Zero indexed. - * @param amount - * Amount to decrease by. - * @return - * Actual amount the item amount was decreased by. - */ - public int reduceStackInSlot(int slot, int amount) { - System.out.println("Reducing item in slot " + slot + " by " + amount); - if(slot >= items.length - || locked - || amount <= 0) { - return 0; - } else { - final int available = items[slot].stackSize; - final int take = Math.min(available, amount); - items[slot].stackSize -= take; - if(take == available) { - items[slot] = null; - } - return take; - } - } - - -} diff --git a/src/main/java/kekztech/ServerProxy.java b/src/main/java/kekztech/ServerProxy.java new file mode 100644 index 0000000000..0291cf687f --- /dev/null +++ b/src/main/java/kekztech/ServerProxy.java @@ -0,0 +1,7 @@ +package kekztech; + +import common.CommonProxy; + +public class ServerProxy extends CommonProxy { + +} diff --git a/src/main/java/reactor/Reactor.java b/src/main/java/reactor/Reactor.java new file mode 100644 index 0000000000..f6f955b230 --- /dev/null +++ b/src/main/java/reactor/Reactor.java @@ -0,0 +1,9 @@ +package reactor; + +public class Reactor { + + private long energyPerSecond; + private long heat; + private long maxHeat; + +} diff --git a/src/main/java/reactor/itemBehaviour/IReactorItemBehaviour.java b/src/main/java/reactor/itemBehaviour/IReactorItemBehaviour.java new file mode 100644 index 0000000000..1990938270 --- /dev/null +++ b/src/main/java/reactor/itemBehaviour/IReactorItemBehaviour.java @@ -0,0 +1,20 @@ +package reactor.itemBehaviour; + +import java.util.HashMap; + +public abstract class IReactorItemBehaviour { + + protected final HashMap<String, String> properties; + + protected IReactorItemBehaviour(String propertiesKey) { + // load + + properties = new HashMap<>(); + } + + public abstract void apply(); + + public abstract boolean hasDurabilityBar(); + + public abstract double getDurabilityForDisplay(); +} diff --git a/src/main/java/util/MultiBlockTooltipBuilder.java b/src/main/java/util/MultiBlockTooltipBuilder.java deleted file mode 100644 index c0573667ab..0000000000 --- a/src/main/java/util/MultiBlockTooltipBuilder.java +++ /dev/null @@ -1,179 +0,0 @@ -package util; - -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; - -/** - * Have you ever felt like your tooltips just aren't enterprise enough? Use this! - * - * @author kekzdealer - * - */ -public class MultiBlockTooltipBuilder { - - private static final String TAB = " "; - private static final String COLON = ": "; - - private final List<String> iLines; - private final List<String> sLines; - - private String[] iArray; - private String[] sArray; - - // Localized keywords - private static final String KW_dimensions = StatCollector.translateToLocal("mbdesc.beginStructureBlock.Dimensions"); - private static final String KW_structure = StatCollector.translateToLocal("mbdesc.beginStructureBlock.Structure"); - private static final String KW_controller = StatCollector.translateToLocal("mbdesc.addController.Controller"); - private static final String KW_atleast = StatCollector.translateToLocal("mbdesc.addCasing.atleast"); - private static final String KW_energyhatch = StatCollector.translateToLocal("mbdesc.addEnergyHatch.EnergyHatch"); - private static final String KW_dynamohatch = StatCollector.translateToLocal("mbdesc.addDynamoHatch.DynamoHatch"); - private static final String KW_maintenancehatch = StatCollector.translateToLocal("mbdesc.addMaintenanceHatch.MaintenanceHatch"); - private static final String KW_iohatches = StatCollector.translateToLocal("mbdesc.addIOHatches.IOHatches"); - private static final String KW_inputbus = StatCollector.translateToLocal("mbdesc.addInputBus.InputBus"); - private static final String KW_inputhatch = StatCollector.translateToLocal("mbdesc.addInputHatch.InputHatch"); - private static final String KW_outputbus = StatCollector.translateToLocal("mbdesc.addOutputBus.OutputBus"); - private static final String KW_outputhatch = StatCollector.translateToLocal("mbdesc.addOutputHatch.OutputHatch"); - private static final String KW_hold = StatCollector.translateToLocal("mbdesc.signAndFinalize.Hold"); - private static final String KW_todisplay = StatCollector.translateToLocal("mbdesc.signAndFinalize.todisplay"); - private static final String KW_createdby = StatCollector.translateToLocal("mbdesc.signAndFinalize.createdby"); - - public MultiBlockTooltipBuilder() { - iLines = new LinkedList<>(); - sLines = new LinkedList<>(); - - - } - - /** - * Add a basic line of information about this structure - * - * @param info - * The line to be added. - * @return Instance this method was called on. - */ - public MultiBlockTooltipBuilder addInfo(String info) { - iLines.add(info); - return this; - } - - /** - * Add a separator line like this:<br> - * ------------------------------- - * - * @return Instance this method was called on. - */ - public MultiBlockTooltipBuilder addSeparator() { - iLines.add("-----------------------------------------"); - return this; - } - - /** - * Begin adding structural information by adding a line about the structure's dimensions - * and then inserting a "Structure:" line. - * - * @param w - * Structure width. - * @param h - * Structure height. - * @param l - * Structure depth/length. - * @return Instance this method was called on. - */ - public MultiBlockTooltipBuilder beginStructureBlock(int w, int h, int l) { - sLines.add(KW_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL)"); - sLines.add(KW_structure + COLON); - return this; - } - - public MultiBlockTooltipBuilder addController(String info) { - sLines.add(TAB + KW_controller + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addCasingInfo(String casingName, int minCount) { - sLines.add(TAB + minCount +"x " + casingName + " " + KW_atleast); - return this; - } - - public MultiBlockTooltipBuilder addEnergyHatch(String info) { - sLines.add(TAB + KW_energyhatch + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addDynamoHatch(String info) { - sLines.add(TAB + KW_dynamohatch + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addMaintenanceHatch(String info) { - sLines.add(TAB + KW_maintenancehatch + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addIOHatches(String info) { - sLines.add(TAB + KW_iohatches + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addInputBus(String info) { - sLines.add(TAB + KW_inputbus + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addInputHatch(String info) { - sLines.add(TAB + KW_inputhatch + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addOutputBus(String info) { - sLines.add(TAB + KW_outputbus + COLON + info); - return this; - } - - public MultiBlockTooltipBuilder addOutputHatch(String info) { - sLines.add(TAB + KW_outputhatch + COLON + info); - return this; - } - - /** - * Use this method to add a structural part that isn't covered by the builders capabilities. - * - * @param name - * Name of the hatch or other component. - * @param info - * Positional information. - * @return Instance this method was called on. - */ - public MultiBlockTooltipBuilder addOtherStructurePart(String name, String info) { - sLines.add(TAB + name + COLON + info); - return this; - } - - /** - * Call at the very end.<br> - * Adds a final line with the authors name and information on how to display the structure guidelines.<br> - * Ends the building process. - * - * @param author - * Name of the creator of this Machine - */ - public void signAndFinalize(String author) { - iLines.add(KW_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + KW_todisplay); - iLines.add(KW_createdby + " " + author); - iArray = new String[iLines.size()]; - sArray = new String[sLines.size()]; - iLines.toArray(iArray); - sLines.toArray(sArray); - } - - public String[] getInformation() { - return iArray; - } - - public String[] getStructureInformation() { - return sArray; - } -} diff --git a/src/main/java/util/Util.java b/src/main/java/util/Util.java index aa362d67d7..8ccf3313ac 100644 --- a/src/main/java/util/Util.java +++ b/src/main/java/util/Util.java @@ -1,51 +1,51 @@ -package util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import items.ErrorItem;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.oredict.OreDictionary;
-
-public class Util {
-
- public static ItemStack getStackofAmountFromOreDict(String oredictName, final int amount){
- final ArrayList<ItemStack> list = OreDictionary.getOres(oredictName);
- if(!list.isEmpty()) {
- final ItemStack ret = list.get(0).copy();
- ret.stackSize = amount;
- return ret;
- }
- System.err.println("Failed to find " + oredictName + " in OreDict");
- return new ItemStack(ErrorItem.getInstance(), amount);
- }
-
- public static ItemStack[] toItemStackArray(List<ItemStack> stacksList) {
- if(stacksList.size() == 0) {
- return null;
- }
-
- ItemStack[] ret = new ItemStack[stacksList.size()];
- Iterator<ItemStack> iterator = stacksList.iterator();
- for(int i = 0; i < ret.length; i++ ) {
- ret[i] = iterator.next();
- }
- return ret;
- }
-
- public static FluidStack[] toFluidStackArray(List<FluidStack> stacksList) {
- if(stacksList.size() == 0) {
- return null;
- }
-
- FluidStack[] ret = new FluidStack[stacksList.size()];
- Iterator<FluidStack> iterator = stacksList.iterator();
- for(int i = 0; i < ret.length; i++ ) {
- ret[i] = iterator.next();
- }
- return ret;
- }
-
-}
+package util; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import common.items.ErrorItem; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class Util { + + public static ItemStack getStackofAmountFromOreDict(String oredictName, final int amount){ + final ArrayList<ItemStack> list = OreDictionary.getOres(oredictName); + if(!list.isEmpty()) { + final ItemStack ret = list.get(0).copy(); + ret.stackSize = amount; + return ret; + } + System.err.println("Failed to find " + oredictName + " in OreDict"); + return new ItemStack(ErrorItem.getInstance(), amount); + } + + public static ItemStack[] toItemStackArray(List<ItemStack> stacksList) { + if(stacksList.size() == 0) { + return null; + } + + ItemStack[] ret = new ItemStack[stacksList.size()]; + Iterator<ItemStack> iterator = stacksList.iterator(); + for(int i = 0; i < ret.length; i++ ) { + ret[i] = iterator.next(); + } + return ret; + } + + public static FluidStack[] toFluidStackArray(List<FluidStack> stacksList) { + if(stacksList.size() == 0) { + return null; + } + + FluidStack[] ret = new FluidStack[stacksList.size()]; + Iterator<FluidStack> iterator = stacksList.iterator(); + for(int i = 0; i < ret.length; i++ ) { + ret[i] = iterator.next(); + } + return ret; + } + +} |