diff options
Diffstat (limited to 'src/main/java/common')
66 files changed, 6583 insertions, 0 deletions
diff --git a/src/main/java/common/Blocks.java b/src/main/java/common/Blocks.java new file mode 100644 index 0000000000..18725b6000 --- /dev/null +++ b/src/main/java/common/Blocks.java @@ -0,0 +1,104 @@ +package common; + +import common.blocks.*; +import kekztech.KekzCore; +import net.minecraft.block.Block; + +public class Blocks { + + public static Block yszUnit; + public static Block gdcUnit; + + public static Block tfftCasing; + public static Block tfftStorageField1; + public static Block tfftStorageField2; + public static Block tfftStorageField3; + public static Block tfftStorageField4; + public static Block tfftStorageField5; + public static Block tfftMultiHatch; + + public static Block reactorChamberOFF; + public static Block reactorChamberON; + public static Block reactorControlRod; + + public static Block itemServerDrive; + public static Block itemServerRackCasing; + public static Block itemServerIOPort; + + public static Block itemProxyCable; + public static Block itemProxySource; + public static Block itemProxyEndpoint; + + public static Block jarThaumiumReinforced; + public static Block jarIchor; + + public static Block lscLapotronicEnergyUnit; + + public static Block spaceElevatorStructure; + public static Block spaceElevatorCapacitor; + public static Block spaceElevatorTether; + + public static void preInit() { + KekzCore.LOGGER.info("Registering blocks..."); + + registerBlocks_SOFC(); + registerBlocks_TFFT(); + registerBlocks_Nuclear(); + //registerBlocks_ItemServer(); + //registerBlocks_ItemProxy(); + registerBlocks_Jars(); + registerBlocks_LSC(); + registerBlocks_SpaceElevator(); + + KekzCore.LOGGER.info("Finished registering blocks"); + } + + private static void registerBlocks_SOFC() { + yszUnit = Block_YSZUnit.registerBlock(); + gdcUnit = Block_GDCUnit.registerBlock(); + } + + private static void registerBlocks_TFFT() { + tfftCasing = Block_TFFTCasing.registerBlock(); + tfftStorageField1 = Block_TFFTStorageFieldBlockT1.registerBlock(); + tfftStorageField2 = Block_TFFTStorageFieldBlockT2.registerBlock(); + tfftStorageField3 = Block_TFFTStorageFieldBlockT3.registerBlock(); + tfftStorageField4 = Block_TFFTStorageFieldBlockT4.registerBlock(); + tfftStorageField5 = Block_TFFTStorageFieldBlockT5.registerBlock(); + tfftMultiHatch = Block_TFFTMultiHatch.registerBlock(); + } + + 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(); + jarIchor = Block_IchorJar.registerBlock(); + } + + private static void registerBlocks_LSC() { + lscLapotronicEnergyUnit = Block_LapotronicEnergyUnit.registerBlock(); + } + + private static void registerBlocks_SpaceElevator() { + spaceElevatorStructure = Block_SpaceElevator.registerBlock(); + spaceElevatorCapacitor = Block_SpaceElevatorCapacitor.registerBlock(); + spaceElevatorTether = Block_SpaceElevatorTether.registerBlock(); + } + +} diff --git a/src/main/java/common/Recipes.java b/src/main/java/common/Recipes.java new file mode 100644 index 0000000000..0e3fdfc41f --- /dev/null +++ b/src/main/java/common/Recipes.java @@ -0,0 +1,622 @@ +package common; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +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; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import thaumcraft.api.ItemApi; +import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.aspects.Aspect; +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 { + + public static final HashMap<String, InfusionRecipe> infusionRecipes = new HashMap<>(); + + public static void postInit() { + KekzCore.LOGGER.info("Registering recipes..."); + + registerRecipes_TFFT(); + registerRecipes_SOFC(); + registerRecipes_Nuclear(); + //registerRecipes_ItemServer(); + registerRecipes_Jars(); + registerRecipes_LSC(); + registerRecipes_SpaceElevator(); + + 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 + final Object[] tfft_recipe = { + "HFH", "PVP", "CFC", + 'H', OrePrefixes.pipeMedium.get(Materials.StainlessSteel), + 'F', ItemList.Field_Generator_MV.get(1L), + 'P', ItemList.Electric_Pump_HV.get(1L), + 'V', OrePrefixes.rotor.get(Materials.VibrantAlloy), + 'C', OrePrefixes.circuit.get(Materials.Data) + }; + GT_ModHandler.addCraftingRecipe(KekzCore.fms.getStackForm(1), tfft_recipe); + + // Blocks + final ItemStack[] tfftcasing = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.DarkSteel, 3), + 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_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.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); + } + + private static void registerRecipes_SOFC() { + + final MetaItem_CraftingComponent craftingItem = MetaItem_CraftingComponent.getInstance(); + + // Controller + final Object[] mk1_recipe = { + "CCC", "PHP", "FBL", + 'C', OrePrefixes.circuit.get(Materials.Advanced), + 'P', ItemList.Electric_Pump_HV.get(1L), + 'H', ItemList.Hull_HV.get(1L), + 'F', GT_OreDictUnificator.get(OrePrefixes.pipeSmall, Materials.StainlessSteel, 1), + '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); + final Object[] mk2_recipe = { + "CCC", "PHP", "FBL", + 'C', OrePrefixes.circuit.get(Materials.Master), + 'P', ItemList.Electric_Pump_IV.get(1L), + 'H', ItemList.Hull_IV.get(1L), + 'F', GT_OreDictUnificator.get(OrePrefixes.pipeSmall, Materials.Ultimate, 1), + 'B', Util.getStackofAmountFromOreDict("wireGt04SuperconductorEV", 1), + 'L', GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Ultimate, 1) + }; + GT_ModHandler.addCraftingRecipe(KekzCore.sofc2.getStackForm(1), mk2_recipe); + + // Blocks + final ItemStack[] yszUnit = { + GT_Utility.getIntegratedCircuit(6), + craftingItem.getStackOfAmountFromDamage(Items.YSZCeramicPlate.getMetaID(), 4), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Yttrium, 1), + GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.StainlessSteel, 1), + ItemList.Electric_Motor_HV.get(1L), + }; + GT_Values.RA.addAssemblerRecipe( + yszUnit, + Materials.Hydrogen.getGas(4000), + new ItemStack(Blocks.yszUnit, 1), + 1200, 480); + final ItemStack[] gdcUnit = { + GT_Utility.getIntegratedCircuit(6), + craftingItem.getStackOfAmountFromDamage(Items.GDCCeramicPlate.getMetaID(), 8), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Gadolinium, new ItemStack(ErrorItem.getInstance(), 1), 1), + GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.Desh, new ItemStack(ErrorItem.getInstance(), 1), 1), + ItemList.Electric_Motor_IV.get(1L), + }; + GT_Values.RA.addAssemblerRecipe( + gdcUnit, + Materials.Hydrogen.getGas(16000), + new ItemStack(Blocks.gdcUnit, 1), + 2400, 1920); + + // Items + GT_Values.RA.addAlloySmelterRecipe( + craftingItem.getStackOfAmountFromDamage(Items.YSZCeramicDust.getMetaID(), Loader.isModLoaded("bartworks") ? 3 : 10), + ItemList.Shape_Mold_Plate.get(0), + craftingItem.getStackOfAmountFromDamage(Items.YSZCeramicPlate.getMetaID(), 1), + 400, 480); + GT_Values.RA.addFormingPressRecipe( + craftingItem.getStackOfAmountFromDamage(Items.GDCCeramicDust.getMetaID(), 10), + ItemList.Shape_Mold_Plate.get(0), + craftingItem.getStackOfAmountFromDamage(Items.GDCCeramicPlate.getMetaID(), 1), + 800, 480); + + if (!Loader.isModLoaded("bartworks")) { + GT_Values.RA.addChemicalRecipe( + Materials.Yttrium.getDust(1), GT_Utility.getIntegratedCircuit(6), Materials.Oxygen.getGas(3000), + null, craftingItem.getStackOfAmountFromDamage(Items.YttriaDust.getMetaID(), 1), null, + 400, 30); + GT_Values.RA.addChemicalRecipe( + Util.getStackofAmountFromOreDict("dustZirconium", 1), GT_Utility.getIntegratedCircuit(6), Materials.Oxygen.getGas(2000), + null, craftingItem.getStackOfAmountFromDamage(Items.ZirconiaDust.getMetaID(), 1), null, + 400, 30); + } + + GT_Values.RA.addChemicalRecipe( + Materials.Cerium.getDust(2), GT_Utility.getIntegratedCircuit(6), Materials.Oxygen.getGas(3000), + null, craftingItem.getStackOfAmountFromDamage(Items.CeriaDust.getMetaID(), 2), null, + 400, 30); + GT_Values.RA.addMixerRecipe( + Items.YttriaDust.getOreDictedItemStack(1), + Items.ZirconiaDust.getOreDictedItemStack(5), + GT_Utility.getIntegratedCircuit(6), null, null, null, + craftingItem.getStackOfAmountFromDamage(Items.YSZCeramicDust.getMetaID(), 6), + 400, 96); + GT_Values.RA.addMixerRecipe( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Gadolinium, new ItemStack(ErrorItem.getInstance(), 1), 1), + craftingItem.getStackOfAmountFromDamage(Items.CeriaDust.getMetaID(), 9), + GT_Utility.getIntegratedCircuit(6), null, null, null, + craftingItem.getStackOfAmountFromDamage(Items.GDCCeramicDust.getMetaID(), 10), + 400, 1920); + } + + private static void registerRecipes_Nuclear() { + + final MetaItem_CraftingComponent craftingItem = MetaItem_CraftingComponent.getInstance(); + + // Controller + + // Blocks + final ItemStack[] controlrod = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.Lead, 1), + GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Steel, 4), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Carbon, 64) + }; + GT_Values.RA.addAssemblerRecipe( + controlrod, + null, + new ItemStack(Blocks.reactorControlRod, 1), + 800, 480); + final ItemStack[] reactorchamber = { + GT_Utility.getIntegratedCircuit(6), + GT_OreDictUnificator.get(OrePrefixes.pipeHuge, Materials.Lead, 1), + GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.Lead, 9), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.TungstenSteel, 18), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Steel, 2), + }; + GT_Values.RA.addAssemblerRecipe( + reactorchamber, + FluidRegistry.getFluidStack("wet.concrete", 144), + new ItemStack(Blocks.reactorChamberOFF, 1), + 1600, 480); + + // Items + GT_Values.RA.addMixerRecipe(Materials.Boron.getDust(1), Materials.Arsenic.getDust(1), GT_Utility.getIntegratedCircuit(6), null, + null, null, craftingItem.getStackOfAmountFromDamage(Items.BoronArsenideDust.getMetaID(), 2), + 100, 1920); + GT_Values.RA.addChemicalRecipe( + Materials.Ammonia.getCells(2), + Materials.CarbonDioxide.getCells(1), + null, + null, + craftingItem.getStackOfAmountFromDamage(Items.AmineCarbamiteDust.getMetaID(), 1), + Util.getStackofAmountFromOreDict("cellEmpty", 3), + 400, 30); + GT_Values.RA.addChemicalRecipe( + craftingItem.getStackOfAmountFromDamage(Items.AmineCarbamiteDust.getMetaID(), 1), + Materials.Diamond.getDust(16), + Materials.CarbonDioxide.getGas(1000), + null, + craftingItem.getStackOfAmountFromDamage(Items.IsotopicallyPureDiamondDust.getMetaID(), 1), + null, 1200, 480); + + GT_Values.RA.addAutoclaveRecipe( + craftingItem.getStackOfAmountFromDamage(Items.IsotopicallyPureDiamondDust.getMetaID(), 4), + Materials.CarbonDioxide.getGas(16000), + craftingItem.getStackOfAmountFromDamage(Items.IsotopicallyPureDiamondCrystal.getMetaID(), 1), 10000, 2400, 7680); + GT_Values.RA.addAutoclaveRecipe( + craftingItem.getStackOfAmountFromDamage(Items.BoronArsenideDust.getMetaID(), 4), + Materials.Nitrogen.getGas(4000), + craftingItem.getStackOfAmountFromDamage(Items.BoronArsenideCrystal.getMetaID(), 1), 10000, 2400, 1920); + + GT_Values.RA.addLatheRecipe( + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.AnnealedCopper, 1), + craftingItem.getStackFromDamage(Items.CopperHeatPipe.getMetaID()), + null, 120, 120); + GT_Values.RA.addLatheRecipe( + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Silver, 1), + craftingItem.getStackFromDamage(Items.SilverHeatPipe.getMetaID()), + null, 120, 480); + GT_Values.RA.addLatheRecipe( + craftingItem.getStackOfAmountFromDamage(Items.BoronArsenideCrystal.getMetaID(), 4), + craftingItem.getStackFromDamage(Items.BoronArsenideHeatPipe.getMetaID()), + null, 1200, 1920); + GT_Values.RA.addLatheRecipe( + 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() { + + // Thaumium Reinforced Jar + final ItemStack[] recipe_jarthaumiumreinforced = { + GameRegistry.makeItemStack("Thaumcraft:ItemResource", 15, 1, null), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Thaumium, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Thaumium, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Titanium, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Thaumium, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Thaumium, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + }; + final AspectList aspects_jarthaumiumreinforced = new AspectList() + .add(Aspect.ARMOR, 64) + .add(Aspect.ORDER, 32) + .add(Aspect.WATER, 32) + .add(Aspect.GREED, 16) + .add(Aspect.VOID, 16) + .add(Aspect.AIR, 8); + infusionRecipes.put("THAUMIUMREINFORCEDJAR", + 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 + }; + final AspectList aspects_voidjarupgrade = new AspectList() + .add(Aspect.VOID, 14) + .add(Aspect.MAGIC, 14) + .add(Aspect.ENTROPY, 14) + .add(Aspect.WATER, 14); + infusionRecipes.put("THAUMIUMREINFORCEDVOIDJAR", + ThaumcraftApi.addInfusionCraftingRecipe("THAUMIUMREINFORCEDJAR", new ItemStack(Blocks.jarThaumiumReinforced, 1, 3), + 2, aspects_voidjarupgrade, new ItemStack(Blocks.jarThaumiumReinforced, 1, 0), recipe_voidjarupgrade)); + + final ItemStack[] recipe_jarichor = { + GT_ModHandler.getModItem("ThaumicTinkerer", "kamiResource", 1, 0), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Diamond, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmiridium, 1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Diamond, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + GT_OreDictUnificator.get(OrePrefixes.gemExquisite, Materials.Diamond, 1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Diamond, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmiridium, 1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Diamond, 1), + new ItemStack(net.minecraft.init.Blocks.glass_pane), + }; + final AspectList aspects_jarichor = new AspectList() + .add(Aspect.ARMOR, 256) + .add(Aspect.ELDRITCH, 128) + .add(Aspect.ORDER, 128) + .add(Aspect.WATER, 128) + .add(Aspect.GREED, 64) + .add(Aspect.VOID, 64) + .add(Aspect.AIR, 32); + infusionRecipes.put("ICHORJAR", + ThaumcraftApi.addInfusionCraftingRecipe("ICHORJAR", new ItemStack(Blocks.jarIchor, 1, 0), + 15, aspects_jarichor, ItemApi.getBlock("blockJar", 0), recipe_jarichor)); + // Ichor Void Jar + infusionRecipes.put("ICHORVOIDJAR", + ThaumcraftApi.addInfusionCraftingRecipe("ICHORJAR", new ItemStack(Blocks.jarIchor, 1, 3), + 5, aspects_voidjarupgrade, new ItemStack(Blocks.jarIchor, 1, 0), recipe_voidjarupgrade)); + + } + + private static void registerRecipes_LSC(){ + + // Controller + final Object[] lsc_recipe = { + "LPL", "CBC", "LPL", + 'L', ItemList.IC2_LapotronCrystal.getWithCharge(1L, 10000000), + 'P', ItemList.Circuit_Chip_PIC.get(1L), + 'C', OrePrefixes.circuit.get(Materials.Master), + 'B', new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 0), + }; + GT_ModHandler.addCraftingRecipe(KekzCore.lsc.getStackForm(1), lsc_recipe); + + // Blocks + final Object[] lcBase_recipe = { + "WBW", "RLR", "WBW", + 'W', OrePrefixes.plate.get(Materials.Tantalum), + 'B', OrePrefixes.frameGt.get(Materials.TungstenSteel), + 'R', OrePrefixes.stickLong.get(Materials.TungstenSteel), + 'L', OrePrefixes.block.get(Materials.Lapis) + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 0), lcBase_recipe); + final Object[] lcIV_recipe = { + "SLS", "LOL", "SLS", + 'S', OrePrefixes.screw.get(Materials.Lapis), + 'L', OrePrefixes.plate.get(Materials.Lapis), + 'O', ItemList.Energy_LapotronicOrb.get(1L) + }; + 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) + }, + new FluidStack[] { + Materials.SolderingAlloy.getMolten(2880), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 16000) + }, + ItemList.Energy_Module.get(1), 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) + }, + new FluidStack[] { + Materials.SolderingAlloy.getMolten(2880), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 16000) + }, + ItemList.Energy_Cluster.get(1), 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, 1), + ItemList.Energy_LapotronicOrb.get(1L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Lapis, 4), + 1200, 32); + GT_Values.RA.addUnboxingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 2), + ItemList.Energy_LapotronicOrb2.get(1L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Osmiridium, 24), + 1200, 32); + GT_Values.RA.addUnboxingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 3), + ItemList.Energy_Module.get(1L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.NaquadahAlloy, 24), + 1200, 32); + GT_Values.RA.addUnboxingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 4), + ItemList.Energy_Cluster.get(1L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Neutronium, 24), + 1200, 32); + GT_Values.RA.addUnboxingRecipe(new ItemStack(Blocks.lscLapotronicEnergyUnit, 1, 5), + ItemList.ZPM2.get(1L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.CosmicNeutronium, 24), + 1200, 32); + } + + private static void registerRecipes_SpaceElevator() { + // Controller + final Object[] se_recipe = { + "BCB", "CPC", "BCB", + 'B', new ItemStack(Blocks.spaceElevatorStructure, 1, 0), + 'C', OrePrefixes.cableGt16.get(Materials.Aluminium), + 'P', OrePrefixes.circuit.get(Materials.Master) + }; + GT_ModHandler.addCraftingRecipe(KekzCore.se.getStackForm(1), se_recipe); + // Blocks + final Object[] seBase_recipe = { + "DRD", "RCR", "DRD", + 'D', OrePrefixes.plate.get(Materials.DarkSteel), + 'R', OrePrefixes.stick.get(Materials.Steel), + 'C', OrePrefixes.block.get(Materials.Concrete), + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.spaceElevatorStructure, 1, 0), seBase_recipe); + final Object[] seCoilHolder_recipe = { + "DRD", "RCR", "DRD", + 'D', OrePrefixes.plate.get(Materials.DarkSteel), + 'R', OrePrefixes.ring.get(Materials.Steel), + 'C', OrePrefixes.cableGt01.get(Materials.Aluminium) + }; + GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.spaceElevatorStructure, 1, 1), seCoilHolder_recipe); + } +} diff --git a/src/main/java/common/Researches.java b/src/main/java/common/Researches.java new file mode 100644 index 0000000000..8982a4c583 --- /dev/null +++ b/src/main/java/common/Researches.java @@ -0,0 +1,60 @@ +package common; + +import kekztech.KekzCore; +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.research.ResearchItem; +import thaumcraft.api.research.ResearchPage; +import thaumic.tinkerer.common.research.KamiResearchItem; + +public class Researches { + + public static final String THAUMIUMREINFORCEDJAR = "THAUMIUMREINFORCEDJAR"; + public static final String ICHORJAR = "ICHORJAR"; + + public static void preInit() { + // Blacklist these researches from being a requirement to unlock TTKami + KekzCore.LOGGER.info("Blacklisting research " + THAUMIUMREINFORCEDJAR + " from /iskamiunlocked"); + KamiResearchItem.Blacklist.add(ICHORJAR); + KekzCore.LOGGER.info("Blacklisting research" +ICHORJAR+ "from /iskamiunlocked"); + KamiResearchItem.Blacklist.add(ICHORJAR); + } + + public static void postInit() { + final AspectList aspects_jarthaumiumreinforced = new AspectList() + .add(Aspect.ARMOR, 3) + .add(Aspect.WATER, 3) + .add(Aspect.GREED, 3) + .add(Aspect.VOID, 3); + @SuppressWarnings("unused") + final ResearchItem jar_thaumiumreinforced = new ResearchItem("THAUMIUMREINFORCEDJAR", "ALCHEMY", aspects_jarthaumiumreinforced, 3, -4, 2, new ItemStack(Blocks.jarThaumiumReinforced, 1)) + .setPages( + new ResearchPage("kekztech.research_page.THAUMIUMREINFORCEDJAR.0"), + new ResearchPage(Recipes.infusionRecipes.get("THAUMIUMREINFORCEDJAR")), + new ResearchPage(Recipes.infusionRecipes.get("THAUMIUMREINFORCEDVOIDJAR")), + new ResearchPage("kekztech.research_page.THAUMIUMREINFORCEDJAR.1") + ) + .setConcealed() + .setParents("JARLABEL") + .registerResearchItem(); + + final AspectList aspects_jarichor = new AspectList() + .add(Aspect.ARMOR, 3) + .add(Aspect.ELDRITCH, 3) + .add(Aspect.WATER, 3) + .add(Aspect.GREED, 5) + .add(Aspect.VOID, 5); + @SuppressWarnings("unused") + final ResearchItem jar_ichor = new ResearchItem("ICHORJAR", "ALCHEMY", aspects_jarichor, 2, -5, 3, new ItemStack(Blocks.jarIchor, 1)) + .setPages( + new ResearchPage("kekztech.research_page.ICHORJAR.0"), + new ResearchPage(Recipes.infusionRecipes.get("ICHORJAR")), + new ResearchPage(Recipes.infusionRecipes.get("ICHORVOIDJAR")) + ) + .setConcealed() + .setParents("THAUMIUMREINFORCEDJAR") + .setParentsHidden("ICHOR") + .registerResearchItem(); + } +} diff --git a/src/main/java/common/blocks/BaseGTUpdateableBlock.java b/src/main/java/common/blocks/BaseGTUpdateableBlock.java new file mode 100644 index 0000000000..6f554101ca --- /dev/null +++ b/src/main/java/common/blocks/BaseGTUpdateableBlock.java @@ -0,0 +1,58 @@ +package common.blocks; + + +import gregtech.api.GregTech_API; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +/** + * Any blocks that are used as structure parts for GregTech multi machines + * have to inherit from this class. Otherwise the checkMachine() method + * that verifies a machine's structure won't be called correctly. + */ +public abstract class BaseGTUpdateableBlock extends Block { + + protected BaseGTUpdateableBlock(Material material) { + super(material); + GregTech_API.registerMachineBlock(this, -1); + super.setHarvestLevel("wrench", 2); + } + + @Override + public int damageDropped(int meta){ + return meta; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } +} diff --git a/src/main/java/common/blocks/Block_ControlRod.java b/src/main/java/common/blocks/Block_ControlRod.java new file mode 100644 index 0000000000..808881dead --- /dev/null +++ b/src/main/java/common/blocks/Block_ControlRod.java @@ -0,0 +1,28 @@ +package common.blocks; + +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_ControlRod extends BaseGTUpdateableBlock { + + private static final Block_ControlRod instance = new Block_ControlRod(); + + private Block_ControlRod() { + super(Material.iron); + } + + public static Block registerBlock() { + final String blockName = "kekztech_controlrod_block"; + instance.setBlockName(blockName); + instance.setCreativeTab(CreativeTabs.tabMisc); + instance.setBlockTextureName(KekzCore.MODID + ":" + "ControlRod"); + instance.setHardness(5.0f); + instance.setResistance(6.0f); + GameRegistry.registerBlock(instance, blockName); + + return instance; + } +} diff --git a/src/main/java/common/blocks/Block_GDCUnit.java b/src/main/java/common/blocks/Block_GDCUnit.java new file mode 100644 index 0000000000..aab81e1aeb --- /dev/null +++ b/src/main/java/common/blocks/Block_GDCUnit.java @@ -0,0 +1,28 @@ +package common.blocks;
+
+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_GDCUnit extends BaseGTUpdateableBlock {
+
+ private static final Block_GDCUnit instance = new Block_GDCUnit();
+
+ private Block_GDCUnit() {
+ super(Material.iron);
+ }
+
+ public static Block registerBlock() {
+ final String blockName = "kekztech_gdcceramicelectrolyteunit_block";
+ instance.setBlockName(blockName);
+ instance.setCreativeTab(CreativeTabs.tabMisc);
+ instance.setBlockTextureName(KekzCore.MODID + ":" + "GDCCeramicElectrolyteUnit");
+ instance.setHardness(5.0f);
+ instance.setResistance(6.0f);
+ GameRegistry.registerBlock(instance, blockName);
+
+ return instance;
+ }
+}
diff --git a/src/main/java/common/blocks/Block_IchorJar.java b/src/main/java/common/blocks/Block_IchorJar.java new file mode 100644 index 0000000000..560fd0c37b --- /dev/null +++ b/src/main/java/common/blocks/Block_IchorJar.java @@ -0,0 +1,222 @@ +package common.blocks; + +import common.itemBlocks.IB_IchorJar; +import common.tileentities.TE_IchorJar; +import common.tileentities.TE_IchorVoidJar; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.blocks.BlockJar; +import thaumcraft.common.config.ConfigBlocks; +import thaumcraft.common.config.ConfigItems; +import thaumcraft.common.items.ItemEssence; +import thaumcraft.common.tiles.TileJarFillable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Block_IchorJar extends BlockJar { + + private static final Block_IchorJar INSTANCE = new Block_IchorJar(); + + private Block_IchorJar() { + super(); + + super.setHardness(12.0F); + super.setResistance(3.0f); + } + + public static Block registerBlock() { + final String blockName = "kekztech_ichorjar_block"; + INSTANCE.setBlockName(blockName); + GameRegistry.registerBlock(INSTANCE, IB_IchorJar.class, blockName); + + return INSTANCE; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister ir) { + super.iconLiquid = ir.registerIcon("thaumcraft:animatedglow"); + super.iconJarSide = ir.registerIcon("kekztech:ichor_jar_side"); + super.iconJarTop = ir.registerIcon("kekztech:ichor_jar_top"); + super.iconJarTopVoid = ir.registerIcon("kekztech:ichor_jar_top_void"); + super.iconJarSideVoid = ir.registerIcon("kekztech:ichor_jar_side_void"); + super.iconJarBottom = ir.registerIcon("kekztech:ichor_jar_bottom"); + } + + @Override + @SideOnly(Side.CLIENT) + @SuppressWarnings({"unchecked"}) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 0)); // Normal jar + par3List.add(new ItemStack(par1, 1, 3)); // Void jar + } + + @Override + public TileEntity createTileEntity(World world, int meta) { + if(meta == 3) { + return new TE_IchorVoidJar(); + } else { + return new TE_IchorJar(); + } + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float f1, float f2, float f3) { + // Call parent method to handle jar emptying, labels stuff etc + super.onBlockActivated(world, x, y, z, player, side, f1, f2, f3); + // Interact with Essentia Phials if the player holds one + final ItemStack heldItem = player.getHeldItem(); + if(heldItem != null && heldItem.getItem() == ConfigItems.itemEssence) { + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_IchorJar) { + return dealWithPhial(world, player, x, y, z); + } else if(te instanceof TE_IchorVoidJar) { + return dealWithPhial(world, player, x, y, z); + } + } + + return true; + } + + /** + * Handle compatibility with Essentia Phials + * @param world + * Pass through from onBlockActivated() + * @param player + * Pass through from onBlockActivated() + * @param x + * Pass through from onBlockActivated() + * @param y + * Pass through from onBlockActivated() + * @param z + * Pass through from onBlockActivated() + * @return Not sure tbh + */ + private boolean dealWithPhial(World world, EntityPlayer player, int x, int y, int z) { + final TileJarFillable jarTE = (TileJarFillable) world.getTileEntity(x, y, z); + final ItemStack heldItem = player.getHeldItem(); + // Check whether to fill or to drain the phial + if(heldItem.getItemDamage() == 0) { + if(jarTE.amount >= 8){ + if (world.isRemote) { + player.swingItem(); + return false; + } + + final Aspect jarAspect = Aspect.getAspect(jarTE.aspect.getTag()); + if(jarTE.takeFromContainer(jarAspect, 8)) { + // Take an empty phial from the player's inventory + heldItem.stackSize--; + // Fill a new phial + final ItemStack filledPhial = new ItemStack(ConfigItems.itemEssence, 1, 1); + final AspectList phialContent = new AspectList().add(jarAspect, 8); + ((ItemEssence) ConfigItems.itemEssence).setAspects(filledPhial, phialContent); + // Drop on ground if there's no inventory space + if (!player.inventory.addItemStackToInventory(filledPhial)) { + world.spawnEntityInWorld(new EntityItem(world, (float)x + 0.5F, (float)y + 0.5F, (float)z + 0.5F, filledPhial)); + } + + world.playSoundAtEntity(player, "game.neutral.swim", 0.25F, 1.0F); + player.inventoryContainer.detectAndSendChanges(); + return true; + } + } + } else { + final AspectList phialContent = ((ItemEssence) ConfigItems.itemEssence).getAspects(heldItem); + if(phialContent != null && phialContent.size() == 1) { + final Aspect phialAspect = phialContent.getAspects()[0]; + if(jarTE.amount + 8 <= jarTE.maxAmount && jarTE.doesContainerAccept(phialAspect)) { + if (world.isRemote) { + player.swingItem(); + return false; + } + + if(jarTE.addToContainer(phialAspect, 8) == 0) { + world.markBlockForUpdate(x, y, z); + jarTE.markDirty(); + heldItem.stackSize--; + // Drop on ground if there's no inventory space + if (!player.inventory.addItemStackToInventory(new ItemStack(ConfigItems.itemEssence, 1, 0))) { + world.spawnEntityInWorld(new EntityItem(world, (float)x + 0.5F, (float)y + 0.5F, (float)z + 0.5F, new ItemStack(ConfigItems.itemEssence, 1, 0))); + } + + world.playSoundAtEntity(player, "game.neutral.swim", 0.25F, 1.0F); + player.inventoryContainer.detectAndSendChanges(); + return true; + } + } + } + } + + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_IchorJar) { + final TE_IchorJar ite = (TE_IchorJar) te; + breakBlockWarpy(world, x, y, z, ite.amount, 200, 6.0F); + } else if(te instanceof TE_IchorVoidJar) { + final TE_IchorVoidJar ite = (TE_IchorVoidJar) te; + breakBlockWarpy(world, x, y, z, ite.amount, 200, 6.0F); + } + super.breakBlock(world, x, y, z, par5, par6); + } + + private void breakBlockWarpy(World world, int x, int y, int z, int fillAmount, int iterations, float explosionStrength){ + if(fillAmount > 0) { + // Create a decent explosion in the center of the block (TNT has strength 4.0F) + world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, explosionStrength, false); + + // Place a lot of Flux in the area + final int limit = fillAmount / 16; + int created = 0; + for(int i = 0; i < iterations; i++) { + final int xf = x + world.rand.nextInt(7) - world.rand.nextInt(7); + final int yf = x + world.rand.nextInt(7) - world.rand.nextInt(7); + final int zf = x + world.rand.nextInt(7) - world.rand.nextInt(7); + if(world.isAirBlock(xf, yf, zf)) { + if(yf > y) { + world.setBlock(xf, yf, zf, ConfigBlocks.blockFluxGas, 8, 3); + } else { + world.setBlock(xf, yf, zf, ConfigBlocks.blockFluxGoo, 8, 3); + } + + if(created++ > limit) { + break; + } + } + } + } + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(Collections.singleton(new ItemStack(this, 1, (meta == 3) ? 3 : 0))); + } + + @Override + public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + } + + @Override + public boolean canDropFromExplosion(Explosion e) { + return false; + } +} diff --git a/src/main/java/common/blocks/Block_ItemProxyCable.java b/src/main/java/common/blocks/Block_ItemProxyCable.java new file mode 100644 index 0000000000..ce2f1e9820 --- /dev/null +++ b/src/main/java/common/blocks/Block_ItemProxyCable.java @@ -0,0 +1,66 @@ +package common.blocks; + +import common.itemBlocks.IB_ItemProxyCable; +import common.tileentities.TE_ItemProxyCable; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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; +import client.renderer.ConduitRenderer; + +public class Block_ItemProxyCable extends Block { + + private static Block_ItemProxyCable instance = new Block_ItemProxyCable(); + + private Block_ItemProxyCable() { + super(Material.glass); + } + + public static Block registerBlock() { + final String blockName = "kekztech_itemproxycable_block"; + instance.setBlockName(blockName); + instance.setCreativeTab(CreativeTabs.tabMisc); + instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTCasing"); + instance.setHardness(3.0f); + instance.setResistance(2.0f); + GameRegistry.registerBlock(instance, IB_ItemProxyCable.class, blockName); + + return instance; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createTileEntity(World world, int p_149915_2_) { + return new TE_ItemProxyCable(); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public int getRenderType() { + return ConduitRenderer.RID; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } +} diff --git a/src/main/java/common/blocks/Block_ItemProxyEndpoint.java b/src/main/java/common/blocks/Block_ItemProxyEndpoint.java new file mode 100644 index 0000000000..00e0426250 --- /dev/null +++ b/src/main/java/common/blocks/Block_ItemProxyEndpoint.java @@ -0,0 +1,61 @@ +package common.blocks; + +import common.itemBlocks.IB_ItemProxyEndpoint; +import common.tileentities.TE_ItemProxyEndpoint; +import cpw.mods.fml.common.registry.GameRegistry; +import kekztech.GuiHandler; +import kekztech.KekzCore; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Block_ItemProxyEndpoint extends Block { + + private static final Block_ItemProxyEndpoint instance = new Block_ItemProxyEndpoint(); + + private Block_ItemProxyEndpoint() { + super(Material.glass); + } + + public static Block registerBlock() { + final String blockName = "kekztech_itemproxyendpoint_block"; + instance.setBlockName(blockName); + instance.setCreativeTab(CreativeTabs.tabMisc); + instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemProxyEndpoint"); + instance.setHardness(3.0f); + instance.setResistance(2.0f); + instance.setHarvestLevel("wrench", 2); + GameRegistry.registerBlock(instance, IB_ItemProxyEndpoint.class, blockName); + + return instance; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) { + if(world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_ItemProxyEndpoint) { + player.openGui(KekzCore.instance, GuiHandler.ITEM_PROXY_ENDPOINT, world, x, y, z); + return true; + } else { + return false; + } + } + + @Override + public TileEntity createTileEntity(World world, int p_149915_2_) { + return new TE_ItemProxyEndpoint(); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + +}
\ No newline at end of file diff --git a/src/main/java/common/blocks/Block_ItemProxySource.java b/src/main/java/common/blocks/Block_ItemProxySource.java new file mode 100644 index 0000000000..7291c15e6f --- /dev/null +++ b/src/main/java/common/blocks/Block_ItemProxySource.java @@ -0,0 +1,61 @@ +package common.blocks; + +import common.itemBlocks.IB_ItemProxySource; +import common.tileentities.TE_ItemProxySource; +import cpw.mods.fml.common.registry.GameRegistry; +import kekztech.GuiHandler; +import kekztech.KekzCore; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Block_ItemProxySource extends Block { + + private static final Block_ItemProxySource instance = new Block_ItemProxySource(); + + private Block_ItemProxySource() { + super(Material.glass); + } + + public static Block registerBlock() { + final String blockName = "kekztech_itemproxysource_block"; + instance.setBlockName(blockName); + instance.setCreativeTab(CreativeTabs.tabMisc); + instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemProxySource"); + instance.setHardness(3.0f); + instance.setResistance(2.0f); + instance.setHarvestLevel("wrench", 2); + GameRegistry.registerBlock(instance, IB_ItemProxySource.class, blockName); + + return instance; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) { + if(world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_ItemProxySource) { + player.openGui(KekzCore.instance, GuiHandler.ITEM_PROXY_SOURCE, world, x, y, z); + return true; + } else { + return false; + } + } + + @Override + public TileEntity createTileEntity(World world, int p_149915_2_) { + return new TE_ItemProxySource(); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + +} diff --git a/src/main/java/common/blocks/Block_ItemServerDrive.java b/src/main/java/common/blocks/Block_ItemServerDrive.java new file mode 100644 index 0000000000..63747a8598 --- /dev/null +++ b/src/main/java/common/blocks/Block_ItemServerDrive.java @@ -0,0 +1,57 @@ +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 new file mode 100644 index 0000000000..6af90b6e42 --- /dev/null +++ b/src/main/java/common/blocks/Block_ItemServerIOPort.java @@ -0,0 +1,43 @@ +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 new file mode 100644 index 0000000000..db0ec9c3e6 --- /dev/null +++ b/src/main/java/common/blocks/Block_ItemServerRackCasing.java @@ -0,0 +1,30 @@ +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 new file mode 100644 index 0000000000..9a6aad0b5b --- /dev/null +++ b/src/main/java/common/blocks/Block_LapotronicEnergyUnit.java @@ -0,0 +1,93 @@ +package common.blocks; + +import java.util.List; + +import common.itemBlocks.IB_LapotronicEnergyUnit; +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.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class Block_LapotronicEnergyUnit extends BaseGTUpdateableBlock { + + private static final Block_LapotronicEnergyUnit instance = new Block_LapotronicEnergyUnit(); + + private IIcon iconBaseSide; + private IIcon iconBaseTop; + + private IIcon iconLapoIVSide; + private IIcon iconLapoIVTop; + private IIcon iconLapoLuVSide; + private IIcon iconLapoLuVTop; + private IIcon iconLapoZPMSide; + private IIcon iconLapoZPMTop; + private IIcon iconLapoUVSide; + private IIcon iconLapoUVTop; + private IIcon iconUltimateSide; + private IIcon iconUltimateTop; + + private Block_LapotronicEnergyUnit() { + super(Material.iron); + } + + 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; + } + + @Override + public void registerBlockIcons(IIconRegister ir) { + iconBaseSide = ir.registerIcon("kekztech:LSCBase_side"); + iconBaseTop = ir.registerIcon("kekztech:LSCBase_top"); + + iconLapoIVSide = ir.registerIcon("kekztech:LapotronicEnergyUnit1_side"); + iconLapoIVTop = ir.registerIcon("kekztech:LapotronicEnergyUnit1_top"); + iconLapoLuVSide = ir.registerIcon("kekztech:LapotronicEnergyUnit2_side"); + iconLapoLuVTop = ir.registerIcon("kekztech:LapotronicEnergyUnit2_top"); + iconLapoZPMSide = ir.registerIcon("kekztech:LapotronicEnergyUnit3_side"); + iconLapoZPMTop = ir.registerIcon("kekztech:LapotronicEnergyUnit3_top"); + iconLapoUVSide = ir.registerIcon("kekztech:LapotronicEnergyUnit4_side"); + iconLapoUVTop = ir.registerIcon("kekztech:LapotronicEnergyUnit4_top"); + + iconUltimateSide = ir.registerIcon("kekztech:UltimateEnergyUnit_side"); + iconUltimateTop = ir.registerIcon("kekztech:UltimateEnergyUnit_top"); + } + + @Override + @SuppressWarnings({"unchecked" }) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + // Multi casing + par3List.add(new ItemStack(par1, 1, 0)); + // Lapo units IV - UV + par3List.add(new ItemStack(par1, 1, 1)); + par3List.add(new ItemStack(par1, 1, 2)); + par3List.add(new ItemStack(par1, 1, 3)); + par3List.add(new ItemStack(par1, 1, 4)); + // Ultimate battery + par3List.add(new ItemStack(par1, 1, 5)); + } + + @Override + public IIcon getIcon(int side, int meta) { + switch(meta) { + case 0: return (side < 2) ? iconBaseTop : iconBaseSide; + case 1: return (side < 2) ? iconLapoIVTop : iconLapoIVSide; + case 2: return (side < 2) ? iconLapoLuVTop : iconLapoLuVSide; + case 3: return (side < 2) ? iconLapoZPMTop : iconLapoZPMSide; + case 4: return (side < 2) ? iconLapoUVTop : iconLapoUVSide; + case 5: return (side < 2) ? iconUltimateTop : iconUltimateSide; + default: return iconUltimateTop; + } + } + +} diff --git a/src/main/java/common/blocks/Block_ReactorChamber_OFF.java b/src/main/java/common/blocks/Block_ReactorChamber_OFF.java new file mode 100644 index 0000000000..e6a5b3c3b3 --- /dev/null +++ b/src/main/java/common/blocks/Block_ReactorChamber_OFF.java @@ -0,0 +1,29 @@ +package common.blocks; + +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_ReactorChamber_OFF extends BaseGTUpdateableBlock { + + private static Block_ReactorChamber_OFF instance = new Block_ReactorChamber_OFF(); + + private Block_ReactorChamber_OFF() { + super(Material.iron); + } + + public static Block registerBlock() { + final String blockName = "kekztech_reactorchamberoff_block"; + instance.setBlockName(blockName); + instance.setCreativeTab(CreativeTabs.tabMisc); + instance.setBlockTextureName(KekzCore.MODID + ":" + "ReactorChamber_OFF"); + instance.setHardness(10.0f); + instance.setResistance(16.0f); + GameRegistry.registerBlock(instance, blockName); + + return instance; + } + +} diff --git a/src/main/java/common/blocks/Block_ReactorChamber_ON.java b/src/main/java/common/blocks/Block_ReactorChamber_ON.java new file mode 100644 index 0000000000..0c7e230a11 --- /dev/null +++ b/src/main/java/common/blocks/Block_ReactorChamber_ON.java @@ -0,0 +1,34 @@ +package common.blocks; + +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_ReactorChamber_ON extends BaseGTUpdateableBlock { + + private static Block_ReactorChamber_ON instance = new Block_ReactorChamber_ON(); + + private Block_ReactorChamber_ON() { + super(Material.iron); + } + + public static Block registerBlock() { + final String blockName = "kekztech_reactorchamberon_block"; + instance.setBlockName(blockName); + instance.setCreativeTab(CreativeTabs.tabMisc); + instance.setBlockTextureName(KekzCore.MODID + ":" + "ReactorChamber_ON"); + instance.setHardness(-1.0f); + instance.setResistance(16.0f); + GameRegistry.registerBlock(instance, blockName); + + return instance; + } + + @Override + public int getLightValue() { + return 15; + } + +} diff --git a/src/main/java/common/blocks/Block_SpaceElevator.java b/src/main/java/common/blocks/Block_SpaceElevator.java new file mode 100644 index 0000000000..524f34ba46 --- /dev/null +++ b/src/main/java/common/blocks/Block_SpaceElevator.java @@ -0,0 +1,61 @@ +package common.blocks; + +import common.itemBlocks.IB_SpaceElevator; +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.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import java.util.List; + +public class Block_SpaceElevator extends BaseGTUpdateableBlock { + + private static final Block_SpaceElevator INSTANCE = new Block_SpaceElevator(); + + private IIcon baseTop; + private IIcon baseSide; + private IIcon coilHolder; + + private Block_SpaceElevator() { + super(Material.iron); + } + + public static Block registerBlock() { + final String blockName = "kekztech_spaceelevator_block"; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(7.0f); + INSTANCE.setResistance(10.0f); + GameRegistry.registerBlock(INSTANCE, IB_SpaceElevator.class, blockName); + + return INSTANCE; + } + + @Override + public void registerBlockIcons(IIconRegister ir) { + baseTop = ir.registerIcon("kekztech:SpaceElevatorBase_top"); + baseSide = ir.registerIcon("kekztech:SpaceElevatorBase_side"); + coilHolder = ir.registerIcon("kekztech:CoilHolder"); + } + + @Override + @SuppressWarnings({"unchecked" }) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 0)); + par3List.add(new ItemStack(par1, 1, 1)); + } + + @Override + public IIcon getIcon(int side, int meta) { + if(meta == 0) { + return (side < 2) ? baseTop : baseSide; + } else { + return coilHolder; + } + } +} diff --git a/src/main/java/common/blocks/Block_SpaceElevatorCapacitor.java b/src/main/java/common/blocks/Block_SpaceElevatorCapacitor.java new file mode 100644 index 0000000000..509c8a681d --- /dev/null +++ b/src/main/java/common/blocks/Block_SpaceElevatorCapacitor.java @@ -0,0 +1,80 @@ +package common.blocks; + +import common.itemBlocks.IB_SpaceElevatorCapacitor; +import common.tileentities.TE_SpaceElevatorCapacitor; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class Block_SpaceElevatorCapacitor extends BaseGTUpdateableBlock { + + private static final Block_SpaceElevatorCapacitor INSTANCE = new Block_SpaceElevatorCapacitor(); + + private IIcon top; + private IIcon side; + + private Block_SpaceElevatorCapacitor() { + super(Material.iron); + } + + public static Block registerBlock() { + final String blockName = "kekztech_spaceelevatorcapacitor_block"; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(5.0f); + INSTANCE.setResistance(3.0f); + GameRegistry.registerBlock(INSTANCE, IB_SpaceElevatorCapacitor.class, blockName); + + return INSTANCE; + } + + @Override + public void registerBlockIcons(IIconRegister ir) { + top = ir.registerIcon("kekztech:SpaceElevatorCapacitor_top_fullbase"); + side = ir.registerIcon("kekztech:SpaceElevatorCapacitor_side_fullbase"); + } + + @Override + public IIcon getIcon(int side, int meta) { + return (side < 2) ? this.top : this.side; + } + + @Override + public TileEntity createTileEntity(World world, int p_149915_2_) { + return new TE_SpaceElevatorCapacitor(); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + return false; + } + + @Override + public int getLightValue() { + return 2; + } +} diff --git a/src/main/java/common/blocks/Block_SpaceElevatorTether.java b/src/main/java/common/blocks/Block_SpaceElevatorTether.java new file mode 100644 index 0000000000..3031cd8a12 --- /dev/null +++ b/src/main/java/common/blocks/Block_SpaceElevatorTether.java @@ -0,0 +1,70 @@ +package common.blocks; + +import common.tileentities.TE_ItemProxyCable; +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.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class Block_SpaceElevatorTether extends BaseGTUpdateableBlock { + + private static final Block_SpaceElevatorTether INSTANCE = new Block_SpaceElevatorTether(); + + private IIcon top; + private IIcon side; + + private Block_SpaceElevatorTether() { + super(Material.glass); + } + + public static Block registerBlock() { + final String blockName = "kekztech_spaceelevatortether_block"; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(15.0f); + INSTANCE.setResistance(15.0f); + GameRegistry.registerBlock(INSTANCE, blockName); + + return INSTANCE; + } + + @Override + public void registerBlockIcons(IIconRegister ir) { + top = ir.registerIcon("kekztech:Tether_top"); + side = ir.registerIcon("kekztech:Tether_side"); + } + + @Override + public IIcon getIcon(int side, int meta) { + return (side < 2) ? this.top : this.side; + } + + @Override + public TileEntity createTileEntity(World world, int p_149915_2_) { + return new TE_SpaceElevatorTether(); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + +} diff --git a/src/main/java/common/blocks/Block_TFFTCasing.java b/src/main/java/common/blocks/Block_TFFTCasing.java new file mode 100644 index 0000000000..5815a75862 --- /dev/null +++ b/src/main/java/common/blocks/Block_TFFTCasing.java @@ -0,0 +1,28 @@ +package common.blocks;
+
+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_TFFTCasing extends BaseGTUpdateableBlock {
+
+ private static Block_TFFTCasing instance = new Block_TFFTCasing();
+
+ private Block_TFFTCasing() {
+ super(Material.iron);
+ }
+
+ public static Block registerBlock() {
+ final String blockName = "kekztech_tfftcasingblock_block";
+ instance.setBlockName(blockName);
+ instance.setCreativeTab(CreativeTabs.tabMisc);
+ instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTCasing");
+ instance.setHardness(5.0f);
+ instance.setResistance(6.0f);
+ GameRegistry.registerBlock(instance, blockName);
+
+ return instance;
+ }
+}
diff --git a/src/main/java/common/blocks/Block_TFFTMultiHatch.java b/src/main/java/common/blocks/Block_TFFTMultiHatch.java new file mode 100644 index 0000000000..be7b588fa5 --- /dev/null +++ b/src/main/java/common/blocks/Block_TFFTMultiHatch.java @@ -0,0 +1,65 @@ +package common.blocks; + +import common.itemBlocks.IB_TFFTMultiHatch; +import common.tileentities.TE_TFFTMultiHatch; +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.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { + + private static Block_TFFTMultiHatch instance = new Block_TFFTMultiHatch(); + + 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; + } + + @Override + public TileEntity createTileEntity(World world, int p_149915_2_) { + return new TE_TFFTMultiHatch(); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @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; + } +} diff --git a/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT1.java b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT1.java new file mode 100644 index 0000000000..f7554c4724 --- /dev/null +++ b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT1.java @@ -0,0 +1,38 @@ +package common.blocks;
+
+import common.itemBlocks.IB_TFFTStorageFieldBlockT1;
+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_TFFTStorageFieldBlockT1 extends BaseGTUpdateableBlock {
+
+ private static Block_TFFTStorageFieldBlockT1 instance;
+
+ private Block_TFFTStorageFieldBlockT1() {
+ super(Material.iron);
+ }
+
+ public static int getCapacity() {
+ return 500000;
+ }
+
+ public static Block registerBlock() {
+ if(instance == null) {
+ instance = new Block_TFFTStorageFieldBlockT1();
+ }
+
+ final String blockName = "kekztech_tfftstoragefieldblock1_block";
+ instance.setBlockName(blockName);
+ instance.setCreativeTab(CreativeTabs.tabMisc);
+ instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTStorageFieldBlock1");
+ instance.setHardness(5.0f);
+ instance.setResistance(6.0f);
+ GameRegistry.registerBlock(instance, IB_TFFTStorageFieldBlockT1.class, blockName);
+
+ return instance;
+ }
+
+}
diff --git a/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT2.java b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT2.java new file mode 100644 index 0000000000..394fbcf90f --- /dev/null +++ b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT2.java @@ -0,0 +1,37 @@ +package common.blocks;
+
+import common.itemBlocks.IB_TFFTStorageFieldBlockT2;
+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_TFFTStorageFieldBlockT2 extends BaseGTUpdateableBlock {
+
+ private static Block_TFFTStorageFieldBlockT2 instance;
+
+ private Block_TFFTStorageFieldBlockT2() {
+ super(Material.iron);
+ }
+
+ public static int getCapacity() {
+ return 4000000;
+ }
+
+ public static Block registerBlock() {
+ if(instance == null) {
+ instance = new Block_TFFTStorageFieldBlockT2();
+ }
+
+ final String blockName = "kekztech_tfftstoragefieldblock2_block";
+ instance.setBlockName(blockName);
+ instance.setCreativeTab(CreativeTabs.tabMisc);
+ instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTStorageFieldBlock2");
+ instance.setHardness(5.0f);
+ instance.setResistance(6.0f);
+ GameRegistry.registerBlock(instance, IB_TFFTStorageFieldBlockT2.class, blockName);
+
+ return instance;
+ }
+}
diff --git a/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT3.java b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT3.java new file mode 100644 index 0000000000..0b2123ae87 --- /dev/null +++ b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT3.java @@ -0,0 +1,37 @@ +package common.blocks;
+
+import common.itemBlocks.IB_TFFTStorageFieldBlockT3;
+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_TFFTStorageFieldBlockT3 extends BaseGTUpdateableBlock {
+
+ private static Block_TFFTStorageFieldBlockT3 instance;
+
+ private Block_TFFTStorageFieldBlockT3() {
+ super(Material.iron);
+ }
+
+ public static int getCapacity() {
+ return 16000000;
+ }
+
+ public static Block registerBlock() {
+ if(instance == null) {
+ instance = new Block_TFFTStorageFieldBlockT3();
+ }
+
+ final String blockName = "kekztech_tfftstoragefieldblock3_block";
+ instance.setBlockName(blockName);
+ instance.setCreativeTab(CreativeTabs.tabMisc);
+ instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTStorageFieldBlock3");
+ instance.setHardness(5.0f);
+ instance.setResistance(6.0f);
+ GameRegistry.registerBlock(instance, IB_TFFTStorageFieldBlockT3.class, blockName);
+
+ return instance;
+ }
+}
diff --git a/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT4.java b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT4.java new file mode 100644 index 0000000000..138c66ac0c --- /dev/null +++ b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT4.java @@ -0,0 +1,37 @@ +package common.blocks;
+
+import common.itemBlocks.IB_TFFTStorageFieldBlockT4;
+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_TFFTStorageFieldBlockT4 extends BaseGTUpdateableBlock {
+
+ private static Block_TFFTStorageFieldBlockT4 instance;
+
+ private Block_TFFTStorageFieldBlockT4() {
+ super(Material.iron);
+ }
+
+ public static int getCapacity() {
+ return 64000000;
+ }
+
+ public static Block registerBlock() {
+ if(instance == null) {
+ instance = new Block_TFFTStorageFieldBlockT4();
+ }
+
+ final String blockName = "kekztech_tfftstoragefieldblock4_block";
+ instance.setBlockName(blockName);
+ instance.setCreativeTab(CreativeTabs.tabMisc);
+ instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTStorageFieldBlock4");
+ instance.setHardness(5.0f);
+ instance.setResistance(6.0f);
+ GameRegistry.registerBlock(instance, IB_TFFTStorageFieldBlockT4.class, blockName);
+
+ return instance;
+ }
+}
diff --git a/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT5.java b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT5.java new file mode 100644 index 0000000000..7e30695804 --- /dev/null +++ b/src/main/java/common/blocks/Block_TFFTStorageFieldBlockT5.java @@ -0,0 +1,37 @@ +package common.blocks; + +import common.itemBlocks.IB_TFFTStorageFieldBlockT5; +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_TFFTStorageFieldBlockT5 extends BaseGTUpdateableBlock { + + private static Block_TFFTStorageFieldBlockT5 instance; + + private Block_TFFTStorageFieldBlockT5() { + super(Material.iron); + } + + public static int getCapacity() { + return 256000000; + } + + public static Block registerBlock() { + if(instance == null) { + instance = new Block_TFFTStorageFieldBlockT5(); + } + + final String blockName = "kekztech_tfftstoragefieldblock5_block"; + instance.setBlockName(blockName); + instance.setCreativeTab(CreativeTabs.tabMisc); + instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTStorageFieldBlock5"); + instance.setHardness(5.0f); + instance.setResistance(6.0f); + GameRegistry.registerBlock(instance, IB_TFFTStorageFieldBlockT5.class, blockName); + + return instance; + } +}
\ No newline at end of file diff --git a/src/main/java/common/blocks/Block_ThaumiumReinforcedJar.java b/src/main/java/common/blocks/Block_ThaumiumReinforcedJar.java new file mode 100644 index 0000000000..61ca0e2390 --- /dev/null +++ b/src/main/java/common/blocks/Block_ThaumiumReinforcedJar.java @@ -0,0 +1,244 @@ +package common.blocks; + +import common.itemBlocks.IB_ThaumiumReinforcedJar; +import common.tileentities.TE_ThaumiumReinforcedJar; +import common.tileentities.TE_ThaumiumReinforcedVoidJar; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.blocks.BlockJar; +import thaumcraft.common.config.ConfigBlocks; +import thaumcraft.common.config.ConfigItems; +import thaumcraft.common.items.ItemEssence; +import thaumcraft.common.tiles.TileJarFillable; + +import java.util.ArrayList; +import java.util.List; + +public class Block_ThaumiumReinforcedJar extends BlockJar { + + private static final Block_ThaumiumReinforcedJar instance = new Block_ThaumiumReinforcedJar(); + + private Block_ThaumiumReinforcedJar() { + super(); + + super.setHardness(6.0F); + super.setResistance(6.0F); + } + + public static Block registerBlock() { + final String blockName = "kekztech_thaumiumreinforcedjar_block"; + instance.setBlockName(blockName); + GameRegistry.registerBlock(instance, IB_ThaumiumReinforcedJar.class, blockName); + + return instance; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister ir) { + super.iconLiquid = ir.registerIcon("thaumcraft:animatedglow"); + super.iconJarSide = ir.registerIcon("kekztech:thaumreinforced_jar_side"); + super.iconJarTop = ir.registerIcon("kekztech:thaumreinforced_jar_top"); + super.iconJarTopVoid = ir.registerIcon("kekztech:thaumreinforced_jar_top_void"); + super.iconJarSideVoid = ir.registerIcon("kekztech:thaumreinforced_jar_side_void"); + super.iconJarBottom = ir.registerIcon("kekztech:thaumreinforced_jar_bottom"); + } + + @Override + @SideOnly(Side.CLIENT) + @SuppressWarnings({"unchecked"}) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 0)); // Normal jar + par3List.add(new ItemStack(par1, 1, 3)); // Void jar + } + + @Override + public TileEntity createTileEntity(World world, int meta) { + if(meta == 3) { + return new TE_ThaumiumReinforcedVoidJar(); + } else { + return new TE_ThaumiumReinforcedJar(); + } + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_ThaumiumReinforcedJar) { + final TE_ThaumiumReinforcedJar ite = (TE_ThaumiumReinforcedJar) te; + breakBlockWarpy(world, x, y, z, ite.amount, 50, 1.0F); + } else if(te instanceof TE_ThaumiumReinforcedVoidJar) { + final TE_ThaumiumReinforcedVoidJar ite = (TE_ThaumiumReinforcedVoidJar) te; + breakBlockWarpy(world, x, y, z, ite.amount, 50, 1.0F); + } + super.breakBlock(world, x, y, z, par5, par6); + } + + private void breakBlockWarpy(World world, int x, int y, int z, int fillAmount, int iterations, float explosionStrength){ + if(fillAmount > 0) { + // Create a decent explosion in the center of the block (TNT has strength 4.0F) + world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, explosionStrength, false); + + // Place a lot of Flux in the area + final int limit = fillAmount / 16; + int created = 0; + for(int i = 0; i < iterations; i++) { + final int xf = x + world.rand.nextInt(7) - world.rand.nextInt(7); + final int yf = x + world.rand.nextInt(7) - world.rand.nextInt(7); + final int zf = x + world.rand.nextInt(7) - world.rand.nextInt(7); + if(world.isAirBlock(xf, yf, zf)) { + if(yf > y) { + world.setBlock(xf, yf, zf, ConfigBlocks.blockFluxGas, 8, 3); + } else { + world.setBlock(xf, yf, zf, ConfigBlocks.blockFluxGoo, 8, 3); + } + + if(created++ > limit) { + break; + } + } + } + } + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float f1, float f2, float f3) { + // Call parent method to handle jar emptying, labels stuff etc + super.onBlockActivated(world, x, y, z, player, side, f1, f2, f3); + // Interact with Essentia Phials if the player holds one + final ItemStack heldItem = player.getHeldItem(); + if(heldItem != null && heldItem.getItem() == ConfigItems.itemEssence) { + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_ThaumiumReinforcedJar) { + return dealWithPhial(world, player, x, y, z); + } else if(te instanceof TE_ThaumiumReinforcedVoidJar) { + return dealWithPhial(world, player, x, y, z); + } + } + + return true; + } + + /** + * Handle compatibility with Essentia Phials + * @param world + * Pass through from onBlockActivated() + * @param player + * Pass through from onBlockActivated() + * @param x + * Pass through from onBlockActivated() + * @param y + * Pass through from onBlockActivated() + * @param z + * Pass through from onBlockActivated() + * @return Not sure tbh + */ + private boolean dealWithPhial(World world, EntityPlayer player, int x, int y, int z) { + final TileJarFillable kte = (TileJarFillable) world.getTileEntity(x, y, z); + final ItemStack heldItem = player.getHeldItem(); + // Check whether to fill or to drain the phial + if(heldItem.getItemDamage() == 0) { + if(kte.amount >= 8){ + if (world.isRemote) { + player.swingItem(); + return false; + } + + final Aspect jarAspect = Aspect.getAspect(kte.aspect.getTag()); + if(kte.takeFromContainer(jarAspect, 8)) { + // Take an empty phial from the player's inventory + heldItem.stackSize--; + // Fill a new phial + final ItemStack filledPhial = new ItemStack(ConfigItems.itemEssence, 1, 1); + final AspectList phialContent = new AspectList().add(jarAspect, 8); + ((ItemEssence) ConfigItems.itemEssence).setAspects(filledPhial, phialContent); + // Drop on ground if there's no inventory space + if (!player.inventory.addItemStackToInventory(filledPhial)) { + world.spawnEntityInWorld(new EntityItem(world, (float)x + 0.5F, (float)y + 0.5F, (float)z + 0.5F, filledPhial)); + } + + world.playSoundAtEntity(player, "game.neutral.swim", 0.25F, 1.0F); + player.inventoryContainer.detectAndSendChanges(); + return true; + } + } + } else { + final AspectList phialContent = ((ItemEssence) ConfigItems.itemEssence).getAspects(heldItem); + if(phialContent != null && phialContent.size() == 1) { + final Aspect phialAspect = phialContent.getAspects()[0]; + if(kte.amount + 8 <= kte.maxAmount && kte.doesContainerAccept(phialAspect)) { + if (world.isRemote) { + player.swingItem(); + return false; + } + + if(kte.addToContainer(phialAspect, 8) == 0) { + world.markBlockForUpdate(x, y, z); + kte.markDirty(); + heldItem.stackSize--; + // Drop on ground if there's no inventory space + if (!player.inventory.addItemStackToInventory(new ItemStack(ConfigItems.itemEssence, 1, 0))) { + world.spawnEntityInWorld(new EntityItem(world, (float)x + 0.5F, (float)y + 0.5F, (float)z + 0.5F, new ItemStack(ConfigItems.itemEssence, 1, 0))); + } + + world.playSoundAtEntity(player, "game.neutral.swim", 0.25F, 1.0F); + player.inventoryContainer.detectAndSendChanges(); + return true; + } + } + } + } + + return true; + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) { + final ArrayList<ItemStack> drops = new ArrayList<>(); + drops.add(new ItemStack(this, 1, (meta == 3) ? 3 : 0)); + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_ThaumiumReinforcedJar) { + final TE_ThaumiumReinforcedJar ite = (TE_ThaumiumReinforcedJar) te; + if(ite.aspectFilter != null){ + final ItemStack droppedLabel = new ItemStack(ConfigItems.itemResource, 1, 13); + droppedLabel.setTagCompound(new NBTTagCompound()); + final AspectList aspect = new AspectList().add(ite.aspectFilter,0); + aspect.writeToNBT(droppedLabel.getTagCompound()); + drops.add(droppedLabel); + } + } else if(te instanceof TE_ThaumiumReinforcedVoidJar) { + final TE_ThaumiumReinforcedVoidJar ite = (TE_ThaumiumReinforcedVoidJar) te; + if(ite.aspectFilter != null) { + final ItemStack droppedLabel = new ItemStack(ConfigItems.itemResource, 1, 13); + droppedLabel.setTagCompound(new NBTTagCompound()); + final AspectList aspect = new AspectList().add(ite.aspectFilter,0); + aspect.writeToNBT(droppedLabel.getTagCompound()); + drops.add(droppedLabel); + } + } + return drops; + } + + @Override + public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + } + + @Override + public boolean canDropFromExplosion(Explosion e) { + return false; + } +} diff --git a/src/main/java/common/blocks/Block_YSZUnit.java b/src/main/java/common/blocks/Block_YSZUnit.java new file mode 100644 index 0000000000..fad48dd1b2 --- /dev/null +++ b/src/main/java/common/blocks/Block_YSZUnit.java @@ -0,0 +1,28 @@ +package common.blocks;
+
+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_YSZUnit extends BaseGTUpdateableBlock {
+
+ private static Block_YSZUnit instance = new Block_YSZUnit();
+
+ private Block_YSZUnit() {
+ super(Material.iron);
+ }
+
+ public static Block registerBlock() {
+ final String blockName = "kekztech_yszceramicelectrolyteunit_block";
+ instance.setBlockName(blockName);
+ instance.setCreativeTab(CreativeTabs.tabMisc);
+ instance.setBlockTextureName(KekzCore.MODID + ":" + "YSZCeramicElectrolyteUnit");
+ instance.setHardness(5.0f);
+ instance.setResistance(6.0f);
+ GameRegistry.registerBlock(instance, blockName);
+
+ return instance;
+ }
+}
diff --git a/src/main/java/common/container/Container_ItemProxyEndpoint.java b/src/main/java/common/container/Container_ItemProxyEndpoint.java new file mode 100644 index 0000000000..63f836e001 --- /dev/null +++ b/src/main/java/common/container/Container_ItemProxyEndpoint.java @@ -0,0 +1,68 @@ +package common.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class Container_ItemProxyEndpoint extends Container { + + private final IInventory teInventory; + + private int slotID = 0; + + public Container_ItemProxyEndpoint(TileEntity te, EntityPlayer player) { + this.teInventory = (IInventory) te; + + // Source Slot + addSlotToContainer(new Slot(teInventory, slotID++, 80, 35)); + // Config slot + addSlotToContainer(new Slot(teInventory, slotID++, 100, 35)); + + //Inventory + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + // Hotbar + for (int i = 0; i < 9; i++) { + addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) { + ItemStack stack = null; + final Slot slot = (Slot) inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) { + final ItemStack stackInSlot = slot.getStack(); + stack = stackInSlot.copy(); + + if (slotRaw < 3 * 9) { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) { + return null; + } + + if (stackInSlot.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + } + return stack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return teInventory.isUseableByPlayer(player); + } + +} + diff --git a/src/main/java/common/container/Container_ItemProxySource.java b/src/main/java/common/container/Container_ItemProxySource.java new file mode 100644 index 0000000000..2f59b97b73 --- /dev/null +++ b/src/main/java/common/container/Container_ItemProxySource.java @@ -0,0 +1,80 @@ +package common.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class Container_ItemProxySource extends Container { + + private final IInventory teInventory; + + private int slotID = 0; + + public Container_ItemProxySource(TileEntity te, EntityPlayer player) { + this.teInventory = (IInventory) te; + + // Source Slots + addSlotToContainer(new Slot(teInventory, slotID++, 53, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 53, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 53, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 53, 62)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 62)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 62)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 62)); + + //Inventory + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + // Hotbar + for (int i = 0; i < 9; i++) { + addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) { + ItemStack stack = null; + final Slot slot = (Slot) inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) { + final ItemStack stackInSlot = slot.getStack(); + stack = stackInSlot.copy(); + + if (slotRaw < 3 * 9) { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) { + return null; + } + + if (stackInSlot.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + } + return stack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return teInventory.isUseableByPlayer(player); + } + +} diff --git a/src/main/java/common/container/Container_ModularNuclearReactor.java b/src/main/java/common/container/Container_ModularNuclearReactor.java new file mode 100644 index 0000000000..f5430351e5 --- /dev/null +++ b/src/main/java/common/container/Container_ModularNuclearReactor.java @@ -0,0 +1,78 @@ +package common.container;
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import reactor.ButtonSlot;
+
+public class Container_ModularNuclearReactor extends Container {
+
+ private int nextSlotID = 0;
+ private final Slot[] REACTOR_SLOTS = new Slot[54];
+ private final Slot SLOT_CONFIGURATION;
+ private final Slot BUTTON_EU_MODE;
+ private final Slot BUTTON_FLUID_MODE;
+ private final Slot BUTTON_CONDITION;
+ private final Slot BUTTON_CONFIGURE;
+ private final Slot BUTTON_RESET;
+
+
+ public Container_ModularNuclearReactor(IGregTechTileEntity te, EntityPlayer player) {
+
+ // Add the reactor chamber
+ for(int x = 0; x < 9; x++) {
+ for(int y = 0; y < 6; y++){
+ REACTOR_SLOTS[nextSlotID] = super.addSlotToContainer(new Slot(te, getNextSlotID(), (16 + 67 * x), (16 + 67 * y)));
+ }
+ }
+ // Add the configuration slot
+ SLOT_CONFIGURATION = super.addSlotToContainer(new Slot(te, getNextSlotID(), 0, 0));
+
+ // Add buttons (they're also slots)
+ BUTTON_EU_MODE = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0));
+ BUTTON_FLUID_MODE = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0));
+ BUTTON_CONDITION = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0));
+ BUTTON_CONFIGURE = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0));
+ BUTTON_RESET = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0));
+
+ }
+
+ private int getNextSlotID() {
+ nextSlotID++;
+ return nextSlotID - 1;
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) {
+ ItemStack stack = null;
+ final Slot slot = (Slot) inventorySlots.get(slotRaw);
+
+ if (slot != null && slot.getHasStack()) {
+ final ItemStack stackInSlot = slot.getStack();
+ stack = stackInSlot.copy();
+
+ if (slotRaw < 3 * 9) {
+ if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) {
+ return null;
+ }
+ } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) {
+ return null;
+ }
+
+ if (stackInSlot.stackSize == 0) {
+ slot.putStack(null);
+ } else {
+ slot.onSlotChanged();
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+}
diff --git a/src/main/java/common/itemBlocks/IB_IchorJar.java b/src/main/java/common/itemBlocks/IB_IchorJar.java new file mode 100644 index 0000000000..11d63c4432 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_IchorJar.java @@ -0,0 +1,26 @@ +package common.itemBlocks; + + import net.minecraft.block.Block; + import net.minecraft.item.ItemBlock; + import net.minecraft.item.ItemStack; + +public class IB_IchorJar extends ItemBlock { + + public IB_IchorJar(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(); + } +} + diff --git a/src/main/java/common/itemBlocks/IB_ItemProxyCable.java b/src/main/java/common/itemBlocks/IB_ItemProxyCable.java new file mode 100644 index 0000000000..e4ae431c55 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_ItemProxyCable.java @@ -0,0 +1,22 @@ +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_ItemProxyCable extends ItemBlock { + + public IB_ItemProxyCable(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_itemproxycable_block.0.desc")); + } +} diff --git a/src/main/java/common/itemBlocks/IB_ItemProxyEndpoint.java b/src/main/java/common/itemBlocks/IB_ItemProxyEndpoint.java new file mode 100644 index 0000000000..b0a1a558a9 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_ItemProxyEndpoint.java @@ -0,0 +1,23 @@ +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_ItemProxyEndpoint extends ItemBlock { + + public IB_ItemProxyEndpoint(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_itemproxyendpoint_block.0.desc")); + lines.add(StatCollector.translateToLocal("tile.kekztech_itemproxyendpoint_block.1.desc")); + } +} diff --git a/src/main/java/common/itemBlocks/IB_ItemProxySource.java b/src/main/java/common/itemBlocks/IB_ItemProxySource.java new file mode 100644 index 0000000000..68ab1b00ff --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_ItemProxySource.java @@ -0,0 +1,24 @@ +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_ItemProxySource extends ItemBlock { + + public IB_ItemProxySource(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile:kekztech_itemproxysource_block.0.desc")); + lines.add(StatCollector.translateToLocal("tile:kekztech_itemproxysource_block.1.desc")); + lines.add(StatCollector.translateToLocal("tile:kekztech_itemproxysource_block.2.desc")); + } +} diff --git a/src/main/java/common/itemBlocks/IB_ItemServerDrive.java b/src/main/java/common/itemBlocks/IB_ItemServerDrive.java new file mode 100644 index 0000000000..a937230da5 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_ItemServerDrive.java @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000000..10803af14c --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_ItemServerIOPort.java @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000000..f1da1fcb5e --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_ItemServerRackCasing.java @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000000..7891be8ea1 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_LapotronicEnergyUnit.java @@ -0,0 +1,44 @@ +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_LapotronicEnergyUnit extends ItemBlock { + + public IB_LapotronicEnergyUnit(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_lapotronicenergyunit_block.desc")); + switch(stack.getItemDamage()) { + case 1: lines.add("Capacity: 100,000,000 EU"); break; + case 2: lines.add("Capacity: 1,000,000,000 EU"); break; + 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; + } + } +} diff --git a/src/main/java/common/itemBlocks/IB_SpaceElevator.java b/src/main/java/common/itemBlocks/IB_SpaceElevator.java new file mode 100644 index 0000000000..e2cceda494 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_SpaceElevator.java @@ -0,0 +1,35 @@ +package common.itemBlocks; + +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; + +import java.util.List; + +public class IB_SpaceElevator extends ItemBlock { + + public IB_SpaceElevator(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_spaceelevator_block.desc")); + } +} diff --git a/src/main/java/common/itemBlocks/IB_SpaceElevatorCapacitor.java b/src/main/java/common/itemBlocks/IB_SpaceElevatorCapacitor.java new file mode 100644 index 0000000000..053cb2c567 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_SpaceElevatorCapacitor.java @@ -0,0 +1,22 @@ +package common.itemBlocks; + +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; + +import java.util.List; + +public class IB_SpaceElevatorCapacitor extends ItemBlock { + + public IB_SpaceElevatorCapacitor(Block block) { + super(block); + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_spaceelevatorcapacitor_block.desc")); + } +} diff --git a/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java new file mode 100644 index 0000000000..38b8997f0f --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_TFFTMultiHatch.java @@ -0,0 +1,25 @@ +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_TFFTMultiHatch extends ItemBlock { + + public IB_TFFTMultiHatch(Block block) { + super(block); + } + + @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/common/itemBlocks/IB_TFFTStorageFieldBlockT1.java b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT1.java new file mode 100644 index 0000000000..13e6e06f50 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT1.java @@ -0,0 +1,26 @@ +package common.itemBlocks; + +import java.util.List; + +import common.blocks.Block_TFFTStorageFieldBlockT1; +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_TFFTStorageFieldBlockT1 extends ItemBlock { + + public IB_TFFTStorageFieldBlockT1(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_tfftstoragefieldblock1_block.0.desc")); + lines.add("Capacity: " + Block_TFFTStorageFieldBlockT1.getCapacity() + "L"); + lines.add("Power Draw: +0.5EU/t"); + } + +} diff --git a/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT2.java b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT2.java new file mode 100644 index 0000000000..e6a680f1f6 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT2.java @@ -0,0 +1,26 @@ +package common.itemBlocks; + +import java.util.List; + +import common.blocks.Block_TFFTStorageFieldBlockT2; +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_TFFTStorageFieldBlockT2 extends ItemBlock { + + public IB_TFFTStorageFieldBlockT2(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_tfftstoragefieldblock1_block.0.desc")); + lines.add("Capacity: " + Block_TFFTStorageFieldBlockT2.getCapacity() + "L"); + lines.add("Power Draw: +1EU/t"); + } + +} diff --git a/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT3.java b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT3.java new file mode 100644 index 0000000000..847e43f8ab --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT3.java @@ -0,0 +1,26 @@ +package common.itemBlocks; + +import java.util.List; + +import common.blocks.Block_TFFTStorageFieldBlockT3; +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_TFFTStorageFieldBlockT3 extends ItemBlock { + + public IB_TFFTStorageFieldBlockT3(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_tfftstoragefieldblock1_block.0.desc")); + lines.add("Capacity: " + Block_TFFTStorageFieldBlockT3.getCapacity() + "L"); + lines.add("Power Draw: +2EU/t"); + } + +} diff --git a/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT4.java b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT4.java new file mode 100644 index 0000000000..ce35f9c4d4 --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT4.java @@ -0,0 +1,26 @@ +package common.itemBlocks; + +import java.util.List; + +import common.blocks.Block_TFFTStorageFieldBlockT4; +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_TFFTStorageFieldBlockT4 extends ItemBlock { + + public IB_TFFTStorageFieldBlockT4(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_tfftstoragefieldblock1_block.0.desc")); + lines.add("Capacity: " + Block_TFFTStorageFieldBlockT4.getCapacity() + "L"); + lines.add("Power Draw: +4EU/t"); + } + +} diff --git a/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT5.java b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT5.java new file mode 100644 index 0000000000..b7c8e8190c --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_TFFTStorageFieldBlockT5.java @@ -0,0 +1,26 @@ +package common.itemBlocks; + +import java.util.List; + +import common.blocks.Block_TFFTStorageFieldBlockT5; +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_TFFTStorageFieldBlockT5 extends ItemBlock { + + public IB_TFFTStorageFieldBlockT5(Block block) { + super(block); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { + lines.add(StatCollector.translateToLocal("tile.kekztech_tfftstoragefieldblock1_block.0.desc")); + lines.add("Capacity: " + Block_TFFTStorageFieldBlockT5.getCapacity() + "L"); + lines.add("Power Draw: +8EU/t"); + } + +}
\ No newline at end of file diff --git a/src/main/java/common/itemBlocks/IB_ThaumiumReinforcedJar.java b/src/main/java/common/itemBlocks/IB_ThaumiumReinforcedJar.java new file mode 100644 index 0000000000..30b44f962c --- /dev/null +++ b/src/main/java/common/itemBlocks/IB_ThaumiumReinforcedJar.java @@ -0,0 +1,25 @@ +package common.itemBlocks; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class IB_ThaumiumReinforcedJar extends ItemBlock { + + public IB_ThaumiumReinforcedJar(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(); + } +} diff --git a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java new file mode 100644 index 0000000000..1c32525c4e --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java @@ -0,0 +1,531 @@ +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;
+ }
+}
\ 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 new file mode 100644 index 0000000000..cfff360ce4 --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_ItemServer.java @@ -0,0 +1,393 @@ +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 new file mode 100644 index 0000000000..fc743a56d3 --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java @@ -0,0 +1,558 @@ +package common.tileentities; + +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoTunnel; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel; +import common.Blocks; +import gregtech.api.enums.Dyes; +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; +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 net.minecraft.block.Block; +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 org.lwjgl.input.Keyboard; +import util.MultiBlockTooltipBuilder; +import util.Vector3i; +import util.Vector3ic; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlockBase { + + private final static String glassNameBorosilicate = "BW_GlasBlocks"; + private static final Block LSC_PART = Blocks.lscLapotronicEnergyUnit; + private static final int CASING_META = 0; + private static final int CASING_TEXTURE_ID = 62; + + private static final BigInteger MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE); + private static final BigDecimal PASSIVE_DISCHARGE_FACTOR_PER_TICK = + BigDecimal.valueOf(0.01D / 1728000.0D); // The magic number is ticks per 24 hours + + private final Set<GT_MetaTileEntity_Hatch_EnergyMulti> mEnergyHatchesTT = new HashSet<>(); + private final Set<GT_MetaTileEntity_Hatch_DynamoMulti> mDynamoHatchesTT = new HashSet<>(); + 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 BigInteger capacity = BigInteger.ZERO; + private BigInteger stored = BigInteger.ZERO; + private BigInteger passiveDischargeAmount = BigInteger.ZERO; + private BigInteger intputLastTick = BigInteger.ZERO; + private BigInteger outputLastTick = BigInteger.ZERO; + private int repairStatusCache = 0; + + public GTMTE_LapotronicSuperCapacitor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GTMTE_LapotronicSuperCapacitor(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { + return new GTMTE_LapotronicSuperCapacitor(super.mName); + } + + @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"); + 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) { + ITexture[] sTexture = new ITexture[]{new GT_RenderedTexture(BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + if (aSide == aFacing && aActive) { + sTexture = new ITexture[]{new GT_RenderedTexture(BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW, + Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + } + return sTexture; + } + + 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 stack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack stack) { + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEUt = 0; + this.mEfficiencyIncrease = 10000; + return true; + } + + 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 + ); + boolean formationChecklist = true; + int minCasingAmount = 16; + int firstGlassMeta = -1; + // Reset capacitor counts + Arrays.fill(capacitors, 0); + // Clear TT hatches + mEnergyHatchesTT.clear(); + mDynamoHatchesTT.clear(); + mEnergyTunnelsTT.clear(); + mDynamoTunnelsTT.clear(); + // Temp var for loss calculation + BigInteger tempCapacity = BigInteger.ZERO; + + // Capacitor base + for(int Y = 0; Y <= 1; Y++) { + for(int X = -2; X <= 2; X++) { + for(int Z = 0; Z >= -4; Z--) { + if(X == 0 && Y == 0 && Z == 0) { + continue; // Skip controller + } + + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 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 + if ( !super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID) + && !this.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID) + && !this.addDynamoToMachineList(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()) == LSC_PART) + && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == CASING_META)) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else { + formationChecklist = false; + } + } + } + } + } + // Capacitor units + int firstGlassHeight = 3; // Initialize at basic height (-1 because it's an offset) + for(int X = -1; X <= 1; X++) { + for(int Z = -1; Z >= -3; Z--) { + // Y has to be the innermost loop to properly deal with the dynamic height. + // This way each "pillar" of capacitors is checked from bottom to top until it hits glass. + for(int Y = 2; Y <= 17; Y++) { + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z); + + 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); + } + capacitors[meta - 1]++; + } else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameBorosilicate)){ + firstGlassHeight = Y; + break; + } else { + formationChecklist = false; + } + } + } + } + // Glass shell + // Make Y the outermost loop, so each layer is checked completely before moving up + for(int Y = 2; Y <= firstGlassHeight; Y++) { + for(int X = -2; X <= 2; X++) { + for(int Z = 0; Z >= -4; Z--) { + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z); + final String blockNameAt = thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName(); + final int meta = thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()); + // Check only outer ring, except when on roof height + if((Y < firstGlassHeight)){ + if(X == -2 || X == 2 || Z == 0 || Z == 4){ + if(glassNameBorosilicate.equals(blockNameAt)) { + if(firstGlassMeta == -1) { + firstGlassMeta = meta; + } else if(meta != firstGlassMeta) { + formationChecklist = false; + } + } else { + formationChecklist = false; + } + } + } else { + if (glassNameBorosilicate.equals(blockNameAt)) { + if(meta != firstGlassMeta) { + formationChecklist = false; + } + } else { + formationChecklist = false; + } + } + } + } + } + + if(minCasingAmount > 0){ + formationChecklist = false; + } + + // Make sure glass tier is T-2 of the highest tier capacitor in the structure + // Count down from the highest tier until an entry is found + // 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; + } + } + + // Glass has to be at least UV-tier to allow TT Laser hatches + if(colourCorrectedMeta < 5) { + if(mEnergyTunnelsTT.size() > 0 || mDynamoTunnelsTT.size() > 0) { + formationChecklist = false; + } + mEnergyTunnelsTT.clear(); + mDynamoTunnelsTT.clear(); + + } + + // 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]))); + } + } + // 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; + } + + @Override + public boolean addEnergyInputToMachineList(IGregTechTileEntity te, int aBaseCasingIndex) { + if (te == null) { + return false; + } else { + final IMetaTileEntity mte = te.getMetaTileEntity(); + 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); + } else if(mte instanceof GT_MetaTileEntity_Hatch_EnergyTunnel) { + // Add TT Laser hatches + 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); + } else { + return false; + } + } + } + + @Override + public boolean addDynamoToMachineList(IGregTechTileEntity te, int aBaseCasingIndex) { + if (te == null) { + return false; + } else { + final IMetaTileEntity mte = te.getMetaTileEntity(); + 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); + } else if(mte instanceof GT_MetaTileEntity_Hatch_DynamoTunnel) { + // Add TT Laser hatches + return mDynamoTunnelsTT.add((GT_MetaTileEntity_Hatch_DynamoTunnel) mte); + } 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); + } else { + return false; + } + } + } + + @Override + public boolean onRunningTick(ItemStack stack){ + // Reset I/O cache + intputLastTick = BigInteger.ZERO; + outputLastTick = BigInteger.ZERO; + + // Draw energy from GT hatches + for(GT_MetaTileEntity_Hatch_Energy eHatch : super.mEnergyHatches) { + if(eHatch == null || eHatch.getBaseMetaTileEntity().isInvalidTileEntity()) { + continue; + } + final long power = getPowerToDraw(eHatch.maxEUInput() * eHatch.maxAmperesIn()); + if(eHatch.getEUVar() >= power) { + eHatch.setEUVar(eHatch.getEUVar() - power); + stored = stored.add(BigInteger.valueOf(power)); + intputLastTick = intputLastTick.add(BigInteger.valueOf(power)); + } + } + // Output energy to GT hatches + for(GT_MetaTileEntity_Hatch_Dynamo eDynamo : super.mDynamoHatches){ + if(eDynamo == null || eDynamo.getBaseMetaTileEntity().isInvalidTileEntity()){ + continue; + } + final long power = getPowerToPush(eDynamo.maxEUOutput() * eDynamo.maxAmperesOut()); + if(power <= eDynamo.maxEUStore() - eDynamo.getEUVar()) { + eDynamo.setEUVar(eDynamo.getEUVar() + power); + stored = stored.subtract(BigInteger.valueOf(power)); + outputLastTick = outputLastTick.add(BigInteger.valueOf(power)); + } + } + // Draw energy from TT hatches + for(GT_MetaTileEntity_Hatch_EnergyMulti eHatch : mEnergyHatchesTT) { + if(eHatch == null || eHatch.getBaseMetaTileEntity().isInvalidTileEntity()) { + continue; + } + final long power = getPowerToDraw(eHatch.maxEUInput() * eHatch.maxAmperesIn()); + if(eHatch.getEUVar() >= power) { + eHatch.setEUVar(eHatch.getEUVar() - power); + stored = stored.add(BigInteger.valueOf(power)); + intputLastTick = intputLastTick.add(BigInteger.valueOf(power)); + } + } + // Output energy to TT hatches + for(GT_MetaTileEntity_Hatch_DynamoMulti eDynamo : mDynamoHatchesTT){ + if(eDynamo == null || eDynamo.getBaseMetaTileEntity().isInvalidTileEntity()){ + continue; + } + final long power = getPowerToPush(eDynamo.maxEUOutput() * eDynamo.maxAmperesOut()); + if(power <= eDynamo.maxEUStore() - eDynamo.getEUVar()) { + eDynamo.setEUVar(eDynamo.getEUVar() + power); + stored = stored.subtract(BigInteger.valueOf(power)); + outputLastTick = outputLastTick.add(BigInteger.valueOf(power)); + } + } + // Draw energy from TT Laser hatches + for(GT_MetaTileEntity_Hatch_EnergyTunnel eHatch : mEnergyTunnelsTT) { + if(eHatch == null || eHatch.getBaseMetaTileEntity().isInvalidTileEntity()) { + continue; + } + final long ttLaserWattage = eHatch.maxEUInput() * eHatch.Amperes - (eHatch.Amperes / 20); + final long power = getPowerToDraw(ttLaserWattage); + if(eHatch.getEUVar() >= power) { + eHatch.setEUVar(eHatch.getEUVar() - power); + stored = stored.add(BigInteger.valueOf(power)); + intputLastTick = intputLastTick.add(BigInteger.valueOf(power)); + } + } + // Output energy to TT Laser hatches + for(GT_MetaTileEntity_Hatch_DynamoTunnel eDynamo : mDynamoTunnelsTT){ + if(eDynamo == null || eDynamo.getBaseMetaTileEntity().isInvalidTileEntity()){ + continue; + } + final long ttLaserWattage = eDynamo.maxEUOutput() * eDynamo.Amperes - (eDynamo.Amperes / 20); + final long power = getPowerToPush(ttLaserWattage); + if(power <= eDynamo.maxEUStore() - eDynamo.getEUVar()) { + eDynamo.setEUVar(eDynamo.getEUVar() + power); + stored = stored.subtract(BigInteger.valueOf(power)); + outputLastTick = outputLastTick.add(BigInteger.valueOf(power)); + } + } + // Loose some energy + // Recalculate if the repair status changed + if(super.getRepairStatus() != repairStatusCache) { + passiveDischargeAmount = recalculateLossWithMaintenance(super.getRepairStatus()); + } + stored = stored.subtract(passiveDischargeAmount); + stored = (stored.compareTo(BigInteger.ZERO) <= 0) ? BigInteger.ZERO : stored; + + return true; + } + + /** + * To be called whenever the maintenance status changes or the capacity was recalculated + * @param repairStatus + * This machine's repair status + * @return new BigInteger instance for passiveDischargeAmount + */ + private BigInteger recalculateLossWithMaintenance(int repairStatus) { + repairStatusCache = repairStatus; + return new BigDecimal(passiveDischargeAmount) + .multiply(BigDecimal.valueOf(1.0D + 0.2D * repairStatus)).toBigInteger(); + } + + /** + * Calculate how much EU to draw from an Energy Hatch + * @param hatchWatts + * Hatch amperage * voltage + * @return EU amount + */ + private long getPowerToDraw(long hatchWatts){ + final BigInteger remcapActual = capacity.subtract(stored); + final BigInteger recampLimited = (MAX_LONG.compareTo(remcapActual) > 0) ? remcapActual : MAX_LONG; + return Math.min(hatchWatts, recampLimited.longValue()); + } + + /** + * Calculate how much EU to push into a Dynamo Hatch + * @param hatchWatts + * Hatch amperage * voltage + * @return EU amount + */ + private long getPowerToPush(long hatchWatts){ + final BigInteger remStoredLimited = (MAX_LONG.compareTo(stored) > 0) ? stored : MAX_LONG; + return Math.min(hatchWatts, remStoredLimited.longValue()); + } + + @Override + public String[] getInfoData() { + 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 OUT: " + NumberFormat.getNumberInstance().format(outputLastTick) + "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.setByteArray("capacity", capacity.toByteArray()); + nbt.setByteArray("stored", stored.toByteArray()); + nbt.setByteArray("passiveDischargeAmount", passiveDischargeAmount.toByteArray()); + + super.saveNBTData(nbt); + } + + @Override + public void loadNBTData(NBTTagCompound nbt) { + nbt = (nbt == null) ? new NBTTagCompound() : nbt; + + capacity = new BigInteger(nbt.getByteArray("capacity")); + stored = new BigInteger(nbt.getByteArray("stored")); + passiveDischargeAmount = new BigInteger(nbt.getByteArray("passiveDischargeAmount")); + + super.loadNBTData(nbt); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack stack) { return 10000; } + + @Override + public int getPollutionPerTick(ItemStack stack) { return 0; } + + @Override + public int getDamageToComponent(ItemStack stack) { return 0; } + + @Override + public boolean explodesOnComponentBreak(ItemStack stack) { return false; } + +} diff --git a/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java b/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java new file mode 100644 index 0000000000..5e0b86ed69 --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java @@ -0,0 +1,244 @@ +package common.tileentities;
+
+import org.joml.Vector3i;
+import org.lwjgl.input.Keyboard;
+
+import client.gui.GUIContainer_ModularNuclearReactor;
+import common.Blocks;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.objects.GT_RenderedTexture;
+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 {
+
+ private final Block CASING = GregTech_API.sBlockCasings3;
+ private final int CASING_META = 12;
+ private final int CASING_TEXTURE_ID = 44;
+
+ private final Block CHAMBER_OFF = Blocks.reactorChamberOFF;
+ private final Block CHAMBER_ON = Blocks.reactorChamberON;
+ private final Block CONTROL_ROD = Blocks.reactorControlRod;
+
+ private boolean euMode = true;
+
+ public GTMTE_ModularNuclearReactor(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+
+ }
+
+ public GTMTE_ModularNuclearReactor(String aName) {
+ super(aName);
+
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
+ return new GTMTE_ModularNuclearReactor(super.mName);
+ }
+
+ @Override
+ public String[] getDescription() {
+ final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
+ b.addInfo("Can be built, BUT DOES NOT WORK")
+ .addInfo("Converts fissile material and outputs power or heat")
+ .addSeparator()
+ .addInfo("EU-MODE:")
+ .addInfo(" Directly outputs electricity depending on inserted fuel rods")
+ .addSeparator()
+ .addInfo("COOLANT-MODE:")
+ .addInfo(" Requires coolant to be pumped into the reactor.")
+ .addInfo(" Coolant is heated and should be drained and converted to electricity by other means.")
+ .addSeparator()
+ .addInfo("NOTES:")
+ .addInfo(" Does NOT use Industrialcraft 2 reactor components!")
+ .addInfo(" Consult controller GUI on how to arrange the outer casings.")
+ .addSeparator()
+ .beginStructureBlock(7, 6, 7)
+ .addController("Front bottom Center")
+ .addCasingInfo("Radiation Proof Machine Casing", 100)
+ .addOtherStructurePart("Control Rods", "Four pillars, four blocks high each. Diagonal to the inner edges of the shell")
+ .addOtherStructurePart("Nuclear Reactor Chamber", "17 of them to fill out the rest of the floor inside the shell")
+ .addDynamoHatch("ONLY in EU-mode, at least one")
+ .addOtherStructurePart("Input Bus, Output Bus", "Optional but required for automation")
+ .addOtherStructurePart("Input Hatch, Output Hatch", "ONLY in Coolant-Mode, at least one each")
+ .signAndFinalize("Kekzdealer");
+ if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ 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 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]};
+ }
+
+ // TODO: Opening UI crashes server. Controller isn't craftable right now.
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ /*return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(),
+ "MultiblockDisplay.png");*/
+ return new GUIContainer_ModularNuclearReactor(aBaseMetaTileEntity, aPlayerInventory.player);
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack stack) {
+ return true;
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack stack) {
+ return false;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity thisController, long aTick) {
+ super.onPostTick(thisController, aTick);
+
+ if(super.getBaseMetaTileEntity().isActive()) {
+ // Switch to ON blocks
+ } else {
+ // Switch to OFF blocks
+ }
+ }
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) {
+ // Figure out the vector for the direction the back face of the controller is facing
+ final int dirX = ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX;
+ final int dirZ = ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ;
+ int minCasingAmount = 100;
+ boolean checklist = true; // if this is still true at the end, machine is good to go :)
+
+ // Determine the ground level center of the structure
+ final Vector3i center = new Vector3i(
+ thisController.getXCoord(),
+ thisController.getYCoord(),
+ thisController.getZCoord())
+ .add(dirX * 3, 0, dirZ * 3);
+ // Scan for outer tube
+ // - Scan sides
+ for(int x = -3; x <= 3; x++) {
+ for(int z = -3; z <= 3; z++) {
+ // Only scan the three wide even sides, skip rest
+ if((Math.abs(x) <= 1 && Math.abs(z) == 3) || (Math.abs(z) <= 1 && Math.abs(x) == 3)) {
+ for(int h = 0; h < 6; h++) {
+ final Vector3i pos = new Vector3i(center.x() + x, center.y() + h, center.z() + z);
+ if(h == 0 && pos.x() == thisController.getXCoord() && pos.y() == thisController.getYCoord() && pos.z() == thisController.getZCoord()) {
+ // Ignore controller
+ continue;
+ } else if (thisController.getBlock(pos.x(), pos.y(), pos.z()) == CASING
+ && thisController.getMetaID(pos.x(), pos.y(), pos.z()) == CASING_META) {
+ minCasingAmount--;
+ } else {
+ checklist = false;
+ }
+ }
+ }
+ }
+ }
+ // - Scan corners of tube
+ for(int x = -2; x <= 2; x++) {
+ for(int z = -2; z <= 2; z++) {
+ // Only scan the four corners, skip rest
+ if(Math.abs(x) + Math.abs(z) == 4) {
+ for(int h = 0; h < 6; h++) {
+ final Vector3i pos = new Vector3i(center.x() + x, center.y() + h, center.z() + z);
+ if(h == 0 && pos.x() == thisController.getXCoord() && pos.y() == thisController.getYCoord() && pos.z() == thisController.getZCoord()) {
+ // Ignore controller
+ continue;
+ } else if (thisController.getBlock(pos.x(), pos.y(), pos.z()) == CASING
+ && thisController.getMetaID(pos.x(), pos.y(), pos.z()) == CASING_META) {
+ minCasingAmount--;
+ } else {
+ checklist = false;
+ }
+ }
+ }
+ }
+ }
+ // Scan ground layer
+ for(int x = -2; x <= 2; x++) {
+ for(int z = -2; z <= 2; z++) {
+ if(!(thisController.getBlock(center.x() + x, center.y(), center.z() + z) == CASING
+ && thisController.getMetaID(center.x() + x, center.y(), center.z() + z) == CASING_META)) {
+ checklist = false;
+ } else {
+ minCasingAmount--;
+ }
+ }
+ }
+ // Scan reactor chambers
+ for(int x = -2; x <= 2; x++) {
+ for(int z = -2; z <= 2; z++) {
+ // Skip if diagonal, don't skip center
+ if(Math.abs(x) == Math.abs(z) && !(x == 0 && z == 0)) {
+ continue;
+ }
+ if(!(thisController.getBlock(center.x() + x, center.y() + 1, center.z() + z) == CHAMBER_OFF
+ || thisController.getBlock(center.x() + x, center.y() + 1, center.z() + z) == CHAMBER_ON)) {
+ checklist = false;
+ }
+ }
+ }
+ // Scan control rods
+ for(int h = 1; h < 5; h++) {
+ for(int x = -1; x <= 1; x++) {
+ for(int z = -1; z <= 1; z++) {
+ // Only check diagonal
+ if(x == 0 || z == 0) {
+ continue;
+ }
+ if(!(thisController.getBlock(center.x() + x, center.y() + h, center.z() + z) == CONTROL_ROD)) {
+ checklist = false;
+ }
+ }
+ }
+ }
+
+
+
+
+ if(minCasingAmount > 0) {
+ checklist = false;
+ }
+
+ return checklist;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack stack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack stack) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack stack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack stack) {
+ return false;
+ }
+
+}
diff --git a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java new file mode 100644 index 0000000000..76536f0e50 --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java @@ -0,0 +1,335 @@ +package common.tileentities;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.lwjgl.input.Keyboard;
+
+import common.Blocks;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+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;
+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_Recipe;
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import net.minecraft.block.Block;
+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;
+
+public class GTMTE_SOFuelCellMK1 extends GT_MetaTileEntity_MultiBlockBase {
+
+ private final Block CASING = GregTech_API.sBlockCasings4;
+ private final int CASING_META = 1;
+ private final int CASING_TEXTURE_ID = 49;
+
+ private final int OXYGEN_PER_SEC = 400;
+ private final int EU_PER_TICK = 1024;
+ private final int STEAM_PER_SEC = 18000;
+
+ public GTMTE_SOFuelCellMK1(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+
+ }
+
+ public GTMTE_SOFuelCellMK1(String aName) {
+ super(aName);
+
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
+ return new GTMTE_SOFuelCellMK1(super.mName);
+ }
+
+ @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");
+ if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ 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 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]};
+ }
+
+ 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 stack) {
+ return true;
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack stack) {
+ final ArrayList<FluidStack> storedFluids = super.getStoredFluids();
+ Collection<GT_Recipe> recipeList = GT_Recipe_Map.sTurbineFuels.mRecipeList;
+
+ if((storedFluids.size() > 0 && recipeList != null)) {
+
+ final Iterator<FluidStack> fluidsIterator = storedFluids.iterator();
+ while(fluidsIterator.hasNext()) {
+
+ final FluidStack hatchFluid = fluidsIterator.next();
+ final Iterator<GT_Recipe> recipeIterator = recipeList.iterator();
+ while(recipeIterator.hasNext()) {
+
+ final GT_Recipe aFuel = recipeIterator.next();
+ FluidStack liquid;
+ if((liquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null
+ && hatchFluid.isFluidEqual(liquid)) {
+
+ liquid.amount = Math.round((EU_PER_TICK * 20) / aFuel.mSpecialValue);
+
+ if(super.depleteInput(liquid)) {
+
+ if(!super.depleteInput(Materials.Oxygen.getGas(OXYGEN_PER_SEC))) {
+ super.mEUt = 0;
+ super.mEfficiency = 0;
+ return false;
+ }
+
+ super.mEUt = EU_PER_TICK;
+ super.mMaxProgresstime = 20;
+ super.mEfficiencyIncrease = 40;
+ if(super.mEfficiency == getMaxEfficiency(null)) {
+ super.addOutput(GT_ModHandler.getSteam(STEAM_PER_SEC));
+ }
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ super.mEUt = 0;
+ super.mEfficiency = 0;
+ return false;
+ }
+
+ 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 = 12;
+ boolean formationChecklist = true; // if this is still true at the end, machine is good to go :)
+
+ // Front slice
+ for(int X = -1; X <= 1; X++) {
+ for(int Y = -1; Y <= 1; 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());
+
+ // 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.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !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.
+ if ((thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING)
+ && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == CASING_META)) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+
+ // Middle three slices
+ for(int X = -1; X <= 1; X++) {
+ for(int Y = -1; Y <= 1; Y++) {
+ for(int Z = -1; Z >= -3; Z--) {
+ final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z);
+ if(X == 0 && Y == 0) {
+ if(!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals(Blocks.yszUnit.getUnlocalizedName())) {
+ formationChecklist = false;
+ }
+ continue;
+ }
+ if(Y == 0 && (X == -1 || X == 1)) {
+ if(!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals("blockAlloyGlass")) {
+ formationChecklist = false;
+ }
+ continue;
+ }
+ // Get next TE
+ IGregTechTileEntity currentTE =
+ thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());// x, y ,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 (TAE for GT++)
+ if ( !super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !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.
+ if ((thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING)
+ && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == CASING_META)) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+ }
+
+ // Back slice
+ for(int X = -1; X <= 1; X++) {
+ for(int Y = -1; Y <= 1; Y++) {
+ // Get next TE
+ final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -4);
+ IGregTechTileEntity currentTE =
+ thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());// x, y ,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 (TAE for GT++)
+ if ( !super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addDynamoToMachineList(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)
+ && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == CASING_META)) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+
+ if(minCasingAmount > 0) {
+ formationChecklist = false;
+ }
+
+ if(this.mDynamoHatches.size() != 1) {
+ System.out.println("Exactly one dynamo hatch is required!");
+ formationChecklist = false;
+ }
+ if(this.mInputHatches.size() < 2) {
+ System.out.println("At least two input hatches are required!");
+ formationChecklist = false;
+ }
+
+ if(this.mMaintenanceHatches.size() < 1) {
+ System.out.println("You need a maintenance hatch to do maintenance.");
+ }
+
+ return formationChecklist;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack stack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack stack) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack stack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack stack) {
+ return false;
+ }
+
+}
diff --git a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java new file mode 100644 index 0000000000..fb3fb7e9c7 --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java @@ -0,0 +1,335 @@ +package common.tileentities;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.lwjgl.input.Keyboard;
+
+import common.Blocks;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+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;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.InventoryPlayer;
+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;
+
+public class GTMTE_SOFuelCellMK2 extends GT_MetaTileEntity_MultiBlockBase {
+
+ final Block CASING = GregTech_API.sBlockCasings4;
+ final int CASING_META = 0;
+ final int CASING_TEXTURE_ID = 48;
+
+ private final int OXYGEN_PER_SEC = 2000;
+ private final int EU_PER_TICK = 24576; // 100% Efficiency, 3A IV
+ private final int STEAM_PER_SEC = 96000; // SH Steam (10,800EU/t @ 150% Efficiency)
+
+ public GTMTE_SOFuelCellMK2(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+
+ }
+
+ public GTMTE_SOFuelCellMK2(String aName) {
+ super(aName);
+
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
+ return new GTMTE_SOFuelCellMK2(super.mName);
+ }
+
+ @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");
+ if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ 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 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]};
+ }
+
+ 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 stack) {
+ return true;
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack stack) {
+ final ArrayList<FluidStack> storedFluids = super.getStoredFluids();
+ Collection<GT_Recipe> recipeList = GT_Recipe_Map.sTurbineFuels.mRecipeList;
+
+ if((storedFluids.size() > 0 && recipeList != null)) {
+
+ final Iterator<FluidStack> fluidsIterator = storedFluids.iterator();
+ while(fluidsIterator.hasNext()) {
+
+ final FluidStack hatchFluid = fluidsIterator.next();
+ final Iterator<GT_Recipe> recipeIterator = recipeList.iterator();
+ while(recipeIterator.hasNext()) {
+
+ final GT_Recipe aFuel = recipeIterator.next();
+ FluidStack liquid;
+ if((liquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null
+ && hatchFluid.isFluidEqual(liquid)) {
+
+ liquid.amount = Math.round((EU_PER_TICK * 20) / aFuel.mSpecialValue);
+
+ if(super.depleteInput(liquid)) {
+
+ if(!super.depleteInput(Materials.Oxygen.getGas(OXYGEN_PER_SEC))) {
+ super.mEUt = 0;
+ super.mEfficiency = 0;
+ return false;
+ }
+
+ super.mEUt = EU_PER_TICK;
+ super.mMaxProgresstime = 20;
+ super.mEfficiencyIncrease = 80;
+ if(super.mEfficiency == getMaxEfficiency(null)) {
+ super.addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", STEAM_PER_SEC));
+ }
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ super.mEUt = 0;
+ super.mEfficiency = 0;
+ return false;
+ }
+
+ 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 = 12;
+ boolean formationChecklist = true; // if this is still true at the end, machine is good to go :)
+
+ // Front slice
+ for(int X = -1; X <= 1; X++) {
+ for(int Y = -1; Y <= 1; 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());
+
+ // 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.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !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.
+ if ((thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING)
+ && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == CASING_META)) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+
+ // Middle three slices
+ for(int X = -1; X <= 1; X++) {
+ for(int Y = -1; Y <= 1; Y++) {
+ for(int Z = -1; Z >= -3; Z--) {
+ final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z);
+ if(X == 0 && Y == 0) {
+ if(!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals(Blocks.gdcUnit.getUnlocalizedName())) {
+ formationChecklist = false;
+ }
+ continue;
+ }
+ if(Y == 0 && (X == -1 || X == 1)) {
+ if(!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals("blockAlloyGlass")) {
+ formationChecklist = false;
+ }
+ continue;
+ }
+ // Get next TE
+ IGregTechTileEntity currentTE =
+ thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());// x, y ,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 (TAE for GT++)
+ if ( !super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !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.
+ if ((thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING)
+ && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == CASING_META)) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+ }
+
+ // Back slice
+ for(int X = -1; X <= 1; X++) {
+ for(int Y = -1; Y <= 1; Y++) {
+ // Get next TE
+ final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -4);
+ IGregTechTileEntity currentTE =
+ thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());// x, y ,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 (TAE for GT++)
+ if ( !super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addDynamoToMachineList(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)
+ && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == CASING_META)) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+
+ if(minCasingAmount > 0) {
+ formationChecklist = false;
+ }
+
+ if(this.mDynamoHatches.size() != 1) {
+ System.out.println("Exactly one dynamo hatch is required!");
+ formationChecklist = false;
+ }
+ if(this.mInputHatches.size() < 2) {
+ System.out.println("At least two input hatches are required!");
+ formationChecklist = false;
+ }
+
+ if(this.mMaintenanceHatches.size() < 1) {
+ System.out.println("You need a maintenance hatch to do maintenance.");
+ }
+
+ return formationChecklist;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack stack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack stack) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack stack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack stack) {
+ return false;
+ }
+
+}
diff --git a/src/main/java/common/tileentities/GTMTE_SpaceElevator.java b/src/main/java/common/tileentities/GTMTE_SpaceElevator.java new file mode 100644 index 0000000000..8f7827f4be --- /dev/null +++ b/src/main/java/common/tileentities/GTMTE_SpaceElevator.java @@ -0,0 +1,265 @@ +package common.tileentities; + +import common.Blocks; +import gregtech.api.enums.Dyes; +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; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +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; + +import java.util.ArrayList; +import java.util.HashSet; + +public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase { + + private static final Block BASE_BLOCK = Blocks.spaceElevatorStructure; + private static final Block CAP_BLOCK = Blocks.spaceElevatorCapacitor; + private static final Block TETHER_BLOCK = Blocks.spaceElevatorTether; + private static final int BASE_META = 0; + private static final int COIL_HOLDER_META = 1; + private final static String glassNameBorosilicate = "BW_GlasBlocks"; + private static final int HATCH_OVERLAY_ID = 16; + + // Scan positions for capacitor banks + // Start with top left bank, clockwise + // Start with top middle pillar within bank, clockwise, middle last + private static final int[] bankOffsetsX = {-7, 5, 5, -7}; + private static final int[] bankOffsetsY = {-7, -7, 5, 5}; + private static final int[] scanOffsetsX = {1, 2, 1, 0, 1}; + private static final int[] scanOffsetsY = {0, 1, 2, 1, 1}; + + private final HashSet<TE_SpaceElevatorCapacitor> capacitors = new HashSet<>(); + private long lastLaunchEUCost = 0; + + public GTMTE_SpaceElevator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GTMTE_SpaceElevator(String aName) { super(aName); } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) { + return new GTMTE_SpaceElevator((super.mName)); + } + + @Override + public String[] getDescription() { + 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") + .addInfo("Regenerative Breaking will recover up to X% of the energy spent on launch") + .addInfo("Energy recovered depends on coil tier: +10% per coil tier, up to 90%") + .addSeparator() + .beginStructureBlock(15, 11, 15) + .addController("Bottom Center") + .addEnergyHatch("Instead of any casing in the bottom floor") + .addMaintenanceHatch("Instead of any casing in the bottom floor") + .addCasingInfo("Solid Steel Machine Casing", 320) + .addOtherStructurePart("Any EBF coil", "40x, have to be all the same") + .addOtherStructurePart("Space Elevator Tether", "4x") + .addOtherStructurePart("Space Elevator Cabin Block", "42x") + .addOtherStructurePart("Space Elevator Cabin Guide", "8x") + .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) { + ITexture[] sTexture = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + if (aSide == aFacing && aActive) { + sTexture = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW, + Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + } + return sTexture; + } + + 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 stack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack stack) { + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEUt = 0; + this.mEfficiencyIncrease = 10000; + return true; + } + + public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) { + final Vector3i offset = new Vector3i(0, 0, 0); + // 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) { + // Make sure the controller is either facing up or down + if(thisController.getFrontFacing() > 1) { + return false; + } + + // 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; + int minCasingAmount = 320; + int firstCoilMeta = -1; + + // Base floor + for(int X = -7; X <= 7; X++){ + for(int Y = -7; Y <= 7; Y++){ + if(X == 0 && Y == 0){ + continue; // Skip controller + } + + final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0); + 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 + if ( !super.addMaintenanceToMachineList(currentTE, HATCH_OVERLAY_ID) + && !this.addEnergyInputToMachineList(currentTE, HATCH_OVERLAY_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()) == BASE_BLOCK) + && (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == BASE_META)) { + // Seems to be valid casing. Decrement counter. + minCasingAmount--; + } else { + formationChecklist = false; + } + } + } + } + System.out.println(""); + // Capacitor banks + for(int bank = 0; bank < 4; bank++) { + for(int Z = 1; Z <= 5; Z++) { + for(int scan = 0; scan < 5; scan++){ + final Vector3ic offset = rotateOffsetVector(forgeDirection, + bankOffsetsX[bank] + scanOffsetsX[scan], + bankOffsetsY[bank] + scanOffsetsY[scan], + Z); + if(Z == 1 || Z == 5) { + // Check for casings + if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == BASE_BLOCK + && thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == BASE_META) { + minCasingAmount--; + } else { + formationChecklist = false; + } + } else { + if(scan == 4){ + // Check for capacitors + final TileEntity te = thisController.getTileEntityOffset(offset.x(), offset.y(), offset.z()); + if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CAP_BLOCK + && te instanceof TE_SpaceElevatorCapacitor) { + capacitors.add((TE_SpaceElevatorCapacitor) te); + } else { + formationChecklist = false; + } + } else { + // Check for Glass + if(!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameBorosilicate)) { + formationChecklist = false; + } + } + } + } + } + } + // Anchor + + // Coil holders + + // Coils + + if(minCasingAmount > 0) { + formationChecklist = false; + } + + return formationChecklist; + } + + @Override + public String[] getInfoData() { + final ArrayList<String> ll = new ArrayList<>(); + ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); + + 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 stack) { return 10000; } + + @Override + public int getPollutionPerTick(ItemStack stack) { return 0; } + + @Override + public int getDamageToComponent(ItemStack stack) { return 0; } + + @Override + public boolean explodesOnComponentBreak(ItemStack stack) { return false; } +} diff --git a/src/main/java/common/tileentities/TE_IchorJar.java b/src/main/java/common/tileentities/TE_IchorJar.java new file mode 100644 index 0000000000..1baa06a969 --- /dev/null +++ b/src/main/java/common/tileentities/TE_IchorJar.java @@ -0,0 +1,10 @@ +package common.tileentities; + +import thaumcraft.common.tiles.TileJarFillable; + +public class TE_IchorJar extends TileJarFillable { + + public TE_IchorJar() { + super.maxAmount = 4096; + } +} diff --git a/src/main/java/common/tileentities/TE_IchorVoidJar.java b/src/main/java/common/tileentities/TE_IchorVoidJar.java new file mode 100644 index 0000000000..6644461a88 --- /dev/null +++ b/src/main/java/common/tileentities/TE_IchorVoidJar.java @@ -0,0 +1,10 @@ +package common.tileentities; + +import thaumcraft.common.tiles.TileJarFillableVoid; + +public class TE_IchorVoidJar extends TileJarFillableVoid { + + public TE_IchorVoidJar() { + super.maxAmount = 4096; + } +} diff --git a/src/main/java/common/tileentities/TE_ItemProxyCable.java b/src/main/java/common/tileentities/TE_ItemProxyCable.java new file mode 100644 index 0000000000..f4caab3d36 --- /dev/null +++ b/src/main/java/common/tileentities/TE_ItemProxyCable.java @@ -0,0 +1,121 @@ +package common.tileentities; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class TE_ItemProxyCable extends TileEntity { + + private static final float THICKNESS = 0.5F; + private byte connections = 0; + private byte connectionAllowed = 63; + private String idCache = null; + + public TE_ItemProxyCable() { + + } + + @Override + public void updateEntity() { + // Check all 6 sides and connect the conduit if it is allowed to + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final TileEntity te = super.getWorldObj().getTileEntity( + super.xCoord + side.offsetX, + super.yCoord + side.offsetY, + super.zCoord + side.offsetZ); + if(te instanceof TE_ItemProxyCable) { + final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; + setConnection(side, cable.isConnectionAllowed(side.getOpposite())); + } else { + setConnection(side, false); + } + } + } + + public static float getThickness() { + return THICKNESS; + } + + /** + * Builds a simple unique identifier for this TileEntity by appending + * the x, y, and z coordinates in a string. + * + * @return unique identifier for this TileEntity + */ + public String getIdentifier() { + if(idCache == null) { + idCache = "" + super.xCoord + super.yCoord + super.zCoord; + return idCache; + } else { + return idCache; + } + } + + /** + * 0 0 0 0 0 0 0 0 = 0 -> no connection </br> + * 0 0 0 0 0 0 0 1 = 1 -> down </br> + * 0 0 0 0 0 0 1 0 = 2 -> up </br> + * 0 0 0 0 0 1 0 0 = 4 -> north </br> + * 0 0 0 0 1 0 0 0 = 8 -> south </br> + * 0 0 0 1 0 0 0 0 = 16 -> west </br> + * 0 0 1 0 0 0 0 0 = 32 -> east </br> + * + * @param side + * The side for which to set the connection status. + * @param connected + * Whether this side should be connected or not + * @return + * True if the connection was allowed + */ + public boolean setConnection(ForgeDirection side, boolean connected) { + if(isConnectionAllowed(side)){ + switch(side) { + case DOWN: connections = (byte) ((connected) ? connections | 1 : connections ^ 1); break; + case UP: connections = (byte) ((connected) ? connections | 2 : connections ^ 2); break; + case NORTH: connections = (byte) ((connected) ? connections | 4 : connections ^ 4); break; + case SOUTH: connections = (byte) ((connected) ? connections | 8 : connections ^ 8); break; + case WEST: connections = (byte) ((connected) ? connections | 16 : connections ^ 16); break; + case EAST: connections = (byte) ((connected) ? connections | 32 : connections ^ 32); break; + default: return false; + } + return true; + } else { + return false; + } + } + + public boolean isConnected(ForgeDirection side) { + switch(side) { + case DOWN: return (connections & 1) == 1; + case UP: return (connections & 2) == 2; + case NORTH: return (connections & 4) == 4; + case SOUTH: return (connections & 8) == 8; + case WEST: return (connections & 16) == 16; + case EAST: return (connections & 32) == 32; + default: return false; + } + } + + public void setConnectionAllowed(ForgeDirection side, boolean allowed) { + switch(side) { + case DOWN: connectionAllowed = (byte) ((allowed) ? connectionAllowed | 1 : connectionAllowed ^ 1); break; + case UP: connectionAllowed = (byte) ((allowed) ? connectionAllowed | 2 : connectionAllowed ^ 2); break; + case NORTH: connectionAllowed = (byte) ((allowed) ? connectionAllowed | 4 : connectionAllowed ^ 4); break; + case SOUTH: connectionAllowed = (byte) ((allowed) ? connectionAllowed | 8 : connectionAllowed ^ 8); break; + case WEST: connectionAllowed = (byte) ((allowed) ? connectionAllowed | 16 : connectionAllowed ^ 16); break; + case EAST: connectionAllowed = (byte) ((allowed) ? connectionAllowed | 32 : connectionAllowed ^ 32); break; + default: break; + } + } + + public boolean isConnectionAllowed(ForgeDirection side) { + switch(side) { + case DOWN: return (connectionAllowed & 1) == 1; + case UP: return (connectionAllowed & 2) == 2; + case NORTH: return (connectionAllowed & 4) == 4; + case SOUTH: return (connectionAllowed & 8) == 8; + case WEST: return (connectionAllowed & 16) == 16; + case EAST: return (connectionAllowed & 32) == 32; + default: return false; + } + } +} diff --git a/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java b/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java new file mode 100644 index 0000000000..1eca1ff3df --- /dev/null +++ b/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java @@ -0,0 +1,179 @@ +package common.tileentities; + +import java.util.HashSet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class TE_ItemProxyEndpoint extends TileEntity implements ISidedInventory { + + private byte channel = -1; + private IInventory proxyInventory = null; + private int tickCounter = 0; + + public TE_ItemProxyEndpoint() { + channel = 0; + } + + public void setChannel(byte channel) { + this.channel = channel; + } + + public int getChannel() { return channel; } + + @Override + public void updateEntity() { + if(tickCounter == 20) { + if(channel != -1) { + proxyInventory = searchSource(); + } + tickCounter = 0; + } + tickCounter++; + } + + private TE_ItemProxySource searchSource() { + + final HashSet<TE_ItemProxySource> sources = new HashSet<>(); + final HashSet<String> visited = new HashSet<>(); + + for(ForgeDirection next : ForgeDirection.VALID_DIRECTIONS) { + final TileEntity te = super.getWorldObj().getTileEntity( + super.xCoord + next.offsetX, + super.yCoord + next.offsetY, + super.zCoord + next.offsetZ); + if(te instanceof TE_ItemProxyCable) { + final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; + if(cable.isConnected(next.getOpposite())) { + searchSourceRecursive(sources, visited, next.getOpposite(), cable); + } + } + } + + if(sources.isEmpty()) { + return null; + } else { + return sources.iterator().next(); + } + + } + + private void searchSourceRecursive(HashSet<TE_ItemProxySource> sources, HashSet<String> visited, + ForgeDirection from, TE_ItemProxyCable nextTarget) { + + if(!visited.contains(nextTarget.getIdentifier())) { + visited.add(nextTarget.getIdentifier()); + + for(ForgeDirection next : ForgeDirection.VALID_DIRECTIONS) { + if(next != from) { + final TileEntity te = super.getWorldObj().getTileEntity( + nextTarget.xCoord + next.offsetX, + nextTarget.yCoord + next.offsetY, + nextTarget.zCoord + next.offsetZ); + if(te instanceof TE_ItemProxyCable) { + final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; + if(cable.isConnected(next.getOpposite())) { + searchSourceRecursive(sources, visited, next.getOpposite(), cable); + } + } else if (te instanceof TE_ItemProxySource) { + sources.add((TE_ItemProxySource) te); + } + } + } + } + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public ItemStack getStackInSlot(int slot) { + if(proxyInventory != null && slot == 0) { + return proxyInventory.getStackInSlot(channel); + } else { + return null; + } + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + if(proxyInventory != null && slot == 0) { + return proxyInventory.decrStackSize(channel, amount); + } else { + return null; + } + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return (proxyInventory != null) ? proxyInventory.getStackInSlotOnClosing(channel) : null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemStack) { + if(proxyInventory != null && slot == 0) { + proxyInventory.setInventorySlotContents(channel, itemStack); + } + } + + @Override + public String getInventoryName() { + return (proxyInventory != null) ? "Connected: " + proxyInventory.getInventoryName() : "Untethered Proxy"; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public int getInventoryStackLimit() { + return (proxyInventory != null) ? proxyInventory.getInventoryStackLimit() : 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) { + if(proxyInventory != null && slot == 0) { + return proxyInventory.isItemValidForSlot(channel, itemStack); + } else { + return false; + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[]{0}; + } + + @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 slot == 0; + } + +} diff --git a/src/main/java/common/tileentities/TE_ItemProxySource.java b/src/main/java/common/tileentities/TE_ItemProxySource.java new file mode 100644 index 0000000000..a960a7b914 --- /dev/null +++ b/src/main/java/common/tileentities/TE_ItemProxySource.java @@ -0,0 +1,112 @@ +package common.tileentities; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class TE_ItemProxySource extends TileEntity implements IInventory { + + private ItemStack[] slots = new ItemStack[16]; + private String idCache = null; + + /** + * Builds a simple unique identifier for this TileEntity by appending + * the x, y, and z coordinates in a string. + * + * @return unique identifier for this TileEntity + */ + public String getIdentifier() { + if(idCache == null) { + idCache = "" + super.xCoord + super.yCoord + super.zCoord; + return idCache; + } else { + return idCache; + } + } + + @Override + public int getSizeInventory() { + return slots.length; + } + + @Override + public ItemStack getStackInSlot(int slot) { + return slots[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + if(slots[slot] != null) { + + ItemStack copy; + + if(slots[slot].stackSize == amount) { + copy = slots[slot]; + slots[slot] = null; + super.markDirty(); + return copy; + } else { + copy = slots[slot].splitStack(amount); + if(slots[slot].stackSize == 0) { + slots[slot] = null; + } + return copy; + } + + } else { + return null; + } + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemStack) { + slots[slot] = itemStack; + if(itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { + itemStack.stackSize = getInventoryStackLimit(); + } + super.markDirty(); + } + + @Override + public String getInventoryName() { + return "Item Proxy Source"; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemStack) { + return true; + } +} diff --git a/src/main/java/common/tileentities/TE_ItemServerIOPort.java b/src/main/java/common/tileentities/TE_ItemServerIOPort.java new file mode 100644 index 0000000000..0e96ff75b9 --- /dev/null +++ b/src/main/java/common/tileentities/TE_ItemServerIOPort.java @@ -0,0 +1,145 @@ +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_SpaceElevatorCapacitor.java b/src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java new file mode 100644 index 0000000000..a8de775f98 --- /dev/null +++ b/src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java @@ -0,0 +1,54 @@ +package common.tileentities; + +import net.minecraft.tileentity.TileEntity; + +public class TE_SpaceElevatorCapacitor extends TileEntity { + + private float chargeLevel = 0.0F; + private boolean isDamaged = true; + + /** + * Called by {@link GTMTE_SpaceElevator} while charging + * @param charge + * Current elevator charge + * @param maxCharge + * Charge level it is trying to reach + */ + public void updateChargeLevel(int charge, int maxCharge) { + chargeLevel = ((float) charge) / ((float) maxCharge); + } + + /** + * Called by {@link client.renderer.TESR_SECapacitor} to calculate the block's colour saturation + * @return + * Charge level from 0.0F to 1.0F + */ + public float getChargeLevel() { + return chargeLevel; + } + + /** + * Called by {@link GTMTE_SpaceElevator} in case of power loss + */ + public void resetChargeLevel() { + chargeLevel = 0.0F; + } + + /** + * Called by {@link GTMTE_SpaceElevator} in case of maintenance issues + * @param isDamaged + * has maintenance issue + */ + public void setIsDamaged(boolean isDamaged) { + this.isDamaged = isDamaged; + } + + /** + * Called by {@link client.renderer.TESR_SECapacitor} to check whether the block should be rendered red + * @return + * should be rendered red + */ + public boolean isDamaged() { + return isDamaged; + } +} diff --git a/src/main/java/common/tileentities/TE_SpaceElevatorTether.java b/src/main/java/common/tileentities/TE_SpaceElevatorTether.java new file mode 100644 index 0000000000..c4df059563 --- /dev/null +++ b/src/main/java/common/tileentities/TE_SpaceElevatorTether.java @@ -0,0 +1,23 @@ +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; + +public class TE_SpaceElevatorTether extends TileEntity { + + @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_TFFTMultiHatch.java b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java new file mode 100644 index 0000000000..c4f9451478 --- /dev/null +++ b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java @@ -0,0 +1,222 @@ +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; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { + + private static final int OUTPUT_PER_SECOND = 1000; // L/s + + private MultiFluidHandler mfh; + private int tickCounter = 0; + private boolean autoOutput = false; + + public void setMultiFluidHandler(MultiFluidHandler mfh) { + this.mfh = mfh; + } + + public void toggleAutoOutput() { + autoOutput = !autoOutput; + } + + public boolean isOutputting() { + return autoOutput; + } + + @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; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return (mfh != null) ? mfh.pushFluid(resource, doFill) : 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return (mfh != null) ? new FluidStack(resource.getFluid(), mfh.pullFluid(resource, doDrain)) : null; + } + + /** + * Drains fluid out of 0th internal tank. + * If the TFFT Controller contains an Integrated Circuit, drain fluid + * from the slot equal to the circuit configuration. + * + * @param from + * Orientation the fluid is drained to. + * @param maxDrain + * Maximum amount of fluid to drain. + * @param doDrain + * If false, drain will only be simulated. + * @return FluidStack representing the Fluid and amount that was (or would have been, if + * simulated) drained. + */ + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if(mfh != null) { + final FluidStack drain = mfh.getFluid(0); + if(drain != null) { + // If there's no integrated circuit in the T.F.F.T. controller, output slot 0 + final byte selectedSlot = (mfh.getSelectedFluid() == -1) ? 0 : mfh.getSelectedFluid(); + + return new FluidStack( + drain.getFluid(), + mfh.pullFluid(new FluidStack(drain.getFluid(), maxDrain), selectedSlot, doDrain) + ); + } + } + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return (mfh != null) && mfh.couldPush(new FluidStack(fluid, 1)); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return (mfh != null) && mfh.contains(new FluidStack(fluid, 1)); + } + + @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; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + nbt = (nbt == null) ? new NBTTagCompound() : nbt; + + nbt.setBoolean("autoOutput", autoOutput); + + super.writeToNBT(nbt); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + nbt = (nbt == null) ? new NBTTagCompound() : nbt; + + autoOutput = nbt.getBoolean("autoOutput"); + + super.readFromNBT(nbt); + } + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/src/main/java/common/tileentities/TE_ThaumiumReinforcedJar.java b/src/main/java/common/tileentities/TE_ThaumiumReinforcedJar.java new file mode 100644 index 0000000000..23b19495ae --- /dev/null +++ b/src/main/java/common/tileentities/TE_ThaumiumReinforcedJar.java @@ -0,0 +1,10 @@ +package common.tileentities; + +import thaumcraft.common.tiles.TileJarFillable; + +public class TE_ThaumiumReinforcedJar extends TileJarFillable { + + public TE_ThaumiumReinforcedJar() { + super.maxAmount = 256; + } +} diff --git a/src/main/java/common/tileentities/TE_ThaumiumReinforcedVoidJar.java b/src/main/java/common/tileentities/TE_ThaumiumReinforcedVoidJar.java new file mode 100644 index 0000000000..c648d4be00 --- /dev/null +++ b/src/main/java/common/tileentities/TE_ThaumiumReinforcedVoidJar.java @@ -0,0 +1,10 @@ +package common.tileentities; + +import thaumcraft.common.tiles.TileJarFillableVoid; + +public class TE_ThaumiumReinforcedVoidJar extends TileJarFillableVoid { + + public TE_ThaumiumReinforcedVoidJar() { + super.maxAmount = 256; + } +} |