From 95ae4bcb0146fbccb6eaf0f0b3477050b8dde533 Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Fri, 11 Oct 2019 02:29:41 +0200 Subject: Fixed TFFT persistency. Made TFFT storage more expensive. Added Multi Hatch recipe. Increased version #. Perparing for release. --- src/main/java/blocks/Block_TFFTCasing.java | 2 +- src/main/java/kekztech/KekzCore.java | 52 ++- src/main/java/kekztech/MultiFluidHandler.java | 28 +- .../java/tileentities/GTMTE_FluidMultiStorage.java | 376 ++++++++++----------- .../tileentities/GTMTE_ModularNuclearReactor.java | 7 +- 5 files changed, 251 insertions(+), 214 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/blocks/Block_TFFTCasing.java b/src/main/java/blocks/Block_TFFTCasing.java index f2011a8bae..02f44a9dd7 100644 --- a/src/main/java/blocks/Block_TFFTCasing.java +++ b/src/main/java/blocks/Block_TFFTCasing.java @@ -20,7 +20,7 @@ public class Block_TFFTCasing extends Block { } public void registerBlock() { - final String blockName = "kekztech_tfftcasing_block"; + final String blockName = "kekztech_tfftcasingblock_block"; super.setBlockName(blockName); super.setCreativeTab(CreativeTabs.tabMisc); super.setBlockTextureName(KekzCore.MODID + ":" + "TFFTCasing"); diff --git a/src/main/java/kekztech/KekzCore.java b/src/main/java/kekztech/KekzCore.java index 33ad34d015..94aea7adc2 100644 --- a/src/main/java/kekztech/KekzCore.java +++ b/src/main/java/kekztech/KekzCore.java @@ -32,6 +32,12 @@ import tileentities.GTMTE_SOFuelCellMK2; import tileentities.TE_TFFTMultiHatch; import util.Util; +/** + * 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" @@ -40,13 +46,14 @@ public class KekzCore { public static final String NAME = "KekzTech"; public static final String MODID = "kekztech"; - public static final String VERSION = "0.1a"; + public static final String VERSION = "0.2"; @Mod.Instance("kekztech") public static KekzCore instance; private GTMTE_SOFuelCellMK1 sofc1; private GTMTE_SOFuelCellMK2 sofc2; + @SuppressWarnings("unused") private GTMTE_ModularNuclearReactor mdr; private GTMTE_FluidMultiStorage fms; @@ -72,10 +79,10 @@ public class KekzCore { @Mod.EventHandler public void init(FMLInitializationEvent event ) { // Multiblock controllers - sofc1 = new GTMTE_SOFuelCellMK1(5000, "multimachine.fuelcellmk1", "Solid-Oxide Fuel Cell Mk I"); - sofc2 = new GTMTE_SOFuelCellMK2(5001, "multimachine.fuelcellmk2", "Solid-Oxide Fuel Cell Mk II"); - mdr = new GTMTE_ModularNuclearReactor(5002, "multimachine.nuclearreactor", "Nuclear Reactor"); - fms = new GTMTE_FluidMultiStorage(5003, "multimachine.tf_fluidtank", "T.F.F.T"); + 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"); } @Mod.EventHandler @@ -109,10 +116,10 @@ public class KekzCore { final Object[] tfft_recipe = { "HFH", "PVP", "CFC", 'H', OrePrefixes.pipeMedium.get(Materials.StainlessSteel), - 'F', ItemList.Field_Generator_LV.get(1L, (Object[]) null), + 'F', ItemList.Field_Generator_MV.get(1L, (Object[]) null), 'P', ItemList.Electric_Pump_HV.get(1L, (Object[]) null), 'V', OrePrefixes.rotor.get(Materials.VibrantAlloy), - 'C', OrePrefixes.circuit.get(Materials.Advanced) + 'C', OrePrefixes.circuit.get(Materials.Data) }; GT_ModHandler.addCraftingRecipe(fms.getStackForm(1), tfft_recipe); @@ -156,10 +163,10 @@ public class KekzCore { 200, 256); final ItemStack[] tfftstoragefield1 = { GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Basic, 4), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 4), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.PulsatingIron, 1), GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Steel, 1), - ItemList.Electric_Pump_LV.get(1L, (Object[]) null) + ItemList.Electric_Pump_MV.get(1L, (Object[]) null) }; GT_Values.RA.addAssemblerRecipe( tfftstoragefield1, @@ -168,23 +175,23 @@ public class KekzCore { 200, 256); final ItemStack[] tfftstoragefield2 = { GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 4), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 4), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.PulsatingIron, 4), GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.StainlessSteel, 1), - ItemList.Electric_Pump_MV.get(1L, (Object[]) null) + ItemList.Electric_Pump_HV.get(1L, (Object[]) null) }; GT_Values.RA.addAssemblerRecipe( tfftstoragefield2, - FluidRegistry.getFluidStack("molten.plastic", 144), + FluidRegistry.getFluidStack("molten.plastic", 576), new ItemStack(Block_TFFTStorageFieldBlockT2.getInstance(), 1), 200, 480); final ItemStack[] tfftstoragefield3 = { GT_Utility.getIntegratedCircuit(6), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 4), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 4), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.VibrantAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Titanium, 1), - ItemList.Field_Generator_LV.get(1L, (Object[]) null), - ItemList.Electric_Pump_HV.get(1L, (Object[]) null) + ItemList.Field_Generator_MV.get(1L, (Object[]) null), + ItemList.Electric_Pump_EV.get(1L, (Object[]) null) }; GT_Values.RA.addAssemblerRecipe( tfftstoragefield3, @@ -197,13 +204,26 @@ public class KekzCore { GT_OreDictUnificator.get(OrePrefixes.plateTriple, Materials.NiobiumTitanium, 1), GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.TungstenSteel, 1), ItemList.Field_Generator_HV.get(1L, (Object[]) null), - ItemList.Electric_Pump_EV.get(1L, (Object[]) null) + ItemList.Electric_Pump_IV.get(1L, (Object[]) null) }; GT_Values.RA.addAssemblerRecipe( tfftstoragefield4, FluidRegistry.getFluidStack("molten.epoxid", 1152), new ItemStack(Block_TFFTStorageFieldBlockT4.getInstance(), 1), 400, 4098); + final ItemStack[] tfftmultihatch = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), + GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.StainlessSteel, 25), + GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.RoseGold, 64), + GT_OreDictUnificator.get(OrePrefixes.spring, Materials.Thorium, 12), + ItemList.Field_Generator_HV.get(1L, (Object[]) null), + }; + GT_Values.RA.addAssemblerRecipe( + tfftmultihatch, + FluidRegistry.getFluidStack("molten.epoxid", 576), + new ItemStack(Block_TFFTMultiHatch.getInstance(), 1), + 6000, 480); // Ceramic plates GT_Values.RA.addAlloySmelterRecipe( diff --git a/src/main/java/kekztech/MultiFluidHandler.java b/src/main/java/kekztech/MultiFluidHandler.java index 2565ede1dc..f131cfbb0d 100644 --- a/src/main/java/kekztech/MultiFluidHandler.java +++ b/src/main/java/kekztech/MultiFluidHandler.java @@ -12,10 +12,14 @@ public class MultiFluidHandler { public static final int MAX_DISTINCT_FLUIDS = 25; private final List fluids = new ArrayList<>(MAX_DISTINCT_FLUIDS); - private final int capacityPerFluid; + private int capacityPerFluid; private boolean locked = true; + public MultiFluidHandler() { + + } + public MultiFluidHandler(int capacityPerFluid) { this.capacityPerFluid = capacityPerFluid; } @@ -52,15 +56,35 @@ public class MultiFluidHandler { ? fluids.get(slot) : null; } - public NBTTagCompound getAsNBTTag(NBTTagCompound nbt) { + public NBTTagCompound saveNBTData(NBTTagCompound nbt) { + System.out.println("Saving a multi hatch!"); nbt = (nbt == null) ? new NBTTagCompound() : nbt; + + nbt.setInteger("capacityPerFluid", getCapacity()); int c = 0; for(FluidStack f : fluids) { nbt.setTag("" + c, f.writeToNBT(new NBTTagCompound())); + c++; } return nbt; } + public void loadNBTData(NBTTagCompound nbt) { + nbt = (nbt == null) ? new NBTTagCompound() : nbt; + + capacityPerFluid = nbt.getInteger("capacityPerFluid"); + + fluids.clear(); + 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; + } + fluids.add(FluidStack.loadFluidStackFromNBT(fnbt)); + } + } + public ArrayList getInfoData() { final ArrayList lines = new ArrayList<>(fluids.size()); lines.add(EnumChatFormatting.YELLOW + "Stored Fluids:" + EnumChatFormatting.RESET); diff --git a/src/main/java/tileentities/GTMTE_FluidMultiStorage.java b/src/main/java/tileentities/GTMTE_FluidMultiStorage.java index 051f27047d..ce155c48e6 100644 --- a/src/main/java/tileentities/GTMTE_FluidMultiStorage.java +++ b/src/main/java/tileentities/GTMTE_FluidMultiStorage.java @@ -143,7 +143,6 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { } } - // TODO output seems to ignore circuit // Push out fluids if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) { final int config = guiSlotItem.getItemDamage(); @@ -251,157 +250,119 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { */ @Override public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) { - try { - // 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; + // 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 slice + for(int X = -2; X <= 2; X++) { + for(int Y = -2; Y <= 2; Y++) { + if(X == 0 && Y == 0) { + continue; // is controller + } - // Front slice - for(int X = -2; X <= 2; X++) { - for(int Y = -2; Y <= 2; 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()); - - // 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. - // 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 { - formationChecklist = false; - } + // Get next TE + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); + 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. + // 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 (!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; - } + else { + formationChecklist = false; } } - } - } - - // Middle three slices - 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 += 500000.0f; - } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD2.getUnlocalizedName())) { - runningCostAcc += 1.0f; - fluidCapacityAcc += 4000000.0f; - } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD3.getUnlocalizedName())) { - runningCostAcc += 2.0f; - fluidCapacityAcc += 16000000.0f; - } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() - .equals(STORAGE_FIELD4.getUnlocalizedName())) { - runningCostAcc += 4.0f; - fluidCapacityAcc += 64000000.0f; - } else { - formationChecklist = false; - } - continue; - } - - // Get next TE - IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());// x, y ,z + } else { + if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) + && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) { - // Corner allows only glass or casings - 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(glassNameAE2) - || thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameStained) - || thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING)) { - formationChecklist = false; // do nothing yet - } + // 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 { - // 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(glassNameAE2) - || thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameStained)) { - // do nothing lol - } else { - formationChecklist = false; - } - } + formationChecklist = false; } } } } - - // Back slice - for(int X = -2; X <= 2; X++) { - for(int Y = -2; Y <= 2; Y++) { + } + + // Middle three slices + 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 += 500000.0f; + } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD2.getUnlocalizedName())) { + runningCostAcc += 1.0f; + fluidCapacityAcc += 4000000.0f; + } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD3.getUnlocalizedName())) { + runningCostAcc += 2.0f; + fluidCapacityAcc += 16000000.0f; + } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName() + .equals(STORAGE_FIELD4.getUnlocalizedName())) { + runningCostAcc += 4.0f; + fluidCapacityAcc += 64000000.0f; + } else { + formationChecklist = false; + } + continue; + } + // Get next TE - final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8); IGregTechTileEntity currentTE = - thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z()); + thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());// x, y ,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)) { + // Corner allows only glass or casings + 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(glassNameAE2) + || thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameStained) + || thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING)) { + formationChecklist = false; // do nothing yet + } + } 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--; @@ -412,18 +373,9 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { 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 if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameAE2) + || thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameStained)) { + // do nothing lol } else { formationChecklist = false; } @@ -431,44 +383,86 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { } } } - - 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(minCasingAmount > 0) { - formationChecklist = false; - } - - if(formationChecklist) { - runningCost = (int) Math.round(-runningCostAcc); - // Update MultiFluidHandler in case storage cells have been changed - // TODO update multihatch refs - final int capacityPerFluid = (int) Math.round(fluidCapacityAcc / 25.0f); - if(mfh == null) { - mfh = new MultiFluidHandler(capacityPerFluid); + } + + // Back slice + 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); + 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(mfh.getCapacity() != capacityPerFluid) { - mfh = new MultiFluidHandler(capacityPerFluid, mfh.getFluids()); + 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; + } } } - for(TE_TFFTMultiHatch mh : multiHatches) { - mh.setMultiFluidHandler(mfh); + } + } + + 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(minCasingAmount > 0) { + formationChecklist = false; + } + + if(formationChecklist) { + runningCost = (int) 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()); } } - - return formationChecklist; - } catch (Exception ex) { - System.err.println("CAUGHT CHECKMACHINE EXCEPTION"); - ex.printStackTrace(); + for(TE_TFFTMultiHatch mh : multiHatches) { + mh.setMultiFluidHandler(mfh); + } } - return false; + + return formationChecklist; } @Override @@ -501,12 +495,14 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { @Override public void saveNBTData(NBTTagCompound nbt) { + System.out.println("Saving TFFT!"); nbt = (nbt == null) ? new NBTTagCompound() : nbt; - nbt.setInteger("capacityPerFluid", mfh.getCapacity()); nbt.setInteger("runningCost", runningCost); nbt.setBoolean("doVoidExcess", doVoidExcess); - mfh.getAsNBTTag(nbt); + + nbt.setInteger("capacityPerFluid", mfh.getCapacity()); + nbt.setTag("fluids", mfh.saveNBTData(new NBTTagCompound())); super.saveNBTData(nbt); } @@ -518,17 +514,11 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { runningCost = nbt.getInteger("runningCost"); doVoidExcess = nbt.getBoolean("doVoidExcess"); - final ArrayList fluidList = new ArrayList<>(); - for(int i = 0; i < 25; i++) { - final NBTTagCompound fnbt = (NBTTagCompound) nbt.getTag("" + i); - if(fnbt == null) { - break; - } - fluidList.add(FluidStack.loadFluidStackFromNBT(fnbt)); + mfh = new MultiFluidHandler(); + mfh.loadNBTData(nbt); + for(TE_TFFTMultiHatch mh : multiHatches) { + mh.setMultiFluidHandler(mfh); } - - mfh = new MultiFluidHandler(nbt.getInteger("capacityPerFluid"), fluidList); - super.loadNBTData(nbt); } diff --git a/src/main/java/tileentities/GTMTE_ModularNuclearReactor.java b/src/main/java/tileentities/GTMTE_ModularNuclearReactor.java index f0d529ee54..6e19ab8ae3 100644 --- a/src/main/java/tileentities/GTMTE_ModularNuclearReactor.java +++ b/src/main/java/tileentities/GTMTE_ModularNuclearReactor.java @@ -1,8 +1,8 @@ package tileentities; -import container.GUIContainer_ModularNuclearReactor; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -65,8 +65,11 @@ public class GTMTE_ModularNuclearReactor extends GT_MetaTileEntity_MultiBlockBas // TODO: Opening UI crashes server. Controller isn't craftable right now. public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUIContainer_ModularNuclearReactor(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MultiblockDisplay.png"); + // In case someone ignores the warning... + /*return new GUIContainer_ModularNuclearReactor(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + "MultiblockDisplay.png");*/ } @Override -- cgit