From 7d1f51a8937e0a86486267437d444696e81e8aa0 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:04:28 +0200 Subject: Buildscript + Spotless (#318) * Convert AES.java to readable class * Buildscript * Spotless --- .../xmod/gregtech/common/Meta_GT_Proxy.java | 1176 ++++++------ .../xmod/gregtech/common/StaticFields59.java | 549 +++--- .../common/blocks/GTPP_Block_Machines.java | 988 +++++----- .../gregtech/common/blocks/GTPP_Item_Machines.java | 457 ++--- .../common/blocks/GregtechMetaCasingBlocks.java | 114 +- .../common/blocks/GregtechMetaCasingBlocks2.java | 131 +- .../common/blocks/GregtechMetaCasingBlocks3.java | 693 +++---- .../common/blocks/GregtechMetaCasingBlocks4.java | 184 +- .../common/blocks/GregtechMetaCasingBlocks5.java | 148 +- .../blocks/GregtechMetaCasingBlocksAbstract.java | 260 ++- .../GregtechMetaCasingBlocksPipeGearbox.java | 156 +- .../common/blocks/GregtechMetaCasingItems.java | 9 +- .../common/blocks/GregtechMetaItemCasings1.java | 53 +- .../blocks/GregtechMetaItemCasingsAbstract.java | 98 +- .../blocks/GregtechMetaSpecialMachineCasings.java | 117 +- .../blocks/GregtechMetaSpecialMultiCasings.java | 204 ++- .../blocks/GregtechMetaSpecialMultiCasings2.java | 167 +- .../blocks/GregtechMetaTieredCasingBlocks1.java | 172 +- .../common/blocks/fluid/GregtechFluidHandler.java | 266 ++- .../blocks/textures/CasingTextureHandler.java | 146 +- .../blocks/textures/CasingTextureHandler2.java | 98 +- .../blocks/textures/CasingTextureHandler3.java | 118 +- .../textures/TexturesCentrifugeMultiblock.java | 300 +-- .../common/blocks/textures/TexturesGregtech58.java | 947 +++++----- .../common/blocks/textures/TexturesGregtech59.java | 957 +++++----- .../blocks/textures/TexturesGrinderMultiblock.java | 266 +-- .../common/blocks/textures/TexturesGtBlock.java | 1578 ++++++++-------- .../blocks/textures/TexturesGtCutomCovers.java | 47 +- .../common/blocks/textures/TexturesGtTools.java | 92 +- .../turbine/LargeTurbineTextureHandler.java | 601 +++--- .../common/computer/GT_ComputerCube_Setup.java | 132 +- .../computer/GT_Computercube_Description.java | 702 +++++-- .../common/computer/GT_Computercube_Simulator.java | 269 +-- .../xmod/gregtech/common/covers/CoverManager.java | 198 +- .../common/covers/GTPP_Cover_Overflow.java | 488 ++--- .../common/covers/GTPP_Cover_Overflow_Item.java | 342 ++-- .../common/covers/GTPP_Cover_ToggleVisual.java | 349 ++-- .../gregtech/common/helpers/ChargingHelper.java | 848 ++++----- .../gregtech/common/helpers/CraftingHelper.java | 58 +- .../common/helpers/FlotationRecipeHandler.java | 97 +- .../gregtech/common/helpers/GT_MethodHelper.java | 122 +- .../common/helpers/MachineUpdateHandler.java | 55 +- .../gregtech/common/helpers/TreeFarmHelper.java | 1935 +++++++++---------- .../common/helpers/VolumetricFlaskHelper.java | 305 ++- .../helpers/autocrafter/AC_Helper_Container.java | 203 +- .../helpers/autocrafter/AC_Helper_Utils.java | 132 +- .../common/helpers/tesseract/TesseractHelper.java | 476 +++-- .../common/helpers/treefarm/TreeGenerator.java | 715 ++++---- .../gregtech/common/items/MetaCustomCoverItem.java | 389 ++-- .../common/items/MetaGeneratedGregtechItems.java | 1571 ++++++++++++---- .../common/items/MetaGeneratedGregtechTools.java | 171 +- .../items/behaviours/Behaviour_Choocher.java | 147 +- .../behaviours/Behaviour_Electric_Lighter.java | 388 ++-- .../common/items/behaviours/Behaviour_Grinder.java | 174 +- .../items/behaviours/Behaviour_Prospecting_Ex.java | 226 ++- .../common/items/covers/MetaItemCoverCasings.java | 57 +- .../gregtech/common/render/GTPP_CapeRenderer.java | 996 +++++----- .../gregtech/common/render/GTPP_FlaskRenderer.java | 18 +- .../common/render/GTPP_Render_MachineBlock.java | 1401 +++++++------- .../GT_MetaTileEntity_ElectricAutoWorkbench.java | 1586 ++++++++-------- ...GT_MetaTileEntity_ElectricInventoryManager.java | 1006 +++++----- .../GT_MetaTileEntity_TesseractGenerator.java | 1443 ++++++++------- .../GT_MetaTileEntity_TesseractTerminal.java | 1151 ++++++------ .../generators/GT_MetaTileEntity_Boiler_Base.java | 553 +++--- .../generators/GT_MetaTileEntity_Boiler_HV.java | 75 +- .../generators/GT_MetaTileEntity_Boiler_LV.java | 93 +- .../generators/GT_MetaTileEntity_Boiler_MV.java | 93 +- .../generators/GT_MetaTileEntity_Boiler_Solar.java | 384 ++-- .../generators/GT_MetaTileEntity_RfConvertor.java | 647 +++---- .../GT_MetaTileEntity_SemiFluidGenerator.java | 310 ++-- ...gtechMetaTileEntityDoubleFuelGeneratorBase.java | 297 +-- .../GregtechMetaTileEntityGeothermalGenerator.java | 300 +-- .../GregtechMetaTileEntityRocketFuelGenerator.java | 278 +-- .../GregtechMetaTileEntitySolarGenerator.java | 369 ++-- .../generators/GregtechMetaTileEntity_RTG.java | 751 ++++---- .../GT_MetaTileEntity_ULV_CombustionGenerator.java | 33 +- .../ULV/GT_MetaTileEntity_ULV_GasTurbine.java | 37 +- .../ULV/GT_MetaTileEntity_ULV_SteamTurbine.java | 36 +- .../creative/GregtechMetaCreativeEnergyBuffer.java | 424 +++-- .../basic/GT_MetaTileEntity_CropHarvestor.java | 1372 +++++++------- .../basic/GT_MetaTileEntity_WorldAccelerator.java | 613 +++---- .../GregtechMetaAtmosphericReconditioner.java | 1689 ++++++++--------- .../machines/basic/GregtechMetaCondensor.java | 294 +-- .../basic/GregtechMetaGarbageCollector.java | 702 ++++--- .../basic/GregtechMetaPollutionCreator.java | 835 +++++---- .../basic/GregtechMetaPollutionDetector.java | 935 +++++----- .../basic/GregtechMetaTileEntityChunkLoader.java | 832 +++++---- ...GregtechMetaTileEntityThaumcraftResearcher.java | 466 +++-- .../basic/GregtechMetaTileEntity_AutoChisel.java | 239 +-- .../basic/GregtechMetaTileEntity_BasicWasher.java | 104 +- .../GregtechMetaTileEntity_ChemicalReactor.java | 1283 ++++++------- ...regtechMetaTileEntity_CompactFusionReactor.java | 1382 +++++++------- .../basic/GregtechMetaTileEntity_PocketFusion.java | 1386 +++++++------- .../GregtechMetaTileEntity_ReactorColdTrap.java | 93 +- ...egtechMetaTileEntity_ReactorProcessingUnit.java | 104 +- .../basic/GregtechMetaWirelessCharger.java | 1249 +++++++------ .../machines/multi/misc/GMTE_AmazonPackager.java | 1152 ++++++------ .../multi/misc/GregtechMTE_TeslaTower.java | 949 +++++----- ...gtechMetaTileEntity_IndustrialAlloySmelter.java | 737 ++++---- ...regtechMetaTileEntity_IndustrialArcFurnace.java | 564 +++--- ...regtechMetaTileEntity_IndustrialCentrifuge.java | 430 +++-- .../GregtechMetaTileEntity_IndustrialChisel.java | 818 +++++---- .../GregtechMetaTileEntity_IndustrialCokeOven.java | 419 ++--- ...echMetaTileEntity_IndustrialCuttingMachine.java | 391 ++-- ...regtechMetaTileEntity_IndustrialDehydrator.java | 728 ++++---- ...gtechMetaTileEntity_IndustrialElectrolyzer.java | 318 ++-- .../GregtechMetaTileEntity_IndustrialExtruder.java | 408 ++--- ...egtechMetaTileEntity_IndustrialFluidHeater.java | 388 ++-- ...egtechMetaTileEntity_IndustrialForgeHammer.java | 594 +++--- ...GregtechMetaTileEntity_IndustrialMacerator.java | 444 +++-- .../GregtechMetaTileEntity_IndustrialMixer.java | 398 ++-- ...aTileEntity_IndustrialMolecularTransformer.java | 447 ++--- ...gtechMetaTileEntity_IndustrialMultiMachine.java | 997 +++++----- ...regtechMetaTileEntity_IndustrialPlatePress.java | 414 ++--- .../GregtechMetaTileEntity_IndustrialSifter.java | 390 ++-- .../GregtechMetaTileEntity_IndustrialSinter.java | 24 - ...MetaTileEntity_IndustrialThermalCentrifuge.java | 377 ++-- ...techMetaTileEntity_IndustrialVacuumFreezer.java | 484 ++--- ...GregtechMetaTileEntity_IndustrialWashPlant.java | 623 +++---- .../GregtechMetaTileEntity_IndustrialWireMill.java | 347 ++-- .../GregtechMetaTileEntity_IronBlastFurnace.java | 898 +++++---- .../processing/GregtechMetaTileEntity_IsaMill.java | 1296 +++++++------ .../GregtechMetaTileEntity_SpargeTower.java | 851 ++++----- .../GregtechMetaTileEntity_Adv_AssemblyLine.java | 1302 ++++++------- ...egtechMetaTileEntity_Adv_DistillationTower.java | 889 ++++----- .../advanced/GregtechMetaTileEntity_Adv_EBF.java | 951 +++++----- .../GregtechMetaTileEntity_Adv_Fusion_MK4.java | 199 +- .../GregtechMetaTileEntity_Adv_HeatExchanger.java | 239 ++- .../GregtechMetaTileEntity_Adv_Implosion.java | 358 ++-- .../GregtechMetaTileEntity_SteamCompressor.java | 259 ++- .../GregtechMetaTileEntity_SteamMacerator.java | 264 ++- .../multi/production/GT4Entity_AutoCrafter.java | 1223 +++++++------ .../multi/production/GT4Entity_ThermalBoiler.java | 679 +++---- .../GregtechMTE_ElementalDuplicator.java | 1376 +++++++------- .../production/GregtechMTE_FastNeutronReactor.java | 35 +- .../production/GregtechMTE_FrothFlotationCell.java | 852 +++++---- .../production/GregtechMTE_LargeNaqReactor.java | 111 +- .../production/GregtechMTE_MiniFusionPlant.java | 77 +- .../production/GregtechMTE_NuclearReactor.java | 1046 +++++------ .../GregtechMetaTileEntityGeneratorArray.java | 966 +++++----- .../production/GregtechMetaTileEntityTreeFarm.java | 1070 ++++++----- .../GregtechMetaTileEntity_AlloyBlastSmelter.java | 609 +++--- .../GregtechMetaTileEntity_Cyclotron.java | 847 +++++---- ...egtechMetaTileEntity_IndustrialFishingPond.java | 1185 ++++++------ ...egtechMetaTileEntity_IndustrialRockBreaker.java | 996 +++++----- .../GregtechMetaTileEntity_LargeRocketEngine.java | 1135 ++++++------ ...techMetaTileEntity_LargeSemifluidGenerator.java | 651 ++++--- .../GregtechMetaTileEntity_MassFabricator.java | 1314 ++++++------- .../GregtechMetaTileEntity_Refinery.java | 453 +++-- .../GregtechMetaTileEntity_SolarTower.java | 1491 ++++++++------- .../algae/GregtechMTE_AlgaePondBase.java | 953 +++++----- ...gtechMetaTileEntity_BedrockMiningPlatform1.java | 5 - ...gtechMetaTileEntity_BedrockMiningPlatform2.java | 5 - ...chMetaTileEntity_BedrockMiningPlatformBase.java | 1255 ++++++------- .../chemplant/GregtechMTE_ChemicalPlant.java | 1936 ++++++++++---------- .../turbines/GT_MTE_LargeTurbine_Gas.java | 95 +- .../turbines/GT_MTE_LargeTurbine_Plasma.java | 298 +-- .../turbines/GT_MTE_LargeTurbine_SHSteam.java | 150 +- .../turbines/GT_MTE_LargeTurbine_Steam.java | 151 +- .../GregtechMetaTileEntity_LargerTurbineBase.java | 1620 ++++++++-------- .../storage/GregtechMetaTileEntity_MultiTank.java | 1025 +++++------ ...chMetaTileEntity_PowerSubStationController.java | 1521 +++++++-------- .../misc/GT_TileEntity_ComputerCube.java | 1812 +++++++++--------- .../tileentities/misc/TileEntitySolarHeater.java | 674 +++---- .../redstone/GT_MetaTileEntity_RedstoneBase.java | 230 +-- .../GT_MetaTileEntity_RedstoneButtonPanel.java | 436 +++-- .../GT_MetaTileEntity_RedstoneCircuitBlock.java | 954 +++++----- .../redstone/GT_MetaTileEntity_RedstoneLamp.java | 115 +- .../GT_MetaTileEntity_RedstoneStrengthDisplay.java | 288 +-- .../GT_MetaTileEntity_RedstoneStrengthScale.java | 83 +- .../GT_MetaTileEntity_AdvancedCraftingTable.java | 1069 +++++------ .../GT_MetaTileEntity_BronzeCraftingTable.java | 127 +- .../GT_MetaTileEntity_ConnectableCrate.java | 1101 ++++++----- .../storage/GT_MetaTileEntity_TieredChest.java | 393 ++-- .../storage/GT_MetaTileEntity_TieredTank.java | 310 ++-- .../storage/GregtechMetaEnergyBuffer.java | 897 +++++---- .../storage/GregtechMetaSafeBlock.java | 107 +- .../GT_MetaTileEntity_InfiniteItemHolder.java | 180 +- .../storage/shelving/GT4Entity_Shelf.java | 693 +++---- .../shelving/GT4Entity_Shelf_Compartment.java | 49 +- .../storage/shelving/GT4Entity_Shelf_Desk.java | 68 +- .../shelving/GT4Entity_Shelf_FileCabinet.java | 87 +- .../storage/shelving/GT4Entity_Shelf_Iron.java | 65 +- .../storage/shelving/GT4Entity_Shelf_Large.java | 500 +++-- .../common/tools/TOOL_Gregtech_AngleGrinder.java | 351 ++-- .../gregtech/common/tools/TOOL_Gregtech_Base.java | 340 ++-- .../common/tools/TOOL_Gregtech_Choocher.java | 397 ++-- .../tools/TOOL_Gregtech_ElectricButcherKnife.java | 330 ++-- .../tools/TOOL_Gregtech_ElectricLighter.java | 282 ++- .../common/tools/TOOL_Gregtech_ElectricSnips.java | 125 +- 190 files changed, 54609 insertions(+), 50431 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index fe0be2f126..535b4b7169 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -1,12 +1,5 @@ package gtPlusPlus.xmod.gregtech.common; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -import org.apache.commons.lang3.ArrayUtils; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -34,6 +27,10 @@ import gtPlusPlus.xmod.gregtech.common.helpers.MachineUpdateHandler; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_WorldAccelerator; import ic2.core.init.BlocksItems; import ic2.core.init.InternalName; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.*; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -44,531 +41,547 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; public class Meta_GT_Proxy { - static { - Logger.INFO("GT_PROXY - initialized."); - sDoesVolumetricFlaskExist = ReflectionUtils.doesClassExist("gregtech.common.items.GT_VolumetricFlask"); - } - - public static List GT_BlockIconload = new ArrayList<>(); - public static List GT_ItemIconload = new ArrayList<>(); - - public static AutoMap GT_ValidHeatingCoilMetas = new AutoMap(); - - private static Class sBaseMetaTileEntityClass; - private static Class sBaseMetaTileEntityClass2; - - public static AchievementHandler mAssemblyAchievements; - - public static final Map mCustomGregtechMetaTooltips = new LinkedHashMap(); - - /** - * Does this feature exist within GT? Saves loading useless content if not. - */ - public static final boolean sDoesVolumetricFlaskExist; - - @SideOnly(Side.CLIENT) - public static IIconRegister sBlockIcons, sItemIcons; - - public Meta_GT_Proxy() { - - } - - public static Block sBlockMachines; - - public static void preInit() { - - //New GT++ Block, yay! (Progress) - //sBlockMachines = new GTPP_Block_Machines(); - fixIC2FluidNames(); - - GT_Log.out.println("GT++ Mod: Register TileEntities."); - BaseMetaTileEntity tBaseMetaTileEntity = constructBaseMetaTileEntity(); - BaseMetaTileEntity tBaseMetaTileEntity2 = constructBaseMetaTileEntityCustomPower(); - - GT_Log.out.println("GT++ Mod: Testing BaseMetaTileEntity."); - if (tBaseMetaTileEntity == null || tBaseMetaTileEntity2 == null) { - GT_Log.err.println("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); - CORE.crash("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); - } - - //Gotta set it here so that we don't try call gregtech too early. - //Must set on the correct side - - if (ReflectionUtils.doesFieldExist(GT_Proxy.class, "gt6Pipe")) { - StaticFields59.mGT6StylePipes = (boolean) StaticFields59.getFieldFromGregtechProxy("gt6Pipe"); - } - else { - StaticFields59.mGT6StylePipes = false; - } - - GT_Log.out.println("GT++ Mod: Registering custom BaseMetaTileEntities."); - GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); - GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); - CoverManager.generateCustomCovers(); - } - - public static void init() { - setValidHeatingCoilMetas(); - PollutionUtils.setPollutionFluids(); - fixIC2FluidNames(); - Utils.registerEvent(new MachineUpdateHandler()); - } - - public static void postInit() { - mAssemblyAchievements = new AchievementHandler(); - fixIC2FluidNames(); - - // Finalise TAE - TAE.finalizeTAE(); - } - - @SuppressWarnings("deprecation") - public static void fixIC2FluidNames() { - //Fix IC2 Hot Water name - try { - String aNewHeatedWaterName = "Heated Water"; - Logger.INFO("Renaming [IC2 Hotspring Water] --> ["+aNewHeatedWaterName+"].");LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water"); - LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName); - LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); - - Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); - if (b != null) { - LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); - LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); - } - Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); - if (f != null) { - LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); - int aDam = FluidRegistry.getFluidID(f); - ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); - if (s != null) { - LanguageRegistry.addName(s, aNewHeatedWaterName); - } - } - - String[] aLangs = new String[] { - "de_DE", - "en_US", - "en_GB", - "en_IC", - "es_AR", - "es_ES", - "es_MX", - "es_UY", - "es_VE", - "fr_CA", - "fr_FR", - "it_IT", - "ko_KR", - "pt_BR", - "pt_PT", - "ru_RU", - "sv_SE", - "tr_TR", - "zh_CN", - "zh_TW", - }; - String[] aLangValues = new String[] { - "Erhitztes Wasser", - "Heated Water", - "Heated Water", - "Heated Water", - "Agua caliente", - "Agua caliente", - "Agua caliente", - "Agua caliente", - "Agua caliente", - "Eau chauffée", - "Eau chauffée", - "Acqua riscaldata", - "온수", - "Água aquecida", - "Água aquecida", - "Вода с подогревом", - "Uppvärmt vatten", - "Isıtılmış Su", - "热水", - "热水", - - }; - for (int i=0;i aFreezerMapRebaked = new AutoMap(); - AutoMap aRemovedRecipes = new AutoMap(); - - //Find recipes containing Plasma and map them - for (GT_Recipe y : GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList) { - if (y.mFluidInputs.length > 0) { - for (FluidStack r : y.mFluidInputs) { - if (r.getUnlocalizedName().toLowerCase().contains("plasma")) { - aRemovedRecipes.put(y); - continue; - } - } - aFreezerMapRebaked.put(y); - } - } - - AutoMap aNewRecipes = new AutoMap(); - int aAtomicMass = 0; - int aAtomicTier = 0; - - final FluidStack NULL_PLASMA = Materials._NULL.getPlasma(1); - - for (String s : ELEMENT.NAMES) { - - aAtomicMass++; - aAtomicTier = (aAtomicMass/30)+1; - FluidStack aMoltenFluid = null; - FluidStack aPlasma = null; - - //Try Get Material via Gregtech - Materials aGregMaterial = MaterialUtils.getMaterial(s); - if (aGregMaterial != null) { - aMoltenFluid = aGregMaterial.getMolten(1); - if (aMoltenFluid == null) { - aMoltenFluid = aGregMaterial.getFluid(1); - if (aMoltenFluid == null) { - aMoltenFluid = aGregMaterial.getGas(1); - if (aMoltenFluid == null) { - aMoltenFluid = aGregMaterial.getSolid(1); - } - } - } - aPlasma = aGregMaterial.getPlasma(100); - } - - //Just wildcard values - if (aMoltenFluid == null || aPlasma == null) { - if (aMoltenFluid == null) { - aMoltenFluid = FluidUtils.getWildcardFluidStack(s, 1); - } - if (aPlasma == null) { - aPlasma = FluidUtils.getFluidStack("plasma."+s.toLowerCase(), 1); - } - } - - //Skip this material - if (aMoltenFluid == null || aPlasma == null || aPlasma.isFluidEqual(NULL_PLASMA)) { - Logger.INFO("Could not generate Advanced Vacuum Freezer recipe. Cooling "+s+" plasma. Molten Form Exists? "+(aMoltenFluid != null)+" | Plasma Exists? "+(aPlasma != null)); - continue; - } - else { - //Build a new plasma recipe - int aTotalTickTime = (20 * 1 + (aAtomicMass)); - GTPP_Recipe aTempRecipe = new GTPP_Recipe(true, - new ItemStack[] {}, - new ItemStack[] {}, - null, - new int[] {10000}, - new FluidStack[] { - aPlasma, - FluidUtils.getFluidStack("cryotheum", aTotalTickTime) - }, - new FluidStack[] { - aMoltenFluid - }, - aTotalTickTime, - (int) GT_Values.V[4+aAtomicTier], - aAtomicMass); - - //Add it to the map if it's valid - if (aTempRecipe != null) { - aNewRecipes.put(aTempRecipe); - } - } - - } - - - //Add the new recipes to the map we will rebake over the original - for (GTPP_Recipe w : aNewRecipes) { - aFreezerMapRebaked.put(w); - } - - //Best not touch the original map if we don't have a valid map to override it with. - if (aFreezerMapRebaked.size() > 0) { - - int aOriginalCount = GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.size(); - - //Empty the original map - GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.clear(); - - //Rebake the real map - for (GT_Recipe w : aFreezerMapRebaked) { - GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.add(w); - } - - return GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.size() >= aOriginalCount; - } - - return false; - } - - public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { - if (aMeta == 12) { - return Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower(); - } - else { - return Meta_GT_Proxy.constructBaseMetaTileEntity(); - } - } - - public static BaseCustomTileEntity constructBaseMetaTileEntity() { - if (sBaseMetaTileEntityClass == null) { - try { - sBaseMetaTileEntityClass = BaseCustomTileEntity.class; - return (BaseCustomTileEntity) BaseCustomTileEntity.class.newInstance(); - } catch (Throwable arg1) { - try { - Constructor g = BaseCustomTileEntity.class.getConstructors()[0]; - g.setAccessible(true); - return (BaseCustomTileEntity) g.newInstance(); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException | SecurityException e) { - } - } - } - try { - return (BaseCustomTileEntity) ((BaseCustomTileEntity) sBaseMetaTileEntityClass.newInstance()); - } catch (Throwable arg0) { - arg0.printStackTrace(GT_Log.err); - try { - Constructor g = BaseCustomTileEntity.class.getConstructors()[0]; - g.setAccessible(true); - return (BaseCustomTileEntity) g.newInstance(); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException | SecurityException e) { - GT_Log.err - .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); - e.printStackTrace(GT_Log.err); - CORE.crash("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); - throw new RuntimeException(e); - } - } - } - - public static BaseCustomPower_MTE constructBaseMetaTileEntityCustomPower() { - if (sBaseMetaTileEntityClass2 == null) { - try { - sBaseMetaTileEntityClass2 = BaseCustomPower_MTE.class; - return (BaseCustomPower_MTE) BaseCustomPower_MTE.class.newInstance(); - } catch (Throwable arg1) { - try { - Constructor g = BaseCustomPower_MTE.class.getConstructors()[0]; - g.setAccessible(true); - return (BaseCustomPower_MTE) g.newInstance(); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException | SecurityException e) { - // e.printStackTrace(); - } - } - } - - try { - return (BaseCustomPower_MTE) ((BaseCustomPower_MTE) sBaseMetaTileEntityClass2.newInstance()); - } catch (Throwable arg0) { - arg0.printStackTrace(GT_Log.err); - try { - Constructor g = BaseCustomPower_MTE.class.getConstructors()[0]; - g.setAccessible(true); - return (BaseCustomPower_MTE) g.newInstance(); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException | SecurityException e) { - GT_Log.err - .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); - e.printStackTrace(GT_Log.err); - CORE.crash("GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); - throw new RuntimeException(e); - } - } - } - - - - - - public static boolean setTileEntityClassAsBlacklistedInWorldAccelerator(String aClassName) { - if (CORE.GTNH) { - Class aMainModClass = ReflectionUtils.getClass("com.dreammaster.main.MainRegistry"); - Class aCoreModConfig = ReflectionUtils.getClass("com.dreammaster.config"); - if (aMainModClass != null && aCoreModConfig != null) { - Field aCoreConfig = ReflectionUtils.getField(aMainModClass, "CoreConfig"); - if (aCoreConfig != null) { - Field aBlackList = ReflectionUtils.getField(aCoreModConfig, "BlacklistedTileEntiyClassNames"); - Object aInstance = ReflectionUtils.getFieldValue(aCoreConfig); - if (aBlackList != null && aInstance != null) { - String[] aBlackListValue = (String[]) ReflectionUtils.getFieldValue(aBlackList, aInstance); - if (aBlackListValue != null) { - aBlackListValue = ArrayUtils.add(aBlackListValue, aClassName); - ReflectionUtils.setField(aInstance, aBlackList, aBlackListValue); - return true; - } - } - } - } - } - else { - GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames = ArrayUtils.add(GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames, aClassName); - return true; - } - return false; - } - - - - public static void setValidHeatingCoilMetas() { - for (int i = 0; i <= 6; i++ ) { - GT_ValidHeatingCoilMetas.put(i); - } - if (CORE.GTNH) { - for (int i = 7; i <= 8; i++ ) { - GT_ValidHeatingCoilMetas.put(i); - } - } - } - - public static boolean areWeUsingGregtech5uExperimental(){ - final int version = GregTech_API.VERSION; - if ((version == 508) || (version == 507)){ - return false; - } - else if (version == 509){ - return true; - } - else { - return false; - } - } - - static GT_Proxy[] mProxies = new GT_Proxy[2]; - - /** - * @deprecated Use {@link StaticFields59#getFieldFromGregtechProxy(boolean,String)} instead - */ - public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { - return StaticFields59.getFieldFromGregtechProxy(client, fieldName); - } - - public static void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { - mCustomGregtechMetaTooltips.put(aNbtTagName, aData); - } - - public static void conStructGtTileBlockTooltip(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { - try { - int tDamage = aStack.getItemDamage(); - if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { - return; - } - - if (GregTech_API.METATILEENTITIES[tDamage] != null) { - IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); - if (tTileEntity.getDescription() != null) { - int i = 0; - for (String tDescription : tTileEntity.getDescription()) { - if (GT_Utility.isStringValid(tDescription)) { - if(tDescription.contains("%%%")){ - String[] tString = tDescription.split("%%%"); - if(tString.length>=2){ - StringBuffer tBuffer = new StringBuffer(); - Object tRep[] = new String[tString.length / 2]; - for (int j = 0; j < tString.length; j++) - if (j % 2 == 0) tBuffer.append(tString[j]); - else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} - aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished), tRep)); - } - }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); - aList.add(tTranslated.equals("") ? tDescription : tTranslated);} - }else i++; - } - } - - - - if (tTileEntity.getEUCapacity() > 0L) { - - final long tVoltage = tTileEntity.getInputVoltage(); - byte tTier = (byte) ((byte) Math.max(1, GT_Utility.getTier(tVoltage))); - - //Custom handling - if (tDamage < 30500 && tDamage >= 30400) { - int aOffset = tDamage - 30400; - if ((aOffset) <= 10) { - tTier -= 2; - aList.add(EnumChatFormatting.BOLD+"16"+" Fuse Slots"+EnumChatFormatting.GRAY); - aList.add("Per each fuse, you may insert "+EnumChatFormatting.YELLOW+(GT_Values.V[tTier])+EnumChatFormatting.GRAY+" EU/t"); - aList.add("However this "+EnumChatFormatting.ITALIC+EnumChatFormatting.RED+"MUST"+EnumChatFormatting.GRAY+" be in a single Amp"); - aList.add("This machine can accept upto a single amp of "+GT_Values.VN[Math.min(tTier+2, 12)]+" as a result"); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Breaker_Loss", "Breaker Loss: "+EnumChatFormatting.RED+""+(GT_Values.V[Math.max(tTier-1, 0)]/10)+EnumChatFormatting.GRAY+" EU/t", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - } - - - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Special_Power_1", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_2", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_3", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - } - - - if (tTileEntity.getInputVoltage() > 0L) { - String inA = "0"; - if (tTileEntity.getInputAmperage() >= 1L) { - inA = " at " + EnumChatFormatting.YELLOW + tTileEntity.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - else { - inA = " at " + EnumChatFormatting.WHITE + tTileEntity.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - String a1 = "Voltage IN: "+EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() - + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" - + EnumChatFormatting.GRAY + inA; - aList.add(a1); - } - - if (tTileEntity.getOutputVoltage() > 0L) { - String outA = "0"; - if (tTileEntity.getOutputAmperage() >= 1L) { - outA = " at " + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - else { - outA = " at " + EnumChatFormatting.WHITE + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - String a1 = "Voltage OUT: "+EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() - + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" - + EnumChatFormatting.GRAY + outA; - aList.add(a1); - } - - - if (tTileEntity.getOutputVoltage() > 0L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Lossess_EU", "Transmission Loss: "+EnumChatFormatting.DARK_BLUE+""+(tDamage < 30500 && tDamage >= 30400 ? 0 : 1), !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - } - - if (tTileEntity.getEUCapacity() > 0) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE2", - "Internal Capacity: ", !GregTech_API.sPostloadFinished) + EnumChatFormatting.BLUE - + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY + " EU"); - } - } - - /*if (tTileEntity.getEUCapacity() > 0L) { + static { + Logger.INFO("GT_PROXY - initialized."); + sDoesVolumetricFlaskExist = ReflectionUtils.doesClassExist("gregtech.common.items.GT_VolumetricFlask"); + } + + public static List GT_BlockIconload = new ArrayList<>(); + public static List GT_ItemIconload = new ArrayList<>(); + + public static AutoMap GT_ValidHeatingCoilMetas = new AutoMap(); + + private static Class sBaseMetaTileEntityClass; + private static Class sBaseMetaTileEntityClass2; + + public static AchievementHandler mAssemblyAchievements; + + public static final Map mCustomGregtechMetaTooltips = + new LinkedHashMap(); + + /** + * Does this feature exist within GT? Saves loading useless content if not. + */ + public static final boolean sDoesVolumetricFlaskExist; + + @SideOnly(Side.CLIENT) + public static IIconRegister sBlockIcons, sItemIcons; + + public Meta_GT_Proxy() {} + + public static Block sBlockMachines; + + public static void preInit() { + + // New GT++ Block, yay! (Progress) + // sBlockMachines = new GTPP_Block_Machines(); + fixIC2FluidNames(); + + GT_Log.out.println("GT++ Mod: Register TileEntities."); + BaseMetaTileEntity tBaseMetaTileEntity = constructBaseMetaTileEntity(); + BaseMetaTileEntity tBaseMetaTileEntity2 = constructBaseMetaTileEntityCustomPower(); + + GT_Log.out.println("GT++ Mod: Testing BaseMetaTileEntity."); + if (tBaseMetaTileEntity == null || tBaseMetaTileEntity2 == null) { + GT_Log.err.println( + "GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); + CORE.crash( + "GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); + } + + // Gotta set it here so that we don't try call gregtech too early. + // Must set on the correct side + + if (ReflectionUtils.doesFieldExist(GT_Proxy.class, "gt6Pipe")) { + StaticFields59.mGT6StylePipes = (boolean) StaticFields59.getFieldFromGregtechProxy("gt6Pipe"); + } else { + StaticFields59.mGT6StylePipes = false; + } + + GT_Log.out.println("GT++ Mod: Registering custom BaseMetaTileEntities."); + GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); + GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); + CoverManager.generateCustomCovers(); + } + + public static void init() { + setValidHeatingCoilMetas(); + PollutionUtils.setPollutionFluids(); + fixIC2FluidNames(); + Utils.registerEvent(new MachineUpdateHandler()); + } + + public static void postInit() { + mAssemblyAchievements = new AchievementHandler(); + fixIC2FluidNames(); + + // Finalise TAE + TAE.finalizeTAE(); + } + + @SuppressWarnings("deprecation") + public static void fixIC2FluidNames() { + // Fix IC2 Hot Water name + try { + String aNewHeatedWaterName = "Heated Water"; + Logger.INFO("Renaming [IC2 Hotspring Water] --> [" + aNewHeatedWaterName + "]."); + LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water"); + LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + + Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); + if (b != null) { + LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + } + Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); + if (f != null) { + LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + int aDam = FluidRegistry.getFluidID(f); + ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); + if (s != null) { + LanguageRegistry.addName(s, aNewHeatedWaterName); + } + } + + String[] aLangs = new String[] { + "de_DE", "en_US", "en_GB", "en_IC", "es_AR", "es_ES", "es_MX", "es_UY", "es_VE", "fr_CA", "fr_FR", + "it_IT", "ko_KR", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "tr_TR", "zh_CN", "zh_TW", + }; + String[] aLangValues = new String[] { + "Erhitztes Wasser", + "Heated Water", + "Heated Water", + "Heated Water", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Eau chauffée", + "Eau chauffée", + "Acqua riscaldata", + "온수", + "Água aquecida", + "Água aquecida", + "Вода с подогревом", + "Uppvärmt vatten", + "Isıtılmış Su", + "热水", + "热水", + }; + for (int i = 0; i < aLangs.length; i++) { + Logger.REFLECTION( + "Trying to inject new lang data for " + aLangs[i] + ", using value: " + aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "fluidHotWater", aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "ic2.fluidHotWater", aLangValues[i]); + } + } catch (Throwable t) { + + } + } + + public static boolean generatePlasmaRecipesForAdvVacFreezer() { + + AutoMap aFreezerMapRebaked = new AutoMap(); + AutoMap aRemovedRecipes = new AutoMap(); + + // Find recipes containing Plasma and map them + for (GT_Recipe y : GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList) { + if (y.mFluidInputs.length > 0) { + for (FluidStack r : y.mFluidInputs) { + if (r.getUnlocalizedName().toLowerCase().contains("plasma")) { + aRemovedRecipes.put(y); + continue; + } + } + aFreezerMapRebaked.put(y); + } + } + + AutoMap aNewRecipes = new AutoMap(); + int aAtomicMass = 0; + int aAtomicTier = 0; + + final FluidStack NULL_PLASMA = Materials._NULL.getPlasma(1); + + for (String s : ELEMENT.NAMES) { + + aAtomicMass++; + aAtomicTier = (aAtomicMass / 30) + 1; + FluidStack aMoltenFluid = null; + FluidStack aPlasma = null; + + // Try Get Material via Gregtech + Materials aGregMaterial = MaterialUtils.getMaterial(s); + if (aGregMaterial != null) { + aMoltenFluid = aGregMaterial.getMolten(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getFluid(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getGas(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getSolid(1); + } + } + } + aPlasma = aGregMaterial.getPlasma(100); + } + + // Just wildcard values + if (aMoltenFluid == null || aPlasma == null) { + if (aMoltenFluid == null) { + aMoltenFluid = FluidUtils.getWildcardFluidStack(s, 1); + } + if (aPlasma == null) { + aPlasma = FluidUtils.getFluidStack("plasma." + s.toLowerCase(), 1); + } + } + + // Skip this material + if (aMoltenFluid == null || aPlasma == null || aPlasma.isFluidEqual(NULL_PLASMA)) { + Logger.INFO("Could not generate Advanced Vacuum Freezer recipe. Cooling " + s + + " plasma. Molten Form Exists? " + (aMoltenFluid != null) + " | Plasma Exists? " + + (aPlasma != null)); + continue; + } else { + // Build a new plasma recipe + int aTotalTickTime = (20 * 1 + (aAtomicMass)); + GTPP_Recipe aTempRecipe = new GTPP_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {10000}, + new FluidStack[] {aPlasma, FluidUtils.getFluidStack("cryotheum", aTotalTickTime)}, + new FluidStack[] {aMoltenFluid}, + aTotalTickTime, + (int) GT_Values.V[4 + aAtomicTier], + aAtomicMass); + + // Add it to the map if it's valid + if (aTempRecipe != null) { + aNewRecipes.put(aTempRecipe); + } + } + } + + // Add the new recipes to the map we will rebake over the original + for (GTPP_Recipe w : aNewRecipes) { + aFreezerMapRebaked.put(w); + } + + // Best not touch the original map if we don't have a valid map to override it with. + if (aFreezerMapRebaked.size() > 0) { + + int aOriginalCount = GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.size(); + + // Empty the original map + GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.clear(); + + // Rebake the real map + for (GT_Recipe w : aFreezerMapRebaked) { + GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.add(w); + } + + return GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.size() >= aOriginalCount; + } + + return false; + } + + public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { + if (aMeta == 12) { + return Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower(); + } else { + return Meta_GT_Proxy.constructBaseMetaTileEntity(); + } + } + + public static BaseCustomTileEntity constructBaseMetaTileEntity() { + if (sBaseMetaTileEntityClass == null) { + try { + sBaseMetaTileEntityClass = BaseCustomTileEntity.class; + return (BaseCustomTileEntity) BaseCustomTileEntity.class.newInstance(); + } catch (Throwable arg1) { + try { + Constructor g = BaseCustomTileEntity.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomTileEntity) g.newInstance(); + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | SecurityException e) { + } + } + } + try { + return (BaseCustomTileEntity) ((BaseCustomTileEntity) sBaseMetaTileEntityClass.newInstance()); + } catch (Throwable arg0) { + arg0.printStackTrace(GT_Log.err); + try { + Constructor g = BaseCustomTileEntity.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomTileEntity) g.newInstance(); + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | SecurityException e) { + GT_Log.err.println( + "GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + e.printStackTrace(GT_Log.err); + CORE.crash( + "GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); + throw new RuntimeException(e); + } + } + } + + public static BaseCustomPower_MTE constructBaseMetaTileEntityCustomPower() { + if (sBaseMetaTileEntityClass2 == null) { + try { + sBaseMetaTileEntityClass2 = BaseCustomPower_MTE.class; + return (BaseCustomPower_MTE) BaseCustomPower_MTE.class.newInstance(); + } catch (Throwable arg1) { + try { + Constructor g = BaseCustomPower_MTE.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomPower_MTE) g.newInstance(); + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | SecurityException e) { + // e.printStackTrace(); + } + } + } + + try { + return (BaseCustomPower_MTE) ((BaseCustomPower_MTE) sBaseMetaTileEntityClass2.newInstance()); + } catch (Throwable arg0) { + arg0.printStackTrace(GT_Log.err); + try { + Constructor g = BaseCustomPower_MTE.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomPower_MTE) g.newInstance(); + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | SecurityException e) { + GT_Log.err.println( + "GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + e.printStackTrace(GT_Log.err); + CORE.crash( + "GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); + throw new RuntimeException(e); + } + } + } + + public static boolean setTileEntityClassAsBlacklistedInWorldAccelerator(String aClassName) { + if (CORE.GTNH) { + Class aMainModClass = ReflectionUtils.getClass("com.dreammaster.main.MainRegistry"); + Class aCoreModConfig = ReflectionUtils.getClass("com.dreammaster.config"); + if (aMainModClass != null && aCoreModConfig != null) { + Field aCoreConfig = ReflectionUtils.getField(aMainModClass, "CoreConfig"); + if (aCoreConfig != null) { + Field aBlackList = ReflectionUtils.getField(aCoreModConfig, "BlacklistedTileEntiyClassNames"); + Object aInstance = ReflectionUtils.getFieldValue(aCoreConfig); + if (aBlackList != null && aInstance != null) { + String[] aBlackListValue = (String[]) ReflectionUtils.getFieldValue(aBlackList, aInstance); + if (aBlackListValue != null) { + aBlackListValue = ArrayUtils.add(aBlackListValue, aClassName); + ReflectionUtils.setField(aInstance, aBlackList, aBlackListValue); + return true; + } + } + } + } + } else { + GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames = + ArrayUtils.add(GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames, aClassName); + return true; + } + return false; + } + + public static void setValidHeatingCoilMetas() { + for (int i = 0; i <= 6; i++) { + GT_ValidHeatingCoilMetas.put(i); + } + if (CORE.GTNH) { + for (int i = 7; i <= 8; i++) { + GT_ValidHeatingCoilMetas.put(i); + } + } + } + + public static boolean areWeUsingGregtech5uExperimental() { + final int version = GregTech_API.VERSION; + if ((version == 508) || (version == 507)) { + return false; + } else if (version == 509) { + return true; + } else { + return false; + } + } + + static GT_Proxy[] mProxies = new GT_Proxy[2]; + + /** + * @deprecated Use {@link StaticFields59#getFieldFromGregtechProxy(boolean,String)} instead + */ + public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { + return StaticFields59.getFieldFromGregtechProxy(client, fieldName); + } + + public static void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { + mCustomGregtechMetaTooltips.put(aNbtTagName, aData); + } + + public static void conStructGtTileBlockTooltip( + ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { + try { + int tDamage = aStack.getItemDamage(); + if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { + return; + } + + if (GregTech_API.METATILEENTITIES[tDamage] != null) { + IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); + if (tTileEntity.getDescription() != null) { + int i = 0; + for (String tDescription : tTileEntity.getDescription()) { + if (GT_Utility.isStringValid(tDescription)) { + if (tDescription.contains("%%%")) { + String[] tString = tDescription.split("%%%"); + if (tString.length >= 2) { + StringBuffer tBuffer = new StringBuffer(); + Object tRep[] = new String[tString.length / 2]; + for (int j = 0; j < tString.length; j++) + if (j % 2 == 0) tBuffer.append(tString[j]); + else { + tBuffer.append(" %s"); + tRep[j / 2] = tString[j]; + } + aList.add(String.format( + GT_LanguageManager.addStringLocalization( + "TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, + tBuffer.toString(), + !GregTech_API.sPostloadFinished), + tRep)); + } + } else { + String tTranslated = GT_LanguageManager.addStringLocalization( + "TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, + tDescription, + !GregTech_API.sPostloadFinished); + aList.add(tTranslated.equals("") ? tDescription : tTranslated); + } + } else i++; + } + } + + if (tTileEntity.getEUCapacity() > 0L) { + + final long tVoltage = tTileEntity.getInputVoltage(); + byte tTier = (byte) ((byte) Math.max(1, GT_Utility.getTier(tVoltage))); + + // Custom handling + if (tDamage < 30500 && tDamage >= 30400) { + int aOffset = tDamage - 30400; + if ((aOffset) <= 10) { + tTier -= 2; + aList.add(EnumChatFormatting.BOLD + "16" + " Fuse Slots" + EnumChatFormatting.GRAY); + aList.add("Per each fuse, you may insert " + EnumChatFormatting.YELLOW + + (GT_Values.V[tTier]) + EnumChatFormatting.GRAY + " EU/t"); + aList.add("However this " + EnumChatFormatting.ITALIC + EnumChatFormatting.RED + "MUST" + + EnumChatFormatting.GRAY + " be in a single Amp"); + aList.add("This machine can accept upto a single amp of " + + GT_Values.VN[Math.min(tTier + 2, 12)] + " as a result"); + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_Breaker_Loss", + "Breaker Loss: " + EnumChatFormatting.RED + "" + + (GT_Values.V[Math.max(tTier - 1, 0)] / 10) + + EnumChatFormatting.GRAY + " EU/t", + !GregTech_API.sPostloadFinished) + + EnumChatFormatting.GRAY); + } + + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_Special_Power_1", + EnumChatFormatting.RED + "Special Power Handling, please read manual", + !GregTech_API.sPostloadFinished) + + EnumChatFormatting.GRAY); + // aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_2", + // EnumChatFormatting.RED+"Special Power Handling, please read manual", + // !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + // aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_3", + // EnumChatFormatting.RED+"Special Power Handling, please read manual", + // !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + } + + if (tTileEntity.getInputVoltage() > 0L) { + String inA = "0"; + if (tTileEntity.getInputAmperage() >= 1L) { + inA = " at " + EnumChatFormatting.YELLOW + tTileEntity.getInputAmperage() + + EnumChatFormatting.GRAY + " Amps"; + } else { + inA = " at " + EnumChatFormatting.WHITE + tTileEntity.getInputAmperage() + + EnumChatFormatting.GRAY + " Amps"; + } + String a1 = "Voltage IN: " + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + + EnumChatFormatting.GRAY + inA; + aList.add(a1); + } + + if (tTileEntity.getOutputVoltage() > 0L) { + String outA = "0"; + if (tTileEntity.getOutputAmperage() >= 1L) { + outA = " at " + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + + EnumChatFormatting.GRAY + " Amps"; + } else { + outA = " at " + EnumChatFormatting.WHITE + tTileEntity.getOutputAmperage() + + EnumChatFormatting.GRAY + " Amps"; + } + String a1 = "Voltage OUT: " + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + + EnumChatFormatting.GRAY + outA; + aList.add(a1); + } + + if (tTileEntity.getOutputVoltage() > 0L) { + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_Lossess_EU", + "Transmission Loss: " + EnumChatFormatting.DARK_BLUE + "" + + (tDamage < 30500 && tDamage >= 30400 ? 0 : 1), + !GregTech_API.sPostloadFinished) + + EnumChatFormatting.GRAY); + } + + if (tTileEntity.getEUCapacity() > 0) { + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_EUp_STORE2", "Internal Capacity: ", !GregTech_API.sPostloadFinished) + + EnumChatFormatting.BLUE + + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY + " EU"); + } + } + + /*if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY); } @@ -581,53 +594,60 @@ public class Meta_GT_Proxy { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY); }*/ - } - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - if (aNBT.getBoolean("mMuffler")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished )); - } - if (aNBT.getBoolean("mSteamConverter")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished )); - } - int tAmount = 0; - if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { - aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished )); - } - - FluidStack afluid = net.minecraftforge.fluids.FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - if (afluid != null) { - int tFluidAmount = afluid.amount; - if (tFluidAmount > 0) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_FLUIDTANK", "Tank Fluid: "+tFluidAmount+"L "+afluid.getLocalizedName()+"", !GregTech_API.sPostloadFinished )); - } - } - - } - - //Add Custom Here - - //Add Custom Tooltips - for (String s : mCustomGregtechMetaTooltips.keySet()) { - if (aNBT.hasKey(s)) { - String aTip = mCustomGregtechMetaTooltips.get(s).getTooltip(aNBT.getString(s)); - aList.add(aTip); - } - } - - //Add GT++ Stuff - - if (tDamage >= 30400 && tDamage < 30500) { - aList.add(EnumChatFormatting.UNDERLINE+"Special GT++ Machine"); - } - if ((tDamage >= 750 && tDamage < 1000) || (tDamage >= 30000 && tDamage < 31000)) { - aList.add(CORE.GT_Tooltip); - } - - - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - + } + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + if (aNBT.getBoolean("mMuffler")) { + aList.add(GT_LanguageManager.addStringLocalization( + "GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished)); + } + if (aNBT.getBoolean("mSteamConverter")) { + aList.add(GT_LanguageManager.addStringLocalization( + "GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished)); + } + int tAmount = 0; + if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { + aList.add(tAmount + " " + + GT_LanguageManager.addStringLocalization( + "GT_TileEntity_STEAMTANKS", + "Steam Tank Upgrades", + !GregTech_API.sPostloadFinished)); + } + + FluidStack afluid = + net.minecraftforge.fluids.FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + if (afluid != null) { + int tFluidAmount = afluid.amount; + if (tFluidAmount > 0) { + aList.add(GT_LanguageManager.addStringLocalization( + "GT_TileEntity_FLUIDTANK", + "Tank Fluid: " + tFluidAmount + "L " + afluid.getLocalizedName() + "", + !GregTech_API.sPostloadFinished)); + } + } + } + + // Add Custom Here + + // Add Custom Tooltips + for (String s : mCustomGregtechMetaTooltips.keySet()) { + if (aNBT.hasKey(s)) { + String aTip = mCustomGregtechMetaTooltips.get(s).getTooltip(aNBT.getString(s)); + aList.add(aTip); + } + } + + // Add GT++ Stuff + + if (tDamage >= 30400 && tDamage < 30500) { + aList.add(EnumChatFormatting.UNDERLINE + "Special GT++ Machine"); + } + if ((tDamage >= 750 && tDamage < 1000) || (tDamage >= 30000 && tDamage < 31000)) { + aList.add(CORE.GT_Tooltip); + } + + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 44c580fe4f..0f98d8ab55 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -1,14 +1,5 @@ package gtPlusPlus.xmod.gregtech.common; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; @@ -26,278 +17,280 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; public class StaticFields59 { - - public static boolean mGT6StylePipes; - - public static final Field mGtBlockCasings5; - public static final Field mPreventableComponents; - public static final Field mDisabledItems; - public static final Field mMultiblockChemicalRecipes; - public static final Field mPyrolyseRecipes; - public static final Field mDescriptionArray; - public static final Field mCasingTexturePages; - public static final Field mAssLineVisualMapNEI; - public static final GT_Recipe_Map sAssemblylineVisualRecipes; - - public static final Method mCalculatePollutionReduction; - public static final Method mAddFurnaceRecipe; - - private static final Map mMaterialCache = new LinkedHashMap(); - - - //OrePrefixes - - static { - Logger.INFO("[SH] Creating Static Helper for various fields which require reflective access."); - - mGtBlockCasings5 = getField(GregTech_API.class, "sBlockCasings5"); - Logger.INFO("[SH] Got Field: sBlockCasings5"); - mPreventableComponents = getField(OrePrefixes.class, "mPreventableComponents"); - Logger.INFO("[SH] Got Field: mPreventableComponents"); - mDisabledItems = getField(OrePrefixes.class, "mDisabledItems"); - Logger.INFO("[SH] Got Field: mDisabledItems"); - mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); - Logger.INFO("[SH] Got Field: mDescriptionArray"); - mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); - Logger.INFO("[SH] Got Field: casingTexturePages"); - - mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); - Logger.INFO("[SH] Got Field: mAssLineVisualMapNEI"); - GT_Recipe_Map aTemp; - if (mAssLineVisualMapNEI != null) { - try { - aTemp = (GT_Recipe_Map) mAssLineVisualMapNEI.get(null); - Logger.INFO("[SH] Got Field: sAssemblylineVisualRecipes"); - } catch (IllegalArgumentException | IllegalAccessException e) { - aTemp = null; - } - } else { - aTemp = null; - } - - sAssemblylineVisualRecipes = aTemp; - - mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); - Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); - if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { - mPyrolyseRecipes = getField(GT_Recipe_Map.class, "sPyrolyseRecipes"); - Logger.INFO("[SH] Got Field: sPyrolyseRecipes"); - } - else { - mPyrolyseRecipes = null; - } - - mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", - int.class); - Logger.INFO("[SH] Got Method: calculatePollutionReduction"); - - // Yep... - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, - ItemStack.class); - Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); - } else { - mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, - ItemStack.class, boolean.class); - Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); - } - - } - - public static synchronized final Block getBlockCasings5() { - try { - return (Block) mGtBlockCasings5.get(GregTech_API.class); - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } - - public static int calculatePollutionReducation(GT_MetaTileEntity_Hatch_Muffler h, int i) { - try { - return (int) mCalculatePollutionReduction.invoke(h, i); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return 0; - } - } - - public static Field getField(Class a, String b) { - return ReflectionUtils.getField(a, b); - } - - public static Method getMethod(Class a, String b, Class... params) { - return ReflectionUtils.getMethod(a, b, params); - } - - public static synchronized final Collection getOrePrefixesBooleanDisabledItems() { - try { - return (Collection) mDisabledItems.get(OrePrefixes.class); - } catch (IllegalArgumentException | IllegalAccessException e) { - return new ArrayList(); - } - } - - - public static synchronized final List geOrePrefixesBooleanPreventableComponents() { - try { - return (List) mPreventableComponents.get(OrePrefixes.class); - } catch (IllegalArgumentException | IllegalAccessException e) { - return new ArrayList(); - } - } - - public static synchronized final GT_Recipe_Map getLargeChemicalReactorRecipeMap() { - try { - return (GT_Recipe_Map) mMultiblockChemicalRecipes.get(null); - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } - - public static synchronized final GT_Recipe_Map getPyrolyseRecipeMap() { - try { - return mPyrolyseRecipes != null ? (GT_Recipe_Map) mPyrolyseRecipes.get(null) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } - - public static Materials getMaterial(String aMaterialName) { - Materials m = mMaterialCache.get(aMaterialName); - if (m != null) { - return m; - } - else { - m = Materials.get(aMaterialName); - if (m != null) { - mMaterialCache.put(aMaterialName, m); - return m; - } - return null; - } - } - - public static String[] getDescriptionArray(GT_MetaTileEntity_TieredMachineBlock aTile) { - try { - return (String[]) mDescriptionArray.get(aTile); - } catch (IllegalArgumentException | IllegalAccessException e) { - return new String[] {aTile.mDescription}; - } - } - - public static ITexture getCasingTexturePages(int a, int b) { - try { - ITexture[][] g = (ITexture[][]) mCasingTexturePages.get(null); - if (g != null) { - return g[a][b]; - } - } - catch (Throwable t) { - - } - return null; - } - - - public static Object getFieldFromGregtechProxy(String fieldName) { - return getFieldFromGregtechProxy(Utils.isServer() ? false : true, fieldName); - } - - public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { - Object proxyGT; - - if (Meta_GT_Proxy.mProxies[0] != null && client) { - proxyGT = Meta_GT_Proxy.mProxies[0]; - } else if (Meta_GT_Proxy.mProxies[1] != null && !client) { - proxyGT = Meta_GT_Proxy.mProxies[1]; - } else { - try { - proxyGT = (client ? ProxyFinder.getClientProxy(GT_Mod.instance) - : ProxyFinder.getServerProxy(GT_Mod.instance)); - } catch (final ReflectiveOperationException e1) { - proxyGT = null; - Logger.INFO("Failed to obtain instance of GT " + (client ? "Client" : "Server") + " proxy."); - } - if (Meta_GT_Proxy.mProxies[0] == null && client) { - Meta_GT_Proxy.mProxies[0] = (GT_Proxy) proxyGT; - } else if (Meta_GT_Proxy.mProxies[1] == null && !client) { - Meta_GT_Proxy.mProxies[1] = (GT_Proxy) proxyGT; - } - } - - if (proxyGT != null && proxyGT instanceof GT_Proxy) { - try { - return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); - } catch (IllegalArgumentException | IllegalAccessException e) { - } - } - return null; - } - - - - public static int getTierForCoil(Block aBlock, int aMeta) { - if (aBlock == GregTech_API.sBlockCasings1 && (aMeta >= 12 && aMeta <= 14)) { - return aMeta == 12 ? 1 : aMeta == 13 ? 2 : 3; - } - else if (aBlock == getBlockCasings5() && (aMeta >= 0 && aMeta <= 10)) { - return aMeta; - } - return 0; - } - - public static int getHeatingCapacityForCoil(Block aBlock, int aMeta) { - int aTier = getTierForCoil(aBlock, aMeta); - return aTier > 0 ? getHeatingCapacityForCoilTier(aTier) : 0; - } - - public static int getHeatingCapacityForCoilTier(int aCoilTier) { - int mHeatingCapacity = 0; - switch (aCoilTier) { - case 0: - mHeatingCapacity = 1800; - break; - case 1: - mHeatingCapacity = 2700; - break; - case 2: - mHeatingCapacity = 3600; - break; - case 3: - mHeatingCapacity = 4500; - break; - case 4: - mHeatingCapacity = 5400; - break; - case 5: - mHeatingCapacity = 7200; - break; - case 6: - mHeatingCapacity = 9000; - break; - case 7: - mHeatingCapacity = 9900; - break; - case 8: - mHeatingCapacity = 10800; - break; - case 9: - mHeatingCapacity = 6300; - break; - case 10: - mHeatingCapacity = 9000; - break; - default: - Logger.INFO("Heating Coils are bad."); - mHeatingCapacity = 0; - } - if (CORE.GTNH && aCoilTier <= 10) { - mHeatingCapacity += 1; - } - return mHeatingCapacity; - } + public static boolean mGT6StylePipes; + + public static final Field mGtBlockCasings5; + public static final Field mPreventableComponents; + public static final Field mDisabledItems; + public static final Field mMultiblockChemicalRecipes; + public static final Field mPyrolyseRecipes; + public static final Field mDescriptionArray; + public static final Field mCasingTexturePages; + public static final Field mAssLineVisualMapNEI; + public static final GT_Recipe_Map sAssemblylineVisualRecipes; + + public static final Method mCalculatePollutionReduction; + public static final Method mAddFurnaceRecipe; + + private static final Map mMaterialCache = new LinkedHashMap(); + + // OrePrefixes + + static { + Logger.INFO("[SH] Creating Static Helper for various fields which require reflective access."); + + mGtBlockCasings5 = getField(GregTech_API.class, "sBlockCasings5"); + Logger.INFO("[SH] Got Field: sBlockCasings5"); + mPreventableComponents = getField(OrePrefixes.class, "mPreventableComponents"); + Logger.INFO("[SH] Got Field: mPreventableComponents"); + mDisabledItems = getField(OrePrefixes.class, "mDisabledItems"); + Logger.INFO("[SH] Got Field: mDisabledItems"); + mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); + Logger.INFO("[SH] Got Field: mDescriptionArray"); + mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); + Logger.INFO("[SH] Got Field: casingTexturePages"); + + mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); + Logger.INFO("[SH] Got Field: mAssLineVisualMapNEI"); + GT_Recipe_Map aTemp; + if (mAssLineVisualMapNEI != null) { + try { + aTemp = (GT_Recipe_Map) mAssLineVisualMapNEI.get(null); + Logger.INFO("[SH] Got Field: sAssemblylineVisualRecipes"); + } catch (IllegalArgumentException | IllegalAccessException e) { + aTemp = null; + } + } else { + aTemp = null; + } + + sAssemblylineVisualRecipes = aTemp; + + mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); + Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); + if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { + mPyrolyseRecipes = getField(GT_Recipe_Map.class, "sPyrolyseRecipes"); + Logger.INFO("[SH] Got Field: sPyrolyseRecipes"); + } else { + mPyrolyseRecipes = null; + } + + mCalculatePollutionReduction = + getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", int.class); + Logger.INFO("[SH] Got Method: calculatePollutionReduction"); + + // Yep... + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + mAddFurnaceRecipe = getMethod( + GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); + } else { + mAddFurnaceRecipe = getMethod( + GT_ModHandler.class, + "addSmeltingAndAlloySmeltingRecipe", + ItemStack.class, + ItemStack.class, + boolean.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); + } + } + + public static final synchronized Block getBlockCasings5() { + try { + return (Block) mGtBlockCasings5.get(GregTech_API.class); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + public static int calculatePollutionReducation(GT_MetaTileEntity_Hatch_Muffler h, int i) { + try { + return (int) mCalculatePollutionReduction.invoke(h, i); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return 0; + } + } + + public static Field getField(Class a, String b) { + return ReflectionUtils.getField(a, b); + } + + public static Method getMethod(Class a, String b, Class... params) { + return ReflectionUtils.getMethod(a, b, params); + } + + public static final synchronized Collection getOrePrefixesBooleanDisabledItems() { + try { + return (Collection) mDisabledItems.get(OrePrefixes.class); + } catch (IllegalArgumentException | IllegalAccessException e) { + return new ArrayList(); + } + } + + public static final synchronized List geOrePrefixesBooleanPreventableComponents() { + try { + return (List) mPreventableComponents.get(OrePrefixes.class); + } catch (IllegalArgumentException | IllegalAccessException e) { + return new ArrayList(); + } + } + + public static final synchronized GT_Recipe_Map getLargeChemicalReactorRecipeMap() { + try { + return (GT_Recipe_Map) mMultiblockChemicalRecipes.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + public static final synchronized GT_Recipe_Map getPyrolyseRecipeMap() { + try { + return mPyrolyseRecipes != null ? (GT_Recipe_Map) mPyrolyseRecipes.get(null) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + public static Materials getMaterial(String aMaterialName) { + Materials m = mMaterialCache.get(aMaterialName); + if (m != null) { + return m; + } else { + m = Materials.get(aMaterialName); + if (m != null) { + mMaterialCache.put(aMaterialName, m); + return m; + } + return null; + } + } + + public static String[] getDescriptionArray(GT_MetaTileEntity_TieredMachineBlock aTile) { + try { + return (String[]) mDescriptionArray.get(aTile); + } catch (IllegalArgumentException | IllegalAccessException e) { + return new String[] {aTile.mDescription}; + } + } + + public static ITexture getCasingTexturePages(int a, int b) { + try { + ITexture[][] g = (ITexture[][]) mCasingTexturePages.get(null); + if (g != null) { + return g[a][b]; + } + } catch (Throwable t) { + + } + return null; + } + + public static Object getFieldFromGregtechProxy(String fieldName) { + return getFieldFromGregtechProxy(Utils.isServer() ? false : true, fieldName); + } + + public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { + Object proxyGT; + + if (Meta_GT_Proxy.mProxies[0] != null && client) { + proxyGT = Meta_GT_Proxy.mProxies[0]; + } else if (Meta_GT_Proxy.mProxies[1] != null && !client) { + proxyGT = Meta_GT_Proxy.mProxies[1]; + } else { + try { + proxyGT = (client + ? ProxyFinder.getClientProxy(GT_Mod.instance) + : ProxyFinder.getServerProxy(GT_Mod.instance)); + } catch (final ReflectiveOperationException e1) { + proxyGT = null; + Logger.INFO("Failed to obtain instance of GT " + (client ? "Client" : "Server") + " proxy."); + } + if (Meta_GT_Proxy.mProxies[0] == null && client) { + Meta_GT_Proxy.mProxies[0] = (GT_Proxy) proxyGT; + } else if (Meta_GT_Proxy.mProxies[1] == null && !client) { + Meta_GT_Proxy.mProxies[1] = (GT_Proxy) proxyGT; + } + } + + if (proxyGT != null && proxyGT instanceof GT_Proxy) { + try { + return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + return null; + } + + public static int getTierForCoil(Block aBlock, int aMeta) { + if (aBlock == GregTech_API.sBlockCasings1 && (aMeta >= 12 && aMeta <= 14)) { + return aMeta == 12 ? 1 : aMeta == 13 ? 2 : 3; + } else if (aBlock == getBlockCasings5() && (aMeta >= 0 && aMeta <= 10)) { + return aMeta; + } + return 0; + } + + public static int getHeatingCapacityForCoil(Block aBlock, int aMeta) { + int aTier = getTierForCoil(aBlock, aMeta); + return aTier > 0 ? getHeatingCapacityForCoilTier(aTier) : 0; + } + + public static int getHeatingCapacityForCoilTier(int aCoilTier) { + int mHeatingCapacity = 0; + switch (aCoilTier) { + case 0: + mHeatingCapacity = 1800; + break; + case 1: + mHeatingCapacity = 2700; + break; + case 2: + mHeatingCapacity = 3600; + break; + case 3: + mHeatingCapacity = 4500; + break; + case 4: + mHeatingCapacity = 5400; + break; + case 5: + mHeatingCapacity = 7200; + break; + case 6: + mHeatingCapacity = 9000; + break; + case 7: + mHeatingCapacity = 9900; + break; + case 8: + mHeatingCapacity = 10800; + break; + case 9: + mHeatingCapacity = 6300; + break; + case 10: + mHeatingCapacity = 9000; + break; + default: + Logger.INFO("Heating Coils are bad."); + mHeatingCapacity = 0; + } + if (CORE.GTNH && aCoilTier <= 10) { + mHeatingCapacity += 1; + } + return mHeatingCapacity; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java index 01f655c355..83cbc0065c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java @@ -1,29 +1,24 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.ArrayList; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.IDebugableBlock; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_Generic_Block; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Item_Machines; import gregtech.common.blocks.GT_Material_Machines; -import gregtech.common.render.GT_Renderer_Block; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.client.renderer.texture.IIconRegister; @@ -47,488 +42,497 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class GTPP_Block_Machines extends GT_Generic_Block implements IDebugableBlock, ITileEntityProvider { - public static ThreadLocal mTemporaryTileEntity = new ThreadLocal(); - - public GTPP_Block_Machines() { - super(GTPP_Item_Machines.class, "gtpp.blockmachines", new GT_Material_Machines()); - GregTech_API.registerMachineBlock(this, -1); - this.setHardness(1.0F); - this.setResistance(10.0F); - this.setStepSound(soundTypeMetal); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - this.isBlockContainer = true; - } - - public String getHarvestTool(int aMeta) { - switch (aMeta / 4) { - case 0 : - return "wrench"; - case 1 : - return "wrench"; - case 2 : - return "cutter"; - case 3 : - return "axe"; - default : - return "wrench"; - } - } - - public int getHarvestLevel(int aMeta) { - return aMeta % 4; - } - - protected boolean canSilkHarvest() { - return false; - } - - public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseTileEntity) { - ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); - } - - } - - public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { - super.onBlockAdded(aWorld, aX, aY, aZ); - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - - } - - public String getUnlocalizedName() { - int tDamage = 0; - String aUnlocalName = (tDamage >= 0 && tDamage < GregTech_API.METATILEENTITIES.length) - ? (GregTech_API.METATILEENTITIES[tDamage] != null - ? ("gtpp.blockmachines.name" + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName()) - : ("gtpp.blockmachines.name")) : ""; - - Logger.INFO("Unlocal Name: "+aUnlocalName); - return aUnlocalName; - } - - public String getLocalizedName() { - String aName = StatCollector.translateToLocal(this.getUnlocalizedName() + ".name");; - if (aName.toLowerCase().contains(".name")) { - aName = StatCollector.translateToLocal(getUnlocalizedName() + ".name"); - } - if (aName.toLowerCase().contains(".name")) { - aName = StatCollector.translateToLocal("gt.blockmachines" + ".name"); - } - if (aName.toLowerCase().contains(".name")) { - aName = "BAD"; - } - Logger.INFO("Name: "+aName); - return aName; - } - - public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return 0; - } - - public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 100 : 0; - } - - public int getRenderType() { - return GTPP_Render_MachineBlock.INSTANCE == null ? super.getRenderType() : GTPP_Render_MachineBlock.INSTANCE.mRenderID; - } - - public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { - return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0; - } - - public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0; - } - - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean canConnectRedstone(IBlockAccess var1, int var2, int var3, int var4, int var5) { - return true; - } - - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean hasTileEntity(int aMeta) { - return true; - } - - public boolean hasComparatorInputOverride() { - return true; - } - - public boolean renderAsNormalBlock() { - return false; - } - - public boolean canProvidePower() { - return true; - } - - public boolean isOpaqueCube() { - return false; - } - - public TileEntity createNewTileEntity(World aWorld, int aMeta) { - return this.createTileEntity(aWorld, aMeta); - } - - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { - return BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - public IIcon getIcon(int aSide, int aMeta) { - return BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { - super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity != null ? tTileEntity.receiveClientEvent(aData1, aData2) : false; - } - - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, - Entity collider) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { - ((IGregTechTileEntity) tTileEntity).addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, - collider); - } else { - super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - } - } - - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null - ? ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) - : super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null - ? ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) - : super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { - TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { - AxisAlignedBB bbb = ((IGregTechTileEntity) tTileEntity) - .getCollisionBoundingBoxFromPool(((IGregTechTileEntity) tTileEntity).getWorld(), 0, 0, 0); - this.minX = bbb.minX; - this.minY = bbb.minY; - this.minZ = bbb.minZ; - this.maxX = bbb.maxX; - this.maxY = bbb.maxY; - this.maxZ = bbb.maxZ; - } else { - super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); - } - } - - public void setBlockBoundsForItemRender() { - super.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { - ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } else { - super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) { - - } - - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return super.getBlockHardness(aWorld, aX, aY, aZ); - } - - public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) tTileEntity).privateAccess() - && !((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true) - ? -1.0F - : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); - } - - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, - float par2, float par3) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return false; - } else { - if (aPlayer.isSneaking()) { - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem == null) { - return false; - } - - if (!GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) - && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - return false; - } - } - - return tTileEntity instanceof IGregTechTileEntity - ? (((IGregTechTileEntity) tTileEntity).getTimer() < 50L - ? false - : (!aWorld.isRemote && !((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer) - ? true - : ((IGregTechTileEntity) tTileEntity).onRightclick(aPlayer, (byte) aSide, par1, - par2, par3))) - : false; - } - } - - public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); - } - - } - - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity ? ((IGregTechTileEntity) tTileEntity).getMetaTileID() : 0; - } - - public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseMetaTileEntity) { - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); - } - - super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); - } - - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; - XSTR tRandom = new XSTR(); - mTemporaryTileEntity.set(tGregTechTileEntity); - - for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); ++i) { - ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); - if (tItem != null && tItem.stackSize > 0 && tGregTechTileEntity.isValidSlot(i)) { - EntityItem tItemEntity = new EntityItem(aWorld, - (double) ((float) aX + tRandom.nextFloat() * 0.8F + 0.1F), - (double) ((float) aY + tRandom.nextFloat() * 0.8F + 0.1F), - (double) ((float) aZ + tRandom.nextFloat() * 0.8F + 0.1F), - new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); - if (tItem.hasTagCompound()) { - tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); - } - - tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581D; - tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D; - tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581D; - aWorld.spawnEntityInWorld(tItemEntity); - tItem.stackSize = 0; - tGregTechTileEntity.setInventorySlotContents(i, (ItemStack) null); - } - } - } - - super.breakBlock(aWorld, aX, aY, aZ, par5, par6); - aWorld.removeTileEntity(aX, aY, aZ); - } - - public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity - ? ((IGregTechTileEntity) tTileEntity).getDrops() - : (mTemporaryTileEntity.get() == null - ? new ArrayList() - : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops()); - } - - public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity - ? ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide) - : 0; - } - - public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if (aSide >= 0 && aSide <= 5) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity - ? ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)) - : 0; - } else { - return 0; - } - } - - public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if (aSide >= 0 && aSide <= 5) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity - ? ((IGregTechTileEntity) tTileEntity) - .getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)) - : 0; - } else { - return 0; - } - } - - public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { - if (!aWorld.isRemote) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null && chance < 1.0F) { - if (tTileEntity instanceof BaseMetaTileEntity && GregTech_API.sMachineNonWrenchExplosions) { - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); - } - } else { - super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); - } - } - - } - - public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { - if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { - return true; - } else { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null) { - if (tTileEntity instanceof BaseMetaTileEntity) { - return true; - } - - if (tTileEntity instanceof BaseMetaPipeEntity - && (((BaseMetaPipeEntity) tTileEntity).mConnections & -64) != 0) { - return true; - } - - if (tTileEntity instanceof ICoverable - && ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0) { - return true; - } - } - - return false; - } - } - - public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity == null - ? 0 - : (tTileEntity instanceof IGregTechTileEntity - ? ((IGregTechTileEntity) tTileEntity).getLightOpacity() - : (aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0)); - } - - public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof BaseMetaTileEntity ? ((BaseMetaTileEntity) tTileEntity).getLightValue() : 0; - } - - public TileEntity createTileEntity(World aWorld, int aMeta) { - return (TileEntity) (aMeta >= 4 ? Meta_GT_Proxy.constructBaseMetaTileEntity() : Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower()); - } - - public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, - double explosionY, double explosionZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity - ? ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6) - : 10.0F; - } - - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 100; ++i) { - if (GregTech_API.METATILEENTITIES[(30400 + i)] != null) { - par3List.add(new ItemStack(par1, 1, i)); - } - } - - } - - public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null) { - if (tTileEntity instanceof IGregTechTileEntity) { - IGregTechTileEntity var6 = (IGregTechTileEntity) tTileEntity; - if (aPlayer == null) { - var6.setFrontFacing((byte) 1); - } else { - int var7 = MathHelper.floor_double((double) (aPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int var8 = Math.round(aPlayer.rotationPitch); - if (var8 >= 65 && var6.isValidFacing((byte) 1)) { - var6.setFrontFacing((byte) 1); - } else if (var8 <= -65 && var6.isValidFacing((byte) 0)) { - var6.setFrontFacing((byte) 0); - } else { - switch (var7) { - case 0 : - var6.setFrontFacing((byte) 2); - break; - case 1 : - var6.setFrontFacing((byte) 5); - break; - case 2 : - var6.setFrontFacing((byte) 3); - break; - case 3 : - var6.setFrontFacing((byte) 4); - } - } - } - } - - } - } - - public ArrayList getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { - TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof BaseMetaTileEntity - ? ((BaseMetaTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel) - : (tTileEntity instanceof BaseMetaPipeEntity - ? ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel) - : null); - } - - public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) (~aColor & 15)) { - return false; - } else { - ((IGregTechTileEntity) tTileEntity).setColorization((byte) (~aColor & 15)); - return true; - } - } else { - return false; - } - } -} \ No newline at end of file + public static ThreadLocal mTemporaryTileEntity = new ThreadLocal(); + + public GTPP_Block_Machines() { + super(GTPP_Item_Machines.class, "gtpp.blockmachines", new GT_Material_Machines()); + GregTech_API.registerMachineBlock(this, -1); + this.setHardness(1.0F); + this.setResistance(10.0F); + this.setStepSound(soundTypeMetal); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + this.isBlockContainer = true; + } + + public String getHarvestTool(int aMeta) { + switch (aMeta / 4) { + case 0: + return "wrench"; + case 1: + return "wrench"; + case 2: + return "cutter"; + case 3: + return "axe"; + default: + return "wrench"; + } + } + + public int getHarvestLevel(int aMeta) { + return aMeta % 4; + } + + protected boolean canSilkHarvest() { + return false; + } + + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseTileEntity) { + ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); + } + } + + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + public String getUnlocalizedName() { + int tDamage = 0; + String aUnlocalName = (tDamage >= 0 && tDamage < GregTech_API.METATILEENTITIES.length) + ? (GregTech_API.METATILEENTITIES[tDamage] != null + ? ("gtpp.blockmachines.name" + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName()) + : ("gtpp.blockmachines.name")) + : ""; + + Logger.INFO("Unlocal Name: " + aUnlocalName); + return aUnlocalName; + } + + public String getLocalizedName() { + String aName = StatCollector.translateToLocal(this.getUnlocalizedName() + ".name"); + ; + if (aName.toLowerCase().contains(".name")) { + aName = StatCollector.translateToLocal(getUnlocalizedName() + ".name"); + } + if (aName.toLowerCase().contains(".name")) { + aName = StatCollector.translateToLocal("gt.blockmachines" + ".name"); + } + if (aName.toLowerCase().contains(".name")) { + aName = "BAD"; + } + Logger.INFO("Name: " + aName); + return aName; + } + + public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return 0; + } + + public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 100 : 0; + } + + public int getRenderType() { + return GTPP_Render_MachineBlock.INSTANCE == null + ? super.getRenderType() + : GTPP_Render_MachineBlock.INSTANCE.mRenderID; + } + + public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { + return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0; + } + + public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0; + } + + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + public boolean canConnectRedstone(IBlockAccess var1, int var2, int var3, int var4, int var5) { + return true; + } + + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + public boolean hasTileEntity(int aMeta) { + return true; + } + + public boolean hasComparatorInputOverride() { + return true; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public boolean canProvidePower() { + return true; + } + + public boolean isOpaqueCube() { + return false; + } + + public TileEntity createNewTileEntity(World aWorld, int aMeta) { + return this.createTileEntity(aWorld, aMeta); + } + + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + public IIcon getIcon(int aSide, int aMeta) { + return BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { + super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity != null ? tTileEntity.receiveClientEvent(aData1, aData2) : false; + } + + public void addCollisionBoxesToList( + World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + ((IGregTechTileEntity) tTileEntity) + .addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + } else { + super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null + ? ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) + : super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null + ? ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) + : super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { + TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + AxisAlignedBB bbb = ((IGregTechTileEntity) tTileEntity) + .getCollisionBoundingBoxFromPool(((IGregTechTileEntity) tTileEntity).getWorld(), 0, 0, 0); + this.minX = bbb.minX; + this.minY = bbb.minY; + this.minZ = bbb.minZ; + this.maxX = bbb.maxX; + this.maxY = bbb.maxY; + this.maxZ = bbb.maxZ; + } else { + super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); + } + } + + public void setBlockBoundsForItemRender() { + super.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + } else { + super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) {} + + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return super.getBlockHardness(aWorld, aX, aY, aZ); + } + + public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity + && ((BaseMetaTileEntity) tTileEntity).privateAccess() + && !((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true) + ? -1.0F + : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); + } + + public boolean onBlockActivated( + World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, float par2, float par3) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity == null) { + return false; + } else { + if (aPlayer.isSneaking()) { + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem == null) { + return false; + } + + if (!GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) + && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { + return false; + } + } + + return tTileEntity instanceof IGregTechTileEntity + ? (((IGregTechTileEntity) tTileEntity).getTimer() < 50L + ? false + : (!aWorld.isRemote && !((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer) + ? true + : ((IGregTechTileEntity) tTileEntity) + .onRightclick(aPlayer, (byte) aSide, par1, par2, par3))) + : false; + } + } + + public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); + } + } + + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity ? ((IGregTechTileEntity) tTileEntity).getMetaTileID() : 0; + } + + public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaTileEntity) { + ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + } + + super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); + } + + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; + XSTR tRandom = new XSTR(); + mTemporaryTileEntity.set(tGregTechTileEntity); + + for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); ++i) { + ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); + if (tItem != null && tItem.stackSize > 0 && tGregTechTileEntity.isValidSlot(i)) { + EntityItem tItemEntity = new EntityItem( + aWorld, + (double) ((float) aX + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) aY + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) aZ + tRandom.nextFloat() * 0.8F + 0.1F), + new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); + if (tItem.hasTagCompound()) { + tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) + tItem.getTagCompound().copy()); + } + + tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D; + tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581D; + aWorld.spawnEntityInWorld(tItemEntity); + tItem.stackSize = 0; + tGregTechTileEntity.setInventorySlotContents(i, (ItemStack) null); + } + } + } + + super.breakBlock(aWorld, aX, aY, aZ, par5, par6); + aWorld.removeTileEntity(aX, aY, aZ); + } + + public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getDrops() + : (mTemporaryTileEntity.get() == null + ? new ArrayList() + : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops()); + } + + public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide) + : 0; + } + + public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + if (aSide >= 0 && aSide <= 5) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)) + : 0; + } else { + return 0; + } + } + + public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + if (aSide >= 0 && aSide <= 5) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity) + .getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)) + : 0; + } else { + return 0; + } + } + + public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { + if (!aWorld.isRemote) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null && chance < 1.0F) { + if (tTileEntity instanceof BaseMetaTileEntity && GregTech_API.sMachineNonWrenchExplosions) { + ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + } + } else { + super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); + } + } + } + + public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { + if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { + return true; + } else { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null) { + if (tTileEntity instanceof BaseMetaTileEntity) { + return true; + } + + if (tTileEntity instanceof BaseMetaPipeEntity + && (((BaseMetaPipeEntity) tTileEntity).mConnections & -64) != 0) { + return true; + } + + if (tTileEntity instanceof ICoverable + && ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0) { + return true; + } + } + + return false; + } + } + + public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity == null + ? 0 + : (tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getLightOpacity() + : (aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0)); + } + + public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity ? ((BaseMetaTileEntity) tTileEntity).getLightValue() : 0; + } + + public TileEntity createTileEntity(World aWorld, int aMeta) { + return (TileEntity) + (aMeta >= 4 + ? Meta_GT_Proxy.constructBaseMetaTileEntity() + : Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower()); + } + + public float getExplosionResistance( + Entity par1Entity, + World aWorld, + int aX, + int aY, + int aZ, + double explosionX, + double explosionY, + double explosionZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6) + : 10.0F; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 100; ++i) { + if (GregTech_API.METATILEENTITIES[(30400 + i)] != null) { + par3List.add(new ItemStack(par1, 1, i)); + } + } + } + + public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null) { + if (tTileEntity instanceof IGregTechTileEntity) { + IGregTechTileEntity var6 = (IGregTechTileEntity) tTileEntity; + if (aPlayer == null) { + var6.setFrontFacing((byte) 1); + } else { + int var7 = MathHelper.floor_double((double) (aPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int var8 = Math.round(aPlayer.rotationPitch); + if (var8 >= 65 && var6.isValidFacing((byte) 1)) { + var6.setFrontFacing((byte) 1); + } else if (var8 <= -65 && var6.isValidFacing((byte) 0)) { + var6.setFrontFacing((byte) 0); + } else { + switch (var7) { + case 0: + var6.setFrontFacing((byte) 2); + break; + case 1: + var6.setFrontFacing((byte) 5); + break; + case 2: + var6.setFrontFacing((byte) 3); + break; + case 3: + var6.setFrontFacing((byte) 4); + } + } + } + } + } + } + + public ArrayList getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { + TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity + ? ((BaseMetaTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel) + : (tTileEntity instanceof BaseMetaPipeEntity + ? ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel) + : null); + } + + public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) (~aColor & 15)) { + return false; + } else { + ((IGregTechTileEntity) tTileEntity).setColorization((byte) (~aColor & 15)); + return true; + } + } else { + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Item_Machines.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Item_Machines.java index ba3b05ff8e..9e732d2443 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Item_Machines.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Item_Machines.java @@ -8,8 +8,6 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; - import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -20,210 +18,251 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; public class GTPP_Item_Machines extends ItemBlock { - public GTPP_Item_Machines(Block par1) { - super(par1); - this.setMaxDamage(0); - this.setHasSubtypes(true); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - } - - @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { - try { - int e = this.getDamage(aStack) + 30400; //Add Offset - if (e <= 0 || e >= GregTech_API.METATILEENTITIES.length) { - return; - } - - if (GregTech_API.METATILEENTITIES[e] != null) { - - IGregTechTileEntity aNBT = GregTech_API.METATILEENTITIES[e].getBaseMetaTileEntity(); - - final long tVoltage = aNBT.getInputVoltage(); - byte tTier = (byte) ((byte) Math.max(1, GT_Utility.getTier(tVoltage))); - - /*if (aNBT.getDescription() != null) { - int tAmount = 0; - String[] arg7 = aNBT.getDescription(); - int arg8 = arg7.length-1; - - if (arg7 != null && arg7.length > 0) { - for (String t : arg7) { - aList.add(t); - } - - } - else { - aList.add("ERROR"); - } - - for (int y = 0; y < arg8; y++) { - String tDescription = arg7[y]; - - if (tDescription != null) { - aList.add(tDescription+"|"+arg8); - continue; - } - else { - continue; - } - } - }*/ - - if (aNBT.getEUCapacity() > 0L) { - - //Custom handling - if ((e - 30400) <= 100) { - - - if ((e - 30400) <= 10) { - tTier -= 2; - aList.add(EnumChatFormatting.BOLD+"16"+" Fuse Slots"+EnumChatFormatting.GRAY); - aList.add("Per each fuse, you may insert "+EnumChatFormatting.YELLOW+(GT_Values.V[tTier])+EnumChatFormatting.GRAY+" EU/t"); - aList.add("However this "+EnumChatFormatting.ITALIC+EnumChatFormatting.RED+"MUST"+EnumChatFormatting.GRAY+" be in a single Amp"); - aList.add("This machine can accept upto a single amp of "+GT_Values.VN[Math.min(tTier+2, 12)]+" as a result"); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Breaker_Loss", "Breaker Loss: "+EnumChatFormatting.RED+""+(GT_Values.V[Math.max(tTier-1, 0)]/10)+EnumChatFormatting.GRAY+" EU/t", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - } - - - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Special_Power_1", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_2", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_3", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - } - - - if (aNBT.getInputVoltage() > 0L) { - String inA = "0"; - if (aNBT.getInputAmperage() >= 1L) { - inA = " at " + EnumChatFormatting.YELLOW + aNBT.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - else { - inA = " at " + EnumChatFormatting.WHITE + aNBT.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - String a1 = "Voltage IN: "+EnumChatFormatting.GREEN + aNBT.getInputVoltage() - + " (" + GT_Values.VN[GT_Utility.getTier(aNBT.getInputVoltage())] + ")" - + EnumChatFormatting.GRAY + inA; - aList.add(a1); - } - - if (aNBT.getOutputVoltage() > 0L) { - String outA = "0"; - if (aNBT.getOutputAmperage() >= 1L) { - outA = " at " + EnumChatFormatting.YELLOW + aNBT.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - else { - outA = " at " + EnumChatFormatting.WHITE + aNBT.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; - } - String a1 = "Voltage OUT: "+EnumChatFormatting.GREEN + aNBT.getOutputVoltage() - + " (" + GT_Values.VN[GT_Utility.getTier(aNBT.getOutputVoltage())] + ")" - + EnumChatFormatting.GRAY + outA; - aList.add(a1); - } - - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Lossess_EU", "Transmission Loss: "+EnumChatFormatting.DARK_BLUE+"0", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); - - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE2", "Internal Capacity: ", - !GregTech_API.sPostloadFinished) + EnumChatFormatting.BLUE + aNBT.getEUCapacity() - + EnumChatFormatting.GRAY + " EU"); - } - } - - NBTTagCompound arg16 = aStack.getTagCompound(); - if (arg16 != null) { - if (arg16.getBoolean("mMuffler")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", - !GregTech_API.sPostloadFinished)); - } - - if (arg16.getBoolean("mSteamConverter")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", - "has Steam Upgrade", !GregTech_API.sPostloadFinished)); - } - - boolean arg17 = false; - byte arg18; - if ((arg18 = arg16.getByte("mSteamTanks")) > 0) { - aList.add(arg18 + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", - "Steam Tank Upgrades", !GregTech_API.sPostloadFinished)); - } - } - - - aList.add(EnumChatFormatting.UNDERLINE+"Special GT++ Machine"); - - } catch (Throwable arg15) { - arg15.printStackTrace(GT_Log.err); - } - - } - - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, - float hitX, float hitY, float hitZ) { - return false; - } - - public String getUnlocalizedName(ItemStack aStack) { - short tDamage = (short) (this.getDamage(aStack) + 30400); //Add Offset; - return tDamage >= 0 && tDamage < GregTech_API.METATILEENTITIES.length - ? (GregTech_API.METATILEENTITIES[tDamage] != null - ? "gtpp.blockmachines" + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName() - : "") - : ""; - } - - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - super.onCreated(aStack, aWorld, aPlayer); - short tDamage = (short) ((short) this.getDamage(aStack) + 30400); //Add Offset; - if (tDamage < 0 - || tDamage >= GregTech_API.METATILEENTITIES.length && GregTech_API.METATILEENTITIES[tDamage] != null) { - GregTech_API.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer); - } - - } - - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, - float hitX, float hitY, float hitZ, int aMeta) { - short tDamage = (short) ((short) this.getDamage(aStack) + 30400); //Add Offset; - if (tDamage > 0) { - if (GregTech_API.METATILEENTITIES[tDamage] == null) { - return false; - } - - byte tMetaData = 32; - //byte tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType(); - Logger.INFO("Using Meta: "+tMetaData+" for ID "+tDamage+" | "+GregTech_API.METATILEENTITIES[tDamage].getInventoryName()); - if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tMetaData, 3)) { - return false; - } - - if (aWorld.getBlock(aX, aY, aZ) != this.field_150939_a) { - throw new GT_ItsNotMyFaultException( - "Failed to place Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don\'t report this Bug to me, I don\'t know how to fix it."); - } - - if (aWorld.getBlockMetadata(aX, aY, aZ) != tMetaData) { - throw new GT_ItsNotMyFaultException( - "Failed to set the MetaValue of the Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don\'t report this Bug to me, I don\'t know how to fix it."); - } - - IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null) { - tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage); - if (aPlayer != null) { - tTileEntity.setOwnerName(aPlayer.getDisplayName()); - } - - tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound()); - } - } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { - return false; - } - - if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { - this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); - this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); - } - - return true; - } -} \ No newline at end of file + public GTPP_Item_Machines(Block par1) { + super(par1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + } + + @SuppressWarnings("unchecked") + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { + try { + int e = this.getDamage(aStack) + 30400; // Add Offset + if (e <= 0 || e >= GregTech_API.METATILEENTITIES.length) { + return; + } + + if (GregTech_API.METATILEENTITIES[e] != null) { + + IGregTechTileEntity aNBT = GregTech_API.METATILEENTITIES[e].getBaseMetaTileEntity(); + + final long tVoltage = aNBT.getInputVoltage(); + byte tTier = (byte) ((byte) Math.max(1, GT_Utility.getTier(tVoltage))); + + /*if (aNBT.getDescription() != null) { + int tAmount = 0; + String[] arg7 = aNBT.getDescription(); + int arg8 = arg7.length-1; + + if (arg7 != null && arg7.length > 0) { + for (String t : arg7) { + aList.add(t); + } + + } + else { + aList.add("ERROR"); + } + + for (int y = 0; y < arg8; y++) { + String tDescription = arg7[y]; + + if (tDescription != null) { + aList.add(tDescription+"|"+arg8); + continue; + } + else { + continue; + } + } + }*/ + + if (aNBT.getEUCapacity() > 0L) { + + // Custom handling + if ((e - 30400) <= 100) { + + if ((e - 30400) <= 10) { + tTier -= 2; + aList.add(EnumChatFormatting.BOLD + "16" + " Fuse Slots" + EnumChatFormatting.GRAY); + aList.add("Per each fuse, you may insert " + EnumChatFormatting.YELLOW + + (GT_Values.V[tTier]) + EnumChatFormatting.GRAY + " EU/t"); + aList.add("However this " + EnumChatFormatting.ITALIC + EnumChatFormatting.RED + "MUST" + + EnumChatFormatting.GRAY + " be in a single Amp"); + aList.add("This machine can accept upto a single amp of " + + GT_Values.VN[Math.min(tTier + 2, 12)] + " as a result"); + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_Breaker_Loss", + "Breaker Loss: " + EnumChatFormatting.RED + "" + + (GT_Values.V[Math.max(tTier - 1, 0)] / 10) + + EnumChatFormatting.GRAY + " EU/t", + !GregTech_API.sPostloadFinished) + + EnumChatFormatting.GRAY); + } + + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_Special_Power_1", + EnumChatFormatting.RED + "Special Power Handling, please read manual", + !GregTech_API.sPostloadFinished) + + EnumChatFormatting.GRAY); + // aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_2", + // EnumChatFormatting.RED+"Special Power Handling, please read manual", + // !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + // aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_3", + // EnumChatFormatting.RED+"Special Power Handling, please read manual", + // !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + } + + if (aNBT.getInputVoltage() > 0L) { + String inA = "0"; + if (aNBT.getInputAmperage() >= 1L) { + inA = " at " + EnumChatFormatting.YELLOW + aNBT.getInputAmperage() + EnumChatFormatting.GRAY + + " Amps"; + } else { + inA = " at " + EnumChatFormatting.WHITE + aNBT.getInputAmperage() + EnumChatFormatting.GRAY + + " Amps"; + } + String a1 = "Voltage IN: " + EnumChatFormatting.GREEN + aNBT.getInputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(aNBT.getInputVoltage())] + ")" + + EnumChatFormatting.GRAY + inA; + aList.add(a1); + } + + if (aNBT.getOutputVoltage() > 0L) { + String outA = "0"; + if (aNBT.getOutputAmperage() >= 1L) { + outA = " at " + EnumChatFormatting.YELLOW + aNBT.getOutputAmperage() + + EnumChatFormatting.GRAY + " Amps"; + } else { + outA = " at " + EnumChatFormatting.WHITE + aNBT.getOutputAmperage() + + EnumChatFormatting.GRAY + " Amps"; + } + String a1 = "Voltage OUT: " + EnumChatFormatting.GREEN + aNBT.getOutputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(aNBT.getOutputVoltage())] + ")" + + EnumChatFormatting.GRAY + outA; + aList.add(a1); + } + + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_Lossess_EU", + "Transmission Loss: " + EnumChatFormatting.DARK_BLUE + "0", + !GregTech_API.sPostloadFinished) + + EnumChatFormatting.GRAY); + + aList.add(GT_LanguageManager.addStringLocalization( + "TileEntity_EUp_STORE2", "Internal Capacity: ", !GregTech_API.sPostloadFinished) + + EnumChatFormatting.BLUE + aNBT.getEUCapacity() + + EnumChatFormatting.GRAY + " EU"); + } + } + + NBTTagCompound arg16 = aStack.getTagCompound(); + if (arg16 != null) { + if (arg16.getBoolean("mMuffler")) { + aList.add(GT_LanguageManager.addStringLocalization( + "GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished)); + } + + if (arg16.getBoolean("mSteamConverter")) { + aList.add(GT_LanguageManager.addStringLocalization( + "GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished)); + } + + boolean arg17 = false; + byte arg18; + if ((arg18 = arg16.getByte("mSteamTanks")) > 0) { + aList.add(arg18 + " " + + GT_LanguageManager.addStringLocalization( + "GT_TileEntity_STEAMTANKS", + "Steam Tank Upgrades", + !GregTech_API.sPostloadFinished)); + } + } + + aList.add(EnumChatFormatting.UNDERLINE + "Special GT++ Machine"); + + } catch (Throwable arg15) { + arg15.printStackTrace(GT_Log.err); + } + } + + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ) { + return false; + } + + public String getUnlocalizedName(ItemStack aStack) { + short tDamage = (short) (this.getDamage(aStack) + 30400); // Add Offset; + return tDamage >= 0 && tDamage < GregTech_API.METATILEENTITIES.length + ? (GregTech_API.METATILEENTITIES[tDamage] != null + ? "gtpp.blockmachines" + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName() + : "") + : ""; + } + + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + super.onCreated(aStack, aWorld, aPlayer); + short tDamage = (short) ((short) this.getDamage(aStack) + 30400); // Add Offset; + if (tDamage < 0 + || tDamage >= GregTech_API.METATILEENTITIES.length && GregTech_API.METATILEENTITIES[tDamage] != null) { + GregTech_API.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer); + } + } + + public boolean placeBlockAt( + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int aX, + int aY, + int aZ, + int side, + float hitX, + float hitY, + float hitZ, + int aMeta) { + short tDamage = (short) ((short) this.getDamage(aStack) + 30400); // Add Offset; + if (tDamage > 0) { + if (GregTech_API.METATILEENTITIES[tDamage] == null) { + return false; + } + + byte tMetaData = 32; + // byte tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType(); + Logger.INFO("Using Meta: " + tMetaData + " for ID " + tDamage + " | " + + GregTech_API.METATILEENTITIES[tDamage].getInventoryName()); + if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tMetaData, 3)) { + return false; + } + + if (aWorld.getBlock(aX, aY, aZ) != this.field_150939_a) { + throw new GT_ItsNotMyFaultException( + "Failed to place Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don\'t report this Bug to me, I don\'t know how to fix it."); + } + + if (aWorld.getBlockMetadata(aX, aY, aZ) != tMetaData) { + throw new GT_ItsNotMyFaultException( + "Failed to set the MetaValue of the Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don\'t report this Bug to me, I don\'t know how to fix it."); + } + + IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null) { + tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage); + if (aPlayer != null) { + tTileEntity.setOwnerName(aPlayer.getDisplayName()); + } + + tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound()); + } + } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { + return false; + } + + if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { + this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); + this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); + } + + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java index daeebe2fe6..026d3d471f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java @@ -12,64 +12,66 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -public class GregtechMetaCasingBlocks -extends GregtechMetaCasingBlocksAbstract { +public class GregtechMetaCasingBlocks extends GregtechMetaCasingBlocksAbstract { - CasingTextureHandler TextureHandler = new CasingTextureHandler(); + CasingTextureHandler TextureHandler = new CasingTextureHandler(); - public GregtechMetaCasingBlocks() { - super(GregtechMetaCasingItems.class, "miscutils.blockcasings", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - if (i == 2 || i == 3 || i == 4) { - continue; - } - TAE.registerTexture(0, i, new GTPP_CopiedBlockTexture(this, 6, i)); - } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Centrifuge Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Structural Coke Oven Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Heat Resistant Coke Oven Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Heat Proof Coke Oven Casing"); //60 - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Material Press Machine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Electrolyzer Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Wire Factory Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Maceration Stack Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Matter Generation Coil"); //65 - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Matter Fabricator Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Iron Plated Bricks"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Multitank Exterior Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Hastelloy-N Reactor Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Zeron-100 Reactor Shielding"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Blast Smelter Heat Containment Coil "); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Blast Smelter Casing Block"); - GregtechItemList.Casing_Centrifuge1.set(new ItemStack(this, 1, 0)); - GregtechItemList.Casing_CokeOven.set(new ItemStack(this, 1, 1)); - GregtechItemList.Casing_CokeOven_Coil1.set(new ItemStack(this, 1, 2)); - GregtechItemList.Casing_CokeOven_Coil2.set(new ItemStack(this, 1, 3)); - GregtechItemList.Casing_MaterialPress.set(new ItemStack(this, 1, 4)); - GregtechItemList.Casing_Electrolyzer.set(new ItemStack(this, 1, 5)); - GregtechItemList.Casing_WireFactory.set(new ItemStack(this, 1, 6)); - GregtechItemList.Casing_MacerationStack.set(new ItemStack(this, 1, 7)); - GregtechItemList.Casing_MatterGen.set(new ItemStack(this, 1, 8)); - GregtechItemList.Casing_MatterFab.set(new ItemStack(this, 1, 9)); - GregtechItemList.Casing_IronPlatedBricks.set(new ItemStack(this, 1, 10)); - GregtechItemList.Casing_MultitankExterior.set(new ItemStack(this, 1, 11)); - GregtechItemList.Casing_Reactor_I.set(new ItemStack(this, 1, 12)); - GregtechItemList.Casing_Reactor_II.set(new ItemStack(this, 1, 13)); - GregtechItemList.Casing_Coil_BlastSmelter.set(new ItemStack(this, 1, 14)); - GregtechItemList.Casing_BlastSmelter.set(new ItemStack(this, 1, 15)); - } - - @Override - public IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] - return CasingTextureHandler.getIcon(aSide, aMeta); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { - final GregtechMetaCasingBlocks i = this; - return CasingTextureHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); - } + public GregtechMetaCasingBlocks() { + super(GregtechMetaCasingItems.class, "miscutils.blockcasings", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + if (i == 2 || i == 3 || i == 4) { + continue; + } + TAE.registerTexture(0, i, new GTPP_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Centrifuge Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Structural Coke Oven Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".2.name", "Heat Resistant Coke Oven Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".3.name", "Heat Proof Coke Oven Casing"); // 60 + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".4.name", "Material Press Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Electrolyzer Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Wire Factory Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Maceration Stack Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Matter Generation Coil"); // 65 + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Matter Fabricator Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Iron Plated Bricks"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Multitank Exterior Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Hastelloy-N Reactor Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Zeron-100 Reactor Shielding"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".14.name", "Blast Smelter Heat Containment Coil "); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Blast Smelter Casing Block"); + GregtechItemList.Casing_Centrifuge1.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_CokeOven.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_CokeOven_Coil1.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_CokeOven_Coil2.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_MaterialPress.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_Electrolyzer.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_WireFactory.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_MacerationStack.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_MatterGen.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_MatterFab.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_IronPlatedBricks.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_MultitankExterior.set(new ItemStack(this, 1, 11)); + GregtechItemList.Casing_Reactor_I.set(new ItemStack(this, 1, 12)); + GregtechItemList.Casing_Reactor_II.set(new ItemStack(this, 1, 13)); + GregtechItemList.Casing_Coil_BlastSmelter.set(new ItemStack(this, 1, 14)); + GregtechItemList.Casing_BlastSmelter.set(new ItemStack(this, 1, 15)); + } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { // Texture ID's. case 0 == ID[57] + return CasingTextureHandler.getIcon(aSide, aMeta); + } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon( + final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + final GregtechMetaCasingBlocks i = this; + return CasingTextureHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index 171339b08b..f71805784b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.List; - import gregtech.api.enums.TAE; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; @@ -10,78 +8,81 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler2; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class GregtechMetaCasingBlocks2 -extends GregtechMetaCasingBlocksAbstract { +public class GregtechMetaCasingBlocks2 extends GregtechMetaCasingBlocksAbstract { - CasingTextureHandler2 TextureHandler = new CasingTextureHandler2(); + CasingTextureHandler2 TextureHandler = new CasingTextureHandler2(); - public static class GregtechMetaCasingItemBlocks2 extends GregtechMetaCasingItems { + public static class GregtechMetaCasingItemBlocks2 extends GregtechMetaCasingItems { - public GregtechMetaCasingItemBlocks2(Block par1) { - super(par1); - } + public GregtechMetaCasingItemBlocks2(Block par1) { + super(par1); + } - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - int meta = aStack.getItemDamage(); - int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); - if (meta == 7 && tier > 0) { - long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); - aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); - } - super.addInformation(aStack, aPlayer, aList, aF3_H); - } - } + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int meta = aStack.getItemDamage(); + int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); + if (meta == 7 && tier > 0) { + long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); + aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } - public GregtechMetaCasingBlocks2() { - super(GregtechMetaCasingItemBlocks2.class, "gtplusplus.blockcasings.2", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - if (i == 4 || i == 10 || i == 11 || i == 12 || i == 14) { - continue; - } - TAE.registerTexture(1, i, new GTPP_CopiedBlockTexture(this, 6, i)); - } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Thermal Processing Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Hastelloy-N Sealant Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Hastelloy-X Structural Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Incoloy-DS Fluid Containment Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Wash Plant Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Industrial Sieve Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Large Sieve Grate"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (EV)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Sub-Station External Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Cyclotron Coil"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Autocrafter Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Sterile Farm Casing"); //Tree Farmer Textures - GregtechItemList.Casing_ThermalCentrifuge.set(new ItemStack(this, 1, 0)); - GregtechItemList.Casing_Refinery_External.set(new ItemStack(this, 1, 1)); - GregtechItemList.Casing_Refinery_Structural.set(new ItemStack(this, 1, 2)); - GregtechItemList.Casing_Refinery_Internal.set(new ItemStack(this, 1, 3)); - GregtechItemList.Casing_WashPlant.set(new ItemStack(this, 1, 4)); - GregtechItemList.Casing_Sifter.set(new ItemStack(this, 1, 5)); - GregtechItemList.Casing_SifterGrate.set(new ItemStack(this, 1, 6)); - GregtechItemList.Casing_Vanadium_Redox.set(new ItemStack(this, 1, 7)); - GregtechItemList.Casing_Power_SubStation.set(new ItemStack(this, 1, 8)); - GregtechItemList.Casing_Cyclotron_Coil.set(new ItemStack(this, 1, 9)); - GregtechItemList.Casing_Cyclotron_External.set(new ItemStack(this, 1, 10)); - GregtechItemList.Casing_ThermalContainment.set(new ItemStack(this, 1, 11)); - GregtechItemList.Casing_Autocrafter.set(new ItemStack(this, 1, 12)); - GregtechItemList.Casing_CuttingFactoryFrame.set(new ItemStack(this, 1, 13)); - //GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 14)); - GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.set(new ItemStack(this, 1, 15)); //Tree Farmer Textures - } + public GregtechMetaCasingBlocks2() { + super(GregtechMetaCasingItemBlocks2.class, "gtplusplus.blockcasings.2", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + if (i == 4 || i == 10 || i == 11 || i == 12 || i == 14) { + continue; + } + TAE.registerTexture(1, i, new GTPP_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Thermal Processing Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Hastelloy-N Sealant Block"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Hastelloy-X Structural Block"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".3.name", "Incoloy-DS Fluid Containment Block"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Wash Plant Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Industrial Sieve Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Large Sieve Grate"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (EV)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Sub-Station External Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Cyclotron Coil"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Autocrafter Frame"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".15.name", "Sterile Farm Casing"); // Tree Farmer Textures + GregtechItemList.Casing_ThermalCentrifuge.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Refinery_External.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Refinery_Structural.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Refinery_Internal.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_WashPlant.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_Sifter.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_SifterGrate.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_Vanadium_Redox.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_Power_SubStation.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_Cyclotron_Coil.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_Cyclotron_External.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_ThermalContainment.set(new ItemStack(this, 1, 11)); + GregtechItemList.Casing_Autocrafter.set(new ItemStack(this, 1, 12)); + GregtechItemList.Casing_CuttingFactoryFrame.set(new ItemStack(this, 1, 13)); + // GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 14)); + GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.set(new ItemStack(this, 1, 15)); // Tree Farmer Textures + } - @Override - public IIcon getIcon(final int aSide, final int aMeta) { - return CasingTextureHandler2.getIcon(aSide, aMeta); - } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return CasingTextureHandler2.getIcon(aSide, aMeta); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index e9251d908e..59bcfa5347 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.TAE; @@ -13,358 +11,367 @@ import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler3; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -public class GregtechMetaCasingBlocks3 -extends GregtechMetaCasingBlocksAbstract { +public class GregtechMetaCasingBlocks3 extends GregtechMetaCasingBlocksAbstract { - public static boolean mConnectedMachineTextures = false; - CasingTextureHandler3 TextureHandler = new CasingTextureHandler3(); + public static boolean mConnectedMachineTextures = false; + CasingTextureHandler3 TextureHandler = new CasingTextureHandler3(); - public static class GregtechMetaCasingItemBlocks3 extends GregtechMetaCasingItems { + public static class GregtechMetaCasingItemBlocks3 extends GregtechMetaCasingItems { - public GregtechMetaCasingItemBlocks3(Block par1) { - super(par1); - } + public GregtechMetaCasingItemBlocks3(Block par1) { + super(par1); + } - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - int meta = aStack.getItemDamage(); - int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); - if (tier > 0) { - long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); - aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); - } - super.addInformation(aStack, aPlayer, aList, aF3_H); - } - } + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int meta = aStack.getItemDamage(); + int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); + if (tier > 0) { + long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); + aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } - public GregtechMetaCasingBlocks3() { - super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.3", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - // Free up Redox casing in TAE - if (i >= 4 && i <= 8) { - continue; - } - TAE.registerTexture(2, i, new GTPP_CopiedBlockTexture(this, 6, i)); - } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Aquatic Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel Reinforced Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Multi-Use Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Trinium Plated Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Vanadium Redox Power Cell (IV)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Vanadium Redox Power Cell (LuV)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Vanadium Redox Power Cell (ZPM)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (UV)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Vanadium Redox Power Cell (MAX)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Supply Depot Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Advanced Cryogenic Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Volcanus Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Fusion Machine Casing MK III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Advanced Fusion Coil"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Unnamed"); // Can Use, don't change texture (Used for Fusion MK4) - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Containment Casing"); - GregtechItemList.Casing_FishPond.set(new ItemStack(this, 1, 0)); - GregtechItemList.Casing_Extruder.set(new ItemStack(this, 1, 1)); - GregtechItemList.Casing_Multi_Use.set(new ItemStack(this, 1, 2)); - GregtechItemList.Casing_BedrockMiner.set(new ItemStack(this, 1, 3)); - GregtechItemList.Casing_Vanadium_Redox_IV.set(new ItemStack(this, 1, 4)); - GregtechItemList.Casing_Vanadium_Redox_LuV.set(new ItemStack(this, 1, 5)); - GregtechItemList.Casing_Vanadium_Redox_ZPM.set(new ItemStack(this, 1, 6)); - GregtechItemList.Casing_Vanadium_Redox_UV.set(new ItemStack(this, 1, 7)); - GregtechItemList.Casing_Vanadium_Redox_MAX.set(new ItemStack(this, 1, 8)); - GregtechItemList.Casing_AmazonWarehouse.set(new ItemStack(this, 1, 9)); - GregtechItemList.Casing_AdvancedVacuum.set(new ItemStack(this, 1, 10)); - GregtechItemList.Casing_Adv_BlastFurnace.set(new ItemStack(this, 1, 11)); - GregtechItemList.Casing_Fusion_External.set(new ItemStack(this, 1, 12)); - GregtechItemList.Casing_Fusion_Internal.set(new ItemStack(this, 1, 13)); - GregtechItemList.Casing_Containment.set(new ItemStack(this, 1, 15)); - } + public GregtechMetaCasingBlocks3() { + super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.3", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + // Free up Redox casing in TAE + if (i >= 4 && i <= 8) { + continue; + } + TAE.registerTexture(2, i, new GTPP_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Aquatic Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel Reinforced Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Multi-Use Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Trinium Plated Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".4.name", "Vanadium Redox Power Cell (IV)"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".5.name", "Vanadium Redox Power Cell (LuV)"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".6.name", "Vanadium Redox Power Cell (ZPM)"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (UV)"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".8.name", "Vanadium Redox Power Cell (MAX)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Supply Depot Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Advanced Cryogenic Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Volcanus Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".12.name", "Fusion Machine Casing MK III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Advanced Fusion Coil"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".14.name", + "Unnamed"); // Can Use, don't change texture (Used for Fusion MK4) + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Containment Casing"); + GregtechItemList.Casing_FishPond.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Extruder.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Multi_Use.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_BedrockMiner.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Vanadium_Redox_IV.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_Vanadium_Redox_LuV.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_Vanadium_Redox_ZPM.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_Vanadium_Redox_UV.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_Vanadium_Redox_MAX.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_AmazonWarehouse.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_AdvancedVacuum.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_Adv_BlastFurnace.set(new ItemStack(this, 1, 11)); + GregtechItemList.Casing_Fusion_External.set(new ItemStack(this, 1, 12)); + GregtechItemList.Casing_Fusion_Internal.set(new ItemStack(this, 1, 13)); + GregtechItemList.Casing_Containment.set(new ItemStack(this, 1, 15)); + } - @Override - public IIcon getIcon(final int aSide, final int aMeta) { - return CasingTextureHandler3.getIcon(aSide, aMeta); - } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return CasingTextureHandler3.getIcon(aSide, aMeta); + } - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, - final int aSide) { - final Block thisBlock = aWorld.getBlock(xCoord, yCoord, zCoord); - final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if ((tMeta != 12)|| !GregtechMetaCasingBlocks3.mConnectedMachineTextures) { - return getIcon(aSide, tMeta); - } - final int tStartIndex = 0; - if (tMeta == 12) { - final boolean[] tConnectedSides = { - aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock - && aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta, - aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock - && aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta, - aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock - && aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta, - aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock - && aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta, - aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock - && aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta, - aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock - && aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta}; - switch (aSide) { - case 0 : { - if (tConnectedSides[0]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); - } - if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); - } - if (tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); - } - if (!tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); - } - if (tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); - } - if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); - } - if (!tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (!tConnectedSides[4] && !tConnectedSides[2]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); - } - if (!tConnectedSides[5] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); - } - } - case 1 : { - if (tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); - } - if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); - } - if (tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); - } - if (!tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); - } - if (tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); - } - if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); - } - if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); - } - if (!tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (!tConnectedSides[2] && !tConnectedSides[4]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); - } - if (!tConnectedSides[3] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); - } - } - case 2 : { - if (tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); - } - if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); - } - if (tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); - } - if (!tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); - } - if (tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); - } - if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); - } - if (!tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (!tConnectedSides[2] && !tConnectedSides[4]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); - } - } - case 3 : { - if (tConnectedSides[3]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); - } - if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); - } - if (tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); - } - if (!tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); - } - if (tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); - } - if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); - } - if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); - } - if (!tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (!tConnectedSides[2] && !tConnectedSides[4]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); - } - } - case 4 : { - if (tConnectedSides[4]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); - } - if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); - } - if (tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); - } - if (tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); - } - if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); - } - if (!tConnectedSides[3] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); - } - } - case 5 : { - if (tConnectedSides[2]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); - } - if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); - } - if (tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); - } - if (tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); - } - if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); - } - if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - if (!tConnectedSides[0] && !tConnectedSides[1]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); - } - if (!tConnectedSides[3] && !tConnectedSides[5]) { - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); - } - break; - } - } - return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); - } - return CasingTextureHandler3.getIcon(aSide, tMeta); - } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon( + final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + final Block thisBlock = aWorld.getBlock(xCoord, yCoord, zCoord); + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if ((tMeta != 12) || !GregtechMetaCasingBlocks3.mConnectedMachineTextures) { + return getIcon(aSide, tMeta); + } + final int tStartIndex = 0; + if (tMeta == 12) { + final boolean[] tConnectedSides = { + aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta, + aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta, + aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta, + aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta, + aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta, + aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta + }; + switch (aSide) { + case 0: { + if (tConnectedSides[0]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[2]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[5] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 1: { + if (tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[3] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 2: { + if (tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 3: { + if (tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 4: { + if (tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + if (!tConnectedSides[3] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + } + case 5: { + if (tConnectedSides[2]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + if (!tConnectedSides[3] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + break; + } + } + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + return CasingTextureHandler3.getIcon(aSide, tMeta); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java index 93ec53baba..5456aa27a2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java @@ -10,102 +10,98 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +public class GregtechMetaCasingBlocks4 extends GregtechMetaCasingBlocksAbstract { -public class GregtechMetaCasingBlocks4 -extends GregtechMetaCasingBlocksAbstract { + public GregtechMetaCasingBlocks4() { + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.4", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + if (i == 2 || i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 12 || i == 13 || i == 14 || i == 15) { + continue; + } + TAE.registerTexture(3, i, new GTPP_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Naquadah Reactor Base"); // 48 + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reactor Piping"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Naquadah Containment Chamber"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Tempered Arc Furnace Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + GregtechItemList.Casing_Naq_Reactor_A.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Naq_Reactor_B.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Naq_Reactor_C.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Industrial_Arc_Furnace.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Vacuum_Furnace.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_RocketEngine.set(new ItemStack(this, 1, 11)); + } - public GregtechMetaCasingBlocks4() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.4", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - if (i == 2 || i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 12 || i == 13 || i == 14 || i == 15) { - continue; - } - TAE.registerTexture(3, i, new GTPP_CopiedBlockTexture(this, 6, i)); - } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Naquadah Reactor Base"); //48 - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reactor Piping"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Naquadah Containment Chamber"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Tempered Arc Furnace Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused - GregtechItemList.Casing_Naq_Reactor_A.set(new ItemStack(this, 1, 0)); - GregtechItemList.Casing_Naq_Reactor_B.set(new ItemStack(this, 1, 1)); - GregtechItemList.Casing_Naq_Reactor_C.set(new ItemStack(this, 1, 2)); - GregtechItemList.Casing_Industrial_Arc_Furnace.set(new ItemStack(this, 1, 3)); - GregtechItemList.Casing_Vacuum_Furnace.set(new ItemStack(this, 1, 10)); - GregtechItemList.Casing_RocketEngine.set(new ItemStack(this, 1, 11)); - } + // private static final LargeTurbineTextureHandler mTurbineTextures = new LargeTurbineTextureHandler(); - //private static final LargeTurbineTextureHandler mTurbineTextures = new LargeTurbineTextureHandler(); - - /*@Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { - final GregtechMetaCasingBlocks4 i = this; - return mTurbineTextures.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); - }*/ - - @Override - public IIcon getIcon(final int aSide, final int aMeta) { - return getStaticIcon((byte) aSide, (byte) aMeta); - } - - public static IIcon getStaticIcon(final byte aSide, final byte aMeta) { - //Texture ID's. case 0 == ID[57] - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - case 0: - return TexturesGtBlock.Casing_Trinium_Titanium.getIcon(); - case 1: - return TexturesGtBlock.TEXTURE_TECH_C.getIcon(); - case 2: - return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); - case 3: - return TexturesGtBlock.TEXTURE_METAL_PANEL_A.getIcon(); - case 4: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 5: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 6: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 7: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 8: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 9: - return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); - case 10: - if (aSide <2) { - return TexturesGtBlock.TEXTURE_STONE_RED_B.getIcon(); - } - else { - return TexturesGtBlock.TEXTURE_STONE_RED_A.getIcon(); - } - case 11: - return TexturesGtBlock.TEXTURE_CASING_ROCKETDYNE.getIcon(); - case 12: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 13: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 14: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 15: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - default: - return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + /*@Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + final GregtechMetaCasingBlocks4 i = this; + return mTurbineTextures.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); + }*/ - } - } - return TexturesGtBlock._PlaceHolder.getIcon(); - } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return getStaticIcon((byte) aSide, (byte) aMeta); + } + + public static IIcon getStaticIcon(final byte aSide, final byte aMeta) { + // Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + return TexturesGtBlock.Casing_Trinium_Titanium.getIcon(); + case 1: + return TexturesGtBlock.TEXTURE_TECH_C.getIcon(); + case 2: + return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); + case 3: + return TexturesGtBlock.TEXTURE_METAL_PANEL_A.getIcon(); + case 4: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 5: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 6: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 7: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 8: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 9: + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + case 10: + if (aSide < 2) { + return TexturesGtBlock.TEXTURE_STONE_RED_B.getIcon(); + } else { + return TexturesGtBlock.TEXTURE_STONE_RED_A.getIcon(); + } + case 11: + return TexturesGtBlock.TEXTURE_CASING_ROCKETDYNE.getIcon(); + case 12: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 13: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 14: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 15: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + default: + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + } + } + return TexturesGtBlock._PlaceHolder.getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java index 27fa7349ca..834fb2c186 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java @@ -14,79 +14,85 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +public class GregtechMetaCasingBlocks5 extends GregtechMetaCasingBlocksAbstract { -public class GregtechMetaCasingBlocks5 -extends GregtechMetaCasingBlocksAbstract { + // Free Indexes within TAE: 91, 92, 94, 100, 101, 102, 103, 104, 114, 116, 117, 118, 119, 120, 121, 124, 125, 126, + // 127 + // 19 Free Indexes + private static final TexturesGrinderMultiblock mGrinderOverlayHandler = new TexturesGrinderMultiblock(); - // Free Indexes within TAE: 91, 92, 94, 100, 101, 102, 103, 104, 114, 116, 117, 118, 119, 120, 121, 124, 125, 126, 127 - // 19 Free Indexes - private static final TexturesGrinderMultiblock mGrinderOverlayHandler = new TexturesGrinderMultiblock(); - - public GregtechMetaCasingBlocks5() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.5", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "IsaMill Exterior Casing"); // IsaMill Casing - TAE.registerTexture(0, 2, new GTPP_CopiedBlockTexture(this, 6, 0)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "IsaMill Piping"); // IsaMill Pipe - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "IsaMill Gearbox"); // IsaMill Gearbox - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Elemental Confinement Shell"); // Duplicator Casing - TAE.registerTexture(0, 3, new GTPP_CopiedBlockTexture(this, 6, 3)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Sparge Tower Exterior Casing"); // Sparge Tower Casing - TAE.registerTexture(0, 4, new GTPP_CopiedBlockTexture(this, 6, 4)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Sturdy Printer Casing"); // Unused - TAE.registerTexture(1, 10, new GTPP_CopiedBlockTexture(this, 6, 5)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Forge Casing"); // Forge Hammer Casing - TAE.registerTexture(1, 11, new GTPP_CopiedBlockTexture(this, 6, 6)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused - - GregtechItemList.Casing_IsaMill_Casing.set(new ItemStack(this, 1, 0)); - GregtechItemList.Casing_IsaMill_Pipe.set(new ItemStack(this, 1, 1)); - GregtechItemList.Casing_IsaMill_Gearbox.set(new ItemStack(this, 1, 2)); - GregtechItemList.Casing_ElementalDuplicator.set(new ItemStack(this, 1, 3)); - GregtechItemList.Casing_Sparge_Tower_Exterior.set(new ItemStack(this, 1, 4)); - GregtechItemList.Casing_IndustrialAutoChisel.set(new ItemStack(this, 1, 5)); - GregtechItemList.Casing_IndustrialForgeHammer.set(new ItemStack(this, 1, 6)); - } - - @Override - public IIcon getIcon(final int aSide, final int aMeta) { - return getStaticIcon(aSide, aMeta); - } - + public GregtechMetaCasingBlocks5() { + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.5", GT_Material_Casings.INSTANCE); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".0.name", "IsaMill Exterior Casing"); // IsaMill Casing + TAE.registerTexture(0, 2, new GTPP_CopiedBlockTexture(this, 6, 0)); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".1.name", "IsaMill Piping"); // IsaMill Pipe + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".2.name", "IsaMill Gearbox"); // IsaMill Gearbox + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".3.name", "Elemental Confinement Shell"); // Duplicator Casing + TAE.registerTexture(0, 3, new GTPP_CopiedBlockTexture(this, 6, 3)); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".4.name", "Sparge Tower Exterior Casing"); // Sparge Tower Casing + TAE.registerTexture(0, 4, new GTPP_CopiedBlockTexture(this, 6, 4)); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".5.name", "Sturdy Printer Casing"); // Unused + TAE.registerTexture(1, 10, new GTPP_CopiedBlockTexture(this, 6, 5)); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".6.name", "Forge Casing"); // Forge Hammer Casing + TAE.registerTexture(1, 11, new GTPP_CopiedBlockTexture(this, 6, 6)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused - public static IIcon getStaticIcon(final int aSide, final int aMeta) { - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - case 0: - return TexturesGtBlock.TEXTURE_PIPE_GRINDING_MILL.getIcon(); - case 1: - return TexturesGtBlock.TEXTURE_CASING_GRINDING_MILL.getIcon(); - case 2: - return TexturesGtBlock.TEXTURE_GEARBOX_GRINDING_MILL.getIcon(); - case 3: - return TexturesGtBlock.TEXTURE_TECH_PANEL_D.getIcon(); - case 4: - return TexturesGtBlock.Casing_Machine_Metal_Sheet_H.getIcon(); - case 5: - return TexturesGtBlock.Casing_Machine_Metal_Sheet_I.getIcon(); - case 6: - return TexturesGtBlock.TEXTURE_TECH_PANEL_H.getIcon(); - } - } - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - } + GregtechItemList.Casing_IsaMill_Casing.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_IsaMill_Pipe.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_IsaMill_Gearbox.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_ElementalDuplicator.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Sparge_Tower_Exterior.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_IndustrialAutoChisel.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_IndustrialForgeHammer.set(new ItemStack(this, 1, 6)); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { - final GregtechMetaCasingBlocks5 i = this; - return mGrinderOverlayHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); - } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return getStaticIcon(aSide, aMeta); + } + + public static IIcon getStaticIcon(final int aSide, final int aMeta) { + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + return TexturesGtBlock.TEXTURE_PIPE_GRINDING_MILL.getIcon(); + case 1: + return TexturesGtBlock.TEXTURE_CASING_GRINDING_MILL.getIcon(); + case 2: + return TexturesGtBlock.TEXTURE_GEARBOX_GRINDING_MILL.getIcon(); + case 3: + return TexturesGtBlock.TEXTURE_TECH_PANEL_D.getIcon(); + case 4: + return TexturesGtBlock.Casing_Machine_Metal_Sheet_H.getIcon(); + case 5: + return TexturesGtBlock.Casing_Machine_Metal_Sheet_I.getIcon(); + case 6: + return TexturesGtBlock.TEXTURE_TECH_PANEL_H.getIcon(); + } + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon( + final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + final GregtechMetaCasingBlocks5 i = this; + return mGrinderOverlayHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java index ea59eb50ba..683159de98 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java @@ -1,11 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.List; -import java.util.Random; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gtPlusPlus.core.creative.AddToCreativeTab; +import java.util.List; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -20,131 +22,127 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Block_Casings_Abstract; - -import gtPlusPlus.core.creative.AddToCreativeTab; - -public abstract class GregtechMetaCasingBlocksAbstract -extends GT_Block_Casings_Abstract { - public GregtechMetaCasingBlocksAbstract(final Class aItemClass, final String aName, final Material aMaterial) { - super(aItemClass, aName, aMaterial); - this.setStepSound(soundTypeMetal); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GregTech_API.registerMachineBlock(this, -1); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); - } - - @Override - public String getHarvestTool(final int aMeta) { - return "wrench"; - } - - @Override - public int getHarvestLevel(final int aMeta) { - return 2; - } - - @Override - public float getBlockHardness(final World aWorld, final int aX, final int aY, final int aZ) { - return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); - } - - @Override - public float getExplosionResistance(final Entity aTNT) { - return Blocks.iron_block.getExplosionResistance(aTNT); - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public void onBlockAdded(final World aWorld, final int aX, final int aY, final int aZ) { - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - @Override - public String getUnlocalizedName() { - return this.mUnlocalizedName; - } - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); - } - - @Override - public boolean canBeReplacedByLeaves(final IBlockAccess aWorld, final int aX, final int aY, final int aZ) { - return false; - } - - @Override - public boolean isNormalCube(final IBlockAccess aWorld, final int aX, final int aY, final int aZ) { - return true; - } - - @Override - public boolean renderAsNormalBlock() { - return true; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int getRenderBlockPass() { - return 0; - } - - @Override - public void breakBlock(final World aWorld, final int aX, final int aY, final int aZ, final Block aBlock, final int aMetaData) { - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - @Override - public int damageDropped(final int par1) { - return par1; - } - - @Override - public int getDamageValue(final World par1World, final int par2, final int par3, final int par4) { - return par1World.getBlockMetadata(par2, par3, par4); - } - - @Override - public int quantityDropped(final Random par1Random) { - return 1; - } - - @Override - public Item getItemDropped(final int par1, final Random par2Random, final int par3) { - return Item.getItemFromBlock(this); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister aIconRegister) { - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(final Item aItem, final CreativeTabs par2CreativeTabs, final List aList) { - for (int i = 0; i < 16; i++) { - aList.add(new ItemStack(aItem, 1, i)); - } - } +public abstract class GregtechMetaCasingBlocksAbstract extends GT_Block_Casings_Abstract { + public GregtechMetaCasingBlocksAbstract( + final Class aItemClass, final String aName, final Material aMaterial) { + super(aItemClass, aName, aMaterial); + this.setStepSound(soundTypeMetal); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GregTech_API.registerMachineBlock(this, -1); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); + } + + @Override + public String getHarvestTool(final int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(final int aMeta) { + return 2; + } + + @Override + public float getBlockHardness(final World aWorld, final int aX, final int aY, final int aZ) { + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public float getExplosionResistance(final Entity aTNT) { + return Blocks.iron_block.getExplosionResistance(aTNT); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public void onBlockAdded(final World aWorld, final int aX, final int aY, final int aZ) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public String getUnlocalizedName() { + return this.mUnlocalizedName; + } + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); + } + + @Override + public boolean canBeReplacedByLeaves(final IBlockAccess aWorld, final int aX, final int aY, final int aZ) { + return false; + } + + @Override + public boolean isNormalCube(final IBlockAccess aWorld, final int aX, final int aY, final int aZ) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return true; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public void breakBlock( + final World aWorld, final int aX, final int aY, final int aZ, final Block aBlock, final int aMetaData) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int damageDropped(final int par1) { + return par1; + } + + @Override + public int getDamageValue(final World par1World, final int par2, final int par3, final int par4) { + return par1World.getBlockMetadata(par2, par3, par4); + } + + @Override + public int quantityDropped(final Random par1Random) { + return 1; + } + + @Override + public Item getItemDropped(final int par1, final Random par2Random, final int par3) { + return Item.getItemFromBlock(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister aIconRegister) {} + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(final Item aItem, final CreativeTabs par2CreativeTabs, final List aList) { + for (int i = 0; i < 16; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java index 10c1a4e80f..22c1d87b4e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.HashMap; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -9,95 +7,95 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.common.blocks.GT_Material_Casings; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.HashMap; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class GregtechMetaCasingBlocksPipeGearbox extends GregtechMetaCasingBlocksAbstract { - private static HashMap sMaterialMapping = new HashMap(); - - public GregtechMetaCasingBlocksPipeGearbox() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.pipesgears", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Eglin Steel Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel-792 Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Incoloy MA956 Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Nitinol-60 Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Zeron-100 Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Pikyonium Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Titansteel Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Abyssal Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Babbit Alloy Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Inconel-690 Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Stellite Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Nitinol-60 Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Lafium Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cinobite Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Titansteel Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Abyssal Pipe Casing"); + private static HashMap sMaterialMapping = new HashMap(); - int aMappingID = 0; - sMaterialMapping.put(aMappingID++, ALLOY.EGLIN_STEEL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.INCONEL_792.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.INCOLOY_MA956.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.NITINOL_60.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.ZERON_100.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.PIKYONIUM.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.TITANSTEEL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.ABYSSAL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.BABBIT_ALLOY.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.INCONEL_690.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.STELLITE.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.NITINOL_60.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.LAFIUM.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.CINOBITE.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.TITANSTEEL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.ABYSSAL.getRgbAsHex()); + public GregtechMetaCasingBlocksPipeGearbox() { + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.pipesgears", GT_Material_Casings.INSTANCE); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Eglin Steel Gear Box Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel-792 Gear Box Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".2.name", "Incoloy MA956 Gear Box Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Nitinol-60 Gear Box Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Zeron-100 Gear Box Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Pikyonium Gear Box Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Titansteel Gear Box Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Abyssal Gear Box Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Babbit Alloy Pipe Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Inconel-690 Pipe Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Stellite Pipe Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Nitinol-60 Pipe Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Lafium Pipe Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cinobite Pipe Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Titansteel Pipe Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Abyssal Pipe Casing"); - } + int aMappingID = 0; + sMaterialMapping.put(aMappingID++, ALLOY.EGLIN_STEEL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.INCONEL_792.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.INCOLOY_MA956.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.NITINOL_60.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.ZERON_100.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.PIKYONIUM.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.TITANSTEEL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.ABYSSAL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.BABBIT_ALLOY.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.INCONEL_690.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.STELLITE.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.NITINOL_60.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.LAFIUM.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.CINOBITE.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.TITANSTEEL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, ALLOY.ABYSSAL.getRgbAsHex()); + } - @Override - public IIcon getIcon(final int aSide, final int aMeta) { - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - return TexturesGtBlock.TEXTURE_GEARBOX_GENERIC.getIcon(); - case 8 : - case 9 : - case 10 : - case 11 : - case 12 : - case 13 : - case 14 : - case 15 : - return TexturesGtBlock.TEXTURE_PIPE_GENERIC.getIcon(); - } - } - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + return TexturesGtBlock.TEXTURE_GEARBOX_GENERIC.getIcon(); + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + return TexturesGtBlock.TEXTURE_PIPE_GENERIC.getIcon(); + } + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } @SideOnly(Side.CLIENT) - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { - return sMaterialMapping.get(par1IBlockAccess.getBlockMetadata(par2, par3, par4)); - } + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + return sMaterialMapping.get(par1IBlockAccess.getBlockMetadata(par2, par3, par4)); + } @SideOnly(Side.CLIENT) - @Override - public int getRenderColor(final int aMeta) { - return sMaterialMapping.get(aMeta); - } + @Override + public int getRenderColor(final int aMeta) { + return sMaterialMapping.get(aMeta); + } @SideOnly(Side.CLIENT) - @Override - public int getBlockColor() { - return super.getBlockColor(); - } - + @Override + public int getBlockColor() { + return super.getBlockColor(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingItems.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingItems.java index de51cb164b..9927060164 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingItems.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingItems.java @@ -2,9 +2,8 @@ package gtPlusPlus.xmod.gregtech.common.blocks; import net.minecraft.block.Block; -public class GregtechMetaCasingItems -extends GregtechMetaItemCasingsAbstract { - public GregtechMetaCasingItems(final Block par1) { - super(par1); - } +public class GregtechMetaCasingItems extends GregtechMetaItemCasingsAbstract { + public GregtechMetaCasingItems(final Block par1) { + super(par1); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasings1.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasings1.java index 7fb344a4ec..ba4929c011 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasings1.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasings1.java @@ -1,36 +1,35 @@ package gtPlusPlus.xmod.gregtech.common.blocks; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public class GregtechMetaItemCasings1 -extends GregtechMetaItemCasingsAbstract { - public GregtechMetaItemCasings1(final Block par1) { - super(par1); - } +public class GregtechMetaItemCasings1 extends GregtechMetaItemCasingsAbstract { + public GregtechMetaItemCasings1(final Block par1) { + super(par1); + } - @Override - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { - super.addInformation(aStack, aPlayer, aList, aF3_H); - switch (this.getDamage(aStack)) { - case 0: - aList.add(this.mCasing_Centrifuge); - break; - case 1: - aList.add(this.mCasing_CokeOven); - break; - case 2: - aList.add(this.mCasing_CokeCoil1); - break; - case 3: - aList.add(this.mCasing_CokeCoil2); - break; - default: - aList.add(this.mCasing_CokeCoil2); - break; - } - } + @Override + public void addInformation( + final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + switch (this.getDamage(aStack)) { + case 0: + aList.add(this.mCasing_Centrifuge); + break; + case 1: + aList.add(this.mCasing_CokeOven); + break; + case 2: + aList.add(this.mCasing_CokeCoil1); + break; + case 3: + aList.add(this.mCasing_CokeCoil2); + break; + default: + aList.add(this.mCasing_CokeCoil2); + break; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java index 62e0f0acdf..d9102f0994 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java @@ -1,61 +1,65 @@ package gtPlusPlus.xmod.gregtech.common.blocks; +import gregtech.api.util.GT_LanguageManager; 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 gregtech.api.util.GT_LanguageManager; - -public abstract class GregtechMetaItemCasingsAbstract -extends ItemBlock { +public abstract class GregtechMetaItemCasingsAbstract extends ItemBlock { - protected final String mCasing_Centrifuge = GT_LanguageManager.addStringLocalization("mu.centrifugecasing", "Warning! Standing in the Centrifuge not recommended"); - protected final String mCasing_CokeOven = GT_LanguageManager.addStringLocalization("mu.cokeoven", "Sturdy and Strong"); - protected final String mCasing_CokeCoil1 = GT_LanguageManager.addStringLocalization("mu.coil01tooltip", "Base Heating Capacity = 1350 Kelvin"); - protected final String mCasing_CokeCoil2 = GT_LanguageManager.addStringLocalization("mu.coil02tooltip", "Base Heating Capacity = 2275 Kelvin"); - protected final String mNoMobsToolTip = GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); - protected final String mNoTileEntityToolTip = GT_LanguageManager.addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + protected final String mCasing_Centrifuge = GT_LanguageManager.addStringLocalization( + "mu.centrifugecasing", "Warning! Standing in the Centrifuge not recommended"); + protected final String mCasing_CokeOven = + GT_LanguageManager.addStringLocalization("mu.cokeoven", "Sturdy and Strong"); + protected final String mCasing_CokeCoil1 = + GT_LanguageManager.addStringLocalization("mu.coil01tooltip", "Base Heating Capacity = 1350 Kelvin"); + protected final String mCasing_CokeCoil2 = + GT_LanguageManager.addStringLocalization("mu.coil02tooltip", "Base Heating Capacity = 2275 Kelvin"); + protected final String mNoMobsToolTip = + GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + protected final String mNoTileEntityToolTip = + GT_LanguageManager.addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); - public GregtechMetaItemCasingsAbstract(final Block par1) { - super(par1); - this.setMaxDamage(0); - this.setHasSubtypes(true); - //setCreativeTab(AddToCreativeTab.tabMachines); - } + public GregtechMetaItemCasingsAbstract(final Block par1) { + super(par1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + // setCreativeTab(AddToCreativeTab.tabMachines); + } - @Override - public int getMetadata(final int aMeta) { - return aMeta; - } + @Override + public int getMetadata(final int aMeta) { + return aMeta; + } - @Override - public String getUnlocalizedName(final ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); - } + @Override + public String getUnlocalizedName(final ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); + } - @Override - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { - super.addInformation(aStack, aPlayer, aList, aF3_H); - switch (this.getDamage(aStack)) { - case 0: - //aList.add(this.mCasing_Centrifuge); - break; - case 1: - //aList.add(this.mCasing_CokeOven); - break; - case 2: - //aList.add(this.mCasing_CokeCoil1); - break; - case 3: - //aList.add(this.mCasing_CokeCoil2); - break; - default: - break; - } - aList.add(this.mNoMobsToolTip); - aList.add(this.mNoTileEntityToolTip); - } + @Override + public void addInformation( + final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + switch (this.getDamage(aStack)) { + case 0: + // aList.add(this.mCasing_Centrifuge); + break; + case 1: + // aList.add(this.mCasing_CokeOven); + break; + case 2: + // aList.add(this.mCasing_CokeCoil1); + break; + case 3: + // aList.add(this.mCasing_CokeCoil2); + break; + default: + break; + } + aList.add(this.mNoMobsToolTip); + aList.add(this.mNoTileEntityToolTip); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java index b46e9d7464..f0a69e49d3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.List; - import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.util.GT_LanguageManager; @@ -9,73 +7,74 @@ import gregtech.common.blocks.GT_Material_Casings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - public class GregtechMetaSpecialMachineCasings extends GregtechMetaCasingBlocksAbstract { + public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { - public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { + public SpecialCasingItemBlock(Block par1) { + super(par1); + } - public SpecialCasingItemBlock(Block par1) { - super(par1); - } + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 10) { + // aList.add("Tier: "+GT_Values.VN[aMeta]); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - int aMeta = aStack.getItemDamage(); - if (aMeta < 10) { - //aList.add("Tier: "+GT_Values.VN[aMeta]); - } - super.addInformation(aStack, aPlayer, aList, aF3_H); - } - } - - public GregtechMetaSpecialMachineCasings() { - super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.2", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - //TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); - // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) - } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Strong Bronze Machine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Sturdy Aluminium Machine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Vigorous Laurenium Machine Casing"); - TAE.registerTexture(84, new GTPP_CopiedBlockTexture(this, 6, 2)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Rugged Botmium Machine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused - - GregtechItemList.Casing_Machine_Custom_1.set(new ItemStack(this, 1, 0)); - GregtechItemList.Casing_Machine_Custom_2.set(new ItemStack(this, 1, 1)); - GregtechItemList.Casing_Machine_Custom_3.set(new ItemStack(this, 1, 2)); - GregtechItemList.Casing_Machine_Custom_4.set(new ItemStack(this, 1, 3)); - } + public GregtechMetaSpecialMachineCasings() { + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.2", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + // TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); + // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Strong Bronze Machine Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".1.name", "Sturdy Aluminium Machine Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".2.name", "Vigorous Laurenium Machine Casing"); + TAE.registerTexture(84, new GTPP_CopiedBlockTexture(this, 6, 2)); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".3.name", "Rugged Botmium Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused - public IIcon getIcon(int aSide, int aMeta) { - switch (aMeta) { - case 0: - return Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); - case 1: - return Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); - case 2: - return TexturesGtBlock.Casing_Material_Laurenium.getIcon(); - case 3: - return Textures.BlockIcons.MACHINE_HEATPROOFCASING.getIcon(); - } - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - } + GregtechItemList.Casing_Machine_Custom_1.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Machine_Custom_2.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Machine_Custom_3.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Machine_Custom_4.set(new ItemStack(this, 1, 3)); + } + public IIcon getIcon(int aSide, int aMeta) { + switch (aMeta) { + case 0: + return Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); + case 1: + return Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); + case 2: + return TexturesGtBlock.Casing_Material_Laurenium.getIcon(); + case 3: + return Textures.BlockIcons.MACHINE_HEATPROOFCASING.getIcon(); + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java index 8b8955df43..96a4e6da82 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.TAE; @@ -12,114 +10,120 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine.LargeTurbineTextureHandler; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; - public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbstract { - - public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { - public SpecialCasingItemBlock(Block par1) { - super(par1); - } + public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { + + public SpecialCasingItemBlock(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 10) { + // aList.add("Tier: "+GT_Values.VN[aMeta]); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaSpecialMultiCasings() { + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.1", GT_Material_Casings.INSTANCE); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Turbine Shaft"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".1.name", "Reinforced Steam Turbine Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".2.name", "Reinforced HP Steam Turbine Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".3.name", "Reinforced Gas Turbine Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".4.name", "Reinforced Plasma Turbine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Tesla Containment Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".11.name", "Molecular Containment Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".12.name", "High Voltage Current Capacitor"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Particle Containment Casing"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + ".14.name", "Reinforced Heat Exchanger Casing"); + TAE.registerTexture(1, 12, new GTPP_CopiedBlockTexture(this, 6, 14)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - int aMeta = aStack.getItemDamage(); - if (aMeta < 10) { - //aList.add("Tier: "+GT_Values.VN[aMeta]); - } - super.addInformation(aStack, aPlayer, aList, aF3_H); - } - } - - public GregtechMetaSpecialMultiCasings() { - super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.1", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Turbine Shaft"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reinforced Steam Turbine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Reinforced HP Steam Turbine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Reinforced Gas Turbine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Reinforced Plasma Turbine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Tesla Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Molecular Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "High Voltage Current Capacitor"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Particle Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Reinforced Heat Exchanger Casing"); - TAE.registerTexture(1, 12, new GTPP_CopiedBlockTexture(this, 6, 14)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + GregtechItemList.Casing_Turbine_Shaft.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Turbine_LP.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Turbine_HP.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Turbine_Gas.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Turbine_Plasma.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_SolarTower_Structural.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_SolarTower_SaltContainment.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_SolarTower_HeatContainment.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_Flotation_Cell.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_Reinforced_Engine_Casing.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_Molecular_Transformer_1.set(new ItemStack(this, 1, 11)); + GregtechItemList.Casing_Molecular_Transformer_2.set(new ItemStack(this, 1, 12)); + GregtechItemList.Casing_Molecular_Transformer_3.set(new ItemStack(this, 1, 13)); + GregtechItemList.Casing_XL_HeatExchanger.set(new ItemStack(this, 1, 14)); + } - GregtechItemList.Casing_Turbine_Shaft.set(new ItemStack(this, 1, 0)); - GregtechItemList.Casing_Turbine_LP.set(new ItemStack(this, 1, 1)); - GregtechItemList.Casing_Turbine_HP.set(new ItemStack(this, 1, 2)); - GregtechItemList.Casing_Turbine_Gas.set(new ItemStack(this, 1, 3)); - GregtechItemList.Casing_Turbine_Plasma.set(new ItemStack(this, 1, 4)); - GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 5)); - GregtechItemList.Casing_SolarTower_Structural.set(new ItemStack(this, 1, 6)); - GregtechItemList.Casing_SolarTower_SaltContainment.set(new ItemStack(this, 1, 7)); - GregtechItemList.Casing_SolarTower_HeatContainment.set(new ItemStack(this, 1, 8)); - GregtechItemList.Casing_Flotation_Cell.set(new ItemStack(this, 1, 9)); - GregtechItemList.Casing_Reinforced_Engine_Casing.set(new ItemStack(this, 1, 10)); - GregtechItemList.Casing_Molecular_Transformer_1.set(new ItemStack(this, 1, 11)); - GregtechItemList.Casing_Molecular_Transformer_2.set(new ItemStack(this, 1, 12)); - GregtechItemList.Casing_Molecular_Transformer_3.set(new ItemStack(this, 1, 13)); - GregtechItemList.Casing_XL_HeatExchanger.set(new ItemStack(this, 1, 14)); - - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { - return LargeTurbineTextureHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, this); - } - @Override - public IIcon getIcon(final int aSide, final int aMeta) { - return getStaticIcon((byte) aSide, (byte) aMeta); - } - - public static IIcon getStaticIcon(final byte aSide, final byte aMeta) { - switch (aMeta) { - case 0: - return TexturesGtBlock.Casing_Redox_1.getIcon(); - case 1: - return Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); - case 2: - return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - case 3: - return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); - case 4: - return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - case 5: - return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); - case 6: - return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); - case 7: - return TexturesGtBlock.Casing_Material_Stellite.getIcon(); - case 8: - return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); - case 9: - return TexturesGtBlock.TEXTURE_CASING_FLOTATION.getIcon(); - case 10: - return TexturesGtBlock.Casing_Material_Talonite.getIcon(); - case 11: - return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); - case 12: - return TexturesGtBlock.Casing_Redox_5.getIcon(); - case 13: - return TexturesGtBlock.TEXTURE_MAGIC_PANEL_B.getIcon(); - case 14: - return TexturesGtBlock.Casing_Material_Talonite.getIcon(); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon( + final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + return LargeTurbineTextureHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, this); + } - } - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return getStaticIcon((byte) aSide, (byte) aMeta); + } + public static IIcon getStaticIcon(final byte aSide, final byte aMeta) { + switch (aMeta) { + case 0: + return TexturesGtBlock.Casing_Redox_1.getIcon(); + case 1: + return Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); + case 2: + return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + case 3: + return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); + case 4: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 5: + return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); + case 6: + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + case 7: + return TexturesGtBlock.Casing_Material_Stellite.getIcon(); + case 8: + return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + case 9: + return TexturesGtBlock.TEXTURE_CASING_FLOTATION.getIcon(); + case 10: + return TexturesGtBlock.Casing_Material_Talonite.getIcon(); + case 11: + return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); + case 12: + return TexturesGtBlock.Casing_Redox_5.getIcon(); + case 13: + return TexturesGtBlock.TEXTURE_MAGIC_PANEL_B.getIcon(); + case 14: + return TexturesGtBlock.Casing_Material_Talonite.getIcon(); + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java index a80b788aa1..664f949b30 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -9,99 +7,98 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.common.blocks.GT_Material_Casings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; - public class GregtechMetaSpecialMultiCasings2 extends GregtechMetaCasingBlocksAbstract { - - public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { - public SpecialCasingItemBlock(Block par1) { - super(par1); - } + public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { + + public SpecialCasingItemBlock(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 4) { + aList.add("Provides quantum stability"); + } + if (aMeta >= 4 && aMeta < 8) { + aList.add("Provides quantum modulation"); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaSpecialMultiCasings2() { + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.3", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + // TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); + // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Resonance Chamber I"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Resonance Chamber II"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Resonance Chamber III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Resonance Chamber IV"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Modulator I"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Modulator II"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Modulator III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Modulator IV"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - int aMeta = aStack.getItemDamage(); - if (aMeta < 4) { - aList.add("Provides quantum stability"); - } - if (aMeta >= 4 && aMeta < 8) { - aList.add("Provides quantum modulation"); - } - super.addInformation(aStack, aPlayer, aList, aF3_H); - } - } - - public GregtechMetaSpecialMultiCasings2() { - super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.3", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - //TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); - // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) - } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Resonance Chamber I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Resonance Chamber II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Resonance Chamber III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Resonance Chamber IV"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Modulator I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Modulator II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Modulator III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Modulator IV"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + GregtechItemList.ResonanceChamber_I.set(new ItemStack(this, 1, 0)); + GregtechItemList.ResonanceChamber_II.set(new ItemStack(this, 1, 1)); + GregtechItemList.ResonanceChamber_III.set(new ItemStack(this, 1, 2)); + GregtechItemList.ResonanceChamber_IV.set(new ItemStack(this, 1, 3)); + GregtechItemList.Modulator_I.set(new ItemStack(this, 1, 4)); + GregtechItemList.Modulator_II.set(new ItemStack(this, 1, 5)); + GregtechItemList.Modulator_III.set(new ItemStack(this, 1, 6)); + GregtechItemList.Modulator_IV.set(new ItemStack(this, 1, 7)); + } - GregtechItemList.ResonanceChamber_I.set(new ItemStack(this, 1, 0)); - GregtechItemList.ResonanceChamber_II.set(new ItemStack(this, 1, 1)); - GregtechItemList.ResonanceChamber_III.set(new ItemStack(this, 1, 2)); - GregtechItemList.ResonanceChamber_IV.set(new ItemStack(this, 1, 3)); - GregtechItemList.Modulator_I.set(new ItemStack(this, 1, 4)); - GregtechItemList.Modulator_II.set(new ItemStack(this, 1, 5)); - GregtechItemList.Modulator_III.set(new ItemStack(this, 1, 6)); - GregtechItemList.Modulator_IV.set(new ItemStack(this, 1, 7)); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { - return getStaticIcon((byte) aSide, (byte) aWorld.getBlockMetadata(xCoord, yCoord, zCoord)); - } - - @Override - public IIcon getIcon(final int aSide, final int aMeta) { - return getStaticIcon((byte) aSide, (byte) aMeta); - } - - public static IIcon getStaticIcon(final byte aSide, final byte aMeta) { - switch (aMeta) { - case 0: - return TexturesGtBlock.Casing_Resonance_1.getIcon(); - case 1: - return TexturesGtBlock.Casing_Resonance_2.getIcon(); - case 2: - return TexturesGtBlock.Casing_Resonance_3.getIcon(); - case 3: - return TexturesGtBlock.Casing_Resonance_4.getIcon(); - case 4: - return TexturesGtBlock.Casing_Modulator_1.getIcon(); - case 5: - return TexturesGtBlock.Casing_Modulator_2.getIcon(); - case 6: - return TexturesGtBlock.Casing_Modulator_3.getIcon(); - case 7: - return TexturesGtBlock.Casing_Modulator_4.getIcon(); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon( + final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + return getStaticIcon((byte) aSide, (byte) aWorld.getBlockMetadata(xCoord, yCoord, zCoord)); + } - } - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - } + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return getStaticIcon((byte) aSide, (byte) aMeta); + } + public static IIcon getStaticIcon(final byte aSide, final byte aMeta) { + switch (aMeta) { + case 0: + return TexturesGtBlock.Casing_Resonance_1.getIcon(); + case 1: + return TexturesGtBlock.Casing_Resonance_2.getIcon(); + case 2: + return TexturesGtBlock.Casing_Resonance_3.getIcon(); + case 3: + return TexturesGtBlock.Casing_Resonance_4.getIcon(); + case 4: + return TexturesGtBlock.Casing_Modulator_1.getIcon(); + case 5: + return TexturesGtBlock.Casing_Modulator_2.getIcon(); + case 6: + return TexturesGtBlock.Casing_Modulator_3.getIcon(); + case 7: + return TexturesGtBlock.Casing_Modulator_4.getIcon(); + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java index cbd585e50d..b511926137 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java @@ -1,110 +1,96 @@ package gtPlusPlus.xmod.gregtech.common.blocks; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -import java.util.List; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GT_Values; -import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; -import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Material_Casings; - import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; - +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; public class GregtechMetaTieredCasingBlocks1 extends GregtechMetaCasingBlocksAbstract { + public static class TieredCasingItemBlock extends GregtechMetaCasingItems { + + public TieredCasingItemBlock(Block par1) { + super(par1); + } - public static class TieredCasingItemBlock extends GregtechMetaCasingItems { + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 10) { + aList.add("Tier: " + GT_Values.VN[aMeta]); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } - public TieredCasingItemBlock(Block par1) { - super(par1); - } + public GregtechMetaTieredCasingBlocks1() { + super(TieredCasingItemBlock.class, "gtplusplus.blocktieredcasings.1", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + // TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); + // Don't register these Textures, Hatches should never need to use their Textures. + } + int aIndex = 0; + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Integral Encasement I"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Integral Encasement II"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Integral Encasement III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Integral Encasement IV"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Integral Encasement V"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Integral Framework I"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Integral Framework II"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Integral Framework III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Integral Framework IV"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Integral Framework V"); + // GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); + // GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); + // GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); + // GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); + // GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Placeholder Block"); - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - int aMeta = aStack.getItemDamage(); - if (aMeta < 10) { - aList.add("Tier: "+GT_Values.VN[aMeta]); - } - super.addInformation(aStack, aPlayer, aList, aF3_H); - } - } - - public GregtechMetaTieredCasingBlocks1() { - super(TieredCasingItemBlock.class, "gtplusplus.blocktieredcasings.1", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - //TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); - // Don't register these Textures, Hatches should never need to use their Textures. - } - int aIndex = 0; - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Integral Encasement I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Integral Encasement II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Integral Encasement III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Integral Encasement IV"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Integral Encasement V"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Integral Framework I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Integral Framework II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Integral Framework III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Integral Framework IV"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Integral Framework V"); - //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); - //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); - //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); - //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); - //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Placeholder Block"); - - GregtechItemList.GTPP_Casing_ULV.set(new ItemStack(this, 1, 0)); - GregtechItemList.GTPP_Casing_LV.set(new ItemStack(this, 1, 1)); - GregtechItemList.GTPP_Casing_MV.set(new ItemStack(this, 1, 2)); - GregtechItemList.GTPP_Casing_HV.set(new ItemStack(this, 1, 3)); - GregtechItemList.GTPP_Casing_EV.set(new ItemStack(this, 1, 4)); - GregtechItemList.GTPP_Casing_IV.set(new ItemStack(this, 1, 5)); - GregtechItemList.GTPP_Casing_LuV.set(new ItemStack(this, 1, 6)); - GregtechItemList.GTPP_Casing_ZPM.set(new ItemStack(this, 1, 7)); - GregtechItemList.GTPP_Casing_UV.set(new ItemStack(this, 1, 8)); - GregtechItemList.GTPP_Casing_MAX.set(new ItemStack(this, 1, 9)); - - //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 10)); - //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 11)); - //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 12)); - //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 13)); - //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 14)); - //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 15)); - } + GregtechItemList.GTPP_Casing_ULV.set(new ItemStack(this, 1, 0)); + GregtechItemList.GTPP_Casing_LV.set(new ItemStack(this, 1, 1)); + GregtechItemList.GTPP_Casing_MV.set(new ItemStack(this, 1, 2)); + GregtechItemList.GTPP_Casing_HV.set(new ItemStack(this, 1, 3)); + GregtechItemList.GTPP_Casing_EV.set(new ItemStack(this, 1, 4)); + GregtechItemList.GTPP_Casing_IV.set(new ItemStack(this, 1, 5)); + GregtechItemList.GTPP_Casing_LuV.set(new ItemStack(this, 1, 6)); + GregtechItemList.GTPP_Casing_ZPM.set(new ItemStack(this, 1, 7)); + GregtechItemList.GTPP_Casing_UV.set(new ItemStack(this, 1, 8)); + GregtechItemList.GTPP_Casing_MAX.set(new ItemStack(this, 1, 9)); - public IIcon getIcon(int aSide, int aMeta) { - if (aMeta < 10) { - return TexturesGtBlock.TIERED_MACHINE_HULLS[aMeta].getIcon(); - } - switch (aMeta) { - case 10: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 11: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 12: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 13: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 14: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 15: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - } - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - } + // GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 10)); + // GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 11)); + // GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 12)); + // GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 13)); + // GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 14)); + // GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 15)); + } + public IIcon getIcon(int aSide, int aMeta) { + if (aMeta < 10) { + return TexturesGtBlock.TIERED_MACHINE_HULLS[aMeta].getIcon(); + } + switch (aMeta) { + case 10: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 11: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 12: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 13: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 14: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 15: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java index 3e4b9a3fee..7ffa95c081 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java @@ -1,111 +1,183 @@ package gtPlusPlus.xmod.gregtech.common.blocks.fluid; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; public class GregtechFluidHandler { - protected static int cellID = 0; - - public static void run(){ - start(); - } - - private static void start(){ - - /* Meta_GT_Proxy.addFluid("lubricant", "Lubricant", Materials.Lubricant, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("creosote", "Creosote Oil", Materials.Creosote, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Creosote, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("seedoil", "Seed Oil", Materials.SeedOil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.SeedOil, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("fishoil", "Fish Oil", Materials.FishOil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.FishOil, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("oil", "Oil", Materials.Oil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Oil, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("fuel", "Diesel", Materials.Fuel, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Fuel, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("for.honey", "Honey", Materials.Honey, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Honey, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("biomass", "Biomass", Materials.Biomass, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Biomass, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("bioethanol", "Bio Ethanol", Materials.Ethanol, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Ethanol, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("sulfuricacid", "Sulfuric Acid", Materials.SulfuricAcid, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.SulfuricAcid, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("milk", "Milk", Materials.Milk, 1, 290, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Milk, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("mcguffium", "Mc Guffium 239", Materials.McGuffium239, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.McGuffium239, 1L), ItemUtils.getEmptyCell(), 1000); - Meta_GT_Proxy.addFluid("glue", "Glue", Materials.Glue, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Glue, 1L), ItemUtils.getEmptyCell(), 1000); - */ - - if (!LoadedMods.ThermalFoundation){ - - Logger.INFO("Adding in our own GT versions of Thermal Foundation Fluids if they do not already exist."); - if (!FluidRegistry.isFluidRegistered("cryotheum")) { - FluidUtils.addGtFluid("cryotheum", "Gelid Cryotheum", GT_Materials.Cryotheum, 4, -1200, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Cryotheum, 1L), ItemUtils.getEmptyCell(), 1000); - } - if (!FluidRegistry.isFluidRegistered("pyrotheum")) { - FluidUtils.addGtFluid("pyrotheum", "Blazing Pyrotheum", GT_Materials.Pyrotheum, 4, 4000, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Pyrotheum, 1L), ItemUtils.getEmptyCell(), 1000); - } - if (!FluidRegistry.isFluidRegistered("ender")) { - FluidUtils.addGtFluid("ender", "Resonant Ender", GT_Materials.Ender, 4, 4000, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Ender, 1L), ItemUtils.getEmptyCell(), 1000); - } - - } - - if (LoadedMods.IndustrialCraft2){ - Logger.INFO("Adding in GT Fluids for various nuclear related content."); - - FluidUtils.addGtFluid("hydrofluoricAcid", "Industrial Strength Hydrofluoric Acid", GT_Materials.HydrofluoricAcid, 1, 120, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrofluoricAcid, 1L), ItemUtils.getEmptyCell(), 1000, false); - generateIC2FluidCell("HydrofluoricAcid"); - - FluidUtils.generateFluidNoPrefix("SulfurDioxide", "High Quality Sulfur Dioxide", 263, GT_Materials.SulfurDioxide.mRGBa); - - FluidUtils.addGtFluid("sulfurousAcid", "Sulfurous Acid", GT_Materials.SulfurousAcid, 4, 75, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfurousAcid, 1L), ItemUtils.getEmptyCell(), 1000, false); - generateIC2FluidCell("SulfurousAcid"); - - FluidUtils.addGtFluid("sulfuricApatite", "Sulfuric Apatite Mix", GT_Materials.SulfuricApatite, 4, 500, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricApatite, 1L), ItemUtils.getEmptyCell(), 1000, false); - generateIC2FluidCell("SulfuricApatite"); - - - //Check for IHL Hydrogen Chloride - if (!LoadedMods.IHL || (ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 1) == null)){ - if (FluidUtils.getFluidStack("hydrogenchloride", 1) == null){ - if (LoadedMods.IHL){ - Logger.INFO("IHL Loaded but hydrogen chloride could not be found for some reason. How about we add our own."); - } - else { - Logger.INFO("No Suitable versions of Hydrogen Chloride available, adding our own."); - } - FluidUtils.addGtFluid("hydrogenChloride", "Industrial Strength Hydrogen Chloride", GT_Materials.HydrogenChloride, 4, 75, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrogenChloride, 1L), ItemUtils.getEmptyCell(), 1000, false); - generateIC2FluidCell("HydrogenChloride"); - } - } - - - FluidUtils.addGtFluid("sulfuricLithium", "Sulfuric Lithium Mix", GT_Materials.SulfuricLithium, 4, 280, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricLithium, 1L), ItemUtils.getEmptyCell(), 1000, false); - generateIC2FluidCell("SulfuricLithium"); - - FluidUtils.addGtFluid("lithiumHydroxide", "Lithium Hydroxide", GT_Materials.LithiumHydroxide, 4, 500, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.LithiumHydroxide, 1L), ItemUtils.getEmptyCell(), 1000, false); - generateIC2FluidCell("LithiumHydroxide"); - - - } - } - - private static ItemStack generateIC2FluidCell(final String fluidNameWithCaps){ - Logger.INFO("Adding a Cell for "+fluidNameWithCaps); - if (LoadedMods.IndustrialCraft2 && !LoadedMods.IndustrialCraft2Classic){ - return Utils.createInternalNameAndFluidCell(fluidNameWithCaps); - } - return null; - } - - private static ItemStack generateIC2FluidCellNoOreDict(final String fluidNameWithCaps){ - Logger.INFO("Adding a Cell for "+fluidNameWithCaps); - if (LoadedMods.IndustrialCraft2 && !LoadedMods.IndustrialCraft2Classic){ - return Utils.createInternalNameAndFluidCellNoOreDict(fluidNameWithCaps); - } - return null; - } - + protected static int cellID = 0; + + public static void run() { + start(); + } + + private static void start() { + + /* Meta_GT_Proxy.addFluid("lubricant", "Lubricant", Materials.Lubricant, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("creosote", "Creosote Oil", Materials.Creosote, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Creosote, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("seedoil", "Seed Oil", Materials.SeedOil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.SeedOil, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("fishoil", "Fish Oil", Materials.FishOil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.FishOil, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("oil", "Oil", Materials.Oil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Oil, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("fuel", "Diesel", Materials.Fuel, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Fuel, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("for.honey", "Honey", Materials.Honey, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Honey, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("biomass", "Biomass", Materials.Biomass, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Biomass, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("bioethanol", "Bio Ethanol", Materials.Ethanol, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Ethanol, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("sulfuricacid", "Sulfuric Acid", Materials.SulfuricAcid, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.SulfuricAcid, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("milk", "Milk", Materials.Milk, 1, 290, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Milk, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("mcguffium", "Mc Guffium 239", Materials.McGuffium239, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.McGuffium239, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("glue", "Glue", Materials.Glue, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Glue, 1L), ItemUtils.getEmptyCell(), 1000); + */ + + if (!LoadedMods.ThermalFoundation) { + + Logger.INFO("Adding in our own GT versions of Thermal Foundation Fluids if they do not already exist."); + if (!FluidRegistry.isFluidRegistered("cryotheum")) { + FluidUtils.addGtFluid( + "cryotheum", + "Gelid Cryotheum", + GT_Materials.Cryotheum, + 4, + -1200, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Cryotheum, 1L), + ItemUtils.getEmptyCell(), + 1000); + } + if (!FluidRegistry.isFluidRegistered("pyrotheum")) { + FluidUtils.addGtFluid( + "pyrotheum", + "Blazing Pyrotheum", + GT_Materials.Pyrotheum, + 4, + 4000, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Pyrotheum, 1L), + ItemUtils.getEmptyCell(), + 1000); + } + if (!FluidRegistry.isFluidRegistered("ender")) { + FluidUtils.addGtFluid( + "ender", + "Resonant Ender", + GT_Materials.Ender, + 4, + 4000, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Ender, 1L), + ItemUtils.getEmptyCell(), + 1000); + } + } + + if (LoadedMods.IndustrialCraft2) { + Logger.INFO("Adding in GT Fluids for various nuclear related content."); + + FluidUtils.addGtFluid( + "hydrofluoricAcid", + "Industrial Strength Hydrofluoric Acid", + GT_Materials.HydrofluoricAcid, + 1, + 120, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrofluoricAcid, 1L), + ItemUtils.getEmptyCell(), + 1000, + false); + generateIC2FluidCell("HydrofluoricAcid"); + + FluidUtils.generateFluidNoPrefix( + "SulfurDioxide", "High Quality Sulfur Dioxide", 263, GT_Materials.SulfurDioxide.mRGBa); + + FluidUtils.addGtFluid( + "sulfurousAcid", + "Sulfurous Acid", + GT_Materials.SulfurousAcid, + 4, + 75, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfurousAcid, 1L), + ItemUtils.getEmptyCell(), + 1000, + false); + generateIC2FluidCell("SulfurousAcid"); + + FluidUtils.addGtFluid( + "sulfuricApatite", + "Sulfuric Apatite Mix", + GT_Materials.SulfuricApatite, + 4, + 500, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricApatite, 1L), + ItemUtils.getEmptyCell(), + 1000, + false); + generateIC2FluidCell("SulfuricApatite"); + + // Check for IHL Hydrogen Chloride + if (!LoadedMods.IHL || (ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 1) == null)) { + if (FluidUtils.getFluidStack("hydrogenchloride", 1) == null) { + if (LoadedMods.IHL) { + Logger.INFO( + "IHL Loaded but hydrogen chloride could not be found for some reason. How about we add our own."); + } else { + Logger.INFO("No Suitable versions of Hydrogen Chloride available, adding our own."); + } + FluidUtils.addGtFluid( + "hydrogenChloride", + "Industrial Strength Hydrogen Chloride", + GT_Materials.HydrogenChloride, + 4, + 75, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrogenChloride, 1L), + ItemUtils.getEmptyCell(), + 1000, + false); + generateIC2FluidCell("HydrogenChloride"); + } + } + + FluidUtils.addGtFluid( + "sulfuricLithium", + "Sulfuric Lithium Mix", + GT_Materials.SulfuricLithium, + 4, + 280, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricLithium, 1L), + ItemUtils.getEmptyCell(), + 1000, + false); + generateIC2FluidCell("SulfuricLithium"); + + FluidUtils.addGtFluid( + "lithiumHydroxide", + "Lithium Hydroxide", + GT_Materials.LithiumHydroxide, + 4, + 500, + GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.LithiumHydroxide, 1L), + ItemUtils.getEmptyCell(), + 1000, + false); + generateIC2FluidCell("LithiumHydroxide"); + } + } + + private static ItemStack generateIC2FluidCell(final String fluidNameWithCaps) { + Logger.INFO("Adding a Cell for " + fluidNameWithCaps); + if (LoadedMods.IndustrialCraft2 && !LoadedMods.IndustrialCraft2Classic) { + return Utils.createInternalNameAndFluidCell(fluidNameWithCaps); + } + return null; + } + + private static ItemStack generateIC2FluidCellNoOreDict(final String fluidNameWithCaps) { + Logger.INFO("Adding a Cell for " + fluidNameWithCaps); + if (LoadedMods.IndustrialCraft2 && !LoadedMods.IndustrialCraft2Classic) { + return Utils.createInternalNameAndFluidCellNoOreDict(fluidNameWithCaps); + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java index 123df8fe0f..467602ce04 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java @@ -1,82 +1,84 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - import gregtech.api.enums.Textures; - import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; public class CasingTextureHandler { - //private static final TexturesGregtech59 gregtech59 = new TexturesGregtech59(); - //private static final TexturesGregtech58 gregtech58 = new TexturesGregtech58(); - private static final TexturesCentrifugeMultiblock gregtechX = new TexturesCentrifugeMultiblock(); - - public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - //Centrifuge - case 0: - return TexturesGtBlock.Casing_Material_Centrifuge.getIcon(); - //Coke Oven Frame - case 1: - return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); - //Coke Oven Casing Tier 1 - case 2: - return Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon(); - //Coke Oven Casing Tier 2 - case 3: - return Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon(); - //Material Press Casings - case 4: - return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - //Electrolyzer Casings - case 5: - return TexturesGtBlock.Casing_Material_Potin.getIcon(); - //Broken Blue Fusion Casings - case 6: - return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); - //Maceration Stack Casings - case 7: - return TexturesGtBlock.Casing_Material_Tumbaga.getIcon(); - //Broken Pink Fusion Casings - case 8: - return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); - //Matter Fabricator Casings - case 9: - return TexturesGtBlock.TEXTURE_METAL_PANEL_F.getIcon(); - //Iron Blast Fuance Textures - case 10: - return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); - //Multitank Exterior Casing - case 11: - return TexturesGtBlock.Casing_Material_Grisium.getIcon(); - //Reactor Casing I - case 12: - return TexturesGtBlock.Casing_Material_Stellite.getIcon(); - //Reactor Casing II - case 13: - return TexturesGtBlock.Casing_Material_Zeron100.getIcon(); - case 14: - return TexturesGtBlock.Casing_Staballoy_Firebox.getIcon(); - case 15: - return TexturesGtBlock.Casing_Material_ZirconiumCarbide.getIcon(); - - default: - return Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); + // private static final TexturesGregtech59 gregtech59 = new TexturesGregtech59(); + // private static final TexturesGregtech58 gregtech58 = new TexturesGregtech58(); + private static final TexturesCentrifugeMultiblock gregtechX = new TexturesCentrifugeMultiblock(); - } - } - return Textures.BlockIcons.MACHINE_CASING_GEARBOX_TUNGSTENSTEEL.getIcon(); - } + public static IIcon getIcon(final int aSide, final int aMeta) { // Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + // Centrifuge + case 0: + return TexturesGtBlock.Casing_Material_Centrifuge.getIcon(); + // Coke Oven Frame + case 1: + return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); + // Coke Oven Casing Tier 1 + case 2: + return Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon(); + // Coke Oven Casing Tier 2 + case 3: + return Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon(); + // Material Press Casings + case 4: + return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + // Electrolyzer Casings + case 5: + return TexturesGtBlock.Casing_Material_Potin.getIcon(); + // Broken Blue Fusion Casings + case 6: + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + // Maceration Stack Casings + case 7: + return TexturesGtBlock.Casing_Material_Tumbaga.getIcon(); + // Broken Pink Fusion Casings + case 8: + return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); + // Matter Fabricator Casings + case 9: + return TexturesGtBlock.TEXTURE_METAL_PANEL_F.getIcon(); + // Iron Blast Fuance Textures + case 10: + return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + // Multitank Exterior Casing + case 11: + return TexturesGtBlock.Casing_Material_Grisium.getIcon(); + // Reactor Casing I + case 12: + return TexturesGtBlock.Casing_Material_Stellite.getIcon(); + // Reactor Casing II + case 13: + return TexturesGtBlock.Casing_Material_Zeron100.getIcon(); + case 14: + return TexturesGtBlock.Casing_Staballoy_Firebox.getIcon(); + case 15: + return TexturesGtBlock.Casing_Material_ZirconiumCarbide.getIcon(); + default: + return Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); + } + } + return Textures.BlockIcons.MACHINE_CASING_GEARBOX_TUNGSTENSTEEL.getIcon(); + } - public static IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { - /*if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - return gregtech59.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); - } - return gregtech58.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock);*/ - return gregtechX.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); - } -} \ No newline at end of file + public static IIcon handleCasingsGT( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks thisBlock) { + /*if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + return gregtech59.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + return gregtech58.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock);*/ + return gregtechX.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java index c980997c64..20519c0bb1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -1,57 +1,53 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import net.minecraft.util.IIcon; - import gregtech.api.enums.Textures; +import net.minecraft.util.IIcon; public class CasingTextureHandler2 { - public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - case 0: - return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); - case 1: - return TexturesGtBlock.Casing_Material_HastelloyX.getIcon(); - case 2: - return TexturesGtBlock.Casing_Material_HastelloyN.getIcon(); - case 3: - return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon(); - case 4: - return TexturesGtBlock.Casing_Material_Grisium.getIcon(); - case 5: - return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon(); - case 6: - return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon(); - case 7: - return TexturesGtBlock.Casing_Redox_1.getIcon(); - case 8: - return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon(); - case 9: - return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon(); - case 10: - return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); - case 11: - return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); - case 12: - return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); - case 13: - if (aSide <2) { - return TexturesGtBlock.TEXTURE_TECH_A.getIcon(); - } - else { - return TexturesGtBlock.TEXTURE_TECH_B.getIcon(); - } - case 14: - return Textures.BlockIcons.RENDERING_ERROR.getIcon(); - case 15: - return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon(); - default: - return TexturesGtBlock.Overlay_UU_Matter.getIcon(); - - } - } - return TexturesGtBlock._PlaceHolder.getIcon(); - } - -} \ No newline at end of file + public static IIcon getIcon(final int aSide, final int aMeta) { // Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); + case 1: + return TexturesGtBlock.Casing_Material_HastelloyX.getIcon(); + case 2: + return TexturesGtBlock.Casing_Material_HastelloyN.getIcon(); + case 3: + return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon(); + case 4: + return TexturesGtBlock.Casing_Material_Grisium.getIcon(); + case 5: + return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon(); + case 6: + return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon(); + case 7: + return TexturesGtBlock.Casing_Redox_1.getIcon(); + case 8: + return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon(); + case 9: + return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon(); + case 10: + return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); + case 11: + return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); + case 12: + return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + case 13: + if (aSide < 2) { + return TexturesGtBlock.TEXTURE_TECH_A.getIcon(); + } else { + return TexturesGtBlock.TEXTURE_TECH_B.getIcon(); + } + case 14: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 15: + return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon(); + default: + return TexturesGtBlock.Overlay_UU_Matter.getIcon(); + } + } + return TexturesGtBlock._PlaceHolder.getIcon(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java index 019a432013..da2a09c7d2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java @@ -1,68 +1,66 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import net.minecraft.util.IIcon; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks3; +import net.minecraft.util.IIcon; public class CasingTextureHandler3 { - public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - case 0: - //Aquatic Casing - return TexturesGtBlock.TEXTURE_METAL_PANEL_B.getIcon(); - case 1: - //Inconel Reinforced Casing - return TexturesGtBlock.TEXTURE_METAL_PANEL_D.getIcon(); - case 2: - //Multi-Use Casing - return TexturesGtBlock.TEXTURE_METAL_PANEL_C.getIcon(); - case 3: - //Trinium Plated Mining Platform Casing - return TexturesGtBlock.Casing_Trinium_Naquadah_Vent.getIcon(); - case 4: - //Vanadium Redox IV - return TexturesGtBlock.Casing_Redox_2.getIcon(); - case 5: - //Vanadium Redox LuV - return TexturesGtBlock.Casing_Redox_3.getIcon(); - case 6: - //Vanadium Redox ZPM - return TexturesGtBlock.Casing_Redox_4.getIcon(); - case 7: - //Vanadium Redox UV - return TexturesGtBlock.Casing_Redox_5.getIcon(); - case 8: - //Vanadium Redox MAX - return TexturesGtBlock.Casing_Redox_6.getIcon(); - case 9: - //Amazon Warehouse Casing - return TexturesGtBlock.TEXTURE_CASING_AMAZON.getIcon(); - case 10: - //Adv. Vac. Freezer - return TexturesGtBlock.TEXTURE_CASING_ADVANCED_CRYOGENIC.getIcon(); - case 11: - //Adv. EBF - return TexturesGtBlock.TEXTURE_CASING_ADVANCED_VOLCNUS.getIcon(); - case 12: - return TexturesGtBlock.TEXTURE_CASING_FUSION_COIL_II.getIcon(); - case 13: - return TexturesGtBlock.TEXTURE_CASING_FUSION_COIL_II_INNER.getIcon(); - case 14: - return TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA.getIcon(); - case 15: - return TexturesGtBlock.TEXTURE_MAGIC_PANEL_A.getIcon(); - - default: - return TexturesGtBlock._PlaceHolder.getIcon(); - - } - } - return TexturesGtBlock._PlaceHolder.getIcon(); - } + public static IIcon getIcon(final int aSide, final int aMeta) { // Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + // Aquatic Casing + return TexturesGtBlock.TEXTURE_METAL_PANEL_B.getIcon(); + case 1: + // Inconel Reinforced Casing + return TexturesGtBlock.TEXTURE_METAL_PANEL_D.getIcon(); + case 2: + // Multi-Use Casing + return TexturesGtBlock.TEXTURE_METAL_PANEL_C.getIcon(); + case 3: + // Trinium Plated Mining Platform Casing + return TexturesGtBlock.Casing_Trinium_Naquadah_Vent.getIcon(); + case 4: + // Vanadium Redox IV + return TexturesGtBlock.Casing_Redox_2.getIcon(); + case 5: + // Vanadium Redox LuV + return TexturesGtBlock.Casing_Redox_3.getIcon(); + case 6: + // Vanadium Redox ZPM + return TexturesGtBlock.Casing_Redox_4.getIcon(); + case 7: + // Vanadium Redox UV + return TexturesGtBlock.Casing_Redox_5.getIcon(); + case 8: + // Vanadium Redox MAX + return TexturesGtBlock.Casing_Redox_6.getIcon(); + case 9: + // Amazon Warehouse Casing + return TexturesGtBlock.TEXTURE_CASING_AMAZON.getIcon(); + case 10: + // Adv. Vac. Freezer + return TexturesGtBlock.TEXTURE_CASING_ADVANCED_CRYOGENIC.getIcon(); + case 11: + // Adv. EBF + return TexturesGtBlock.TEXTURE_CASING_ADVANCED_VOLCNUS.getIcon(); + case 12: + return TexturesGtBlock.TEXTURE_CASING_FUSION_COIL_II.getIcon(); + case 13: + return TexturesGtBlock.TEXTURE_CASING_FUSION_COIL_II_INNER.getIcon(); + case 14: + return TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA.getIcon(); + case 15: + return TexturesGtBlock.TEXTURE_MAGIC_PANEL_A.getIcon(); - static { - GregtechMetaCasingBlocks3.mConnectedMachineTextures = true; - } + default: + return TexturesGtBlock._PlaceHolder.getIcon(); + } + } + return TexturesGtBlock._PlaceHolder.getIcon(); + } -} \ No newline at end of file + static { + GregtechMetaCasingBlocks3.mConnectedMachineTextures = true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java index 6326dd2c29..2eef9d37f0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java @@ -1,6 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; @@ -12,155 +11,166 @@ import net.minecraft.world.IBlockAccess; public class TexturesCentrifugeMultiblock { - private static CustomIcon GT8_1_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE1"); - private static CustomIcon GT8_1 = new CustomIcon("iconsets/LARGECENTRIFUGE1"); - private static CustomIcon GT8_2_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE2"); - private static CustomIcon GT8_2 = new CustomIcon("iconsets/LARGECENTRIFUGE2"); - private static CustomIcon GT8_3_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE3"); - private static CustomIcon GT8_3 = new CustomIcon("iconsets/LARGECENTRIFUGE3"); - private static CustomIcon GT8_4_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE4"); - private static CustomIcon GT8_4 = new CustomIcon("iconsets/LARGECENTRIFUGE4"); - private static CustomIcon GT8_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); - private static CustomIcon GT8_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); - private static CustomIcon GT8_6_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE6"); - private static CustomIcon GT8_6 = new CustomIcon("iconsets/LARGECENTRIFUGE6"); - private static CustomIcon GT8_7_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE7"); - private static CustomIcon GT8_7 = new CustomIcon("iconsets/LARGECENTRIFUGE7"); - private static CustomIcon GT8_8_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE8"); - private static CustomIcon GT8_8 = new CustomIcon("iconsets/LARGECENTRIFUGE8"); - private static CustomIcon GT8_9_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE9"); - private static CustomIcon GT8_9 = new CustomIcon("iconsets/LARGECENTRIFUGE9"); + private static CustomIcon GT8_1_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE1"); + private static CustomIcon GT8_1 = new CustomIcon("iconsets/LARGECENTRIFUGE1"); + private static CustomIcon GT8_2_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE2"); + private static CustomIcon GT8_2 = new CustomIcon("iconsets/LARGECENTRIFUGE2"); + private static CustomIcon GT8_3_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE3"); + private static CustomIcon GT8_3 = new CustomIcon("iconsets/LARGECENTRIFUGE3"); + private static CustomIcon GT8_4_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE4"); + private static CustomIcon GT8_4 = new CustomIcon("iconsets/LARGECENTRIFUGE4"); + private static CustomIcon GT8_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT8_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + private static CustomIcon GT8_6_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE6"); + private static CustomIcon GT8_6 = new CustomIcon("iconsets/LARGECENTRIFUGE6"); + private static CustomIcon GT8_7_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE7"); + private static CustomIcon GT8_7 = new CustomIcon("iconsets/LARGECENTRIFUGE7"); + private static CustomIcon GT8_8_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE8"); + private static CustomIcon GT8_8 = new CustomIcon("iconsets/LARGECENTRIFUGE8"); + private static CustomIcon GT8_9_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE9"); + private static CustomIcon GT8_9 = new CustomIcon("iconsets/LARGECENTRIFUGE9"); - private static CustomIcon frontFace_0 = (GT8_1); - private static CustomIcon frontFaceActive_0 = (GT8_1_Active); - private static CustomIcon frontFace_1 = (GT8_2); - private static CustomIcon frontFaceActive_1 = (GT8_2_Active); - private static CustomIcon frontFace_2 = (GT8_3); - private static CustomIcon frontFaceActive_2 = (GT8_3_Active); - private static CustomIcon frontFace_3 = (GT8_4); - private static CustomIcon frontFaceActive_3 = (GT8_4_Active); - private static CustomIcon frontFace_4 = (GT8_5); - private static CustomIcon frontFaceActive_4 = (GT8_5_Active); - private static CustomIcon frontFace_5 = (GT8_6); - private static CustomIcon frontFaceActive_5 = (GT8_6_Active); - private static CustomIcon frontFace_6 = (GT8_7); - private static CustomIcon frontFaceActive_6 = (GT8_7_Active); - private static CustomIcon frontFace_7 = (GT8_8); - private static CustomIcon frontFaceActive_7 = (GT8_8_Active); - private static CustomIcon frontFace_8 = (GT8_9); - private static CustomIcon frontFaceActive_8 = (GT8_9_Active); + private static CustomIcon frontFace_0 = (GT8_1); + private static CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static CustomIcon frontFace_1 = (GT8_2); + private static CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static CustomIcon frontFace_2 = (GT8_3); + private static CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static CustomIcon frontFace_3 = (GT8_4); + private static CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static CustomIcon frontFace_4 = (GT8_5); + private static CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static CustomIcon frontFace_5 = (GT8_6); + private static CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static CustomIcon frontFace_6 = (GT8_7); + private static CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static CustomIcon frontFace_7 = (GT8_8); + private static CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static CustomIcon frontFace_8 = (GT8_9); + private static CustomIcon frontFaceActive_8 = (GT8_9_Active); - CustomIcon[] CENTRIFUGE = new CustomIcon[]{ - frontFace_0, - frontFace_1, - frontFace_2, - frontFace_3, - frontFace_4, - frontFace_5, - frontFace_6, - frontFace_7, - frontFace_8 - }; + CustomIcon[] CENTRIFUGE = new CustomIcon[] { + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; - CustomIcon[] CENTRIFUGE_ACTIVE = new CustomIcon[]{ - frontFaceActive_0, - frontFaceActive_1, - frontFaceActive_2, - frontFaceActive_3, - frontFaceActive_4, - frontFaceActive_5, - frontFaceActive_6, - frontFaceActive_7, - frontFaceActive_8 - }; + CustomIcon[] CENTRIFUGE_ACTIVE = new CustomIcon[] { + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; - public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { - return this.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); - } + public IIcon handleCasingsGT( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks thisBlock) { + return this.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } - private static int isCentrifugeControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; - IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; - if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialCentrifuge && tTile.getFrontFacing() == aSide) - return tTile.isActive() ? 1 : 2; - return 0; - } + private static int isCentrifugeControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; + IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; + if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialCentrifuge + && tTile.getFrontFacing() == aSide) return tTile.isActive() ? 1 : 2; + return 0; + } - public IIcon handleCasingsGT58(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { - final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if (tMeta != 0) { - return CasingTextureHandler.getIcon(aSide, tMeta); - } - int tInvertLeftRightMod = aSide % 2 * 2 - 1; - switch (aSide / 2) { - case 0: - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) - continue; - if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide) != 0) { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord, zCoord + i)).getMetaTileEntity(); - return getIconByIndex(tMetaTileEntity, 4 - i * 3 - j); - } - } - } - break; - case 1: - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) - continue; - if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide) != 0) { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord + i, zCoord)).getMetaTileEntity(); - return getIconByIndex(tMetaTileEntity, 4 + i * 3 - j * tInvertLeftRightMod); - } - } - } - break; - case 2: - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) - continue; - if (isCentrifugeControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide) != 0) { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord, yCoord + i, zCoord + j)).getMetaTileEntity(); - return getIconByIndex(tMetaTileEntity, 4 + i * 3 + j * tInvertLeftRightMod); - } - } - } - break; - } - return TexturesGtBlock.Casing_Material_Centrifuge.getIcon(); - } - - public boolean isCentrifugeRunning(IMetaTileEntity aTile) { - if (aTile == null) { - return false; - } - else { - return aTile.getBaseMetaTileEntity().isActive(); - } - - - } - - public boolean isUsingAnimatedTexture(IMetaTileEntity aMetaTileEntity) { - if (aMetaTileEntity != null) { - if (aMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge) { - return ((GregtechMetaTileEntity_IndustrialCentrifuge) aMetaTileEntity).usingAnimations(); - } - } - return false; - } + public IIcon handleCasingsGT58( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks thisBlock) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (tMeta != 0) { + return CasingTextureHandler.getIcon(aSide, tMeta); + } + int tInvertLeftRightMod = aSide % 2 * 2 - 1; + switch (aSide / 2) { + case 0: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) + aWorld.getTileEntity(xCoord + j, yCoord, zCoord + i)) + .getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 - i * 3 - j); + } + } + } + break; + case 1: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) + aWorld.getTileEntity(xCoord + j, yCoord + i, zCoord)) + .getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 - j * tInvertLeftRightMod); + } + } + } + break; + case 2: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + if (isCentrifugeControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) + aWorld.getTileEntity(xCoord, yCoord + i, zCoord + j)) + .getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 + j * tInvertLeftRightMod); + } + } + } + break; + } + return TexturesGtBlock.Casing_Material_Centrifuge.getIcon(); + } - public IIcon getIconByIndex(IMetaTileEntity aMetaTileEntity, int aIndex) { - if (isUsingAnimatedTexture(aMetaTileEntity)) { - if (isCentrifugeRunning(aMetaTileEntity)) { - return this.CENTRIFUGE_ACTIVE[aIndex].getIcon(); - } - } - return this.CENTRIFUGE[aIndex].getIcon(); - } - + public boolean isCentrifugeRunning(IMetaTileEntity aTile) { + if (aTile == null) { + return false; + } else { + return aTile.getBaseMetaTileEntity().isActive(); + } + } + + public boolean isUsingAnimatedTexture(IMetaTileEntity aMetaTileEntity) { + if (aMetaTileEntity != null) { + if (aMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge) { + return ((GregtechMetaTileEntity_IndustrialCentrifuge) aMetaTileEntity).usingAnimations(); + } + } + return false; + } + + public IIcon getIconByIndex(IMetaTileEntity aMetaTileEntity, int aIndex) { + if (isUsingAnimatedTexture(aMetaTileEntity)) { + if (isCentrifugeRunning(aMetaTileEntity)) { + return this.CENTRIFUGE_ACTIVE[aIndex].getIcon(); + } + } + return this.CENTRIFUGE[aIndex].getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java index e772f0f48c..2298e0731e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java @@ -1,443 +1,536 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCentrifuge; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; public class TexturesGregtech58 { - private static Textures.BlockIcons.CustomIcon GT8_1_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE1"); - private static Textures.BlockIcons.CustomIcon GT8_1 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE1"); - private static Textures.BlockIcons.CustomIcon GT8_2_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE2"); - private static Textures.BlockIcons.CustomIcon GT8_2 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE2"); - private static Textures.BlockIcons.CustomIcon GT8_3_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE3"); - private static Textures.BlockIcons.CustomIcon GT8_3 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE3"); - private static Textures.BlockIcons.CustomIcon GT8_4_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE4"); - private static Textures.BlockIcons.CustomIcon GT8_4 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE4"); - private static Textures.BlockIcons.CustomIcon GT8_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE5"); - private static Textures.BlockIcons.CustomIcon GT8_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE5"); - private static Textures.BlockIcons.CustomIcon GT8_6_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE6"); - private static Textures.BlockIcons.CustomIcon GT8_6 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE6"); - private static Textures.BlockIcons.CustomIcon GT8_7_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE7"); - private static Textures.BlockIcons.CustomIcon GT8_7 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE7"); - private static Textures.BlockIcons.CustomIcon GT8_8_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE8"); - private static Textures.BlockIcons.CustomIcon GT8_8 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE8"); - private static Textures.BlockIcons.CustomIcon GT8_9_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE9"); - private static Textures.BlockIcons.CustomIcon GT8_9 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE9"); - - private static Textures.BlockIcons.CustomIcon frontFace_0 = (GT8_1); - private static Textures.BlockIcons.CustomIcon frontFaceActive_0 = (GT8_1_Active); - private static Textures.BlockIcons.CustomIcon frontFace_1 = (GT8_2); - private static Textures.BlockIcons.CustomIcon frontFaceActive_1 = (GT8_2_Active); - private static Textures.BlockIcons.CustomIcon frontFace_2 = (GT8_3); - private static Textures.BlockIcons.CustomIcon frontFaceActive_2 = (GT8_3_Active); - private static Textures.BlockIcons.CustomIcon frontFace_3 = (GT8_4); - private static Textures.BlockIcons.CustomIcon frontFaceActive_3 = (GT8_4_Active); - private static Textures.BlockIcons.CustomIcon frontFace_4 = (GT8_5); - private static Textures.BlockIcons.CustomIcon frontFaceActive_4 = (GT8_5_Active); - private static Textures.BlockIcons.CustomIcon frontFace_5 = (GT8_6); - private static Textures.BlockIcons.CustomIcon frontFaceActive_5 = (GT8_6_Active); - private static Textures.BlockIcons.CustomIcon frontFace_6 = (GT8_7); - private static Textures.BlockIcons.CustomIcon frontFaceActive_6 = (GT8_7_Active); - private static Textures.BlockIcons.CustomIcon frontFace_7 = (GT8_8); - private static Textures.BlockIcons.CustomIcon frontFaceActive_7 = (GT8_8_Active); - private static Textures.BlockIcons.CustomIcon frontFace_8 = (GT8_9); - private static Textures.BlockIcons.CustomIcon frontFaceActive_8 = (GT8_9_Active); - - Textures.BlockIcons.CustomIcon[] TURBINE = new Textures.BlockIcons.CustomIcon[]{ - frontFace_0, - frontFace_1, - frontFace_2, - frontFace_3, - frontFace_4, - frontFace_5, - frontFace_6, - frontFace_7, - frontFace_8 - }; - - Textures.BlockIcons.CustomIcon[] TURBINE_ACTIVE = new Textures.BlockIcons.CustomIcon[]{ - frontFaceActive_0, - frontFaceActive_1, - frontFaceActive_2, - frontFaceActive_3, - frontFaceActive_4, - frontFaceActive_5, - frontFaceActive_6, - frontFaceActive_7, - frontFaceActive_8 - }; + private static Textures.BlockIcons.CustomIcon GT8_1_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE1"); + private static Textures.BlockIcons.CustomIcon GT8_1 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE1"); + private static Textures.BlockIcons.CustomIcon GT8_2_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE2"); + private static Textures.BlockIcons.CustomIcon GT8_2 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE2"); + private static Textures.BlockIcons.CustomIcon GT8_3_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE3"); + private static Textures.BlockIcons.CustomIcon GT8_3 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE3"); + private static Textures.BlockIcons.CustomIcon GT8_4_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE4"); + private static Textures.BlockIcons.CustomIcon GT8_4 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE4"); + private static Textures.BlockIcons.CustomIcon GT8_5_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE5"); + private static Textures.BlockIcons.CustomIcon GT8_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE5"); + private static Textures.BlockIcons.CustomIcon GT8_6_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE6"); + private static Textures.BlockIcons.CustomIcon GT8_6 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE6"); + private static Textures.BlockIcons.CustomIcon GT8_7_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE7"); + private static Textures.BlockIcons.CustomIcon GT8_7 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE7"); + private static Textures.BlockIcons.CustomIcon GT8_8_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE8"); + private static Textures.BlockIcons.CustomIcon GT8_8 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE8"); + private static Textures.BlockIcons.CustomIcon GT8_9_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE9"); + private static Textures.BlockIcons.CustomIcon GT8_9 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE9"); + private static Textures.BlockIcons.CustomIcon frontFace_0 = (GT8_1); + private static Textures.BlockIcons.CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static Textures.BlockIcons.CustomIcon frontFace_1 = (GT8_2); + private static Textures.BlockIcons.CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static Textures.BlockIcons.CustomIcon frontFace_2 = (GT8_3); + private static Textures.BlockIcons.CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static Textures.BlockIcons.CustomIcon frontFace_3 = (GT8_4); + private static Textures.BlockIcons.CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static Textures.BlockIcons.CustomIcon frontFace_4 = (GT8_5); + private static Textures.BlockIcons.CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static Textures.BlockIcons.CustomIcon frontFace_5 = (GT8_6); + private static Textures.BlockIcons.CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static Textures.BlockIcons.CustomIcon frontFace_6 = (GT8_7); + private static Textures.BlockIcons.CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static Textures.BlockIcons.CustomIcon frontFace_7 = (GT8_8); + private static Textures.BlockIcons.CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static Textures.BlockIcons.CustomIcon frontFace_8 = (GT8_9); + private static Textures.BlockIcons.CustomIcon frontFaceActive_8 = (GT8_9_Active); - public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { - return this.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); - } + Textures.BlockIcons.CustomIcon[] TURBINE = new Textures.BlockIcons.CustomIcon[] { + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; + Textures.BlockIcons.CustomIcon[] TURBINE_ACTIVE = new Textures.BlockIcons.CustomIcon[] { + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; - public IIcon handleCasingsGT58(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { - final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if (((tMeta != 6) && (tMeta != 8) && (tMeta != 0))) { - return CasingTextureHandler.getIcon(aSide, tMeta); - } - final int tStartIndex = tMeta == 6 ? 1 : 13; - if (tMeta == 0) { - if ((aSide == 2) || (aSide == 3)) { - TileEntity tTileEntity; - IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[0].getIcon(); - } - return this.TURBINE[0].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[3].getIcon(); - } - return this.TURBINE[3].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[6].getIcon(); - } - return this.TURBINE[6].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[1].getIcon(); - } - return this.TURBINE[1].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[7].getIcon(); - } - return this.TURBINE[7].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[8].getIcon(); - } - return this.TURBINE[8].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[5].getIcon(); - } - return this.TURBINE[5].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[2].getIcon(); - } - return this.TURBINE[2].getIcon(); - } - } else if ((aSide == 4) || (aSide == 5)) { - TileEntity tTileEntity; - Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[0].getIcon(); - } - return this.TURBINE[0].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[3].getIcon(); - } - return this.TURBINE[3].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[6].getIcon(); - } - return this.TURBINE[6].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[1].getIcon(); - } - return this.TURBINE[1].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[7].getIcon(); - } - return this.TURBINE[7].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[8].getIcon(); - } - return this.TURBINE[8].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[5].getIcon(); - } - return this.TURBINE[5].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[2].getIcon(); - } - return this.TURBINE[2].getIcon(); - } - } - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - } - final boolean[] tConnectedSides = {(aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; - switch (aSide) { - case 0: - if (tConnectedSides[0]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 1: - if (tConnectedSides[1]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 2: - if (tConnectedSides[5]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 3: - if (tConnectedSides[3]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 4: - if (tConnectedSides[4]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - case 5: - if (tConnectedSides[2]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - break; - } - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } + public IIcon handleCasingsGT( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks thisBlock) { + return this.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + public IIcon handleCasingsGT58( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks thisBlock) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (((tMeta != 6) && (tMeta != 8) && (tMeta != 0))) { + return CasingTextureHandler.getIcon(aSide, tMeta); + } + final int tStartIndex = tMeta == 6 ? 1 : 13; + if (tMeta == 0) { + if ((aSide == 2) || (aSide == 3)) { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } else if ((aSide == 4) || (aSide == 5)) { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + final boolean[] tConnectedSides = { + (aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), + (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), + (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), + (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), + (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), + (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta) + }; + switch (aSide) { + case 0: + if (tConnectedSides[0]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 1: + if (tConnectedSides[1]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 2: + if (tConnectedSides[5]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 3: + if (tConnectedSides[3]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 4: + if (tConnectedSides[4]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + case 5: + if (tConnectedSides[2]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + break; + } + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java index ac721d81c3..990db20285 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java @@ -1,444 +1,545 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCentrifuge; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; public class TexturesGregtech59 { - private static Textures.BlockIcons.CustomIcon GT8_1_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE1"); - private static Textures.BlockIcons.CustomIcon GT8_1 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST1"); - private static Textures.BlockIcons.CustomIcon GT8_2_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE2"); - private static Textures.BlockIcons.CustomIcon GT8_2 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST2"); - private static Textures.BlockIcons.CustomIcon GT8_3_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE3"); - private static Textures.BlockIcons.CustomIcon GT8_3 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST3"); - private static Textures.BlockIcons.CustomIcon GT8_4_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE4"); - private static Textures.BlockIcons.CustomIcon GT8_4 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST4"); - private static Textures.BlockIcons.CustomIcon GT8_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE5"); - private static Textures.BlockIcons.CustomIcon GT8_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST5"); - private static Textures.BlockIcons.CustomIcon GT8_6_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE6"); - private static Textures.BlockIcons.CustomIcon GT8_6 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST6"); - private static Textures.BlockIcons.CustomIcon GT8_7_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE7"); - private static Textures.BlockIcons.CustomIcon GT8_7 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST7"); - private static Textures.BlockIcons.CustomIcon GT8_8_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE8"); - private static Textures.BlockIcons.CustomIcon GT8_8 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST8"); - private static Textures.BlockIcons.CustomIcon GT8_9_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE9"); - private static Textures.BlockIcons.CustomIcon GT8_9 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST9"); - - private static Textures.BlockIcons.CustomIcon frontFace_0 = (GT8_1); - private static Textures.BlockIcons.CustomIcon frontFaceActive_0 = (GT8_1_Active); - private static Textures.BlockIcons.CustomIcon frontFace_1 = (GT8_2); - private static Textures.BlockIcons.CustomIcon frontFaceActive_1 = (GT8_2_Active); - private static Textures.BlockIcons.CustomIcon frontFace_2 = (GT8_3); - private static Textures.BlockIcons.CustomIcon frontFaceActive_2 = (GT8_3_Active); - private static Textures.BlockIcons.CustomIcon frontFace_3 = (GT8_4); - private static Textures.BlockIcons.CustomIcon frontFaceActive_3 = (GT8_4_Active); - private static Textures.BlockIcons.CustomIcon frontFace_4 = (GT8_5); - private static Textures.BlockIcons.CustomIcon frontFaceActive_4 = (GT8_5_Active); - private static Textures.BlockIcons.CustomIcon frontFace_5 = (GT8_6); - private static Textures.BlockIcons.CustomIcon frontFaceActive_5 = (GT8_6_Active); - private static Textures.BlockIcons.CustomIcon frontFace_6 = (GT8_7); - private static Textures.BlockIcons.CustomIcon frontFaceActive_6 = (GT8_7_Active); - private static Textures.BlockIcons.CustomIcon frontFace_7 = (GT8_8); - private static Textures.BlockIcons.CustomIcon frontFaceActive_7 = (GT8_8_Active); - private static Textures.BlockIcons.CustomIcon frontFace_8 = (GT8_9); - private static Textures.BlockIcons.CustomIcon frontFaceActive_8 = (GT8_9_Active); - - Textures.BlockIcons.CustomIcon[] TURBINE = new Textures.BlockIcons.CustomIcon[]{ - frontFace_0, - frontFace_1, - frontFace_2, - frontFace_3, - frontFace_4, - frontFace_5, - frontFace_6, - frontFace_7, - frontFace_8 - }; - - Textures.BlockIcons.CustomIcon[] TURBINE_ACTIVE = new Textures.BlockIcons.CustomIcon[]{ - frontFaceActive_0, - frontFaceActive_1, - frontFaceActive_2, - frontFaceActive_3, - frontFaceActive_4, - frontFaceActive_5, - frontFaceActive_6, - frontFaceActive_7, - frontFaceActive_8 - }; - + private static Textures.BlockIcons.CustomIcon GT8_1_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE1"); + private static Textures.BlockIcons.CustomIcon GT8_1 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST1"); + private static Textures.BlockIcons.CustomIcon GT8_2_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE2"); + private static Textures.BlockIcons.CustomIcon GT8_2 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST2"); + private static Textures.BlockIcons.CustomIcon GT8_3_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE3"); + private static Textures.BlockIcons.CustomIcon GT8_3 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST3"); + private static Textures.BlockIcons.CustomIcon GT8_4_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE4"); + private static Textures.BlockIcons.CustomIcon GT8_4 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST4"); + private static Textures.BlockIcons.CustomIcon GT8_5_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE5"); + private static Textures.BlockIcons.CustomIcon GT8_5 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST5"); + private static Textures.BlockIcons.CustomIcon GT8_6_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE6"); + private static Textures.BlockIcons.CustomIcon GT8_6 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST6"); + private static Textures.BlockIcons.CustomIcon GT8_7_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE7"); + private static Textures.BlockIcons.CustomIcon GT8_7 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST7"); + private static Textures.BlockIcons.CustomIcon GT8_8_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE8"); + private static Textures.BlockIcons.CustomIcon GT8_8 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST8"); + private static Textures.BlockIcons.CustomIcon GT8_9_Active = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE9"); + private static Textures.BlockIcons.CustomIcon GT8_9 = + new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST9"); - public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { - return this.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); - } + private static Textures.BlockIcons.CustomIcon frontFace_0 = (GT8_1); + private static Textures.BlockIcons.CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static Textures.BlockIcons.CustomIcon frontFace_1 = (GT8_2); + private static Textures.BlockIcons.CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static Textures.BlockIcons.CustomIcon frontFace_2 = (GT8_3); + private static Textures.BlockIcons.CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static Textures.BlockIcons.CustomIcon frontFace_3 = (GT8_4); + private static Textures.BlockIcons.CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static Textures.BlockIcons.CustomIcon frontFace_4 = (GT8_5); + private static Textures.BlockIcons.CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static Textures.BlockIcons.CustomIcon frontFace_5 = (GT8_6); + private static Textures.BlockIcons.CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static Textures.BlockIcons.CustomIcon frontFace_6 = (GT8_7); + private static Textures.BlockIcons.CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static Textures.BlockIcons.CustomIcon frontFace_7 = (GT8_8); + private static Textures.BlockIcons.CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static Textures.BlockIcons.CustomIcon frontFace_8 = (GT8_9); + private static Textures.BlockIcons.CustomIcon frontFaceActive_8 = (GT8_9_Active); + Textures.BlockIcons.CustomIcon[] TURBINE = new Textures.BlockIcons.CustomIcon[] { + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; - public IIcon handleCasingsGT59(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { - final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if (((tMeta != 6) && (tMeta != 8) && (tMeta != 0))) { - return CasingTextureHandler.getIcon(aSide, tMeta); - } - final int tStartIndex = tMeta == 6 ? 1 : 13; - if (tMeta == 0) { - if ((aSide == 2) || (aSide == 3)) { - TileEntity tTileEntity; - IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[0].getIcon(); - } - return this.TURBINE[0].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[3].getIcon(); - } - return this.TURBINE[3].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[6].getIcon(); - } - return this.TURBINE[6].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[1].getIcon(); - } - return this.TURBINE[1].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[7].getIcon(); - } - return this.TURBINE[7].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[8].getIcon(); - } - return this.TURBINE[8].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[5].getIcon(); - } - return this.TURBINE[5].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[2].getIcon(); - } - return this.TURBINE[2].getIcon(); - } - } else if ((aSide == 4) || (aSide == 5)) { - TileEntity tTileEntity; - Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[0].getIcon(); - } - return this.TURBINE[0].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[3].getIcon(); - } - return this.TURBINE[3].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[6].getIcon(); - } - return this.TURBINE[6].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[1].getIcon(); - } - return this.TURBINE[1].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[7].getIcon(); - } - return this.TURBINE[7].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[8].getIcon(); - } - return this.TURBINE[8].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[5].getIcon(); - } - return this.TURBINE[5].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return this.TURBINE_ACTIVE[2].getIcon(); - } - return this.TURBINE[2].getIcon(); - } - } - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - } - final boolean[] tConnectedSides = {(aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; - switch (aSide) { - case 0: - if (tConnectedSides[0]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 1: - if (tConnectedSides[1]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 2: - if (tConnectedSides[5]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 3: - if (tConnectedSides[3]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 4: - if (tConnectedSides[4]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - case 5: - if (tConnectedSides[2]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - break; - } - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } + Textures.BlockIcons.CustomIcon[] TURBINE_ACTIVE = new Textures.BlockIcons.CustomIcon[] { + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; + public IIcon handleCasingsGT( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks thisBlock) { + return this.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + public IIcon handleCasingsGT59( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks thisBlock) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (((tMeta != 6) && (tMeta != 8) && (tMeta != 0))) { + return CasingTextureHandler.getIcon(aSide, tMeta); + } + final int tStartIndex = tMeta == 6 ? 1 : 13; + if (tMeta == 0) { + if ((aSide == 2) || (aSide == 3)) { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } else if ((aSide == 4) || (aSide == 5)) { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + final boolean[] tConnectedSides = { + (aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), + (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), + (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), + (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), + (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock) + && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), + (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock) + && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta) + }; + switch (aSide) { + case 0: + if (tConnectedSides[0]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 1: + if (tConnectedSides[1]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 2: + if (tConnectedSides[5]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 3: + if (tConnectedSides[3]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 4: + if (tConnectedSides[4]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + case 5: + if (tConnectedSides[2]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + break; + } + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java index b254fdbc1e..e2d304572a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java @@ -1,6 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks5; @@ -12,139 +11,146 @@ import net.minecraft.world.IBlockAccess; public class TexturesGrinderMultiblock { - private static CustomIcon GT8_1_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE1"); - private static CustomIcon GT8_1 = new CustomIcon("iconsets/Grinder/GRINDER1"); - private static CustomIcon GT8_2_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE2"); - private static CustomIcon GT8_2 = new CustomIcon("iconsets/Grinder/GRINDER2"); - private static CustomIcon GT8_3_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE3"); - private static CustomIcon GT8_3 = new CustomIcon("iconsets/Grinder/GRINDER3"); - private static CustomIcon GT8_4_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE4"); - private static CustomIcon GT8_4 = new CustomIcon("iconsets/Grinder/GRINDER4"); - private static CustomIcon GT8_5_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5"); - private static CustomIcon GT8_5 = new CustomIcon("iconsets/Grinder/GRINDER5"); - private static CustomIcon GT8_6_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE6"); - private static CustomIcon GT8_6 = new CustomIcon("iconsets/Grinder/GRINDER6"); - private static CustomIcon GT8_7_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE7"); - private static CustomIcon GT8_7 = new CustomIcon("iconsets/Grinder/GRINDER7"); - private static CustomIcon GT8_8_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE8"); - private static CustomIcon GT8_8 = new CustomIcon("iconsets/Grinder/GRINDER8"); - private static CustomIcon GT8_9_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE9"); - private static CustomIcon GT8_9 = new CustomIcon("iconsets/Grinder/GRINDER9"); + private static CustomIcon GT8_1_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE1"); + private static CustomIcon GT8_1 = new CustomIcon("iconsets/Grinder/GRINDER1"); + private static CustomIcon GT8_2_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE2"); + private static CustomIcon GT8_2 = new CustomIcon("iconsets/Grinder/GRINDER2"); + private static CustomIcon GT8_3_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE3"); + private static CustomIcon GT8_3 = new CustomIcon("iconsets/Grinder/GRINDER3"); + private static CustomIcon GT8_4_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE4"); + private static CustomIcon GT8_4 = new CustomIcon("iconsets/Grinder/GRINDER4"); + private static CustomIcon GT8_5_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5"); + private static CustomIcon GT8_5 = new CustomIcon("iconsets/Grinder/GRINDER5"); + private static CustomIcon GT8_6_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE6"); + private static CustomIcon GT8_6 = new CustomIcon("iconsets/Grinder/GRINDER6"); + private static CustomIcon GT8_7_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE7"); + private static CustomIcon GT8_7 = new CustomIcon("iconsets/Grinder/GRINDER7"); + private static CustomIcon GT8_8_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE8"); + private static CustomIcon GT8_8 = new CustomIcon("iconsets/Grinder/GRINDER8"); + private static CustomIcon GT8_9_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE9"); + private static CustomIcon GT8_9 = new CustomIcon("iconsets/Grinder/GRINDER9"); - private static CustomIcon frontFace_0 = (GT8_1); - private static CustomIcon frontFaceActive_0 = (GT8_1_Active); - private static CustomIcon frontFace_1 = (GT8_2); - private static CustomIcon frontFaceActive_1 = (GT8_2_Active); - private static CustomIcon frontFace_2 = (GT8_3); - private static CustomIcon frontFaceActive_2 = (GT8_3_Active); - private static CustomIcon frontFace_3 = (GT8_4); - private static CustomIcon frontFaceActive_3 = (GT8_4_Active); - private static CustomIcon frontFace_4 = (GT8_5); - private static CustomIcon frontFaceActive_4 = (GT8_5_Active); - private static CustomIcon frontFace_5 = (GT8_6); - private static CustomIcon frontFaceActive_5 = (GT8_6_Active); - private static CustomIcon frontFace_6 = (GT8_7); - private static CustomIcon frontFaceActive_6 = (GT8_7_Active); - private static CustomIcon frontFace_7 = (GT8_8); - private static CustomIcon frontFaceActive_7 = (GT8_8_Active); - private static CustomIcon frontFace_8 = (GT8_9); - private static CustomIcon frontFaceActive_8 = (GT8_9_Active); + private static CustomIcon frontFace_0 = (GT8_1); + private static CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static CustomIcon frontFace_1 = (GT8_2); + private static CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static CustomIcon frontFace_2 = (GT8_3); + private static CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static CustomIcon frontFace_3 = (GT8_4); + private static CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static CustomIcon frontFace_4 = (GT8_5); + private static CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static CustomIcon frontFace_5 = (GT8_6); + private static CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static CustomIcon frontFace_6 = (GT8_7); + private static CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static CustomIcon frontFace_7 = (GT8_8); + private static CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static CustomIcon frontFace_8 = (GT8_9); + private static CustomIcon frontFaceActive_8 = (GT8_9_Active); - CustomIcon[] GRINDER = new CustomIcon[]{ - frontFace_0, - frontFace_1, - frontFace_2, - frontFace_3, - frontFace_4, - frontFace_5, - frontFace_6, - frontFace_7, - frontFace_8 - }; + CustomIcon[] GRINDER = new CustomIcon[] { + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; - CustomIcon[] GRINDER_ACTIVE = new CustomIcon[]{ - frontFaceActive_0, - frontFaceActive_1, - frontFaceActive_2, - frontFaceActive_3, - frontFaceActive_4, - frontFaceActive_5, - frontFaceActive_6, - frontFaceActive_7, - frontFaceActive_8 - }; + CustomIcon[] GRINDER_ACTIVE = new CustomIcon[] { + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; - private static int isIsaControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; - IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; - if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IsaMill && tTile.getFrontFacing() == aSide) - return tTile.isActive() ? 1 : 2; - return 0; - } + private static int isIsaControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; + IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; + if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IsaMill && tTile.getFrontFacing() == aSide) + return tTile.isActive() ? 1 : 2; + return 0; + } - public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks5 ii) { - final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if (tMeta != 1) { - return GregtechMetaCasingBlocks5.getStaticIcon(aSide, tMeta); - } - int tInvertLeftRightMod = aSide % 2 * 2 - 1; - switch (aSide / 2) { - case 0: - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) - continue; - if (isIsaControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide) != 0) { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord, zCoord + i)).getMetaTileEntity(); - return getIconByIndex(tMetaTileEntity, 4 - i * 3 - j); - } - } - } - break; - case 1: - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) - continue; - if (isIsaControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide) != 0) { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord + i, zCoord)).getMetaTileEntity(); - return getIconByIndex(tMetaTileEntity, 4 + i * 3 - j * tInvertLeftRightMod); - } - } - } - break; - case 2: - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) - continue; - if (isIsaControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide) != 0) { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord, yCoord + i, zCoord + j)).getMetaTileEntity(); - return getIconByIndex(tMetaTileEntity, 4 + i * 3 + j * tInvertLeftRightMod); - } - } - } - break; - } - return TexturesGtBlock.TEXTURE_CASING_GRINDING_MILL.getIcon(); - } - - public boolean isCentrifugeRunning(IMetaTileEntity aTile) { - if (aTile == null) { - return false; - } - else { - return aTile.getBaseMetaTileEntity().isActive(); - } - } + public IIcon handleCasingsGT( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaCasingBlocks5 ii) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (tMeta != 1) { + return GregtechMetaCasingBlocks5.getStaticIcon(aSide, tMeta); + } + int tInvertLeftRightMod = aSide % 2 * 2 - 1; + switch (aSide / 2) { + case 0: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + if (isIsaControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) + aWorld.getTileEntity(xCoord + j, yCoord, zCoord + i)) + .getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 - i * 3 - j); + } + } + } + break; + case 1: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + if (isIsaControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) + aWorld.getTileEntity(xCoord + j, yCoord + i, zCoord)) + .getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 - j * tInvertLeftRightMod); + } + } + } + break; + case 2: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + if (isIsaControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) + aWorld.getTileEntity(xCoord, yCoord + i, zCoord + j)) + .getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 + j * tInvertLeftRightMod); + } + } + } + break; + } + return TexturesGtBlock.TEXTURE_CASING_GRINDING_MILL.getIcon(); + } - public IIcon getIconByIndex(IMetaTileEntity aMetaTileEntity, int aIndex) { - if (isCentrifugeRunning(aMetaTileEntity)) { - return this.GRINDER_ACTIVE[aIndex].getIcon(); - } - - return this.GRINDER[aIndex].getIcon(); - } - + public boolean isCentrifugeRunning(IMetaTileEntity aTile) { + if (aTile == null) { + return false; + } else { + return aTile.getBaseMetaTileEntity().isActive(); + } + } + + public IIcon getIconByIndex(IMetaTileEntity aMetaTileEntity, int aIndex) { + if (isCentrifugeRunning(aMetaTileEntity)) { + return this.GRINDER_ACTIVE[aIndex].getIcon(); + } + + return this.GRINDER[aIndex].getIcon(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 27c33e53b6..a0e7fd0875 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -1,773 +1,831 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - import gregtech.api.GregTech_API; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; public class TexturesGtBlock { - private static AutoMap mCustomiconMap = new AutoMap(); - - static { - - } - - //public static ITexture[] CASING_BLOCKS_GTPP = new ITexture[256]; - - /* - * Handles Custom Textures. - */ - - public static class CustomIcon implements IIconContainer, Runnable { - protected IIcon mIcon; - protected String mIconName; - protected String mModID; - - public CustomIcon(final String aIconName) { - this(CORE.MODID, aIconName); - } - - public CustomIcon(final String aModID, final String aIconName) { - this.mIconName = aIconName; - this.mModID = aModID; - mCustomiconMap.put(this); - Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); - GregTech_API.sGTBlockIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return null; - } - - @Override - public void run() { - this.mIcon = GregTech_API.sBlockIcons.registerIcon(this.mModID + ":" + this.mIconName); - Logger.WARNING("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationBlocksTexture; - } - } - - - public static class VanillaIcon implements IIconContainer, Runnable { - protected IIcon mIcon; - protected String mIconName; - - public VanillaIcon(final String aIconName) { - this.mIconName = aIconName; - mCustomiconMap.put(this); - Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); - GregTech_API.sGTBlockIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return null; - } - - @Override - public void run() { - this.mIcon = GregTech_API.sBlockIcons.registerIcon("minecraft" + ":" + this.mIconName); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationBlocksTexture; - } - } - - public static GT_RenderedTexture getTextureFromIcon(CustomIcon aIcon, short[] aRGB) { - return new GT_RenderedTexture(aIcon, aRGB); - } - - /* - * Add Some Custom Textures below. - * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. - * Right? - */ - - //Vanilla Textures - public static final VanillaIcon VanillaIcon_OakPlanks = new VanillaIcon("planks_oak"); - - - - //PlaceHolder Texture - private static final CustomIcon Internal_PlaceHolder = new CustomIcon("TileEntities/_PlaceHolder"); - public static final CustomIcon _PlaceHolder = Internal_PlaceHolder; - - //Energy overlays - public static final CustomIcon OVERLAY_ENERGY_OUT_BUFFER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_BUFFER"); - public static final CustomIcon OVERLAY_ENERGY_OUT_MULTI_BUFFER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_MULTI_BUFFER"); - - //Wooden Shelf and Compartment Overlays - public static final CustomIcon OVERLAY_WOODEN_SHELF_FRONT = new CustomIcon("TileEntities/Compartment/wood_shelf"); - public static final CustomIcon OVERLAY_WOODEN_SHELF_CANS_FRONT = new CustomIcon("TileEntities/Compartment/wood_shelf_cans"); - public static final CustomIcon OVERLAY_WOODEN_SHELF_PAPER_FRONT = new CustomIcon("TileEntities/Compartment/wood_shelf_paper"); - public static final CustomIcon OVERLAY_CABINET_1 = new CustomIcon("TileEntities/Compartment/0"); - public static final CustomIcon OVERLAY_CABINET_2 = new CustomIcon("TileEntities/Compartment/1"); - public static final CustomIcon OVERLAY_CABINET_3 = new CustomIcon("TileEntities/Compartment/2"); - public static final CustomIcon OVERLAY_CABINET_4 = new CustomIcon("TileEntities/Compartment/3"); - public static final CustomIcon OVERLAY_CABINET_5 = new CustomIcon("TileEntities/Compartment/4"); - public static final CustomIcon OVERLAY_CABINET_6 = new CustomIcon("TileEntities/Compartment/5"); - public static final CustomIcon OVERLAY_CABINET_7 = new CustomIcon("TileEntities/Compartment/6"); - public static final CustomIcon OVERLAY_CABINET_8 = new CustomIcon("TileEntities/Compartment/7"); - public static final CustomIcon OVERLAY_CABINET_9 = new CustomIcon("TileEntities/Compartment/8"); - public static final CustomIcon OVERLAY_CABINET_10 = new CustomIcon("TileEntities/Compartment/9"); - public static final CustomIcon OVERLAY_CABINET_11 = new CustomIcon("TileEntities/Compartment/10"); - public static final CustomIcon OVERLAY_CABINET_12 = new CustomIcon("TileEntities/Compartment/11"); - public static final CustomIcon OVERLAY_CABINET_13 = new CustomIcon("TileEntities/Compartment/12"); - public static final CustomIcon OVERLAY_CABINET_14 = new CustomIcon("TileEntities/Compartment/13"); - public static final CustomIcon OVERLAY_CABINET_15 = new CustomIcon("TileEntities/Compartment/14"); - public static final CustomIcon OVERLAY_CABINET_16 = new CustomIcon("TileEntities/Compartment/15"); - public static final CustomIcon OVERLAY_COMPARTMENT_1 = new CustomIcon("TileEntities/Compartment/16"); - public static final CustomIcon OVERLAY_COMPARTMENT_2 = new CustomIcon("TileEntities/Compartment/17"); - public static final CustomIcon OVERLAY_COMPARTMENT_3 = new CustomIcon("TileEntities/Compartment/18"); - public static final CustomIcon OVERLAY_COMPARTMENT_4 = new CustomIcon("TileEntities/Compartment/19"); - public static final CustomIcon OVERLAY_COMPARTMENT_5 = new CustomIcon("TileEntities/Compartment/20"); - public static final CustomIcon OVERLAY_COMPARTMENT_6 = new CustomIcon("TileEntities/Compartment/21"); - public static final CustomIcon OVERLAY_COMPARTMENT_7 = new CustomIcon("TileEntities/Compartment/22"); - public static final CustomIcon OVERLAY_COMPARTMENT_8 = new CustomIcon("TileEntities/Compartment/23"); - public static final CustomIcon OVERLAY_COMPARTMENT_9 = new CustomIcon("TileEntities/Compartment/24"); - public static final CustomIcon OVERLAY_COMPARTMENT_10 = new CustomIcon("TileEntities/Compartment/25"); - public static final CustomIcon OVERLAY_COMPARTMENT_11 = new CustomIcon("TileEntities/Compartment/26"); - public static final CustomIcon OVERLAY_COMPARTMENT_12 = new CustomIcon("TileEntities/Compartment/27"); - public static final CustomIcon OVERLAY_COMPARTMENT_13 = new CustomIcon("TileEntities/Compartment/28"); - public static final CustomIcon OVERLAY_COMPARTMENT_14 = new CustomIcon("TileEntities/Compartment/29"); - public static final CustomIcon OVERLAY_COMPARTMENT_15 = new CustomIcon("TileEntities/Compartment/30"); - public static final CustomIcon OVERLAY_COMPARTMENT_16 = new CustomIcon("TileEntities/Compartment/31"); - - //Controllers - private static final CustomIcon Internal_Casing_Fusion_Simple_Front = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT"); - public static final CustomIcon Casing_Fusion_Simple_Front = Internal_Casing_Fusion_Simple_Front; - private static final CustomIcon Internal_Casing_Fusion_Simple_Front_Active = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE"); - public static final CustomIcon Casing_Fusion_Simple_Front_Active = Internal_Casing_Fusion_Simple_Front_Active; - - //Machine Casings - //Simple - private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); - public static final CustomIcon Casing_Machine_Simple_Top = Internal_Casing_Machine_Simple_Top; - private static final CustomIcon Internal_Casing_Machine_Simple_Bottom = new CustomIcon("TileEntities/machine_bottom"); - public static final CustomIcon Casing_Machine_Simple_Bottom = Internal_Casing_Machine_Simple_Bottom; - //Advanced and Ultra - private static final CustomIcon Internal_Casing_Machine_Advanced = new CustomIcon("TileEntities/high_adv_machine"); - public static final CustomIcon Casing_Machine_Advanced = Internal_Casing_Machine_Advanced; - private static final CustomIcon Internal_Casing_Machine_Ultra = new CustomIcon("TileEntities/adv_machine_lesu"); - public static final CustomIcon Casing_Machine_Ultra = Internal_Casing_Machine_Ultra; - //Dimensional - Non Overlay - private static final CustomIcon Internal_Casing_Machine_Dimensional = new CustomIcon("TileEntities/adv_machine_dimensional"); - public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; - private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); - public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; - - //Material Casings - private static final CustomIcon Internal_Casing_Tantalloy61 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); - public static final CustomIcon Casing_Material_Tantalloy61 = Internal_Casing_Tantalloy61; - private static final CustomIcon Internal_Casing_MaragingSteel = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_MARAGINGSTEEL"); - public static final CustomIcon Casing_Material_MaragingSteel = Internal_Casing_MaragingSteel; - private static final CustomIcon Internal_Casing_Stellite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_STELLITE"); - public static final CustomIcon Casing_Material_Stellite = Internal_Casing_Stellite; - private static final CustomIcon Internal_Casing_Talonite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TALONITE"); - public static final CustomIcon Casing_Material_Talonite = Internal_Casing_Talonite; - private static final CustomIcon Internal_Casing_Tumbaga = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TUMBAGA"); - public static final CustomIcon Casing_Material_Tumbaga = Internal_Casing_Tumbaga; - private static final CustomIcon Internal_Casing_Zeron100 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZERON100"); - public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; - private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); - public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; - - private static final CustomIcon Internal_Casing_Grisium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_GRISIUM"); - public static final CustomIcon Casing_Material_Grisium = Internal_Casing_Grisium; - private static final CustomIcon Internal_Casing_RedSteel = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_RED_STEEL"); - public static final CustomIcon Casing_Material_RedSteel = Internal_Casing_RedSteel; - private static final CustomIcon Internal_Casing_Incoloy020 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_020"); - public static final CustomIcon Casing_Material_Incoloy020 = Internal_Casing_Incoloy020; - private static final CustomIcon Internal_Casing_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_DS"); - public static final CustomIcon Casing_Material_IncoloyDS = Internal_Casing_IncoloyDS; - private static final CustomIcon Internal_Casing_IncoloyMA956 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_MA956"); - public static final CustomIcon Casing_Material_IncoloyMA956 = Internal_Casing_IncoloyMA956; - private static final CustomIcon Internal_Casing_ZirconiumCarbide = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE"); - public static final CustomIcon Casing_Material_ZirconiumCarbide = Internal_Casing_ZirconiumCarbide; - - - private static final CustomIcon Internal_Casing_HastelloyX = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_HASTELLOY_X"); - public static final CustomIcon Casing_Material_HastelloyX = Internal_Casing_HastelloyX; - private static final CustomIcon Internal_Casing_HastelloyN = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_HASTELLOY_N"); - public static final CustomIcon Casing_Material_HastelloyN = Internal_Casing_HastelloyN; - private static final CustomIcon Internal_Casing_Fluid_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_FLUID_INCOLOY_DS"); - public static final CustomIcon Casing_Material_Fluid_IncoloyDS = Internal_Casing_Fluid_IncoloyDS; - - private static final CustomIcon Internal_Casing_Laurenium = new CustomIcon("TileEntities/MACHINE_CASING_LAURENIUM"); - public static final CustomIcon Casing_Material_Laurenium = Internal_Casing_Laurenium; - - //Trinium Alloys - public static final CustomIcon Casing_Trinium_Titanium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_TITANIUM"); - public static final CustomIcon Casing_Trinium_Naquadah = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH"); - public static final CustomIcon Casing_Trinium_Naquadah_Vent = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH_VENT"); - public static final CustomIcon Casing_Trinium_Naquadah_Carbon = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH_CARBON"); - - //Material Machine/Firebox Casings - private static final CustomIcon Internal_Casing_Staballoy_Firebox = new CustomIcon("TileEntities/MACHINE_CASING_FIREBOX_STABALLOY"); - public static final CustomIcon Casing_Staballoy_Firebox = Internal_Casing_Staballoy_Firebox; - - //Misc Casings - private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); - public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; - private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); - public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; - - //Redox Cells - public static final CustomIcon Casing_Redox_1 = new CustomIcon("redox/redox1"); - public static final CustomIcon Casing_Redox_2 = new CustomIcon("redox/redox2"); - public static final CustomIcon Casing_Redox_3 = new CustomIcon("redox/redox3"); - public static final CustomIcon Casing_Redox_4 = new CustomIcon("redox/redox4"); - public static final CustomIcon Casing_Redox_5 = new CustomIcon("redox/redox5"); - public static final CustomIcon Casing_Redox_6 = new CustomIcon("redox/redox6"); - //public static final CustomIcon Casing_Redox_7 = new CustomIcon("redox/redox7"); - //public static final CustomIcon Casing_Redox_8 = new CustomIcon("redox/redox8"); - - // Special Block 2 - public static final CustomIcon Casing_Resonance_1 = new CustomIcon("special/block_1"); - public static final CustomIcon Casing_Resonance_2 = new CustomIcon("special/block_2"); - public static final CustomIcon Casing_Resonance_3 = new CustomIcon("special/block_3"); - public static final CustomIcon Casing_Resonance_4 = new CustomIcon("special/block_4"); - public static final CustomIcon Casing_Modulator_1 = new CustomIcon("special/block_5"); - public static final CustomIcon Casing_Modulator_2 = new CustomIcon("special/block_6"); - public static final CustomIcon Casing_Modulator_3 = new CustomIcon("special/block_7"); - public static final CustomIcon Casing_Modulator_4 = new CustomIcon("special/block_8"); - - //Centrifuge Casing - private static final CustomIcon Internal_Casing_Centrifuge = new CustomIcon("TileEntities/MACHINE_CASING_CENTRIFUGE"); - public static final CustomIcon Casing_Material_Centrifuge = Internal_Casing_Centrifuge; - - //MACHINE_CASING_FARM_MANAGER_STRUCTURAL - //Farm Manager Casings - private static final CustomIcon Internal_Casing_Machine_Farm_Manager = new CustomIcon("TileEntities/MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); - public static final CustomIcon Casing_Machine_Farm_Manager = Internal_Casing_Machine_Farm_Manager; - //Acacia_Log - private static final CustomIcon Internal_Casing_Machine_Acacia_Log = new CustomIcon("TileEntities/log_acacia_top"); - public static final CustomIcon Casing_Machine_Acacia_Log = Internal_Casing_Machine_Acacia_Log; - //Podzol Top - private static final CustomIcon Internal_Casing_Machine_Podzol = new CustomIcon("TileEntities/dirt_podzol_top"); - public static final CustomIcon Casing_Machine_Podzol = Internal_Casing_Machine_Podzol; - - //Structural Blocks - private static final CustomIcon Internal_Casing_Machine_Metal_Grate_A = new CustomIcon("chrono/MetalGrate"); - public static final CustomIcon Casing_Machine_Metal_Grate_A = Internal_Casing_Machine_Metal_Grate_A; - private static final CustomIcon Internal_Casing_Machine_Metal_Grate_A_Solid = new CustomIcon("chrono/MetalGrateA_Solid"); - public static final CustomIcon Casing_Machine_Metal_Grate_A_Solid = Internal_Casing_Machine_Metal_Grate_A_Solid; - private static final CustomIcon Internal_Casing_Machine_Metal_Grate_B = new CustomIcon("chrono/MetalGrate2"); - public static final CustomIcon Casing_Machine_Metal_Grate_B = Internal_Casing_Machine_Metal_Grate_B; - private static final CustomIcon Internal_Casing_Machine_Metal_Panel_A = new CustomIcon("chrono/MetalPanel"); - public static final CustomIcon Casing_Machine_Metal_Panel_A = Internal_Casing_Machine_Metal_Panel_A; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_A = new CustomIcon("chrono/MetalSheet"); - public static final CustomIcon Casing_Machine_Metal_Sheet_A = Internal_Casing_Machine_Metal_Sheet_A; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_B = new CustomIcon("chrono/MetalSheet2"); - public static final CustomIcon Casing_Machine_Metal_Sheet_B = Internal_Casing_Machine_Metal_Sheet_B; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_C = new CustomIcon("chrono/MetalSheet3"); - public static final CustomIcon Casing_Machine_Metal_Sheet_C = Internal_Casing_Machine_Metal_Sheet_C; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_D = new CustomIcon("chrono/MetalSheet4"); - public static final CustomIcon Casing_Machine_Metal_Sheet_D = Internal_Casing_Machine_Metal_Sheet_D; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_E = new CustomIcon("chrono/MetalSheet5"); - public static final CustomIcon Casing_Machine_Metal_Sheet_E = Internal_Casing_Machine_Metal_Sheet_E; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_F = new CustomIcon("chrono/MetalSheet6"); - public static final CustomIcon Casing_Machine_Metal_Sheet_F = Internal_Casing_Machine_Metal_Sheet_F; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_G = new CustomIcon("chrono/MetalSheet7"); - public static final CustomIcon Casing_Machine_Metal_Sheet_G = Internal_Casing_Machine_Metal_Sheet_G; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_H = new CustomIcon("chrono/MetalSheet8"); - public static final CustomIcon Casing_Machine_Metal_Sheet_H = Internal_Casing_Machine_Metal_Sheet_H; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_I = new CustomIcon("chrono/MetalSheet9"); - public static final CustomIcon Casing_Machine_Metal_Sheet_I = Internal_Casing_Machine_Metal_Sheet_I; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_J = new CustomIcon("chrono/MetalSheet10"); - public static final CustomIcon Casing_Machine_Metal_Sheet_J = Internal_Casing_Machine_Metal_Sheet_J; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_K = new CustomIcon("chrono/MetalSheet11"); - public static final CustomIcon Casing_Machine_Metal_Sheet_K = Internal_Casing_Machine_Metal_Sheet_K; - private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_L = new CustomIcon("chrono/MetalSheet12"); - public static final CustomIcon Casing_Machine_Metal_Sheet_L = Internal_Casing_Machine_Metal_Sheet_L; - private static final CustomIcon Internal_Overlay_Machine_Cyber_A = new CustomIcon("chrono/CyberPanel"); - public static final CustomIcon Overlay_Machine_Cyber_A = Internal_Overlay_Machine_Cyber_A; - private static final CustomIcon Internal_Overlay_Machine_Cyber_B = new CustomIcon("chrono/CyberPanel2"); - public static final CustomIcon Overlay_Machine_Cyber_B = Internal_Overlay_Machine_Cyber_B; - - - public static final CustomIcon TEXTURE_CASING_AMAZON = new CustomIcon("TileEntities/CASING_AMAZON"); - public static final CustomIcon TEXTURE_CASING_ADVANCED_CRYOGENIC = new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_CRYOGENIC"); - public static final CustomIcon TEXTURE_CASING_ADVANCED_VOLCNUS = new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_VOLCANUS"); - public static final CustomIcon TEXTURE_CASING_ROCKETDYNE = new CustomIcon("TileEntities/MACHINE_CASING_ROCKETDYNE"); - public static final CustomIcon TEXTURE_CASING_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_GRINDING_FACTORY"); - public static final CustomIcon TEXTURE_CASING_FLOTATION = new CustomIcon("TileEntities/MACHINE_CASING_FLOTATION"); - - // Custom Pipes - public static final CustomIcon TEXTURE_PIPE_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_PIPE_T1"); - public static final CustomIcon TEXTURE_PIPE_GENERIC = new CustomIcon("iconsets/MACHINE_CASING_PIPE_GENERIC"); - - public static final CustomIcon TEXTURE_PIPE_T1_BABBIT_ALLOY = new CustomIcon("iconsets/MACHINE_CASING_PIPE_BABBIT_ALLOY"); - public static final CustomIcon TEXTURE_PIPE_T2_INCONEL_690 = new CustomIcon("iconsets/MACHINE_CASING_PIPE_INCONEL_690"); - public static final CustomIcon TEXTURE_PIPE_T3_STELLITE = new CustomIcon("iconsets/MACHINE_CASING_PIPE_STELLITE"); - public static final CustomIcon TEXTURE_PIPE_T4_NITINOL_60 = new CustomIcon("iconsets/MACHINE_CASING_PIPE_NITINOL_60"); - public static final CustomIcon TEXTURE_PIPE_T5_LAFIUM = new CustomIcon("iconsets/MACHINE_CASING_PIPE_LAFIUM"); - public static final CustomIcon TEXTURE_PIPE_T6_CINOBITE = new CustomIcon("iconsets/MACHINE_CASING_PIPE_CINOBITE"); - public static final CustomIcon TEXTURE_PIPE_T7_TITANSTEEL = new CustomIcon("iconsets/MACHINE_CASING_PIPE_TITANSTEEL"); - public static final CustomIcon TEXTURE_PIPE_T8_ABYSSAL = new CustomIcon("iconsets/MACHINE_CASING_PIPE_ABYSSAL"); - - // Custom Gearboxes - public static final CustomIcon TEXTURE_GEARBOX_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_GEARBOX_T1"); - public static final CustomIcon TEXTURE_GEARBOX_GENERIC = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_GENERIC"); - - public static final CustomIcon TEXTURE_GEARBOX_T1_EGLIN_STEEL = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_EGLIN_STEEL"); - public static final CustomIcon TEXTURE_GEARBOX_T2_INCONEL_792 = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_INCONEL_792"); - public static final CustomIcon TEXTURE_GEARBOX_T3_INCOLOY_MA956 = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_INCOLOY_MA956"); - public static final CustomIcon TEXTURE_GEARBOX_T4_NITINOL_60 = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_NITINOL_60"); - public static final CustomIcon TEXTURE_GEARBOX_T5_ZERON_100 = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_ZERON_100"); - public static final CustomIcon TEXTURE_GEARBOX_T6_PIKYONIUM = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_PIKYONIUM"); - public static final CustomIcon TEXTURE_GEARBOX_T7_TITANSTEEL = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_TITANSTEEL"); - public static final CustomIcon TEXTURE_GEARBOX_T8_ABYSSAL = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_ABYSSAL"); - - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II = new CustomIcon("iconsets/MACHINE_CASING_FUSION_3"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_INNER = new CustomIcon("iconsets/MACHINE_CASING_FUSION_COIL_II"); - public static final CustomIcon TEXTURE_CASING_FUSION_CASING_ULTRA = new CustomIcon("iconsets/MACHINE_CASING_FUSION_GLASS_ULTRA"); - // - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_1 = new CustomIcon("iconsets/FUSIONIII_1"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_2 = new CustomIcon("iconsets/FUSIONIII_2"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_3 = new CustomIcon("iconsets/FUSIONIII_3"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_4 = new CustomIcon("iconsets/FUSIONIII_4"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_5 = new CustomIcon("iconsets/FUSIONIII_5"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_6 = new CustomIcon("iconsets/FUSIONIII_6"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_7 = new CustomIcon("iconsets/FUSIONIII_7"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_8 = new CustomIcon("iconsets/FUSIONIII_8"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_9 = new CustomIcon("iconsets/FUSIONIII_9"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_10 = new CustomIcon("iconsets/FUSIONIII_10"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_11 = new CustomIcon("iconsets/FUSIONIII_11"); - public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_12 = new CustomIcon("iconsets/FUSIONIII_12"); - - //Overlays - //Fan Textures - private static final CustomIcon Internal_Overlay_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); - public static final CustomIcon Overlay_Machine_Vent = Internal_Overlay_Machine_Vent; - private static final CustomIcon Internal_Overlay_Machine_Vent_Fast = new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); - public static final CustomIcon Overlay_Machine_Vent_Fast = Internal_Overlay_Machine_Vent_Fast; - private static final CustomIcon Internal_Overlay_Machine_Vent_Adv = new CustomIcon("TileEntities/adv_machine_vent_rotating"); - public static final CustomIcon Overlay_Machine_Vent_Adv = Internal_Overlay_Machine_Vent_Adv; - private static final CustomIcon Internal_Overlay_Machine_Turbine_Active = new CustomIcon("TileEntities/STEAM_TURBINE_SIDE_ACTIVE"); - public static final CustomIcon Overlay_Machine_Turbine_Active = Internal_Overlay_Machine_Turbine_Active; - //Grate Texture - public static final CustomIcon OVERLAY_GRATE_A = new CustomIcon("metro/OVERLAY_GRATE_A"); - //Speaker Texture - private static final CustomIcon Internal_Overlay_Machine_Sound = new CustomIcon("TileEntities/audio_out"); - public static final CustomIcon Overlay_Machine_Sound = Internal_Overlay_Machine_Sound; - private static final CustomIcon Internal_Overlay_Machine_Sound_Active = new CustomIcon("TileEntities/audio_out_active"); - public static final CustomIcon Overlay_Machine_Sound_Active = Internal_Overlay_Machine_Sound_Active; - //Diesel Engines - private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical = new CustomIcon("TileEntities/machine_top_dieselmotor"); - public static final CustomIcon Overlay_Machine_Diesel_Vertical = Internal_Overlay_Machine_Diesel_Vertical; - private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal = new CustomIcon("TileEntities/machine_top_dieselmotor2"); - public static final CustomIcon Overlay_Machine_Diesel_Horizontal = Internal_Overlay_Machine_Diesel_Horizontal; - private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical_Active = new CustomIcon("TileEntities/machine_top_dieselmotor_active"); - public static final CustomIcon Overlay_Machine_Diesel_Vertical_Active = Internal_Overlay_Machine_Diesel_Vertical_Active; - private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal_Active = new CustomIcon("TileEntities/machine_top_dieselmotor2_active"); - public static final CustomIcon Overlay_Machine_Diesel_Horizontal_Active = Internal_Overlay_Machine_Diesel_Horizontal_Active; - //Computer Screens - private static final CustomIcon Internal_Casing_Machine_Screen_1 = new CustomIcon("TileEntities/adv_machine_screen_random1"); - public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; - private static final CustomIcon Internal_Casing_Machine_Screen_2 = new CustomIcon("TileEntities/adv_machine_screen_random2"); - public static final CustomIcon Casing_Machine_Screen_2 = Internal_Casing_Machine_Screen_2; - private static final CustomIcon Internal_Casing_Machine_Screen_3 = new CustomIcon("TileEntities/adv_machine_screen_random3"); - public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; - private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = new CustomIcon("TileEntities/adv_machine_screen_frequency"); - public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; - private static final CustomIcon Internal_Overlay_Machine_Screen_Logo = new CustomIcon("TileEntities/adv_machine_screen_logo"); - public static final CustomIcon Overlay_Machine_Screen_Logo = Internal_Overlay_Machine_Screen_Logo; - private static final CustomIcon Internal_Overlay_Machine_Cyber_Interface = new CustomIcon("chrono/Overlay_Cyber"); - public static final CustomIcon Overlay_Machine_Cyber_Interface = Internal_Overlay_Machine_Cyber_Interface; - - //Machine Controller Overlays - private static final CustomIcon Internal_Overlay_Machine_Controller_Default = new CustomIcon("iconsets/OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ANIMATED"); - public static final CustomIcon Overlay_Machine_Controller_Default = Internal_Overlay_Machine_Controller_Default; - private static final CustomIcon Internal_Overlay_Machine_Controller_Default_Active = new CustomIcon("iconsets/OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ANIMATED_ACTIVE"); - public static final CustomIcon Overlay_Machine_Controller_Default_Active = Internal_Overlay_Machine_Controller_Default_Active; - - private static final CustomIcon Internal_Overlay_Machine_Controller_Advanced = new CustomIcon("iconsets/OVERLAY_FRONT_ADVANCED_MULTIBLOCK_ANIMATED"); - public static final CustomIcon Overlay_Machine_Controller_Advanced = Internal_Overlay_Machine_Controller_Advanced; - private static final CustomIcon Internal_Overlay_Machine_Controller_Advanced_Active = new CustomIcon("iconsets/OVERLAY_FRONT_ADVANCED_MULTIBLOCK_ANIMATED_ACTIVE"); - public static final CustomIcon Overlay_Machine_Controller_Advanced_Active = Internal_Overlay_Machine_Controller_Advanced_Active; - - //Fluid Reactor Overlays - public static final CustomIcon Overlay_FluidReactor_Front = new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT"); - public static final CustomIcon Overlay_FluidReactor_Side = new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE"); - public static final CustomIcon Overlay_FluidReactor_Top = new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP"); - public static final CustomIcon Overlay_FluidReactor_Front_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT_ACTIVE"); - public static final CustomIcon Overlay_FluidReactor_Side_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE_ACTIVE"); - public static final CustomIcon Overlay_FluidReactor_Top_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP_ACTIVE"); - - //Crafting Overlays - public static final CustomIcon Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); - public static final CustomIcon Overlay_Crafting_Steel = new CustomIcon("TileEntities/cover_crafting"); - - public static final CustomIcon Casing_Workbench_Crafting_Overlay = new CustomIcon("TileEntities/gt4/bronze_top_crafting"); - public static final CustomIcon Casing_Workbench_Top = new CustomIcon("TileEntities/gt4/bronze_top"); - public static final CustomIcon Casing_Workbench_Side = new CustomIcon("TileEntities/gt4/bronze_side"); - public static final CustomIcon Casing_Workbench_Bottom = new CustomIcon("TileEntities/gt4/bronze_bottom"); - public static final CustomIcon Casing_Adv_Workbench_Crafting_Overlay = new CustomIcon("TileEntities/gt4/machine_top_crafting"); - public static final CustomIcon Casing_Adv_Workbench_Top = new CustomIcon("TileEntities/gt4/machine_top"); - public static final CustomIcon Casing_Adv_Workbench_Side = new CustomIcon("TileEntities/gt4/machine_side"); - public static final CustomIcon Casing_Adv_Workbench_Bottom = new CustomIcon("TileEntities/gt4/machine_bottom"); - - - public static final CustomIcon Casing_Redstone_Top_Off = new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_off"); - public static final CustomIcon Casing_Redstone_Top_Main_Off = new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_main_off"); - public static final CustomIcon Casing_Redstone_Top_On = new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_on"); - public static final CustomIcon Casing_Redstone_Top_Main_On = new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_main_on"); - - public static final CustomIcon Casing_Redstone_Side_Off = new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_off"); - public static final CustomIcon Casing_Redstone_Side_Main_Off = new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_main_off"); - public static final CustomIcon Casing_Redstone_Side_On = new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_on"); - public static final CustomIcon Casing_Redstone_Side_Main_On = new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_main_on"); - - public static final CustomIcon Casing_Redstone_Bottom_Off = new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_off"); - public static final CustomIcon Casing_Redstone_Bottom_Main_Off = new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_main_off"); - public static final CustomIcon Casing_Redstone_Bottom_On = new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_on"); - public static final CustomIcon Casing_Redstone_Bottom_Main_On = new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_main_on"); - - - public static final CustomIcon Casing_Electric_Auto_Workbench_Side = new CustomIcon("TileEntities/gt4/OVERLAY_SIDE_CABINET"); - public static final CustomIcon Casing_Computer_Cube = new CustomIcon("TileEntities/gt4/computer"); - - public static final CustomIcon Casing_CropHarvester_Cutter = new CustomIcon("TileEntities/gt4/OVERLAY_CROP"); - public static final CustomIcon Casing_CropHarvester_Boxes = new CustomIcon("TileEntities/gt4/OVERLAY_BOXES"); - - public static final CustomIcon Casing_InventoryManagaer_Cyan = new CustomIcon("TileEntities/gt4/OVERLAY_CYAN"); - public static final CustomIcon Casing_InventoryManagaer_Green = new CustomIcon("TileEntities/gt4/OVERLAY_GREEN"); - public static final CustomIcon Casing_InventoryManagaer_Purple = new CustomIcon("TileEntities/gt4/OVERLAY_PURPLE"); - public static final CustomIcon Casing_InventoryManagaer_Red = new CustomIcon("TileEntities/gt4/OVERLAY_RED"); - public static final CustomIcon Casing_InventoryManagaer_Yellow = new CustomIcon("TileEntities/gt4/OVERLAY_YELLOW"); - public static final CustomIcon Casing_InventoryManagaer_Blue = new CustomIcon("TileEntities/gt4/OVERLAY_BLUE"); - - public static final CustomIcon Casing_InventoryManagaer_Cyan_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_CYAN_REDSTONE"); - public static final CustomIcon Casing_InventoryManagaer_Green_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_GREEN_REDSTONE"); - public static final CustomIcon Casing_InventoryManagaer_Purple_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_PURPLE_REDSTONE"); - public static final CustomIcon Casing_InventoryManagaer_Red_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_RED_REDSTONE"); - public static final CustomIcon Casing_InventoryManagaer_Yellow_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_YELLOW_REDSTONE"); - public static final CustomIcon Casing_InventoryManagaer_Blue_Redstone = new CustomIcon("TileEntities/gt4/OVERLAY_BLUE_REDSTONE"); - - private static final CustomIcon Casing_Test_1 = new CustomIcon("number/1"); - private static final CustomIcon Casing_Test_2 = new CustomIcon("number/2"); - private static final CustomIcon Casing_Test_3 = new CustomIcon("number/3"); - private static final CustomIcon Casing_Test_4 = new CustomIcon("number/4"); - private static final CustomIcon Casing_Test_5 = new CustomIcon("number/5"); - private static final CustomIcon Casing_Test_6 = new CustomIcon("number/6"); - private static final CustomIcon Casing_Test_7 = new CustomIcon("number/7"); - private static final CustomIcon Casing_Test_8 = new CustomIcon("number/8"); - private static final CustomIcon Casing_Test_9 = new CustomIcon("number/9"); - private static final CustomIcon Casing_Test_10 = new CustomIcon("number/10"); - private static final CustomIcon Casing_Test_11 = new CustomIcon("number/11"); - private static final CustomIcon Casing_Test_12 = new CustomIcon("number/12"); - private static final CustomIcon Casing_Test_13 = new CustomIcon("number/13"); - private static final CustomIcon Casing_Test_14 = new CustomIcon("number/14"); - private static final CustomIcon Casing_Test_15 = new CustomIcon("number/15"); - private static final CustomIcon Casing_Test_16 = new CustomIcon("number/16"); - - public static final CustomIcon[] TEST_NUMBER = new CustomIcon[] { - Casing_Test_1, Casing_Test_2, Casing_Test_3, Casing_Test_4, - Casing_Test_5, Casing_Test_6, Casing_Test_7, Casing_Test_8, - Casing_Test_9, Casing_Test_10, Casing_Test_11, Casing_Test_12, - Casing_Test_13, Casing_Test_14, Casing_Test_15, Casing_Test_16 - - }; - - //Covers - private static final CustomIcon Internal_Overlay_Overflow_Valve = new CustomIcon("iconsets/OVERLAY_OVERFLOW_VALVE"); - public static final CustomIcon Overlay_Overflow_Valve = Internal_Overlay_Overflow_Valve; - - - //Hatch Overlays - //Charger Texture - private static final CustomIcon Internal_Overlay_Hatch_Charger = new CustomIcon("TileEntities/cover_charger"); - public static final CustomIcon Overlay_Hatch_Charger = Internal_Overlay_Hatch_Charger; - //Discharger Texture - private static final CustomIcon Internal_Overlay_Hatch_Discharger = new CustomIcon("TileEntities/cover_discharge"); - public static final CustomIcon Overlay_Hatch_Discharger = Internal_Overlay_Hatch_Discharger; - //Advanced Muffler - private static final CustomIcon Internal_Overlay_Hatch_Muffler_Adv = new CustomIcon("iconsets/OVERLAY_MUFFLER_ADV"); - public static final CustomIcon Overlay_Hatch_Muffler_Adv = Internal_Overlay_Hatch_Muffler_Adv; - //Control Core Bus - private static final CustomIcon Internal_Overlay_Hatch_Control_Core = new CustomIcon("iconsets/OVERLAY_CONTROL_CORE_BUS"); - public static final CustomIcon Overlay_Hatch_Control_Core = Internal_Overlay_Hatch_Control_Core; - // Milling Ball Bus - private static final CustomIcon Internal_Overlay_Bus_Milling_Balls = new CustomIcon("iconsets/OVERLAY_MILLING_BALL_BUS"); - public static final CustomIcon Overlay_Bus_Milling_Balls = Internal_Overlay_Bus_Milling_Balls; - // Catalyst Bus - private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS"); - public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst; - - - public static final CustomIcon Overlay_Cobble = new CustomIcon("iconsets/OVERLAY_COBBLE"); - public static final CustomIcon Overlay_Connector = new CustomIcon("iconsets/OVERLAY_CONNECTOR"); - public static final CustomIcon Overlay_Fire = new CustomIcon("iconsets/OVERLAY_FIRE"); - public static final CustomIcon Overlay_Grinder = new CustomIcon("iconsets/OVERLAY_GRINDER"); - public static final CustomIcon Overlay_GT_Logo = new CustomIcon("iconsets/OVERLAY_GT"); - public static final CustomIcon Overlay_Ice = new CustomIcon("iconsets/OVERLAY_ICE"); - public static final CustomIcon Overlay_Implosion = new CustomIcon("iconsets/OVERLAY_IMPLOSION"); - // Lapo Orb Hatch - public static final CustomIcon Overlay_Hatch_Lapo_Orb = new CustomIcon("iconsets/OVERLAY_LAPO"); - // Data Orb Hatch - public static final CustomIcon Overlay_Hatch_Data_Orb = new CustomIcon("iconsets/OVERLAY_DATA_ORB"); - - // RTG Hatch - private static final CustomIcon Internal_Overlay_Hatch_RTG_Off = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_OFF"); - public static final CustomIcon Overlay_Hatch_RTG_Off = Internal_Overlay_Hatch_RTG_Off; - private static final CustomIcon Internal_Overlay_Hatch_RTG_On = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_ON"); - public static final CustomIcon Overlay_Hatch_RTG_On = Internal_Overlay_Hatch_RTG_On; - - //Dimensional - private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); - public static final CustomIcon Overlay_Machine_Dimensional_Blue = Internal_Overlay_Machine_Dimensional_Blue; - private static final CustomIcon Internal_Overlay_Machine_Dimensional_Orange = new CustomIcon("TileEntities/adv_machine_dimensional_cover_orange"); - public static final CustomIcon Overlay_Machine_Dimensional_Orange = Internal_Overlay_Machine_Dimensional_Orange; - //Icons - private static final CustomIcon Internal_Overlay_MatterFab = new CustomIcon("TileEntities/adv_machine_matterfab"); - public static final CustomIcon Overlay_MatterFab = Internal_Overlay_MatterFab; - private static final CustomIcon Internal_Overlay_MatterFab_Active = new CustomIcon("TileEntities/adv_machine_matterfab_active"); - public static final CustomIcon Overlay_MatterFab_Active = Internal_Overlay_MatterFab_Active; - - private static final CustomIcon Internal_Overlay_MatterFab_Animated = new CustomIcon("TileEntities/adv_machine_matterfab_animated"); - public static final CustomIcon Overlay_MatterFab_Animated = Internal_Overlay_MatterFab_Animated; - private static final CustomIcon Internal_Overlay_MatterFab_Active_Animated = new CustomIcon("TileEntities/adv_machine_matterfab_active_animated"); - public static final CustomIcon Overlay_MatterFab_Active_Animated = Internal_Overlay_MatterFab_Active_Animated; - - private static final CustomIcon Internal_Overlay_Oil = new CustomIcon("TileEntities/adv_machine_oil"); - public static final CustomIcon Overlay_Oil = Internal_Overlay_Oil; - private static final CustomIcon Internal_Overlay_Water = new CustomIcon("TileEntities/adv_machine_water"); - public static final CustomIcon Overlay_Water = Internal_Overlay_Water; - private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); - public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; - - // GT++ Tiered Hulls - public static final CustomIcon TEXTURE_CASING_TIERED_ULV = new CustomIcon("iconsets/TieredHulls/CASING_ULV"); - public static final CustomIcon TEXTURE_CASING_TIERED_LV = new CustomIcon("iconsets/TieredHulls/CASING_LV"); - public static final CustomIcon TEXTURE_CASING_TIERED_MV = new CustomIcon("iconsets/TieredHulls/CASING_MV"); - public static final CustomIcon TEXTURE_CASING_TIERED_HV = new CustomIcon("iconsets/TieredHulls/CASING_HV"); - public static final CustomIcon TEXTURE_CASING_TIERED_EV = new CustomIcon("iconsets/TieredHulls/CASING_EV"); - public static final CustomIcon TEXTURE_CASING_TIERED_IV = new CustomIcon("iconsets/TieredHulls/CASING_IV"); - public static final CustomIcon TEXTURE_CASING_TIERED_LuV = new CustomIcon("iconsets/TieredHulls/CASING_LuV"); - public static final CustomIcon TEXTURE_CASING_TIERED_ZPM = new CustomIcon("iconsets/TieredHulls/CASING_ZPM"); - public static final CustomIcon TEXTURE_CASING_TIERED_UV = new CustomIcon("iconsets/TieredHulls/CASING_UV"); - public static final CustomIcon TEXTURE_CASING_TIERED_MAX = new CustomIcon("iconsets/TieredHulls/CASING_MAX"); - - //Metroid related - public static final CustomIcon TEXTURE_METAL_PANEL_A = new CustomIcon("metro/TEXTURE_METAL_PANEL_A"); - public static final CustomIcon TEXTURE_METAL_PANEL_B = new CustomIcon("metro/TEXTURE_METAL_PANEL_B"); - public static final CustomIcon TEXTURE_METAL_PANEL_C = new CustomIcon("metro/TEXTURE_METAL_PANEL_C"); - public static final CustomIcon TEXTURE_METAL_PANEL_D = new CustomIcon("metro/TEXTURE_METAL_PANEL_D"); - public static final CustomIcon TEXTURE_METAL_PANEL_E = new CustomIcon("metro/TEXTURE_METAL_PANEL_E"); - public static final CustomIcon TEXTURE_METAL_PANEL_F = new CustomIcon("metro/TEXTURE_METAL_PANEL_F"); - public static final CustomIcon TEXTURE_METAL_PANEL_G = new CustomIcon("metro/TEXTURE_METAL_PANEL_G"); - public static final CustomIcon TEXTURE_METAL_PANEL_H = new CustomIcon("metro/TEXTURE_METAL_PANEL_H"); - public static final CustomIcon TEXTURE_METAL_PANEL_I = new CustomIcon("metro/TEXTURE_METAL_PANEL_I"); - - public static final CustomIcon TEXTURE_MAGIC_PANEL_A = new CustomIcon("metro/TEXTURE_MAGIC_A"); - public static final CustomIcon TEXTURE_MAGIC_PANEL_B = new CustomIcon("metro/TEXTURE_MAGIC_B"); - - public static final CustomIcon TEXTURE_ORGANIC_PANEL_A = new CustomIcon("metro/TEXTURE_ORGANIC_PANEL_A"); - public static final CustomIcon TEXTURE_ORGANIC_PANEL_A_GLOWING = new CustomIcon("metro/TEXTURE_ORGANIC_PANEL_A_GLOWING"); - - public static final CustomIcon TEXTURE_STONE_BIRD_A = new CustomIcon("metro/TEXTURE_STONE_BIRD_A"); - public static final CustomIcon TEXTURE_STONE_BIRD_A_LEFT = new CustomIcon("metro/TEXTURE_STONE_BIRD_A_LEFT"); - public static final CustomIcon TEXTURE_STONE_BIRD_A_RIGHT = new CustomIcon("metro/TEXTURE_STONE_BIRD_A_RIGHT"); - public static final CustomIcon TEXTURE_STONE_RED_A = new CustomIcon("metro/TEXTURE_STONE_RED_A"); - public static final CustomIcon TEXTURE_STONE_RED_B = new CustomIcon("metro/TEXTURE_STONE_RED_B"); - public static final CustomIcon TEXTURE_STONE_BLUE_A = new CustomIcon("metro/TEXTURE_STONE_BLUE_A"); - public static final CustomIcon TEXTURE_STONE_GREEN_A = new CustomIcon("metro/TEXTURE_STONE_GREEN_A"); - public static final CustomIcon TEXTURE_STONE_TABLET_A = new CustomIcon("metro/TEXTURE_STONE_TABLET_A"); - public static final CustomIcon TEXTURE_STONE_TABLET_B = new CustomIcon("metro/TEXTURE_STONE_TABLET_B"); - - public static final CustomIcon TEXTURE_TECH_A = new CustomIcon("metro/TEXTURE_TECH_A"); - public static final CustomIcon TEXTURE_TECH_B = new CustomIcon("metro/TEXTURE_TECH_B"); - public static final CustomIcon TEXTURE_TECH_C = new CustomIcon("metro/TEXTURE_TECH_C"); - - public static final CustomIcon TEXTURE_TECH_PANEL_A = new CustomIcon("metro/TEXTURE_TECH_PANEL_A"); - public static final CustomIcon TEXTURE_TECH_PANEL_B = new CustomIcon("metro/TEXTURE_TECH_PANEL_B"); - public static final CustomIcon TEXTURE_TECH_PANEL_C = new CustomIcon("metro/TEXTURE_TECH_PANEL_C"); - public static final CustomIcon TEXTURE_TECH_PANEL_D = new CustomIcon("metro/TEXTURE_TECH_PANEL_D"); - public static final CustomIcon TEXTURE_TECH_PANEL_E = new CustomIcon("metro/TEXTURE_TECH_PANEL_E"); - public static final CustomIcon TEXTURE_TECH_PANEL_F = new CustomIcon("metro/TEXTURE_TECH_PANEL_F"); - public static final CustomIcon TEXTURE_TECH_PANEL_G = new CustomIcon("metro/TEXTURE_TECH_PANEL_G"); - public static final CustomIcon TEXTURE_TECH_PANEL_H = new CustomIcon("metro/TEXTURE_TECH_PANEL_H"); - public static final CustomIcon TEXTURE_TECH_PANEL_I = new CustomIcon("metro/TEXTURE_TECH_PANEL_I"); - - public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE = new CustomIcon("TileEntities/DecayablesChest_bottom"); - public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE_ALT = new CustomIcon("TileEntities/DecayablesChest_top"); - - // LFTR Single blocks - public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_FRONT = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_FRONT"); - public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_FRONT_ACTIVE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_FRONT_ACTIVE"); - public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_SIDE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_SIDE"); - public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_SIDE_ACTIVE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_SIDE_ACTIVE"); - public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_TOP = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_TOP"); - public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_TOP_ACTIVE"); - - public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_FRONT = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_FRONT"); - public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_FRONT_ACTIVE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_FRONT_ACTIVE"); - public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_SIDE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_SIDE"); - public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_SIDE_ACTIVE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_SIDE_ACTIVE"); - public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_TOP = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_TOP"); - public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_TOP_ACTIVE"); - - - //Overlay Arrays - public static ITexture[] OVERLAYS_ENERGY_OUT_BUFFER = new ITexture[]{ - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{220, 220, 220, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{220, 220, 220, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{255, 100, 0, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{255, 255, 30, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{128, 128, 128, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, - new short[]{240, 240, 245, 0})}; - - public static ITexture[] OVERLAYS_ENERGY_OUT_MULTI_BUFFER = new ITexture[]{ - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{220, 220, 220, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{220, 220, 220, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{255, 100, 0, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{255, 255, 30, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{128, 128, 128, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{240, 240, 245, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, - new short[]{240, 240, 245, 0})}; - - public static ITexture[] OVERLAYS_CABINET_FRONT = new ITexture[]{ - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_1, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_2, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_3, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_4, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_5, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_6, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_7, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_8, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_9, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_10, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_11, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_12, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_13, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_14, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_15, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_16, - new short[]{255, 255, 255, 0}),}; - - public static ITexture[] OVERLAYS_COMPARTMENT_FRONT = new ITexture[]{ - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_1, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_2, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_3, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_4, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_5, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_6, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_7, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_8, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_9, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_10, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_11, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_12, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_13, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_14, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_15, - new short[]{255, 255, 255, 0}), - new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_16, - new short[]{255, 255, 255, 0}),}; - - public static IIconContainer[] CONNECTED_FUSION_HULLS = new IIconContainer[]{ - TEXTURE_CASING_FUSION_COIL_II_1, TEXTURE_CASING_FUSION_COIL_II_2, TEXTURE_CASING_FUSION_COIL_II_3, - TEXTURE_CASING_FUSION_COIL_II_4, TEXTURE_CASING_FUSION_COIL_II_5, TEXTURE_CASING_FUSION_COIL_II_6, - TEXTURE_CASING_FUSION_COIL_II_7, TEXTURE_CASING_FUSION_COIL_II_8, TEXTURE_CASING_FUSION_COIL_II_9, - TEXTURE_CASING_FUSION_COIL_II_10, TEXTURE_CASING_FUSION_COIL_II_11, TEXTURE_CASING_FUSION_COIL_II_12}; - - public static IIconContainer[] TIERED_MACHINE_HULLS = new IIconContainer[]{ - TEXTURE_CASING_TIERED_ULV, - TEXTURE_CASING_TIERED_LV, - TEXTURE_CASING_TIERED_MV, - TEXTURE_CASING_TIERED_HV, - TEXTURE_CASING_TIERED_EV, - TEXTURE_CASING_TIERED_IV, - TEXTURE_CASING_TIERED_LuV, - TEXTURE_CASING_TIERED_ZPM, - TEXTURE_CASING_TIERED_UV, - TEXTURE_CASING_TIERED_MAX}; - - - public static Object Casing_Material_Turbine; - - + private static AutoMap mCustomiconMap = new AutoMap(); + + static { + } + + // public static ITexture[] CASING_BLOCKS_GTPP = new ITexture[256]; + + /* + * Handles Custom Textures. + */ + + public static class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + protected String mModID; + + public CustomIcon(final String aIconName) { + this(CORE.MODID, aIconName); + } + + public CustomIcon(final String aModID, final String aIconName) { + this.mIconName = aIconName; + this.mModID = aModID; + mCustomiconMap.put(this); + Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sBlockIcons.registerIcon(this.mModID + ":" + this.mIconName); + Logger.WARNING( + "FIND ME _ Processing texture: " + this.getTextureFile().getResourcePath()); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + + public static class VanillaIcon implements IIconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + + public VanillaIcon(final String aIconName) { + this.mIconName = aIconName; + mCustomiconMap.put(this); + Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sBlockIcons.registerIcon("minecraft" + ":" + this.mIconName); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + + public static GT_RenderedTexture getTextureFromIcon(CustomIcon aIcon, short[] aRGB) { + return new GT_RenderedTexture(aIcon, aRGB); + } + + /* + * Add Some Custom Textures below. + * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. + * Right? + */ + + // Vanilla Textures + public static final VanillaIcon VanillaIcon_OakPlanks = new VanillaIcon("planks_oak"); + + // PlaceHolder Texture + private static final CustomIcon Internal_PlaceHolder = new CustomIcon("TileEntities/_PlaceHolder"); + public static final CustomIcon _PlaceHolder = Internal_PlaceHolder; + + // Energy overlays + public static final CustomIcon OVERLAY_ENERGY_OUT_BUFFER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_BUFFER"); + public static final CustomIcon OVERLAY_ENERGY_OUT_MULTI_BUFFER = + new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_MULTI_BUFFER"); + + // Wooden Shelf and Compartment Overlays + public static final CustomIcon OVERLAY_WOODEN_SHELF_FRONT = new CustomIcon("TileEntities/Compartment/wood_shelf"); + public static final CustomIcon OVERLAY_WOODEN_SHELF_CANS_FRONT = + new CustomIcon("TileEntities/Compartment/wood_shelf_cans"); + public static final CustomIcon OVERLAY_WOODEN_SHELF_PAPER_FRONT = + new CustomIcon("TileEntities/Compartment/wood_shelf_paper"); + public static final CustomIcon OVERLAY_CABINET_1 = new CustomIcon("TileEntities/Compartment/0"); + public static final CustomIcon OVERLAY_CABINET_2 = new CustomIcon("TileEntities/Compartment/1"); + public static final CustomIcon OVERLAY_CABINET_3 = new CustomIcon("TileEntities/Compartment/2"); + public static final CustomIcon OVERLAY_CABINET_4 = new CustomIcon("TileEntities/Compartment/3"); + public static final CustomIcon OVERLAY_CABINET_5 = new CustomIcon("TileEntities/Compartment/4"); + public static final CustomIcon OVERLAY_CABINET_6 = new CustomIcon("TileEntities/Compartment/5"); + public static final CustomIcon OVERLAY_CABINET_7 = new CustomIcon("TileEntities/Compartment/6"); + public static final CustomIcon OVERLAY_CABINET_8 = new CustomIcon("TileEntities/Compartment/7"); + public static final CustomIcon OVERLAY_CABINET_9 = new CustomIcon("TileEntities/Compartment/8"); + public static final CustomIcon OVERLAY_CABINET_10 = new CustomIcon("TileEntities/Compartment/9"); + public static final CustomIcon OVERLAY_CABINET_11 = new CustomIcon("TileEntities/Compartment/10"); + public static final CustomIcon OVERLAY_CABINET_12 = new CustomIcon("TileEntities/Compartment/11"); + public static final CustomIcon OVERLAY_CABINET_13 = new CustomIcon("TileEntities/Compartment/12"); + public static final CustomIcon OVERLAY_CABINET_14 = new CustomIcon("TileEntities/Compartment/13"); + public static final CustomIcon OVERLAY_CABINET_15 = new CustomIcon("TileEntities/Compartment/14"); + public static final CustomIcon OVERLAY_CABINET_16 = new CustomIcon("TileEntities/Compartment/15"); + public static final CustomIcon OVERLAY_COMPARTMENT_1 = new CustomIcon("TileEntities/Compartment/16"); + public static final CustomIcon OVERLAY_COMPARTMENT_2 = new CustomIcon("TileEntities/Compartment/17"); + public static final CustomIcon OVERLAY_COMPARTMENT_3 = new CustomIcon("TileEntities/Compartment/18"); + public static final CustomIcon OVERLAY_COMPARTMENT_4 = new CustomIcon("TileEntities/Compartment/19"); + public static final CustomIcon OVERLAY_COMPARTMENT_5 = new CustomIcon("TileEntities/Compartment/20"); + public static final CustomIcon OVERLAY_COMPARTMENT_6 = new CustomIcon("TileEntities/Compartment/21"); + public static final CustomIcon OVERLAY_COMPARTMENT_7 = new CustomIcon("TileEntities/Compartment/22"); + public static final CustomIcon OVERLAY_COMPARTMENT_8 = new CustomIcon("TileEntities/Compartment/23"); + public static final CustomIcon OVERLAY_COMPARTMENT_9 = new CustomIcon("TileEntities/Compartment/24"); + public static final CustomIcon OVERLAY_COMPARTMENT_10 = new CustomIcon("TileEntities/Compartment/25"); + public static final CustomIcon OVERLAY_COMPARTMENT_11 = new CustomIcon("TileEntities/Compartment/26"); + public static final CustomIcon OVERLAY_COMPARTMENT_12 = new CustomIcon("TileEntities/Compartment/27"); + public static final CustomIcon OVERLAY_COMPARTMENT_13 = new CustomIcon("TileEntities/Compartment/28"); + public static final CustomIcon OVERLAY_COMPARTMENT_14 = new CustomIcon("TileEntities/Compartment/29"); + public static final CustomIcon OVERLAY_COMPARTMENT_15 = new CustomIcon("TileEntities/Compartment/30"); + public static final CustomIcon OVERLAY_COMPARTMENT_16 = new CustomIcon("TileEntities/Compartment/31"); + + // Controllers + private static final CustomIcon Internal_Casing_Fusion_Simple_Front = + new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT"); + public static final CustomIcon Casing_Fusion_Simple_Front = Internal_Casing_Fusion_Simple_Front; + private static final CustomIcon Internal_Casing_Fusion_Simple_Front_Active = + new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE"); + public static final CustomIcon Casing_Fusion_Simple_Front_Active = Internal_Casing_Fusion_Simple_Front_Active; + + // Machine Casings + // Simple + private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); + public static final CustomIcon Casing_Machine_Simple_Top = Internal_Casing_Machine_Simple_Top; + private static final CustomIcon Internal_Casing_Machine_Simple_Bottom = + new CustomIcon("TileEntities/machine_bottom"); + public static final CustomIcon Casing_Machine_Simple_Bottom = Internal_Casing_Machine_Simple_Bottom; + // Advanced and Ultra + private static final CustomIcon Internal_Casing_Machine_Advanced = new CustomIcon("TileEntities/high_adv_machine"); + public static final CustomIcon Casing_Machine_Advanced = Internal_Casing_Machine_Advanced; + private static final CustomIcon Internal_Casing_Machine_Ultra = new CustomIcon("TileEntities/adv_machine_lesu"); + public static final CustomIcon Casing_Machine_Ultra = Internal_Casing_Machine_Ultra; + // Dimensional - Non Overlay + private static final CustomIcon Internal_Casing_Machine_Dimensional = + new CustomIcon("TileEntities/adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; + private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = + new CustomIcon("TileEntities/high_adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; + + // Material Casings + private static final CustomIcon Internal_Casing_Tantalloy61 = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); + public static final CustomIcon Casing_Material_Tantalloy61 = Internal_Casing_Tantalloy61; + private static final CustomIcon Internal_Casing_MaragingSteel = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_MARAGINGSTEEL"); + public static final CustomIcon Casing_Material_MaragingSteel = Internal_Casing_MaragingSteel; + private static final CustomIcon Internal_Casing_Stellite = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_STELLITE"); + public static final CustomIcon Casing_Material_Stellite = Internal_Casing_Stellite; + private static final CustomIcon Internal_Casing_Talonite = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TALONITE"); + public static final CustomIcon Casing_Material_Talonite = Internal_Casing_Talonite; + private static final CustomIcon Internal_Casing_Tumbaga = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TUMBAGA"); + public static final CustomIcon Casing_Material_Tumbaga = Internal_Casing_Tumbaga; + private static final CustomIcon Internal_Casing_Zeron100 = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZERON100"); + public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; + private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); + public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; + + private static final CustomIcon Internal_Casing_Grisium = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_GRISIUM"); + public static final CustomIcon Casing_Material_Grisium = Internal_Casing_Grisium; + private static final CustomIcon Internal_Casing_RedSteel = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_RED_STEEL"); + public static final CustomIcon Casing_Material_RedSteel = Internal_Casing_RedSteel; + private static final CustomIcon Internal_Casing_Incoloy020 = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_020"); + public static final CustomIcon Casing_Material_Incoloy020 = Internal_Casing_Incoloy020; + private static final CustomIcon Internal_Casing_IncoloyDS = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_DS"); + public static final CustomIcon Casing_Material_IncoloyDS = Internal_Casing_IncoloyDS; + private static final CustomIcon Internal_Casing_IncoloyMA956 = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_MA956"); + public static final CustomIcon Casing_Material_IncoloyMA956 = Internal_Casing_IncoloyMA956; + private static final CustomIcon Internal_Casing_ZirconiumCarbide = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE"); + public static final CustomIcon Casing_Material_ZirconiumCarbide = Internal_Casing_ZirconiumCarbide; + + private static final CustomIcon Internal_Casing_HastelloyX = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_HASTELLOY_X"); + public static final CustomIcon Casing_Material_HastelloyX = Internal_Casing_HastelloyX; + private static final CustomIcon Internal_Casing_HastelloyN = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_HASTELLOY_N"); + public static final CustomIcon Casing_Material_HastelloyN = Internal_Casing_HastelloyN; + private static final CustomIcon Internal_Casing_Fluid_IncoloyDS = + new CustomIcon("TileEntities/MACHINE_CASING_FLUID_INCOLOY_DS"); + public static final CustomIcon Casing_Material_Fluid_IncoloyDS = Internal_Casing_Fluid_IncoloyDS; + + private static final CustomIcon Internal_Casing_Laurenium = new CustomIcon("TileEntities/MACHINE_CASING_LAURENIUM"); + public static final CustomIcon Casing_Material_Laurenium = Internal_Casing_Laurenium; + + // Trinium Alloys + public static final CustomIcon Casing_Trinium_Titanium = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_TITANIUM"); + public static final CustomIcon Casing_Trinium_Naquadah = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH"); + public static final CustomIcon Casing_Trinium_Naquadah_Vent = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH_VENT"); + public static final CustomIcon Casing_Trinium_Naquadah_Carbon = + new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH_CARBON"); + + // Material Machine/Firebox Casings + private static final CustomIcon Internal_Casing_Staballoy_Firebox = + new CustomIcon("TileEntities/MACHINE_CASING_FIREBOX_STABALLOY"); + public static final CustomIcon Casing_Staballoy_Firebox = Internal_Casing_Staballoy_Firebox; + + // Misc Casings + private static final CustomIcon Internal_Casing_Machine_Redstone_Off = + new CustomIcon("TileEntities/cover_redstone_conductor"); + public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; + private static final CustomIcon Internal_Casing_Machine_Redstone_On = + new CustomIcon("TileEntities/cover_redstone_emitter"); + public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; + + // Redox Cells + public static final CustomIcon Casing_Redox_1 = new CustomIcon("redox/redox1"); + public static final CustomIcon Casing_Redox_2 = new CustomIcon("redox/redox2"); + public static final CustomIcon Casing_Redox_3 = new CustomIcon("redox/redox3"); + public static final CustomIcon Casing_Redox_4 = new CustomIcon("redox/redox4"); + public static final CustomIcon Casing_Redox_5 = new CustomIcon("redox/redox5"); + public static final CustomIcon Casing_Redox_6 = new CustomIcon("redox/redox6"); + // public static final CustomIcon Casing_Redox_7 = new CustomIcon("redox/redox7"); + // public static final CustomIcon Casing_Redox_8 = new CustomIcon("redox/redox8"); + + // Special Block 2 + public static final CustomIcon Casing_Resonance_1 = new CustomIcon("special/block_1"); + public static final CustomIcon Casing_Resonance_2 = new CustomIcon("special/block_2"); + public static final CustomIcon Casing_Resonance_3 = new CustomIcon("special/block_3"); + public static final CustomIcon Casing_Resonance_4 = new CustomIcon("special/block_4"); + public static final CustomIcon Casing_Modulator_1 = new CustomIcon("special/block_5"); + public static final CustomIcon Casing_Modulator_2 = new CustomIcon("special/block_6"); + public static final CustomIcon Casing_Modulator_3 = new CustomIcon("special/block_7"); + public static final CustomIcon Casing_Modulator_4 = new CustomIcon("special/block_8"); + + // Centrifuge Casing + private static final CustomIcon Internal_Casing_Centrifuge = + new CustomIcon("TileEntities/MACHINE_CASING_CENTRIFUGE"); + public static final CustomIcon Casing_Material_Centrifuge = Internal_Casing_Centrifuge; + + // MACHINE_CASING_FARM_MANAGER_STRUCTURAL + // Farm Manager Casings + private static final CustomIcon Internal_Casing_Machine_Farm_Manager = + new CustomIcon("TileEntities/MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + public static final CustomIcon Casing_Machine_Farm_Manager = Internal_Casing_Machine_Farm_Manager; + // Acacia_Log + private static final CustomIcon Internal_Casing_Machine_Acacia_Log = new CustomIcon("TileEntities/log_acacia_top"); + public static final CustomIcon Casing_Machine_Acacia_Log = Internal_Casing_Machine_Acacia_Log; + // Podzol Top + private static final CustomIcon Internal_Casing_Machine_Podzol = new CustomIcon("TileEntities/dirt_podzol_top"); + public static final CustomIcon Casing_Machine_Podzol = Internal_Casing_Machine_Podzol; + + // Structural Blocks + private static final CustomIcon Internal_Casing_Machine_Metal_Grate_A = new CustomIcon("chrono/MetalGrate"); + public static final CustomIcon Casing_Machine_Metal_Grate_A = Internal_Casing_Machine_Metal_Grate_A; + private static final CustomIcon Internal_Casing_Machine_Metal_Grate_A_Solid = + new CustomIcon("chrono/MetalGrateA_Solid"); + public static final CustomIcon Casing_Machine_Metal_Grate_A_Solid = Internal_Casing_Machine_Metal_Grate_A_Solid; + private static final CustomIcon Internal_Casing_Machine_Metal_Grate_B = new CustomIcon("chrono/MetalGrate2"); + public static final CustomIcon Casing_Machine_Metal_Grate_B = Internal_Casing_Machine_Metal_Grate_B; + private static final CustomIcon Internal_Casing_Machine_Metal_Panel_A = new CustomIcon("chrono/MetalPanel"); + public static final CustomIcon Casing_Machine_Metal_Panel_A = Internal_Casing_Machine_Metal_Panel_A; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_A = new CustomIcon("chrono/MetalSheet"); + public static final CustomIcon Casing_Machine_Metal_Sheet_A = Internal_Casing_Machine_Metal_Sheet_A; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_B = new CustomIcon("chrono/MetalSheet2"); + public static final CustomIcon Casing_Machine_Metal_Sheet_B = Internal_Casing_Machine_Metal_Sheet_B; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_C = new CustomIcon("chrono/MetalSheet3"); + public static final CustomIcon Casing_Machine_Metal_Sheet_C = Internal_Casing_Machine_Metal_Sheet_C; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_D = new CustomIcon("chrono/MetalSheet4"); + public static final CustomIcon Casing_Machine_Metal_Sheet_D = Internal_Casing_Machine_Metal_Sheet_D; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_E = new CustomIcon("chrono/MetalSheet5"); + public static final CustomIcon Casing_Machine_Metal_Sheet_E = Internal_Casing_Machine_Metal_Sheet_E; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_F = new CustomIcon("chrono/MetalSheet6"); + public static final CustomIcon Casing_Machine_Metal_Sheet_F = Internal_Casing_Machine_Metal_Sheet_F; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_G = new CustomIcon("chrono/MetalSheet7"); + public static final CustomIcon Casing_Machine_Metal_Sheet_G = Internal_Casing_Machine_Metal_Sheet_G; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_H = new CustomIcon("chrono/MetalSheet8"); + public static final CustomIcon Casing_Machine_Metal_Sheet_H = Internal_Casing_Machine_Metal_Sheet_H; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_I = new CustomIcon("chrono/MetalSheet9"); + public static final CustomIcon Casing_Machine_Metal_Sheet_I = Internal_Casing_Machine_Metal_Sheet_I; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_J = new CustomIcon("chrono/MetalSheet10"); + public static final CustomIcon Casing_Machine_Metal_Sheet_J = Internal_Casing_Machine_Metal_Sheet_J; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_K = new CustomIcon("chrono/MetalSheet11"); + public static final CustomIcon Casing_Machine_Metal_Sheet_K = Internal_Casing_Machine_Metal_Sheet_K; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_L = new CustomIcon("chrono/MetalSheet12"); + public static final CustomIcon Casing_Machine_Metal_Sheet_L = Internal_Casing_Machine_Metal_Sheet_L; + private static final CustomIcon Internal_Overlay_Machine_Cyber_A = new CustomIcon("chrono/CyberPanel"); + public static final CustomIcon Overlay_Machine_Cyber_A = Internal_Overlay_Machine_Cyber_A; + private static final CustomIcon Internal_Overlay_Machine_Cyber_B = new CustomIcon("chrono/CyberPanel2"); + public static final CustomIcon Overlay_Machine_Cyber_B = Internal_Overlay_Machine_Cyber_B; + + public static final CustomIcon TEXTURE_CASING_AMAZON = new CustomIcon("TileEntities/CASING_AMAZON"); + public static final CustomIcon TEXTURE_CASING_ADVANCED_CRYOGENIC = + new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_CRYOGENIC"); + public static final CustomIcon TEXTURE_CASING_ADVANCED_VOLCNUS = + new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_VOLCANUS"); + public static final CustomIcon TEXTURE_CASING_ROCKETDYNE = new CustomIcon("TileEntities/MACHINE_CASING_ROCKETDYNE"); + public static final CustomIcon TEXTURE_CASING_GRINDING_MILL = + new CustomIcon("TileEntities/MACHINE_CASING_GRINDING_FACTORY"); + public static final CustomIcon TEXTURE_CASING_FLOTATION = new CustomIcon("TileEntities/MACHINE_CASING_FLOTATION"); + + // Custom Pipes + public static final CustomIcon TEXTURE_PIPE_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_PIPE_T1"); + public static final CustomIcon TEXTURE_PIPE_GENERIC = new CustomIcon("iconsets/MACHINE_CASING_PIPE_GENERIC"); + + public static final CustomIcon TEXTURE_PIPE_T1_BABBIT_ALLOY = + new CustomIcon("iconsets/MACHINE_CASING_PIPE_BABBIT_ALLOY"); + public static final CustomIcon TEXTURE_PIPE_T2_INCONEL_690 = + new CustomIcon("iconsets/MACHINE_CASING_PIPE_INCONEL_690"); + public static final CustomIcon TEXTURE_PIPE_T3_STELLITE = new CustomIcon("iconsets/MACHINE_CASING_PIPE_STELLITE"); + public static final CustomIcon TEXTURE_PIPE_T4_NITINOL_60 = + new CustomIcon("iconsets/MACHINE_CASING_PIPE_NITINOL_60"); + public static final CustomIcon TEXTURE_PIPE_T5_LAFIUM = new CustomIcon("iconsets/MACHINE_CASING_PIPE_LAFIUM"); + public static final CustomIcon TEXTURE_PIPE_T6_CINOBITE = new CustomIcon("iconsets/MACHINE_CASING_PIPE_CINOBITE"); + public static final CustomIcon TEXTURE_PIPE_T7_TITANSTEEL = + new CustomIcon("iconsets/MACHINE_CASING_PIPE_TITANSTEEL"); + public static final CustomIcon TEXTURE_PIPE_T8_ABYSSAL = new CustomIcon("iconsets/MACHINE_CASING_PIPE_ABYSSAL"); + + // Custom Gearboxes + public static final CustomIcon TEXTURE_GEARBOX_GRINDING_MILL = + new CustomIcon("TileEntities/MACHINE_CASING_GEARBOX_T1"); + public static final CustomIcon TEXTURE_GEARBOX_GENERIC = new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_GENERIC"); + + public static final CustomIcon TEXTURE_GEARBOX_T1_EGLIN_STEEL = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_EGLIN_STEEL"); + public static final CustomIcon TEXTURE_GEARBOX_T2_INCONEL_792 = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_INCONEL_792"); + public static final CustomIcon TEXTURE_GEARBOX_T3_INCOLOY_MA956 = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_INCOLOY_MA956"); + public static final CustomIcon TEXTURE_GEARBOX_T4_NITINOL_60 = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_NITINOL_60"); + public static final CustomIcon TEXTURE_GEARBOX_T5_ZERON_100 = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_ZERON_100"); + public static final CustomIcon TEXTURE_GEARBOX_T6_PIKYONIUM = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_PIKYONIUM"); + public static final CustomIcon TEXTURE_GEARBOX_T7_TITANSTEEL = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_TITANSTEEL"); + public static final CustomIcon TEXTURE_GEARBOX_T8_ABYSSAL = + new CustomIcon("iconsets/MACHINE_CASING_GEARBOX_ABYSSAL"); + + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II = new CustomIcon("iconsets/MACHINE_CASING_FUSION_3"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_INNER = + new CustomIcon("iconsets/MACHINE_CASING_FUSION_COIL_II"); + public static final CustomIcon TEXTURE_CASING_FUSION_CASING_ULTRA = + new CustomIcon("iconsets/MACHINE_CASING_FUSION_GLASS_ULTRA"); + // + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_1 = new CustomIcon("iconsets/FUSIONIII_1"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_2 = new CustomIcon("iconsets/FUSIONIII_2"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_3 = new CustomIcon("iconsets/FUSIONIII_3"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_4 = new CustomIcon("iconsets/FUSIONIII_4"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_5 = new CustomIcon("iconsets/FUSIONIII_5"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_6 = new CustomIcon("iconsets/FUSIONIII_6"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_7 = new CustomIcon("iconsets/FUSIONIII_7"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_8 = new CustomIcon("iconsets/FUSIONIII_8"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_9 = new CustomIcon("iconsets/FUSIONIII_9"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_10 = new CustomIcon("iconsets/FUSIONIII_10"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_11 = new CustomIcon("iconsets/FUSIONIII_11"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_12 = new CustomIcon("iconsets/FUSIONIII_12"); + + // Overlays + // Fan Textures + private static final CustomIcon Internal_Overlay_Machine_Vent = + new CustomIcon("TileEntities/machine_top_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent = Internal_Overlay_Machine_Vent; + private static final CustomIcon Internal_Overlay_Machine_Vent_Fast = + new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); + public static final CustomIcon Overlay_Machine_Vent_Fast = Internal_Overlay_Machine_Vent_Fast; + private static final CustomIcon Internal_Overlay_Machine_Vent_Adv = + new CustomIcon("TileEntities/adv_machine_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent_Adv = Internal_Overlay_Machine_Vent_Adv; + private static final CustomIcon Internal_Overlay_Machine_Turbine_Active = + new CustomIcon("TileEntities/STEAM_TURBINE_SIDE_ACTIVE"); + public static final CustomIcon Overlay_Machine_Turbine_Active = Internal_Overlay_Machine_Turbine_Active; + // Grate Texture + public static final CustomIcon OVERLAY_GRATE_A = new CustomIcon("metro/OVERLAY_GRATE_A"); + // Speaker Texture + private static final CustomIcon Internal_Overlay_Machine_Sound = new CustomIcon("TileEntities/audio_out"); + public static final CustomIcon Overlay_Machine_Sound = Internal_Overlay_Machine_Sound; + private static final CustomIcon Internal_Overlay_Machine_Sound_Active = + new CustomIcon("TileEntities/audio_out_active"); + public static final CustomIcon Overlay_Machine_Sound_Active = Internal_Overlay_Machine_Sound_Active; + // Diesel Engines + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical = + new CustomIcon("TileEntities/machine_top_dieselmotor"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical = Internal_Overlay_Machine_Diesel_Vertical; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal = + new CustomIcon("TileEntities/machine_top_dieselmotor2"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal = Internal_Overlay_Machine_Diesel_Horizontal; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical_Active = + new CustomIcon("TileEntities/machine_top_dieselmotor_active"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical_Active = + Internal_Overlay_Machine_Diesel_Vertical_Active; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal_Active = + new CustomIcon("TileEntities/machine_top_dieselmotor2_active"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal_Active = + Internal_Overlay_Machine_Diesel_Horizontal_Active; + // Computer Screens + private static final CustomIcon Internal_Casing_Machine_Screen_1 = + new CustomIcon("TileEntities/adv_machine_screen_random1"); + public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; + private static final CustomIcon Internal_Casing_Machine_Screen_2 = + new CustomIcon("TileEntities/adv_machine_screen_random2"); + public static final CustomIcon Casing_Machine_Screen_2 = Internal_Casing_Machine_Screen_2; + private static final CustomIcon Internal_Casing_Machine_Screen_3 = + new CustomIcon("TileEntities/adv_machine_screen_random3"); + public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; + private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = + new CustomIcon("TileEntities/adv_machine_screen_frequency"); + public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; + private static final CustomIcon Internal_Overlay_Machine_Screen_Logo = + new CustomIcon("TileEntities/adv_machine_screen_logo"); + public static final CustomIcon Overlay_Machine_Screen_Logo = Internal_Overlay_Machine_Screen_Logo; + private static final CustomIcon Internal_Overlay_Machine_Cyber_Interface = new CustomIcon("chrono/Overlay_Cyber"); + public static final CustomIcon Overlay_Machine_Cyber_Interface = Internal_Overlay_Machine_Cyber_Interface; + + // Machine Controller Overlays + private static final CustomIcon Internal_Overlay_Machine_Controller_Default = + new CustomIcon("iconsets/OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ANIMATED"); + public static final CustomIcon Overlay_Machine_Controller_Default = Internal_Overlay_Machine_Controller_Default; + private static final CustomIcon Internal_Overlay_Machine_Controller_Default_Active = + new CustomIcon("iconsets/OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ANIMATED_ACTIVE"); + public static final CustomIcon Overlay_Machine_Controller_Default_Active = + Internal_Overlay_Machine_Controller_Default_Active; + + private static final CustomIcon Internal_Overlay_Machine_Controller_Advanced = + new CustomIcon("iconsets/OVERLAY_FRONT_ADVANCED_MULTIBLOCK_ANIMATED"); + public static final CustomIcon Overlay_Machine_Controller_Advanced = Internal_Overlay_Machine_Controller_Advanced; + private static final CustomIcon Internal_Overlay_Machine_Controller_Advanced_Active = + new CustomIcon("iconsets/OVERLAY_FRONT_ADVANCED_MULTIBLOCK_ANIMATED_ACTIVE"); + public static final CustomIcon Overlay_Machine_Controller_Advanced_Active = + Internal_Overlay_Machine_Controller_Advanced_Active; + + // Fluid Reactor Overlays + public static final CustomIcon Overlay_FluidReactor_Front = + new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT"); + public static final CustomIcon Overlay_FluidReactor_Side = new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE"); + public static final CustomIcon Overlay_FluidReactor_Top = new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP"); + public static final CustomIcon Overlay_FluidReactor_Front_Active = + new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT_ACTIVE"); + public static final CustomIcon Overlay_FluidReactor_Side_Active = + new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE_ACTIVE"); + public static final CustomIcon Overlay_FluidReactor_Top_Active = + new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP_ACTIVE"); + + // Crafting Overlays + public static final CustomIcon Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); + public static final CustomIcon Overlay_Crafting_Steel = new CustomIcon("TileEntities/cover_crafting"); + + public static final CustomIcon Casing_Workbench_Crafting_Overlay = + new CustomIcon("TileEntities/gt4/bronze_top_crafting"); + public static final CustomIcon Casing_Workbench_Top = new CustomIcon("TileEntities/gt4/bronze_top"); + public static final CustomIcon Casing_Workbench_Side = new CustomIcon("TileEntities/gt4/bronze_side"); + public static final CustomIcon Casing_Workbench_Bottom = new CustomIcon("TileEntities/gt4/bronze_bottom"); + public static final CustomIcon Casing_Adv_Workbench_Crafting_Overlay = + new CustomIcon("TileEntities/gt4/machine_top_crafting"); + public static final CustomIcon Casing_Adv_Workbench_Top = new CustomIcon("TileEntities/gt4/machine_top"); + public static final CustomIcon Casing_Adv_Workbench_Side = new CustomIcon("TileEntities/gt4/machine_side"); + public static final CustomIcon Casing_Adv_Workbench_Bottom = new CustomIcon("TileEntities/gt4/machine_bottom"); + + public static final CustomIcon Casing_Redstone_Top_Off = + new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_off"); + public static final CustomIcon Casing_Redstone_Top_Main_Off = + new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_main_off"); + public static final CustomIcon Casing_Redstone_Top_On = + new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_on"); + public static final CustomIcon Casing_Redstone_Top_Main_On = + new CustomIcon("TileEntities/gt4/redstone/machine_top_redstone_main_on"); + + public static final CustomIcon Casing_Redstone_Side_Off = + new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_off"); + public static final CustomIcon Casing_Redstone_Side_Main_Off = + new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_main_off"); + public static final CustomIcon Casing_Redstone_Side_On = + new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_on"); + public static final CustomIcon Casing_Redstone_Side_Main_On = + new CustomIcon("TileEntities/gt4/redstone/machine_side_redstone_main_on"); + + public static final CustomIcon Casing_Redstone_Bottom_Off = + new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_off"); + public static final CustomIcon Casing_Redstone_Bottom_Main_Off = + new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_main_off"); + public static final CustomIcon Casing_Redstone_Bottom_On = + new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_on"); + public static final CustomIcon Casing_Redstone_Bottom_Main_On = + new CustomIcon("TileEntities/gt4/redstone/machine_bottom_redstone_main_on"); + + public static final CustomIcon Casing_Electric_Auto_Workbench_Side = + new CustomIcon("TileEntities/gt4/OVERLAY_SIDE_CABINET"); + public static final CustomIcon Casing_Computer_Cube = new CustomIcon("TileEntities/gt4/computer"); + + public static final CustomIcon Casing_CropHarvester_Cutter = new CustomIcon("TileEntities/gt4/OVERLAY_CROP"); + public static final CustomIcon Casing_CropHarvester_Boxes = new CustomIcon("TileEntities/gt4/OVERLAY_BOXES"); + + public static final CustomIcon Casing_InventoryManagaer_Cyan = new CustomIcon("TileEntities/gt4/OVERLAY_CYAN"); + public static final CustomIcon Casing_InventoryManagaer_Green = new CustomIcon("TileEntities/gt4/OVERLAY_GREEN"); + public static final CustomIcon Casing_InventoryManagaer_Purple = new CustomIcon("TileEntities/gt4/OVERLAY_PURPLE"); + public static final CustomIcon Casing_InventoryManagaer_Red = new CustomIcon("TileEntities/gt4/OVERLAY_RED"); + public static final CustomIcon Casing_InventoryManagaer_Yellow = new CustomIcon("TileEntities/gt4/OVERLAY_YELLOW"); + public static final CustomIcon Casing_InventoryManagaer_Blue = new CustomIcon("TileEntities/gt4/OVERLAY_BLUE"); + + public static final CustomIcon Casing_InventoryManagaer_Cyan_Redstone = + new CustomIcon("TileEntities/gt4/OVERLAY_CYAN_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Green_Redstone = + new CustomIcon("TileEntities/gt4/OVERLAY_GREEN_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Purple_Redstone = + new CustomIcon("TileEntities/gt4/OVERLAY_PURPLE_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Red_Redstone = + new CustomIcon("TileEntities/gt4/OVERLAY_RED_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Yellow_Redstone = + new CustomIcon("TileEntities/gt4/OVERLAY_YELLOW_REDSTONE"); + public static final CustomIcon Casing_InventoryManagaer_Blue_Redstone = + new CustomIcon("TileEntities/gt4/OVERLAY_BLUE_REDSTONE"); + + private static final CustomIcon Casing_Test_1 = new CustomIcon("number/1"); + private static final CustomIcon Casing_Test_2 = new CustomIcon("number/2"); + private static final CustomIcon Casing_Test_3 = new CustomIcon("number/3"); + private static final CustomIcon Casing_Test_4 = new CustomIcon("number/4"); + private static final CustomIcon Casing_Test_5 = new CustomIcon("number/5"); + private static final CustomIcon Casing_Test_6 = new CustomIcon("number/6"); + private static final CustomIcon Casing_Test_7 = new CustomIcon("number/7"); + private static final CustomIcon Casing_Test_8 = new CustomIcon("number/8"); + private static final CustomIcon Casing_Test_9 = new CustomIcon("number/9"); + private static final CustomIcon Casing_Test_10 = new CustomIcon("number/10"); + private static final CustomIcon Casing_Test_11 = new CustomIcon("number/11"); + private static final CustomIcon Casing_Test_12 = new CustomIcon("number/12"); + private static final CustomIcon Casing_Test_13 = new CustomIcon("number/13"); + private static final CustomIcon Casing_Test_14 = new CustomIcon("number/14"); + private static final CustomIcon Casing_Test_15 = new CustomIcon("number/15"); + private static final CustomIcon Casing_Test_16 = new CustomIcon("number/16"); + + public static final CustomIcon[] TEST_NUMBER = new CustomIcon[] { + Casing_Test_1, Casing_Test_2, Casing_Test_3, Casing_Test_4, + Casing_Test_5, Casing_Test_6, Casing_Test_7, Casing_Test_8, + Casing_Test_9, Casing_Test_10, Casing_Test_11, Casing_Test_12, + Casing_Test_13, Casing_Test_14, Casing_Test_15, Casing_Test_16 + }; + + // Covers + private static final CustomIcon Internal_Overlay_Overflow_Valve = new CustomIcon("iconsets/OVERLAY_OVERFLOW_VALVE"); + public static final CustomIcon Overlay_Overflow_Valve = Internal_Overlay_Overflow_Valve; + + // Hatch Overlays + // Charger Texture + private static final CustomIcon Internal_Overlay_Hatch_Charger = new CustomIcon("TileEntities/cover_charger"); + public static final CustomIcon Overlay_Hatch_Charger = Internal_Overlay_Hatch_Charger; + // Discharger Texture + private static final CustomIcon Internal_Overlay_Hatch_Discharger = new CustomIcon("TileEntities/cover_discharge"); + public static final CustomIcon Overlay_Hatch_Discharger = Internal_Overlay_Hatch_Discharger; + // Advanced Muffler + private static final CustomIcon Internal_Overlay_Hatch_Muffler_Adv = new CustomIcon("iconsets/OVERLAY_MUFFLER_ADV"); + public static final CustomIcon Overlay_Hatch_Muffler_Adv = Internal_Overlay_Hatch_Muffler_Adv; + // Control Core Bus + private static final CustomIcon Internal_Overlay_Hatch_Control_Core = + new CustomIcon("iconsets/OVERLAY_CONTROL_CORE_BUS"); + public static final CustomIcon Overlay_Hatch_Control_Core = Internal_Overlay_Hatch_Control_Core; + // Milling Ball Bus + private static final CustomIcon Internal_Overlay_Bus_Milling_Balls = + new CustomIcon("iconsets/OVERLAY_MILLING_BALL_BUS"); + public static final CustomIcon Overlay_Bus_Milling_Balls = Internal_Overlay_Bus_Milling_Balls; + // Catalyst Bus + private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS"); + public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst; + + public static final CustomIcon Overlay_Cobble = new CustomIcon("iconsets/OVERLAY_COBBLE"); + public static final CustomIcon Overlay_Connector = new CustomIcon("iconsets/OVERLAY_CONNECTOR"); + public static final CustomIcon Overlay_Fire = new CustomIcon("iconsets/OVERLAY_FIRE"); + public static final CustomIcon Overlay_Grinder = new CustomIcon("iconsets/OVERLAY_GRINDER"); + public static final CustomIcon Overlay_GT_Logo = new CustomIcon("iconsets/OVERLAY_GT"); + public static final CustomIcon Overlay_Ice = new CustomIcon("iconsets/OVERLAY_ICE"); + public static final CustomIcon Overlay_Implosion = new CustomIcon("iconsets/OVERLAY_IMPLOSION"); + // Lapo Orb Hatch + public static final CustomIcon Overlay_Hatch_Lapo_Orb = new CustomIcon("iconsets/OVERLAY_LAPO"); + // Data Orb Hatch + public static final CustomIcon Overlay_Hatch_Data_Orb = new CustomIcon("iconsets/OVERLAY_DATA_ORB"); + + // RTG Hatch + private static final CustomIcon Internal_Overlay_Hatch_RTG_Off = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_OFF"); + public static final CustomIcon Overlay_Hatch_RTG_Off = Internal_Overlay_Hatch_RTG_Off; + private static final CustomIcon Internal_Overlay_Hatch_RTG_On = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_ON"); + public static final CustomIcon Overlay_Hatch_RTG_On = Internal_Overlay_Hatch_RTG_On; + + // Dimensional + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = + new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); + public static final CustomIcon Overlay_Machine_Dimensional_Blue = Internal_Overlay_Machine_Dimensional_Blue; + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Orange = + new CustomIcon("TileEntities/adv_machine_dimensional_cover_orange"); + public static final CustomIcon Overlay_Machine_Dimensional_Orange = Internal_Overlay_Machine_Dimensional_Orange; + // Icons + private static final CustomIcon Internal_Overlay_MatterFab = new CustomIcon("TileEntities/adv_machine_matterfab"); + public static final CustomIcon Overlay_MatterFab = Internal_Overlay_MatterFab; + private static final CustomIcon Internal_Overlay_MatterFab_Active = + new CustomIcon("TileEntities/adv_machine_matterfab_active"); + public static final CustomIcon Overlay_MatterFab_Active = Internal_Overlay_MatterFab_Active; + + private static final CustomIcon Internal_Overlay_MatterFab_Animated = + new CustomIcon("TileEntities/adv_machine_matterfab_animated"); + public static final CustomIcon Overlay_MatterFab_Animated = Internal_Overlay_MatterFab_Animated; + private static final CustomIcon Internal_Overlay_MatterFab_Active_Animated = + new CustomIcon("TileEntities/adv_machine_matterfab_active_animated"); + public static final CustomIcon Overlay_MatterFab_Active_Animated = Internal_Overlay_MatterFab_Active_Animated; + + private static final CustomIcon Internal_Overlay_Oil = new CustomIcon("TileEntities/adv_machine_oil"); + public static final CustomIcon Overlay_Oil = Internal_Overlay_Oil; + private static final CustomIcon Internal_Overlay_Water = new CustomIcon("TileEntities/adv_machine_water"); + public static final CustomIcon Overlay_Water = Internal_Overlay_Water; + private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); + public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; + + // GT++ Tiered Hulls + public static final CustomIcon TEXTURE_CASING_TIERED_ULV = new CustomIcon("iconsets/TieredHulls/CASING_ULV"); + public static final CustomIcon TEXTURE_CASING_TIERED_LV = new CustomIcon("iconsets/TieredHulls/CASING_LV"); + public static final CustomIcon TEXTURE_CASING_TIERED_MV = new CustomIcon("iconsets/TieredHulls/CASING_MV"); + public static final CustomIcon TEXTURE_CASING_TIERED_HV = new CustomIcon("iconsets/TieredHulls/CASING_HV"); + public static final CustomIcon TEXTURE_CASING_TIERED_EV = new CustomIcon("iconsets/TieredHulls/CASING_EV"); + public static final CustomIcon TEXTURE_CASING_TIERED_IV = new CustomIcon("iconsets/TieredHulls/CASING_IV"); + public static final CustomIcon TEXTURE_CASING_TIERED_LuV = new CustomIcon("iconsets/TieredHulls/CASING_LuV"); + public static final CustomIcon TEXTURE_CASING_TIERED_ZPM = new CustomIcon("iconsets/TieredHulls/CASING_ZPM"); + public static final CustomIcon TEXTURE_CASING_TIERED_UV = new CustomIcon("iconsets/TieredHulls/CASING_UV"); + public static final CustomIcon TEXTURE_CASING_TIERED_MAX = new CustomIcon("iconsets/TieredHulls/CASING_MAX"); + + // Metroid related + public static final CustomIcon TEXTURE_METAL_PANEL_A = new CustomIcon("metro/TEXTURE_METAL_PANEL_A"); + public static final CustomIcon TEXTURE_METAL_PANEL_B = new CustomIcon("metro/TEXTURE_METAL_PANEL_B"); + public static final CustomIcon TEXTURE_METAL_PANEL_C = new CustomIcon("metro/TEXTURE_METAL_PANEL_C"); + public static final CustomIcon TEXTURE_METAL_PANEL_D = new CustomIcon("metro/TEXTURE_METAL_PANEL_D"); + public static final CustomIcon TEXTURE_METAL_PANEL_E = new CustomIcon("metro/TEXTURE_METAL_PANEL_E"); + public static final CustomIcon TEXTURE_METAL_PANEL_F = new CustomIcon("metro/TEXTURE_METAL_PANEL_F"); + public static final CustomIcon TEXTURE_METAL_PANEL_G = new CustomIcon("metro/TEXTURE_METAL_PANEL_G"); + public static final CustomIcon TEXTURE_METAL_PANEL_H = new CustomIcon("metro/TEXTURE_METAL_PANEL_H"); + public static final CustomIcon TEXTURE_METAL_PANEL_I = new CustomIcon("metro/TEXTURE_METAL_PANEL_I"); + + public static final CustomIcon TEXTURE_MAGIC_PANEL_A = new CustomIcon("metro/TEXTURE_MAGIC_A"); + public static final CustomIcon TEXTURE_MAGIC_PANEL_B = new CustomIcon("metro/TEXTURE_MAGIC_B"); + + public static final CustomIcon TEXTURE_ORGANIC_PANEL_A = new CustomIcon("metro/TEXTURE_ORGANIC_PANEL_A"); + public static final CustomIcon TEXTURE_ORGANIC_PANEL_A_GLOWING = + new CustomIcon("metro/TEXTURE_ORGANIC_PANEL_A_GLOWING"); + + public static final CustomIcon TEXTURE_STONE_BIRD_A = new CustomIcon("metro/TEXTURE_STONE_BIRD_A"); + public static final CustomIcon TEXTURE_STONE_BIRD_A_LEFT = new CustomIcon("metro/TEXTURE_STONE_BIRD_A_LEFT"); + public static final CustomIcon TEXTURE_STONE_BIRD_A_RIGHT = new CustomIcon("metro/TEXTURE_STONE_BIRD_A_RIGHT"); + public static final CustomIcon TEXTURE_STONE_RED_A = new CustomIcon("metro/TEXTURE_STONE_RED_A"); + public static final CustomIcon TEXTURE_STONE_RED_B = new CustomIcon("metro/TEXTURE_STONE_RED_B"); + public static final CustomIcon TEXTURE_STONE_BLUE_A = new CustomIcon("metro/TEXTURE_STONE_BLUE_A"); + public static final CustomIcon TEXTURE_STONE_GREEN_A = new CustomIcon("metro/TEXTURE_STONE_GREEN_A"); + public static final CustomIcon TEXTURE_STONE_TABLET_A = new CustomIcon("metro/TEXTURE_STONE_TABLET_A"); + public static final CustomIcon TEXTURE_STONE_TABLET_B = new CustomIcon("metro/TEXTURE_STONE_TABLET_B"); + + public static final CustomIcon TEXTURE_TECH_A = new CustomIcon("metro/TEXTURE_TECH_A"); + public static final CustomIcon TEXTURE_TECH_B = new CustomIcon("metro/TEXTURE_TECH_B"); + public static final CustomIcon TEXTURE_TECH_C = new CustomIcon("metro/TEXTURE_TECH_C"); + + public static final CustomIcon TEXTURE_TECH_PANEL_A = new CustomIcon("metro/TEXTURE_TECH_PANEL_A"); + public static final CustomIcon TEXTURE_TECH_PANEL_B = new CustomIcon("metro/TEXTURE_TECH_PANEL_B"); + public static final CustomIcon TEXTURE_TECH_PANEL_C = new CustomIcon("metro/TEXTURE_TECH_PANEL_C"); + public static final CustomIcon TEXTURE_TECH_PANEL_D = new CustomIcon("metro/TEXTURE_TECH_PANEL_D"); + public static final CustomIcon TEXTURE_TECH_PANEL_E = new CustomIcon("metro/TEXTURE_TECH_PANEL_E"); + public static final CustomIcon TEXTURE_TECH_PANEL_F = new CustomIcon("metro/TEXTURE_TECH_PANEL_F"); + public static final CustomIcon TEXTURE_TECH_PANEL_G = new CustomIcon("metro/TEXTURE_TECH_PANEL_G"); + public static final CustomIcon TEXTURE_TECH_PANEL_H = new CustomIcon("metro/TEXTURE_TECH_PANEL_H"); + public static final CustomIcon TEXTURE_TECH_PANEL_I = new CustomIcon("metro/TEXTURE_TECH_PANEL_I"); + + public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE = + new CustomIcon("TileEntities/DecayablesChest_bottom"); + public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE_ALT = + new CustomIcon("TileEntities/DecayablesChest_top"); + + // LFTR Single blocks + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_FRONT = + new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_FRONT"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_FRONT_ACTIVE = + new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_FRONT_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_SIDE = + new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_SIDE"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_SIDE_ACTIVE = + new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_SIDE_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_TOP = + new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_TOP"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE = + new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_TOP_ACTIVE"); + + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_FRONT = + new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_FRONT"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_FRONT_ACTIVE = + new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_FRONT_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_SIDE = + new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_SIDE"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_SIDE_ACTIVE = + new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_SIDE_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_TOP = + new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_TOP"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE = + new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_TOP_ACTIVE"); + + // Overlay Arrays + public static ITexture[] OVERLAYS_ENERGY_OUT_BUFFER = new ITexture[] { + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {255, 100, 0, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {255, 255, 30, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {128, 128, 128, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, new short[] {240, 240, 245, 0}) + }; + + public static ITexture[] OVERLAYS_ENERGY_OUT_MULTI_BUFFER = new ITexture[] { + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {255, 100, 0, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {255, 255, 30, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {128, 128, 128, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] {240, 240, 245, 0}) + }; + + public static ITexture[] OVERLAYS_CABINET_FRONT = new ITexture[] { + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_1, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_2, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_3, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_4, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_5, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_6, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_7, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_8, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_9, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_10, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_11, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_12, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_13, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_14, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_15, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_16, new short[] {255, 255, 255, 0}), + }; + + public static ITexture[] OVERLAYS_COMPARTMENT_FRONT = new ITexture[] { + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_1, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_2, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_3, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_4, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_5, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_6, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_7, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_8, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_9, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_10, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_11, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_12, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_13, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_14, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_15, new short[] {255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_16, new short[] {255, 255, 255, 0}), + }; + + public static IIconContainer[] CONNECTED_FUSION_HULLS = new IIconContainer[] { + TEXTURE_CASING_FUSION_COIL_II_1, TEXTURE_CASING_FUSION_COIL_II_2, TEXTURE_CASING_FUSION_COIL_II_3, + TEXTURE_CASING_FUSION_COIL_II_4, TEXTURE_CASING_FUSION_COIL_II_5, TEXTURE_CASING_FUSION_COIL_II_6, + TEXTURE_CASING_FUSION_COIL_II_7, TEXTURE_CASING_FUSION_COIL_II_8, TEXTURE_CASING_FUSION_COIL_II_9, + TEXTURE_CASING_FUSION_COIL_II_10, TEXTURE_CASING_FUSION_COIL_II_11, TEXTURE_CASING_FUSION_COIL_II_12 + }; + + public static IIconContainer[] TIERED_MACHINE_HULLS = new IIconContainer[] { + TEXTURE_CASING_TIERED_ULV, + TEXTURE_CASING_TIERED_LV, + TEXTURE_CASING_TIERED_MV, + TEXTURE_CASING_TIERED_HV, + TEXTURE_CASING_TIERED_EV, + TEXTURE_CASING_TIERED_IV, + TEXTURE_CASING_TIERED_LuV, + TEXTURE_CASING_TIERED_ZPM, + TEXTURE_CASING_TIERED_UV, + TEXTURE_CASING_TIERED_MAX + }; + + public static Object Casing_Material_Turbine; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java index cc5cf3d55e..bb09531d10 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java @@ -4,29 +4,32 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIco public class TexturesGtCutomCovers { - public static final CustomIcon[] TEXTURE_ZTONES_AGON = new CustomIcon[16]; - public static final CustomIcon[] TEXTURE_ZTONES_ISZM = new CustomIcon[16]; - public static final CustomIcon[] TEXTURE_ZTONES_KORP = new CustomIcon[16]; - public static final CustomIcon[] TEXTURE_ZTONES_JELT = new CustomIcon[16]; - public static final CustomIcon[] TEXTURE_ZTONES_BITT = new CustomIcon[16]; - - public static void init() { - generateZTones(); - } + public static final CustomIcon[] TEXTURE_ZTONES_AGON = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_ISZM = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_KORP = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_JELT = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_BITT = new CustomIcon[16]; - private static void generateZTones() { - // ZTONES - String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" }; - int aArrayIndex = 0; - CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, - TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT }; + public static void init() { + generateZTones(); + } - for (CustomIcon[] t : aArrays) { - for (int s = 0; s < 16; s++) { - t[s] = new CustomIcon("Ztones", "sets/" + aZtoneCoverTextureNames[aArrayIndex] + "/"+aZtoneCoverTextureNames[aArrayIndex]+"_ (" + s + ")"); - } - aArrayIndex++; - } - } + private static void generateZTones() { + // ZTONES + String[] aZtoneCoverTextureNames = new String[] {"agon", "iszm", "korp", "jelt", "bitt"}; + int aArrayIndex = 0; + CustomIcon[][] aArrays = new CustomIcon[][] { + TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT + }; + for (CustomIcon[] t : aArrays) { + for (int s = 0; s < 16; s++) { + t[s] = new CustomIcon( + "Ztones", + "sets/" + aZtoneCoverTextureNames[aArrayIndex] + "/" + aZtoneCoverTextureNames[aArrayIndex] + + "_ (" + s + ")"); + } + aArrayIndex++; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java index ee104eaca3..b068d12d26 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java @@ -1,61 +1,51 @@ package gtPlusPlus.xmod.gregtech.common.blocks.textures; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - import gregtech.api.GregTech_API; import gregtech.api.interfaces.IIconContainer; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; public final class TexturesGtTools { - public final static CustomIcon SKOOKUM_CHOOCHER = new CustomIcon("iconsets/SKOOKUMCHOOCHER"); - public final static CustomIcon ANGLE_GRINDER = new CustomIcon("iconsets/ANGLE_GRINDER"); - public final static CustomIcon ELECTRIC_SNIPS = new CustomIcon("iconsets/ELECTRIC_SNIPS"); - public final static CustomIcon ELECTRIC_LIGHTER = new CustomIcon("iconsets/ELECTRIC_LIGHTER"); - public final static CustomIcon ELECTRIC_BUTCHER_KNIFE = new CustomIcon("iconsets/ELECTRIC_BUTCHER_KNIFE"); - - - - - - - - - public final static class CustomIcon implements IIconContainer, Runnable { - protected IIcon mIcon, mOverlay; - protected final String mIconName; - - public CustomIcon(final String aIconName) { - this.mIconName = aIconName; - Logger.INFO("Constructing a Custom Texture. " + this.mIconName); - GregTech_API.sGTItemIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return this.mOverlay; - } - - @Override - public void run() { - this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName); - //Utils.LOG_INFO("Registering a Custom Texture. "+mIcon.g); - this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName + "_OVERLAY"); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationItemsTexture; - } - } - + public static final CustomIcon SKOOKUM_CHOOCHER = new CustomIcon("iconsets/SKOOKUMCHOOCHER"); + public static final CustomIcon ANGLE_GRINDER = new CustomIcon("iconsets/ANGLE_GRINDER"); + public static final CustomIcon ELECTRIC_SNIPS = new CustomIcon("iconsets/ELECTRIC_SNIPS"); + public static final CustomIcon ELECTRIC_LIGHTER = new CustomIcon("iconsets/ELECTRIC_LIGHTER"); + public static final CustomIcon ELECTRIC_BUTCHER_KNIFE = new CustomIcon("iconsets/ELECTRIC_BUTCHER_KNIFE"); + + public static final class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon, mOverlay; + protected final String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + Logger.INFO("Constructing a Custom Texture. " + this.mIconName); + GregTech_API.sGTItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName); + // Utils.LOG_INFO("Registering a Custom Texture. "+mIcon.g); + this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName + "_OVERLAY"); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java index 7169861340..b811f601e2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java @@ -76,7 +76,6 @@ import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU_ACTIVE9; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaSpecialMultiCasings; import net.minecraft.tileentity.TileEntity; @@ -85,288 +84,348 @@ import net.minecraft.world.IBlockAccess; public class LargeTurbineTextureHandler { - /** - * LP Turbines - */ + /** + * LP Turbines + */ + public static BlockIcons[] OVERLAY_LP_TURBINE = new BlockIcons[] { + LARGETURBINE_ST1, + LARGETURBINE_ST2, + LARGETURBINE_ST3, + LARGETURBINE_ST4, + LARGETURBINE_ST5, + LARGETURBINE_ST6, + LARGETURBINE_ST7, + LARGETURBINE_ST8, + LARGETURBINE_ST9, + }; - public static BlockIcons[] OVERLAY_LP_TURBINE = new BlockIcons[]{ - LARGETURBINE_ST1, - LARGETURBINE_ST2, - LARGETURBINE_ST3, - LARGETURBINE_ST4, - LARGETURBINE_ST5, - LARGETURBINE_ST6, - LARGETURBINE_ST7, - LARGETURBINE_ST8, - LARGETURBINE_ST9, - }; + public static BlockIcons[] OVERLAY_LP_TURBINE_ACTIVE = new BlockIcons[] { + LARGETURBINE_ST_ACTIVE1, + LARGETURBINE_ST_ACTIVE2, + LARGETURBINE_ST_ACTIVE3, + LARGETURBINE_ST_ACTIVE4, + LARGETURBINE_ST_ACTIVE5, + LARGETURBINE_ST_ACTIVE6, + LARGETURBINE_ST_ACTIVE7, + LARGETURBINE_ST_ACTIVE8, + LARGETURBINE_ST_ACTIVE9, + }; - public static BlockIcons[] OVERLAY_LP_TURBINE_ACTIVE = new BlockIcons[]{ - LARGETURBINE_ST_ACTIVE1, - LARGETURBINE_ST_ACTIVE2, - LARGETURBINE_ST_ACTIVE3, - LARGETURBINE_ST_ACTIVE4, - LARGETURBINE_ST_ACTIVE5, - LARGETURBINE_ST_ACTIVE6, - LARGETURBINE_ST_ACTIVE7, - LARGETURBINE_ST_ACTIVE8, - LARGETURBINE_ST_ACTIVE9, - }; + /** + * HP Turbines + */ + public static BlockIcons[] OVERLAY_HP_TURBINE = new BlockIcons[] { + LARGETURBINE_TI1, + LARGETURBINE_TI2, + LARGETURBINE_TI3, + LARGETURBINE_TI4, + LARGETURBINE_TI5, + LARGETURBINE_TI6, + LARGETURBINE_TI7, + LARGETURBINE_TI8, + LARGETURBINE_TI9, + }; - /** - * HP Turbines - */ + public static BlockIcons[] OVERLAY_HP_TURBINE_ACTIVE = new BlockIcons[] { + LARGETURBINE_TI_ACTIVE1, + LARGETURBINE_TI_ACTIVE2, + LARGETURBINE_TI_ACTIVE3, + LARGETURBINE_TI_ACTIVE4, + LARGETURBINE_TI_ACTIVE5, + LARGETURBINE_TI_ACTIVE6, + LARGETURBINE_TI_ACTIVE7, + LARGETURBINE_TI_ACTIVE8, + LARGETURBINE_TI_ACTIVE9, + }; - public static BlockIcons[] OVERLAY_HP_TURBINE = new BlockIcons[]{ - LARGETURBINE_TI1, - LARGETURBINE_TI2, - LARGETURBINE_TI3, - LARGETURBINE_TI4, - LARGETURBINE_TI5, - LARGETURBINE_TI6, - LARGETURBINE_TI7, - LARGETURBINE_TI8, - LARGETURBINE_TI9, - }; + /** + * Gas Turbines + */ + public static BlockIcons[] OVERLAY_GAS_TURBINE = new BlockIcons[] { + LARGETURBINE_SS1, + LARGETURBINE_SS2, + LARGETURBINE_SS3, + LARGETURBINE_SS4, + LARGETURBINE_SS5, + LARGETURBINE_SS6, + LARGETURBINE_SS7, + LARGETURBINE_SS8, + LARGETURBINE_SS9, + }; - public static BlockIcons[] OVERLAY_HP_TURBINE_ACTIVE = new BlockIcons[]{ - LARGETURBINE_TI_ACTIVE1, - LARGETURBINE_TI_ACTIVE2, - LARGETURBINE_TI_ACTIVE3, - LARGETURBINE_TI_ACTIVE4, - LARGETURBINE_TI_ACTIVE5, - LARGETURBINE_TI_ACTIVE6, - LARGETURBINE_TI_ACTIVE7, - LARGETURBINE_TI_ACTIVE8, - LARGETURBINE_TI_ACTIVE9, - }; - - /** - * Gas Turbines - */ - - public static BlockIcons[] OVERLAY_GAS_TURBINE = new BlockIcons[]{ - LARGETURBINE_SS1, - LARGETURBINE_SS2, - LARGETURBINE_SS3, - LARGETURBINE_SS4, - LARGETURBINE_SS5, - LARGETURBINE_SS6, - LARGETURBINE_SS7, - LARGETURBINE_SS8, - LARGETURBINE_SS9, - }; + public static BlockIcons[] OVERLAY_GAS_TURBINE_ACTIVE = new BlockIcons[] { + LARGETURBINE_SS_ACTIVE1, + LARGETURBINE_SS_ACTIVE2, + LARGETURBINE_SS_ACTIVE3, + LARGETURBINE_SS_ACTIVE4, + LARGETURBINE_SS_ACTIVE5, + LARGETURBINE_SS_ACTIVE6, + LARGETURBINE_SS_ACTIVE7, + LARGETURBINE_SS_ACTIVE8, + LARGETURBINE_SS_ACTIVE9, + }; - public static BlockIcons[] OVERLAY_GAS_TURBINE_ACTIVE = new BlockIcons[]{ - LARGETURBINE_SS_ACTIVE1, - LARGETURBINE_SS_ACTIVE2, - LARGETURBINE_SS_ACTIVE3, - LARGETURBINE_SS_ACTIVE4, - LARGETURBINE_SS_ACTIVE5, - LARGETURBINE_SS_ACTIVE6, - LARGETURBINE_SS_ACTIVE7, - LARGETURBINE_SS_ACTIVE8, - LARGETURBINE_SS_ACTIVE9, - }; - - /** - * Plasma Turbines - */ - - public static BlockIcons[] OVERLAY_PLASMA_TURBINE = new BlockIcons[]{ - LARGETURBINE_TU1, - LARGETURBINE_TU2, - LARGETURBINE_TU3, - LARGETURBINE_TU4, - LARGETURBINE_TU5, - LARGETURBINE_TU6, - LARGETURBINE_TU7, - LARGETURBINE_TU8, - LARGETURBINE_TU9, - }; + /** + * Plasma Turbines + */ + public static BlockIcons[] OVERLAY_PLASMA_TURBINE = new BlockIcons[] { + LARGETURBINE_TU1, + LARGETURBINE_TU2, + LARGETURBINE_TU3, + LARGETURBINE_TU4, + LARGETURBINE_TU5, + LARGETURBINE_TU6, + LARGETURBINE_TU7, + LARGETURBINE_TU8, + LARGETURBINE_TU9, + }; - public static BlockIcons[] OVERLAY_PLASMA_TURBINE_ACTIVE = new BlockIcons[]{ - LARGETURBINE_TU_ACTIVE1, - LARGETURBINE_TU_ACTIVE2, - LARGETURBINE_TU_ACTIVE3, - LARGETURBINE_TU_ACTIVE4, - LARGETURBINE_TU_ACTIVE5, - LARGETURBINE_TU_ACTIVE6, - LARGETURBINE_TU_ACTIVE7, - LARGETURBINE_TU_ACTIVE8, - LARGETURBINE_TU_ACTIVE9, - }; + public static BlockIcons[] OVERLAY_PLASMA_TURBINE_ACTIVE = new BlockIcons[] { + LARGETURBINE_TU_ACTIVE1, + LARGETURBINE_TU_ACTIVE2, + LARGETURBINE_TU_ACTIVE3, + LARGETURBINE_TU_ACTIVE4, + LARGETURBINE_TU_ACTIVE5, + LARGETURBINE_TU_ACTIVE6, + LARGETURBINE_TU_ACTIVE7, + LARGETURBINE_TU_ACTIVE8, + LARGETURBINE_TU_ACTIVE9, + }; - public static IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaSpecialMultiCasings i) { - final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + public static IIcon handleCasingsGT( + final IBlockAccess aWorld, + final int xCoord, + final int yCoord, + final int zCoord, + final int aSide, + final GregtechMetaSpecialMultiCasings i) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - //0 shaft - //1 LP - //2 HP - //3 Gas - //4 Plasma + // 0 shaft + // 1 LP + // 2 HP + // 3 Gas + // 4 Plasma - BlockIcons[] mGetCurrentTextureSet = null; - BlockIcons[] mGetCurrentTextureSet_ACTIVE = null; + BlockIcons[] mGetCurrentTextureSet = null; + BlockIcons[] mGetCurrentTextureSet_ACTIVE = null; + if (tMeta <= 0 || tMeta >= 5) { + return GregtechMetaSpecialMultiCasings.getStaticIcon((byte) aSide, (byte) tMeta); + } else { + if (tMeta == 1) { + mGetCurrentTextureSet = OVERLAY_LP_TURBINE; + mGetCurrentTextureSet_ACTIVE = OVERLAY_LP_TURBINE_ACTIVE; + } else if (tMeta == 2) { + mGetCurrentTextureSet = OVERLAY_HP_TURBINE; + mGetCurrentTextureSet_ACTIVE = OVERLAY_HP_TURBINE_ACTIVE; + } else if (tMeta == 3) { + mGetCurrentTextureSet = OVERLAY_GAS_TURBINE; + mGetCurrentTextureSet_ACTIVE = OVERLAY_GAS_TURBINE_ACTIVE; + } else if (tMeta == 4) { + mGetCurrentTextureSet = OVERLAY_PLASMA_TURBINE; + mGetCurrentTextureSet_ACTIVE = OVERLAY_PLASMA_TURBINE_ACTIVE; + } + if (mGetCurrentTextureSet == null || mGetCurrentTextureSet_ACTIVE == null) { + return GregtechMetaSpecialMultiCasings.getStaticIcon((byte) aSide, (byte) tMeta); + } - if (tMeta <= 0 || tMeta >= 5) { - return GregtechMetaSpecialMultiCasings.getStaticIcon((byte) aSide, (byte) tMeta); - } - else { - if (tMeta == 1) { - mGetCurrentTextureSet = OVERLAY_LP_TURBINE; - mGetCurrentTextureSet_ACTIVE = OVERLAY_LP_TURBINE_ACTIVE; - } - else if (tMeta == 2) { - mGetCurrentTextureSet = OVERLAY_HP_TURBINE; - mGetCurrentTextureSet_ACTIVE = OVERLAY_HP_TURBINE_ACTIVE; - } - else if (tMeta == 3) { - mGetCurrentTextureSet = OVERLAY_GAS_TURBINE; - mGetCurrentTextureSet_ACTIVE = OVERLAY_GAS_TURBINE_ACTIVE; - } - else if (tMeta == 4) { - mGetCurrentTextureSet = OVERLAY_PLASMA_TURBINE; - mGetCurrentTextureSet_ACTIVE = OVERLAY_PLASMA_TURBINE_ACTIVE; - } - if (mGetCurrentTextureSet == null || mGetCurrentTextureSet_ACTIVE == null) { - return GregtechMetaSpecialMultiCasings.getStaticIcon((byte) aSide, (byte) tMeta); - } + if ((aSide == 2) || (aSide == 3)) { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[0].getIcon(); + } + return mGetCurrentTextureSet[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[3].getIcon(); + } + return mGetCurrentTextureSet[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[6].getIcon(); + } + return mGetCurrentTextureSet[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[1].getIcon(); + } + return mGetCurrentTextureSet[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[7].getIcon(); + } + return mGetCurrentTextureSet[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[8].getIcon(); + } + return mGetCurrentTextureSet[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[5].getIcon(); + } + return mGetCurrentTextureSet[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[2].getIcon(); + } + return mGetCurrentTextureSet[2].getIcon(); + } + } else if ((aSide == 4) || (aSide == 5)) { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[0].getIcon(); + } + return mGetCurrentTextureSet[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[3].getIcon(); + } + return mGetCurrentTextureSet[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[6].getIcon(); + } + return mGetCurrentTextureSet[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[1].getIcon(); + } + return mGetCurrentTextureSet[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[7].getIcon(); + } + return mGetCurrentTextureSet[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[8].getIcon(); + } + return mGetCurrentTextureSet[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[5].getIcon(); + } + return mGetCurrentTextureSet[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) + && ((tTileEntity instanceof IGregTechTileEntity)) + && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) + && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) + && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[2].getIcon(); + } + return mGetCurrentTextureSet[2].getIcon(); + } + } + } + return GregtechMetaSpecialMultiCasings.getStaticIcon((byte) aSide, (byte) tMeta); + } + public static boolean isUsingAnimatedTexture(TileEntity tTileEntity) { + boolean aVal = true; + IGregTechTileEntity aTile; + if (tTileEntity instanceof IGregTechTileEntity) { + aTile = (IGregTechTileEntity) tTileEntity; + if (aTile != null) { + final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); + if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { + aVal = ((GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity) + .getBaseMetaTileEntity() + .isActive(); + // Logger.INFO("Returning "+aVal+" as Rotor Assembly controller status"); + } + } + } + return aVal; + } - - if ((aSide == 2) || (aSide == 3)) { - TileEntity tTileEntity; - IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[0].getIcon(); - } - return mGetCurrentTextureSet[0].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[3].getIcon(); - } - return mGetCurrentTextureSet[3].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[6].getIcon(); - } - return mGetCurrentTextureSet[6].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[1].getIcon(); - } - return mGetCurrentTextureSet[1].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[7].getIcon(); - } - return mGetCurrentTextureSet[7].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[8].getIcon(); - } - return mGetCurrentTextureSet[8].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[5].getIcon(); - } - return mGetCurrentTextureSet[5].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[2].getIcon(); - } - return mGetCurrentTextureSet[2].getIcon(); - } - } else if ((aSide == 4) || (aSide == 5)) { - TileEntity tTileEntity; - Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[0].getIcon(); - } - return mGetCurrentTextureSet[0].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[3].getIcon(); - } - return mGetCurrentTextureSet[3].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[6].getIcon(); - } - return mGetCurrentTextureSet[6].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[1].getIcon(); - } - return mGetCurrentTextureSet[1].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[7].getIcon(); - } - return mGetCurrentTextureSet[7].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[8].getIcon(); - } - return mGetCurrentTextureSet[8].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[5].getIcon(); - } - return mGetCurrentTextureSet[5].getIcon(); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { - if (isUsingAnimatedTexture(tTileEntity)) { - return mGetCurrentTextureSet_ACTIVE[2].getIcon(); - } - return mGetCurrentTextureSet[2].getIcon(); - } - } - } - return GregtechMetaSpecialMultiCasings.getStaticIcon((byte) aSide, (byte) tMeta); - } - - public static boolean isUsingAnimatedTexture(TileEntity tTileEntity) { - boolean aVal = true; - IGregTechTileEntity aTile; - if (tTileEntity instanceof IGregTechTileEntity) { - aTile = (IGregTechTileEntity) tTileEntity; - if (aTile != null) { - final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); - if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { - aVal = ((GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity).getBaseMetaTileEntity().isActive(); - //Logger.INFO("Returning "+aVal+" as Rotor Assembly controller status"); - } - } - } - return aVal; - } - - public static GT_MetaTileEntity_Hatch_Turbine isTurbineHatch(final IGregTechTileEntity aTileEntity) { - if (aTileEntity != null) { - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { - return (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; - } - } - return null; - } - + public static GT_MetaTileEntity_Hatch_Turbine isTurbineHatch(final IGregTechTileEntity aTileEntity) { + if (aTileEntity != null) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { + return (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; + } + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputerCube_Setup.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputerCube_Setup.java index bd2df1b8ff..4c6dee9c2f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputerCube_Setup.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputerCube_Setup.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.computer; import static gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube.sReactorList; -import java.util.ArrayList; - import Ic2ExpReactorPlanner.ComponentFactory; import gregtech.api.enums.ItemList; import gregtech.api.objects.GT_ItemStack; @@ -14,61 +12,97 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.bartworks.BW_Utils; import gtPlusPlus.xmod.goodgenerator.GG_Utils; +import java.util.ArrayList; import net.minecraft.item.ItemStack; public class GT_ComputerCube_Setup { - public static void init() { - Logger.INFO("[Reactor Simulator] Added " + ComponentFactory.getComponentCount() + " components to ComponentFactory."); - if (sReactorList == null) { - sReactorList = new ArrayList(); - - String[] aIc2Items = new String[]{ - "reactorUraniumSimple", "reactorUraniumDual", "reactorUraniumQuad", /*"reactorIsotopeCell",*/ "reactorReflector", "reactorReflectorThick", "reactorCoolantSimple", - "reactorCoolantTriple", "reactorCoolantSix", "reactorCondensator", "reactorCondensatorLap", "reactorPlating", "reactorPlatingHeat", "reactorPlatingExplosive", "reactorVent", - "reactorVentCore", "reactorVentGold", "reactorVentSpread", "reactorVentDiamond", "reactorHeatSwitch", "reactorHeatSwitchCore", "reactorHeatSwitchSpread", - "reactorHeatSwitchDiamond", /*"reactorHeatpack",*/ - }; - - for (String aItem : aIc2Items) { - ItemStack aStack = GT_ModHandler.getIC2Item(aItem, 1); - if (!ItemUtils.checkForInvalidItems(aStack)) { - Logger.INFO("Unable to find IC2 Item: " + aItem); - CORE.crash("Unable to find IC2 Item: " + aItem); - } - else { - sReactorList.add(new GT_ItemStack(aStack.copy())); - } - } + public static void init() { + Logger.INFO("[Reactor Simulator] Added " + ComponentFactory.getComponentCount() + + " components to ComponentFactory."); + if (sReactorList == null) { + sReactorList = new ArrayList(); - ItemList[] aGtItems = new ItemList[]{ - ItemList.Neutron_Reflector, ItemList.Moxcell_1, ItemList.Moxcell_2, ItemList.Moxcell_4, /*ItemList.Uraniumcell_1, ItemList.Uraniumcell_2, ItemList.Uraniumcell_4,*/ - ItemList.NaquadahCell_1, ItemList.NaquadahCell_2, ItemList.NaquadahCell_4, ItemList.ThoriumCell_1, ItemList.ThoriumCell_2, ItemList.ThoriumCell_4, ItemList.MNqCell_1, - ItemList.MNqCell_2, ItemList.MNqCell_4, ItemList.Reactor_Coolant_He_1, ItemList.Reactor_Coolant_He_3, ItemList.Reactor_Coolant_He_6, ItemList.Reactor_Coolant_NaK_1, - ItemList.Reactor_Coolant_NaK_3, ItemList.Reactor_Coolant_NaK_6, ItemList.Reactor_Coolant_Sp_1, ItemList.Reactor_Coolant_Sp_2, ItemList.Reactor_Coolant_Sp_3, - ItemList.Reactor_Coolant_Sp_6 - }; + String[] aIc2Items = new String[] { + "reactorUraniumSimple", + "reactorUraniumDual", + "reactorUraniumQuad", /*"reactorIsotopeCell",*/ + "reactorReflector", + "reactorReflectorThick", + "reactorCoolantSimple", + "reactorCoolantTriple", + "reactorCoolantSix", + "reactorCondensator", + "reactorCondensatorLap", + "reactorPlating", + "reactorPlatingHeat", + "reactorPlatingExplosive", + "reactorVent", + "reactorVentCore", + "reactorVentGold", + "reactorVentSpread", + "reactorVentDiamond", + "reactorHeatSwitch", + "reactorHeatSwitchCore", + "reactorHeatSwitchSpread", + "reactorHeatSwitchDiamond", /*"reactorHeatpack",*/ + }; - for (ItemList aItem : aGtItems) { - sReactorList.add(new GT_ItemStack(aItem.get(1))); - } + for (String aItem : aIc2Items) { + ItemStack aStack = GT_ModHandler.getIC2Item(aItem, 1); + if (!ItemUtils.checkForInvalidItems(aStack)) { + Logger.INFO("Unable to find IC2 Item: " + aItem); + CORE.crash("Unable to find IC2 Item: " + aItem); + } else { + sReactorList.add(new GT_ItemStack(aStack.copy())); + } + } - if (LoadedMods.BartWorks) { - ArrayList aBartReactorItems = BW_Utils.getAll(1); - for (ItemStack aReactorItem : aBartReactorItems) { - sReactorList.add(new GT_ItemStack(aReactorItem)); - } - } + ItemList[] aGtItems = new ItemList[] { + ItemList.Neutron_Reflector, + ItemList.Moxcell_1, + ItemList.Moxcell_2, + ItemList.Moxcell_4, /*ItemList.Uraniumcell_1, ItemList.Uraniumcell_2, ItemList.Uraniumcell_4,*/ + ItemList.NaquadahCell_1, + ItemList.NaquadahCell_2, + ItemList.NaquadahCell_4, + ItemList.ThoriumCell_1, + ItemList.ThoriumCell_2, + ItemList.ThoriumCell_4, + ItemList.MNqCell_1, + ItemList.MNqCell_2, + ItemList.MNqCell_4, + ItemList.Reactor_Coolant_He_1, + ItemList.Reactor_Coolant_He_3, + ItemList.Reactor_Coolant_He_6, + ItemList.Reactor_Coolant_NaK_1, + ItemList.Reactor_Coolant_NaK_3, + ItemList.Reactor_Coolant_NaK_6, + ItemList.Reactor_Coolant_Sp_1, + ItemList.Reactor_Coolant_Sp_2, + ItemList.Reactor_Coolant_Sp_3, + ItemList.Reactor_Coolant_Sp_6 + }; - if (LoadedMods.GoodGenerator) { - ArrayList aGlodReactorItems = GG_Utils.getAll(1); - for (ItemStack aReactorItem : aGlodReactorItems) { - sReactorList.add(new GT_ItemStack(aReactorItem)); - } - } - Logger.INFO("[Reactor Simulator] Added " + sReactorList.size() + " components to GT_TileEntity_ComputerCube."); + for (ItemList aItem : aGtItems) { + sReactorList.add(new GT_ItemStack(aItem.get(1))); + } - } - } + if (LoadedMods.BartWorks) { + ArrayList aBartReactorItems = BW_Utils.getAll(1); + for (ItemStack aReactorItem : aBartReactorItems) { + sReactorList.add(new GT_ItemStack(aReactorItem)); + } + } + if (LoadedMods.GoodGenerator) { + ArrayList aGlodReactorItems = GG_Utils.getAll(1); + for (ItemStack aReactorItem : aGlodReactorItems) { + sReactorList.add(new GT_ItemStack(aReactorItem)); + } + } + Logger.INFO( + "[Reactor Simulator] Added " + sReactorList.size() + " components to GT_TileEntity_ComputerCube."); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java index fedb4e6028..18ae44ab79 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Description.java @@ -1,194 +1,534 @@ package gtPlusPlus.xmod.gregtech.common.computer; -import java.util.ArrayList; - import gregtech.api.enums.ItemList; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import java.util.ArrayList; import net.minecraft.item.ItemStack; public class GT_Computercube_Description { - public static ArrayList sDescriptions = new ArrayList(); - - public String[] mDescription; - - public ItemStack[] mStacks; - - public GT_Computercube_Description(String[] aDescription, ItemStack[] aStacks) { - this.mDescription = aDescription; - this.mStacks = aStacks; - sDescriptions.add(this); - } - - public static void addStandardDescriptions() { - Logger.INFO("Adding Default Description Set of the Computer Cube"); - new GT_Computercube_Description(new String[] { - "Lightning Rod", "Also known as the Bane of", "Alblaka. The Lightning Rod", "enables you to gain Energy", "from Lightning! To set it up", "you just need the Block", "itself, 4 HV-Transformers", "and a crapton of Ironfences,", "which you then place on top", "of it. After that you have to", - "wait for a Thunderstorm and", "when you are lucky you get", "2.5 MFSU of Energy out of", "it. If a Rod is high enough", "then Rain is also enough to", "get stroke, but with less", "probability ofcourse." }, new ItemStack[] { - GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), ItemList.Machine_IV_LightningRod.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Quantum Chest", "You want to store tons of", "Materials into your Chests", "but you hate the Item limit", "of them? Not anymore! The", "Quantum Chest is able to", "store an INFINITE* amount", "of one single Item type per", "Chest.", "This Chest stores your Items", - "like Data and ever has a", "Stack of the Item ready for", "extraction. It is compatible", "with any Item that doesnt", "have a NBT-Tag. You ask what", "NBT is? I know it, thats enough.", "Up to 2147483391*" }, new ItemStack[] { - ItemList.Quantum_Chest_IV.get(1), ItemList.Quantum_Chest_EV.get(1), ItemList.Quantum_Chest_HV.get(1), ItemList.Quantum_Chest_MV.get(1), ItemList.Quantum_Chest_LV.get(1), null, - null, null, null, null, null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Quantum Tank", "You want to store tons of", "Fluids into your Tanks", "but you hate the capacity", "of them? Not anymore! The", "Quantum Tank is able to", "store an INFINITE* amount", "of one single Fluid type per", "Tank.", "This Tank stores your Fluids", - "like Data and ever has a", "Stack of the Fluid ready for", "extraction. It is compatible", "with any Fluid. ", "You ask what", "NBT is? I know it, thats enough.", "* = 2147483391" }, new ItemStack[] { - ItemList.Quantum_Tank_IV.get(1), ItemList.Quantum_Tank_EV.get(1), ItemList.Quantum_Tank_HV.get(1), ItemList.Quantum_Tank_MV.get(1), ItemList.Quantum_Tank_LV.get(1), null, - null, null, null, null, null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Computer Cube", "The Device you are", "currently using. This Computer", "is running the G.L.A.D.-OS,", "which is containing many", "usefull Apps:", "- Reactor Planner", "- Seedbag Scanner", "- Recipelists for GT-Devices", "- ", - "- ", "- ", "- ", "- ", "And the Description List you", "are currently reading.", "~This Device has private Access~" }, new ItemStack[] { - null, null, null, null, GregtechItemList.Gregtech_Computer_Cube_Machine.get(1), null, null, null, null, null, - null, null, null, null }); - /* new GT_Computercube_Description(new String[] { - "UUM-Assembler", "It's like an automatic", "Crafting Table just for UUM", "It can store 20 UUM-Recipes", "and produces those on demand", "It costs 512EU per used piece", "of Universal-Usable-Matter(TM).", "The integrated Quantum Chest", "allows it to store all your", "UUM inside it.", - "Top and Bottom are for Input,", "while the Output is on the", "Sides. The Output is designed,", "to work with RP-Managers, so", "build it into your recursive", "Autocraftingsystem.", "" }, new ItemStack[] { - null, null, null, GT_ModHandler.getIC2Item("matter", 1), new ItemStack(GregTech_API.sBlockList[1], 1, 5), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Sonictron", "You like Music? Then the", "Sonictron 9001 is your best", "choice! You can compose Alarms,", "Doorbell Sounds or boring", "Elevator Music, with the 64 Slots", "inside it. Just leftclick them", "to switch the Sound, rightclick", "them to switch the modulation", "and shiftclick to remove it.", - "Then apply Redstone to play", "With the mobile Version you can", "play sounds everywhere, after", "you copied them from a normal", "Sonictron via rightclicking", "Sneakrightclicking pastes", "Emits Redstone when finished." }, new ItemStack[] { - null, null, null, GregTech_API.getGregTechItem(32, 1, 0), new ItemStack(GregTech_API.sBlockList[1], 1, 6), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "L.E.S.U.", "The unlaggiest Multiblock ever!", "One Controllerblock, and as many", "'stupid' Storageblocks as you want.", "To use it, place one Controller", "and then place the LESU-Storages", "adjacent to it or other placed", "LESU-Storages. The Tier (max EU/t)", "of it depends on the amount of", "adjacent Storages. The", - "Storageblocks are NOT TileEntities,", "what means that they cause as much", "Lag as a random Dirtblock. And the", "Controller Block only checks ONCE", "for the Storages, so no", "Blockiterationlag, AT. ALL. Anyone,", "who says that they lag gets murdered!" }, new ItemStack[] { - null, null, null, new ItemStack(GregTech_API.sBlockList[0], 1, 6), new ItemStack(GregTech_API.sBlockList[1], 1, 7), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "I.D.S.U.", "The Interdimensional Storage Unit", "is a Device, which is like a", "wireless, crossdimensional and", "enderchestlike EU-Storage Block", "", "Every Player has one Network of", "these. The ID is determined by", "the Hashcode of the Name from the", "first Player, who opens it's GUI", - "", "It stores up to 1 Billion EU", "and emits EV. But you need at", "least two of them for Energy", "Transfer", "", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 8), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "A.E.S.U.", "The Adjustable Energy Storage Unit", "is like 10 MFSU and has an", "adjustable Output between 0 and", "2048EU/t. You could use it as a", "Transformer. It is Tier-IV, so", "it's basically needed to charge", "Energy Orbs and Lapotron Packs", "", "Not much else to say about it.", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 9), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Charge-O-Mat", "An automatable Charging Bench", "It puts (de-)charged Tools into", "the right Outputslots, which are", "accessible on the Sides of it.", "", "The Energy Orb inside stores enough", "to charge your QSuit almost instantly", "", "This is a Tier-V Charging Station", - "even when the Max-IN/OUT is only", "2048EU/t. It also charges your Armor", "when you are standing close to it.", "", "If you apply Redstone, then it", "decharges instead.", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 10), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Centrifuge", "This is a Machine to seperate", "Isotopes.", "", "It has a maximum Consumption Rate", "of 5EU/t, and its Maxinput is", "32EU/t. The time it needs depends", "on the Recipe you use.", "", "It needs Tin Cells for some Recipes,", - "which you put in the Top Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "", "You can pipe Lava into this Device" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 11), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Electrolyzer", "This is a Machine to seperate", "Molecules and electrolyze", "Watercells.", "", "It has a maximum Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs depends", "on the Recipe you use.", "", - "It needs Tin Cells for some Recipes,", "which you put in the Bottom Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 25), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Grinder", "This Machines purpose is to", "macerate and grind Ores.", "It can ONLY grind Ores, don't", "try regular Macerator Recipes.", "It has a fixed Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs is", "5 seconds per Ore Block", "It needs Water for most Recipes,", - "which you put in the Bottom Left Slot", "Top = Input", "Bottom = Water", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, new ItemStack(Block.field_71943_B, 1), new ItemStack(GregTech_API.sBlockList[0], 1, 14), new ItemStack(GregTech_API.sBlockList[0], 1, 13), new ItemStack(GregTech_API.sBlockList[1], 1, 28), null, null, null, null, null, - null, null, null, null });*/ - new GT_Computercube_Description(new String[] { - "Electric Blast Furnace", "You may know the Blast Furnace", "of Railcraft. This one works", "similar, as it can also produce", "Steel out of Iron and Coal.", "", "Its heat Capacity depends on the", "used Machine Casings for building", "it. The better they are, the more", "Heat it can achieve.", - "", "Top = Input 1", "Bottom = Input 2", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, null, null, ItemList.Casing_HeatProof.get(1), ItemList.Machine_Multi_BlastFurnace.get(1), ItemList.Casing_Coil_Cupronickel.get(1), ItemList.Casing_Coil_Kanthal.get(1), ItemList.Casing_Coil_Nichrome.get(1), ItemList.Casing_Coil_TungstenSteel.get(1), ItemList.Casing_Coil_HSSG.get(1), - ItemList.Casing_Coil_HSSS.get(1), ItemList.Casing_Coil_Naquadah.get(1), ItemList.Casing_Coil_NaquadahAlloy.get(1), null }); - /* new GT_Computercube_Description(new String[] { - "Sawmill", "This Device turns your Logs", "into more Planks, than a normal", "Steve can produce with his Hands.", "", "Its byproduct, Wood Pulp, can be", "compressed into special Planks,", "which are burning like Charcoal.", "", "It needs Water for most Recipes,", - "which you put in the Bottom Left Slot", "Top = Input", "Water Sides = Water", "Saw Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, null, GT_MetaItem_Material.instance.getStack(15, 1), GT_MetaItem_Dust.instance.getStack(15, 1), new ItemStack(GregTech_API.sBlockList[1], 1, 32), null, null, null, null, null, - null, null, null, null });*/ - new GT_Computercube_Description(new String[] { - "Implosion Compressor", "You need to turn Dusts back", "into Gems? Or do you just want", "to make Iridium Plates?", "With a bit ITNT you can achieve", "that in this Device!", "", "We strongly recommend to use", "Flint Dust instead of Flints", "for making the ITNT.", - "", "Top = Input", "Explosion Sides = Output", "ITNT Side = ITNT Input", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { - null, null, null, GT_ModHandler.getIC2Item("industrialTnt", 1, new ItemStack(net.minecraft.init.Blocks.tnt, 1)), ItemList.Machine_Multi_ImplosionCompressor.get(1), null, null, null, null, null, - null, null, null, null }); - /* new GT_Computercube_Description(new String[] { - "Superconductor", "Expensive, but superconducting", "nearly infinite EU/p and it has", "no Cableloss!", "Do not confuse this with the", "Superconductor Item!", "", "Supercondensator", "This is a special kind of Transformer", "It allows you to convert anything down", - "to 8192 EU/t, what is like a normal HVT.", "But if you apply Redstone to it then it", "outputs friggin 1000000EU/t!!!", "", "You also need it for the Fusion Reactor.", "Some Machines will require that high", "Voltage in a short period of time." }, new ItemStack[] { - null, null, GregTech_API.getGregTechItem(3, 1, 2), new ItemStack(GregTech_API.sBlockList[1], 1, 12), new ItemStack(GregTech_API.sBlockList[1], 1, 15), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Player Detector", "This nice little Device is able", "to detect Players in a Range of", "16-Spherical Meters and a", "EU-Consumption of 2.5EU/t.", "", "It can be switched to 3 Diffrent", "Modes, to detect YOURSELF, OTHERS", "and ALL Players by Rightclicking it.", "", - "It doesnt detect regular Mobs.", "", "", "", "", "", "~This Device has private Access~" }, new ItemStack[] { - null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 13), null, null, null, null, null, - null, null, null, null });*/ - new GT_Computercube_Description(new String[] { - "Matter Fabricator", "The Matter Fabricator is nothing", "else than a Mass Fabricator, which", "can ONLY run on Scrap and other", "Amplifiers.", "", "With the Default Config it is 100", "times more expensive than normal.", "Of course you can set the Config", "to 166666, to get your normal", - "Massfabricationrate back, or you", "could make Mass Fabrication even", "cheaper, if you really want to", "make Mass Fabrication that easy", "", "", "" }, new ItemStack[] { - null, null, null, GT_Utility.getFluidDisplayStack(FluidUtils.getUUM(1), false), ItemList.Machine_LV_Massfab.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Electric Autocrafting Tables", "These are Crafting Tables for the", "common need of autocrafting in", "Factories. One Craft needs 5000EU to", "be performed, so you have actually to", "lay Wires to it. This Table is", "unique as its also able, to give you", "the used Capsulecellcontainers, made", "by Industrial Corp, back.", "You may use that behaviour to", - "craft anything releated to chemics,", "like the 2xKNO3-Recipe for Saltpeter.", "The 5 Modes are the following:", "1. Craft Recipe, 2. All 5 Modes", "3. Craft all as single Items", "4. 2x2-Grid and 5. a 3x3-Grid.", "It accepts only 32EU/p as Input." }, new ItemStack[] { - null, null, null, null, GregtechItemList.GT4_Electric_Auto_Workbench_LV.get(1), null, null, null, null, null, - null, null, null, null }); - /* new GT_Computercube_Description(new String[] { - "Automation with GregTech", "Translocators and Buffers are the", "newest Way to automate your Machines.", "Screw Buildcraft, these EU-wasting", "Devices are much more awesome.", "They output 32EU/t to their directed", "IN- and OUT-puts, making them usefull", "for things, like saving wires.", "Translocators are taking Stuff from", "the Block at their green Inputfacing", - "and putting it into the Block at the", "red Outputfacing. Buffers do the same,", "but the grab Items from their own", "Inventory, what makes them usefull", "as Pipe-replacement.", "Buffers also have Redstone Intelligence,", "which you can configure in their GUI." }, new ItemStack[] { - null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 19), new ItemStack(GregTech_API.sBlockList[1], 1, 18), new ItemStack(GregTech_API.sBlockList[1], 1, 17), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Silver Ore", "It's rarity is similar to Gold", "Silver can be used, to make", "Circuits cheaper, or you can use", "it for Redpowerstuff.", "", "", "", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, GT_OreDictUnificator.get("dustSilver", 1), GregTech_API.getGregTechItem(0, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 1), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Sapphires and Rubys", "These spawn exactly like Emeralds.", "But Rubies are found in Deserts,", "while Sapphires can be found in", "Oceans.", "", "They currently make only a cheaper", "Recipe for Energycrystals and", "Lapotroncrystals, but they are", "Redpower Compatible.", - "", "They also sometimes drop random", "other Gems, like Garnet for Ruby", "or green Sapphire for Sapphire", "in addition.", "", "" }, new ItemStack[] { - null, GregTech_API.getGregTechItem(0, 1, 32), new ItemStack(GregTech_API.sBlockList[2], 1, 3), GregTech_API.getGregTechItem(0, 1, 33), new ItemStack(GregTech_API.sBlockList[2], 1, 4), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Bauxite Ore", "The Stuff out of which you can", "produce Aluminium and also", "Titanium.", "You find this Ore in Plains and", "Forests.", "", "If you think Aluminium is useless", "then note, that mobs NEVER spawn", "ontop of an Aluminium Block", - "(Same applies also for Silver-,", "Gem- and Iridium Blocks)", "Production Chain:", "macerating Bauxite Ore", "electrolyzing 24 Bauxite Dust", "smelting Aluminium Dust in a", "Blast Furnace" }, new ItemStack[] { - new ItemStack(GregTech_API.sBlockList[0], 1, 7), GregTech_API.getGregTechItem(0, 1, 18), GregTech_API.getGregTechItem(1, 1, 18), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Titanium", "Produced by centrifuging Bauxitedust", "as a byproduct, this Material can make", "anything much more resistant against", "damage, like Explosions.", "Blocks made of Titaniumingots have a", "large Blastresistance", "", "It can also be used to craft tons of", "mixed Metal Ingots", - "", "", "", "", "", "", "" }, new ItemStack[] { - new ItemStack(GregTech_API.sBlockList[0], 1, 8), GregTech_API.getGregTechItem(0, 1, 19), GregTech_API.getGregTechItem(1, 1, 19), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Iridium Ore", "You can find it only when you", "stripmine very large Areas with", "Quarries and such. There is only", "one in every 5th-10th Chunk.", "It's even more rare in Oceans!", "", "Some people disable the UUM-Recipe", "for Iridium, for making getting it", "an Achievement.", - "", "However Iridium Ore contains traces", "of Platinum, so it's best to use the", "Industrial Grinder for this Ore.", "", "", "" }, new ItemStack[] { - null, null, GT_OreDictUnificator.get("plateAlloyIridium", 1), GT_ModHandler.getIC2Item("iridiumOre", 1), new ItemStack(GregTech_API.sBlockList[2], 1, 2), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Helium Coolant Cell", "These are just cheaper, than the", "Water based Coolant Cells, and can", "also hold six times more Heat.", "", "Helium Cells can also be used for", "making Luminators and Mininglasers", "", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - GregTech_API.getGregTechItem(2, 1, 6), GregTech_API.getGregTechItem(2, 1, 3), GregTech_API.getGregTechItem(34, 1, 0), GregTech_API.getGregTechItem(35, 1, 0), GregTech_API.getGregTechItem(36, 1, 0), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Destructopack", "Open its GUI via rightclick and", "dump all the useless Stuff from", "your Inventory into it, instead of", "littering Items into the World.", "", "", "", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, null, GregTech_API.getGregTechItem(33, 1, 0), null, null, null, null, null, - null, null, null, null });*/ - new GT_Computercube_Description(new String[] { - "Data Orbs", "They store Data.", "", "Rightclick on a Computer Cube, to", "extract a Reactorplan", "", "Sneak-Rightclick on it, to insert", "a Reactorplan", "", "Works also with Sonictrons", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, null, ItemList.Tool_DataOrb.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Energy Orbs", "100 Million EU in one Orb!", "", "This is a Tier-IV-Energystorage", "So a MFSU is not enough for it!", "", "Use it to create a Lapotron Pack,", "which is like an ultimate Lap Pack!", "", "", - "", "", "", "", "", "", "" }, new ItemStack[] { - null, null, null, null, ItemList.Energy_LapotronicOrb.get(1), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Iridium Neutron Reflector", "It's used for Fusion Reactor Coils,", "and works like a normal one", "inside a Reactor, but it's also", "INDESTRUCTIBLE*.", "", "", "", "", "", - "", "", "", "", "", "", "* = for weardown" }, new ItemStack[] { - null, null, null, null, ItemList.Neutron_Reflector.get(1), null, null, null, null, null, + public static ArrayList sDescriptions = new ArrayList(); + + public String[] mDescription; + + public ItemStack[] mStacks; + + public GT_Computercube_Description(String[] aDescription, ItemStack[] aStacks) { + this.mDescription = aDescription; + this.mStacks = aStacks; + sDescriptions.add(this); + } + + public static void addStandardDescriptions() { + Logger.INFO("Adding Default Description Set of the Computer Cube"); + new GT_Computercube_Description( + new String[] { + "Lightning Rod", + "Also known as the Bane of", + "Alblaka. The Lightning Rod", + "enables you to gain Energy", + "from Lightning! To set it up", + "you just need the Block", + "itself, 4 HV-Transformers", + "and a crapton of Ironfences,", + "which you then place on top", + "of it. After that you have to", + "wait for a Thunderstorm and", + "when you are lucky you get", + "2.5 MFSU of Energy out of", + "it. If a Rod is high enough", + "then Rain is also enough to", + "get stroke, but with less", + "probability ofcourse." + }, + new ItemStack[] { + GT_ModHandler.getIC2Item("ironFence", 1), + GT_ModHandler.getIC2Item("ironFence", 1), + GT_ModHandler.getIC2Item("ironFence", 1), + GT_ModHandler.getIC2Item("ironFence", 1), + ItemList.Machine_IV_LightningRod.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + new GT_Computercube_Description( + new String[] { + "Quantum Chest", + "You want to store tons of", + "Materials into your Chests", + "but you hate the Item limit", + "of them? Not anymore! The", + "Quantum Chest is able to", + "store an INFINITE* amount", + "of one single Item type per", + "Chest.", + "This Chest stores your Items", + "like Data and ever has a", + "Stack of the Item ready for", + "extraction. It is compatible", + "with any Item that doesnt", + "have a NBT-Tag. You ask what", + "NBT is? I know it, thats enough.", + "Up to 2147483391*" + }, + new ItemStack[] { + ItemList.Quantum_Chest_IV.get(1), + ItemList.Quantum_Chest_EV.get(1), + ItemList.Quantum_Chest_HV.get(1), + ItemList.Quantum_Chest_MV.get(1), + ItemList.Quantum_Chest_LV.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + new GT_Computercube_Description( + new String[] { + "Quantum Tank", + "You want to store tons of", + "Fluids into your Tanks", + "but you hate the capacity", + "of them? Not anymore! The", + "Quantum Tank is able to", + "store an INFINITE* amount", + "of one single Fluid type per", + "Tank.", + "This Tank stores your Fluids", + "like Data and ever has a", + "Stack of the Fluid ready for", + "extraction. It is compatible", + "with any Fluid. ", + "You ask what", + "NBT is? I know it, thats enough.", + "* = 2147483391" + }, + new ItemStack[] { + ItemList.Quantum_Tank_IV.get(1), + ItemList.Quantum_Tank_EV.get(1), + ItemList.Quantum_Tank_HV.get(1), + ItemList.Quantum_Tank_MV.get(1), + ItemList.Quantum_Tank_LV.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + new GT_Computercube_Description( + new String[] { + "Computer Cube", + "The Device you are", + "currently using. This Computer", + "is running the G.L.A.D.-OS,", + "which is containing many", + "usefull Apps:", + "- Reactor Planner", + "- Seedbag Scanner", + "- Recipelists for GT-Devices", + "- ", + "- ", + "- ", + "- ", + "- ", + "And the Description List you", + "are currently reading.", + "~This Device has private Access~" + }, + new ItemStack[] { + null, + null, + null, + null, + GregtechItemList.Gregtech_Computer_Cube_Machine.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + /* new GT_Computercube_Description(new String[] { + "UUM-Assembler", "It's like an automatic", "Crafting Table just for UUM", "It can store 20 UUM-Recipes", "and produces those on demand", "It costs 512EU per used piece", "of Universal-Usable-Matter(TM).", "The integrated Quantum Chest", "allows it to store all your", "UUM inside it.", + "Top and Bottom are for Input,", "while the Output is on the", "Sides. The Output is designed,", "to work with RP-Managers, so", "build it into your recursive", "Autocraftingsystem.", "" }, new ItemStack[] { + null, null, null, GT_ModHandler.getIC2Item("matter", 1), new ItemStack(GregTech_API.sBlockList[1], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Sonictron", "You like Music? Then the", "Sonictron 9001 is your best", "choice! You can compose Alarms,", "Doorbell Sounds or boring", "Elevator Music, with the 64 Slots", "inside it. Just leftclick them", "to switch the Sound, rightclick", "them to switch the modulation", "and shiftclick to remove it.", + "Then apply Redstone to play", "With the mobile Version you can", "play sounds everywhere, after", "you copied them from a normal", "Sonictron via rightclicking", "Sneakrightclicking pastes", "Emits Redstone when finished." }, new ItemStack[] { + null, null, null, GregTech_API.getGregTechItem(32, 1, 0), new ItemStack(GregTech_API.sBlockList[1], 1, 6), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "L.E.S.U.", "The unlaggiest Multiblock ever!", "One Controllerblock, and as many", "'stupid' Storageblocks as you want.", "To use it, place one Controller", "and then place the LESU-Storages", "adjacent to it or other placed", "LESU-Storages. The Tier (max EU/t)", "of it depends on the amount of", "adjacent Storages. The", + "Storageblocks are NOT TileEntities,", "what means that they cause as much", "Lag as a random Dirtblock. And the", "Controller Block only checks ONCE", "for the Storages, so no", "Blockiterationlag, AT. ALL. Anyone,", "who says that they lag gets murdered!" }, new ItemStack[] { + null, null, null, new ItemStack(GregTech_API.sBlockList[0], 1, 6), new ItemStack(GregTech_API.sBlockList[1], 1, 7), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "I.D.S.U.", "The Interdimensional Storage Unit", "is a Device, which is like a", "wireless, crossdimensional and", "enderchestlike EU-Storage Block", "", "Every Player has one Network of", "these. The ID is determined by", "the Hashcode of the Name from the", "first Player, who opens it's GUI", + "", "It stores up to 1 Billion EU", "and emits EV. But you need at", "least two of them for Energy", "Transfer", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 8), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "A.E.S.U.", "The Adjustable Energy Storage Unit", "is like 10 MFSU and has an", "adjustable Output between 0 and", "2048EU/t. You could use it as a", "Transformer. It is Tier-IV, so", "it's basically needed to charge", "Energy Orbs and Lapotron Packs", "", "Not much else to say about it.", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 9), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Charge-O-Mat", "An automatable Charging Bench", "It puts (de-)charged Tools into", "the right Outputslots, which are", "accessible on the Sides of it.", "", "The Energy Orb inside stores enough", "to charge your QSuit almost instantly", "", "This is a Tier-V Charging Station", + "even when the Max-IN/OUT is only", "2048EU/t. It also charges your Armor", "when you are standing close to it.", "", "If you apply Redstone, then it", "decharges instead.", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 10), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Centrifuge", "This is a Machine to seperate", "Isotopes.", "", "It has a maximum Consumption Rate", "of 5EU/t, and its Maxinput is", "32EU/t. The time it needs depends", "on the Recipe you use.", "", "It needs Tin Cells for some Recipes,", + "which you put in the Top Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "", "You can pipe Lava into this Device" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 11), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Electrolyzer", "This is a Machine to seperate", "Molecules and electrolyze", "Watercells.", "", "It has a maximum Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs depends", "on the Recipe you use.", "", + "It needs Tin Cells for some Recipes,", "which you put in the Bottom Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 25), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Grinder", "This Machines purpose is to", "macerate and grind Ores.", "It can ONLY grind Ores, don't", "try regular Macerator Recipes.", "It has a fixed Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs is", "5 seconds per Ore Block", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Bottom = Water", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, new ItemStack(Block.field_71943_B, 1), new ItemStack(GregTech_API.sBlockList[0], 1, 14), new ItemStack(GregTech_API.sBlockList[0], 1, 13), new ItemStack(GregTech_API.sBlockList[1], 1, 28), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description( + new String[] { + "Electric Blast Furnace", + "You may know the Blast Furnace", + "of Railcraft. This one works", + "similar, as it can also produce", + "Steel out of Iron and Coal.", + "", + "Its heat Capacity depends on the", + "used Machine Casings for building", + "it. The better they are, the more", + "Heat it can achieve.", + "", + "Top = Input 1", + "Bottom = Input 2", + "Side = Output", + "Its a lagfree Multiblock Structure,", + "so you need a special Machine Casing", + "for this Device. (see GUI)" + }, + new ItemStack[] { + null, + null, + null, + ItemList.Casing_HeatProof.get(1), + ItemList.Machine_Multi_BlastFurnace.get(1), + ItemList.Casing_Coil_Cupronickel.get(1), + ItemList.Casing_Coil_Kanthal.get(1), + ItemList.Casing_Coil_Nichrome.get(1), + ItemList.Casing_Coil_TungstenSteel.get(1), + ItemList.Casing_Coil_HSSG.get(1), + ItemList.Casing_Coil_HSSS.get(1), + ItemList.Casing_Coil_Naquadah.get(1), + ItemList.Casing_Coil_NaquadahAlloy.get(1), + null + }); + /* new GT_Computercube_Description(new String[] { + "Sawmill", "This Device turns your Logs", "into more Planks, than a normal", "Steve can produce with his Hands.", "", "Its byproduct, Wood Pulp, can be", "compressed into special Planks,", "which are burning like Charcoal.", "", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Water Sides = Water", "Saw Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, GT_MetaItem_Material.instance.getStack(15, 1), GT_MetaItem_Dust.instance.getStack(15, 1), new ItemStack(GregTech_API.sBlockList[1], 1, 32), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description( + new String[] { + "Implosion Compressor", + "You need to turn Dusts back", + "into Gems? Or do you just want", + "to make Iridium Plates?", + "With a bit ITNT you can achieve", + "that in this Device!", + "", + "We strongly recommend to use", + "Flint Dust instead of Flints", + "for making the ITNT.", + "", + "Top = Input", + "Explosion Sides = Output", + "ITNT Side = ITNT Input", + "Its a lagfree Multiblock Structure,", + "so you need a special Machine Casing", + "for this Device. (see GUI)" + }, + new ItemStack[] { + null, + null, + null, + GT_ModHandler.getIC2Item("industrialTnt", 1, new ItemStack(net.minecraft.init.Blocks.tnt, 1)), + ItemList.Machine_Multi_ImplosionCompressor.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + /* new GT_Computercube_Description(new String[] { + "Superconductor", "Expensive, but superconducting", "nearly infinite EU/p and it has", "no Cableloss!", "Do not confuse this with the", "Superconductor Item!", "", "Supercondensator", "This is a special kind of Transformer", "It allows you to convert anything down", + "to 8192 EU/t, what is like a normal HVT.", "But if you apply Redstone to it then it", "outputs friggin 1000000EU/t!!!", "", "You also need it for the Fusion Reactor.", "Some Machines will require that high", "Voltage in a short period of time." }, new ItemStack[] { + null, null, GregTech_API.getGregTechItem(3, 1, 2), new ItemStack(GregTech_API.sBlockList[1], 1, 12), new ItemStack(GregTech_API.sBlockList[1], 1, 15), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Player Detector", "This nice little Device is able", "to detect Players in a Range of", "16-Spherical Meters and a", "EU-Consumption of 2.5EU/t.", "", "It can be switched to 3 Diffrent", "Modes, to detect YOURSELF, OTHERS", "and ALL Players by Rightclicking it.", "", + "It doesnt detect regular Mobs.", "", "", "", "", "", "~This Device has private Access~" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 13), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description( + new String[] { + "Matter Fabricator", + "The Matter Fabricator is nothing", + "else than a Mass Fabricator, which", + "can ONLY run on Scrap and other", + "Amplifiers.", + "", + "With the Default Config it is 100", + "times more expensive than normal.", + "Of course you can set the Config", + "to 166666, to get your normal", + "Massfabricationrate back, or you", + "could make Mass Fabrication even", + "cheaper, if you really want to", + "make Mass Fabrication that easy", + "", + "", + "" + }, + new ItemStack[] { + null, + null, + null, + GT_Utility.getFluidDisplayStack(FluidUtils.getUUM(1), false), + ItemList.Machine_LV_Massfab.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + new GT_Computercube_Description( + new String[] { + "Electric Autocrafting Tables", + "These are Crafting Tables for the", + "common need of autocrafting in", + "Factories. One Craft needs 5000EU to", + "be performed, so you have actually to", + "lay Wires to it. This Table is", + "unique as its also able, to give you", + "the used Capsulecellcontainers, made", + "by Industrial Corp, back.", + "You may use that behaviour to", + "craft anything releated to chemics,", + "like the 2xKNO3-Recipe for Saltpeter.", + "The 5 Modes are the following:", + "1. Craft Recipe, 2. All 5 Modes", + "3. Craft all as single Items", + "4. 2x2-Grid and 5. a 3x3-Grid.", + "It accepts only 32EU/p as Input." + }, + new ItemStack[] { + null, + null, + null, + null, + GregtechItemList.GT4_Electric_Auto_Workbench_LV.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + /* new GT_Computercube_Description(new String[] { + "Automation with GregTech", "Translocators and Buffers are the", "newest Way to automate your Machines.", "Screw Buildcraft, these EU-wasting", "Devices are much more awesome.", "They output 32EU/t to their directed", "IN- and OUT-puts, making them usefull", "for things, like saving wires.", "Translocators are taking Stuff from", "the Block at their green Inputfacing", + "and putting it into the Block at the", "red Outputfacing. Buffers do the same,", "but the grab Items from their own", "Inventory, what makes them usefull", "as Pipe-replacement.", "Buffers also have Redstone Intelligence,", "which you can configure in their GUI." }, new ItemStack[] { + null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 19), new ItemStack(GregTech_API.sBlockList[1], 1, 18), new ItemStack(GregTech_API.sBlockList[1], 1, 17), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Silver Ore", "It's rarity is similar to Gold", "Silver can be used, to make", "Circuits cheaper, or you can use", "it for Redpowerstuff.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("dustSilver", 1), GregTech_API.getGregTechItem(0, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 1), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Sapphires and Rubys", "These spawn exactly like Emeralds.", "But Rubies are found in Deserts,", "while Sapphires can be found in", "Oceans.", "", "They currently make only a cheaper", "Recipe for Energycrystals and", "Lapotroncrystals, but they are", "Redpower Compatible.", + "", "They also sometimes drop random", "other Gems, like Garnet for Ruby", "or green Sapphire for Sapphire", "in addition.", "", "" }, new ItemStack[] { + null, GregTech_API.getGregTechItem(0, 1, 32), new ItemStack(GregTech_API.sBlockList[2], 1, 3), GregTech_API.getGregTechItem(0, 1, 33), new ItemStack(GregTech_API.sBlockList[2], 1, 4), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Bauxite Ore", "The Stuff out of which you can", "produce Aluminium and also", "Titanium.", "You find this Ore in Plains and", "Forests.", "", "If you think Aluminium is useless", "then note, that mobs NEVER spawn", "ontop of an Aluminium Block", + "(Same applies also for Silver-,", "Gem- and Iridium Blocks)", "Production Chain:", "macerating Bauxite Ore", "electrolyzing 24 Bauxite Dust", "smelting Aluminium Dust in a", "Blast Furnace" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 7), GregTech_API.getGregTechItem(0, 1, 18), GregTech_API.getGregTechItem(1, 1, 18), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Titanium", "Produced by centrifuging Bauxitedust", "as a byproduct, this Material can make", "anything much more resistant against", "damage, like Explosions.", "Blocks made of Titaniumingots have a", "large Blastresistance", "", "It can also be used to craft tons of", "mixed Metal Ingots", + "", "", "", "", "", "", "" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 8), GregTech_API.getGregTechItem(0, 1, 19), GregTech_API.getGregTechItem(1, 1, 19), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Iridium Ore", "You can find it only when you", "stripmine very large Areas with", "Quarries and such. There is only", "one in every 5th-10th Chunk.", "It's even more rare in Oceans!", "", "Some people disable the UUM-Recipe", "for Iridium, for making getting it", "an Achievement.", + "", "However Iridium Ore contains traces", "of Platinum, so it's best to use the", "Industrial Grinder for this Ore.", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("plateAlloyIridium", 1), GT_ModHandler.getIC2Item("iridiumOre", 1), new ItemStack(GregTech_API.sBlockList[2], 1, 2), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Helium Coolant Cell", "These are just cheaper, than the", "Water based Coolant Cells, and can", "also hold six times more Heat.", "", "Helium Cells can also be used for", "making Luminators and Mininglasers", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + GregTech_API.getGregTechItem(2, 1, 6), GregTech_API.getGregTechItem(2, 1, 3), GregTech_API.getGregTechItem(34, 1, 0), GregTech_API.getGregTechItem(35, 1, 0), GregTech_API.getGregTechItem(36, 1, 0), null, null, null, null, null, + null, null, null, null }); + new GT_Computercube_Description(new String[] { + "Destructopack", "Open its GUI via rightclick and", "dump all the useless Stuff from", "your Inventory into it, instead of", "littering Items into the World.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(33, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + new GT_Computercube_Description( + new String[] { + "Data Orbs", + "They store Data.", + "", + "Rightclick on a Computer Cube, to", + "extract a Reactorplan", + "", + "Sneak-Rightclick on it, to insert", + "a Reactorplan", + "", + "Works also with Sonictrons", + "", + "", + "", + "", + "", + "", + "" + }, + new ItemStack[] { + null, + null, + null, + null, + ItemList.Tool_DataOrb.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + new GT_Computercube_Description( + new String[] { + "Energy Orbs", + "100 Million EU in one Orb!", + "", + "This is a Tier-IV-Energystorage", + "So a MFSU is not enough for it!", + "", + "Use it to create a Lapotron Pack,", + "which is like an ultimate Lap Pack!", + "", + "", + "", + "", + "", + "", + "", + "", + "" + }, + new ItemStack[] { + null, + null, + null, + null, + ItemList.Energy_LapotronicOrb.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + new GT_Computercube_Description( + new String[] { + "Iridium Neutron Reflector", + "It's used for Fusion Reactor Coils,", + "and works like a normal one", + "inside a Reactor, but it's also", + "INDESTRUCTIBLE*.", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "* = for weardown" + }, + new ItemStack[] { + null, + null, + null, + null, + ItemList.Neutron_Reflector.get(1), + null, + null, + null, + null, + null, + null, + null, + null, + null + }); + /*new GT_Computercube_Description(new String[] { + "Rock Cutter", "You want to get whole Blocks, but", "your Drill is not enchantable?", "The Rock Cutter has an awesome", "SilkTouch-III-Function!", "", "It works like a Drill, but you", "get the whole Block instead of", "'macerated' Ores!", "", + "Put those Blocks into a Macerator", "and double your Diamond Income!", "", "Or better. Use the Industrial", "Grinder to get even more", "Resources!", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(46, 1, 0), null, null, null, null, null, null, null, null, null }); - /*new GT_Computercube_Description(new String[] { - "Rock Cutter", "You want to get whole Blocks, but", "your Drill is not enchantable?", "The Rock Cutter has an awesome", "SilkTouch-III-Function!", "", "It works like a Drill, but you", "get the whole Block instead of", "'macerated' Ores!", "", - "Put those Blocks into a Macerator", "and double your Diamond Income!", "", "Or better. Use the Industrial", "Grinder to get even more", "Resources!", "" }, new ItemStack[] { - null, null, null, null, GregTech_API.getGregTechItem(46, 1, 0), null, null, null, null, null, - null, null, null, null }); - new GT_Computercube_Description(new String[] { - "Tesla Staff", "This completly untested PvP-Weapon", "destroys electric Armor in one hit", "", "The Energy Orb inside it must be", "fully charged to let this work.", "", "We are not responsible for any", "Electrocution Damage to yourself,", "while using it.", - "", "We also dont even know, if this", "Weapon has any effect AT ALL.", "", "", "", "" }, new ItemStack[] { - null, null, null, null, GregTech_API.getGregTechItem(47, 1, 0), null, null, null, null, null, - null, null, null, null });*/ - } + new GT_Computercube_Description(new String[] { + "Tesla Staff", "This completly untested PvP-Weapon", "destroys electric Armor in one hit", "", "The Energy Orb inside it must be", "fully charged to let this work.", "", "We are not responsible for any", "Electrocution Damage to yourself,", "while using it.", + "", "We also dont even know, if this", "Weapon has any effect AT ALL.", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(47, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Simulator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Simulator.java index e0bedb5d18..fc57930dda 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Simulator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_Computercube_Simulator.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.computer; -import java.util.ArrayList; -import java.util.HashMap; - import Ic2ExpReactorPlanner.AutomationSimulator; import Ic2ExpReactorPlanner.Reactor; import Ic2ExpReactorPlanner.SimulationData; @@ -12,138 +9,142 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; +import java.util.ArrayList; +import java.util.HashMap; public class GT_Computercube_Simulator { - private static final HashMap> sSlotPositions = new HashMap>(); - - static { - int aSlot = 4; - for (int column = 0; column < 6; column++) { - for (int row = 0; row < 9; row++) { - sSlotPositions.put(aSlot++, new Pair(row, column)); - } - } - } - - private final Reactor reactor = new Reactor(); - - public AutomationSimulator simulator = null; - /** - * The reactor that was last simulated. - */ - public Reactor simulatedReactor = null; - - private String currentReactorCode = null; - - private String currentReactorOldCode = null; - - private ArrayList output = new ArrayList(); - - private final GT_TileEntity_ComputerCube mTile; - - public GT_Computercube_Simulator(GT_TileEntity_ComputerCube aTile) { - mTile = aTile; - } - - public void slotClick(int aSlot, GT_ItemStack aStack) { - - /*if (selection != null) { - componentToPlace = ComponentFactory.createComponent(selection.getActionCommand()); - if (componentToPlace != null) { - componentToPlace.setInitialHeat(((Number)componentHeatSpinner.getValue()).intValue()); - componentToPlace.setAutomationThreshold(((Number)placingThresholdSpinner.getValue()).intValue()); - componentToPlace.setReactorPause(((Number)placingReactorPauseSpinner.getValue()).intValue()); - } - }*/ - if (aSlot >= 4 && aSlot < 58) { - Pair aSpot = sSlotPositions.get(aSlot); - ReactorItem aItem; - if (aStack == null) { - aItem = null; - } - else { - - Logger.INFO("Using lookup key: "+ItemUtils.getModId(aStack.toStack())+"."+aStack.mItem.getUnlocalizedName()+"."+aStack.mMetaData); - aItem = ReactorItem.sComponentMap.get(ItemUtils.getModId(aStack.toStack())+"."+aStack.mItem.getUnlocalizedName()+"."+aStack.mMetaData); - - } - int aRow = aSpot.getKey(); - int aColumn = aSpot.getValue(); - Logger.INFO("Putting "+(aItem == null ? "null" : aItem.name)+" at x:"+aRow+", y:"+aColumn); - reactor.setComponentAt(aColumn, aRow, aItem); - currentReactorCode = reactor.getCode(); - currentReactorOldCode = reactor.getOldCode(); - Logger.INFO("Code: "+currentReactorCode); - } - //maxHeatLabel.setText(formatI18n("UI.MaxHeatSpecific", reactor.getMaxHeat())); - //heatSpinnerModel.setMaximum(reactor.getMaxHeat() - 1); - //heatSpinnerModel.setValue(Math.min(((Number)heatSpinnerModel.getValue()).intValue(), reactor.getMaxHeat() - 1)); - //temperatureEffectsLabel.setText(formatI18n("UI.TemperatureEffectsSpecific", (int) (reactor.getMaxHeat() * 0.4), (int) (reactor.getMaxHeat() * 0.5), (int) (reactor.getMaxHeat() * 0.7), (int) (reactor.getMaxHeat() * 0.85), (int) (reactor.getMaxHeat() * 1.0))); - } - - public void simulate() { - /*if (Utils.isClient()) { - return; - }*/ - if (simulator != null && simulator.isRunning()) { - Logger.INFO("Simulator Running, Stopping."); - simulator.cancel(); - } - Logger.INFO("Starting Simulator."); - mTile.mHeat = 0; - mTile.mEU = 0; - currentReactorCode = reactor.getCode(); - currentReactorOldCode = reactor.getOldCode(); - output.clear(); - simulatedReactor = new Reactor(); - simulatedReactor.setCode(reactor.getCode()); - Logger.INFO("Making new AutomationSimulator."); - simulator = new AutomationSimulator(simulatedReactor, output, mTile); - Logger.INFO("Starting AutomationSimulator.process()."); - simulator.process(); - Logger.INFO("Done."); - - SimulationData aData = simulator.getData(); - if (aData != null && aData.totalReactorTicks > 0) { - mTile.mEU = aData.avgEUoutput * aData.totalReactorTicks; - mTile.mEUOut = aData.avgEUoutput; - mTile.mHeat = aData.avgHUoutput; - mTile.mMaxHeat = aData.maxHUoutput; - mTile.mExplosionStrength = aData.explosionPower; - mTile.mHEM = (float) aData.hullHeating; - mTile.mProgress = aData.totalReactorTicks; - } - - for (String s : output) { - Logger.INFO(" "+s); - } - } - - public ArrayList getOutputData() { - return output; - } - - private void clearGrid() { - reactor.clearGrid(); - /*for (int i = 0; i < reactorButtons.length; i++) { - for (int j = 0; j < reactorButtons[i].length; j++) { - reactorButtons[i][j].setIcon(null); - reactorButtons[i][j].setToolTipText(null); - reactorButtonPanels[i][j].setBackground(Color.LIGHT_GRAY); - } - }*/ - output.clear(); - /*materialsArea.setText(reactor.getMaterials().toString()); - componentListArea.setText(reactor.getComponentList().toString()); - maxHeatLabel.setText(formatI18n("UI.MaxHeatSpecific", reactor.getMaxHeat())); - heatSpinnerModel.setMaximum(reactor.getMaxHeat() - 1); - heatSpinnerModel.setValue(Math.min(((Number) heatSpinnerModel.getValue()).intValue(), reactor.getMaxHeat() - 1)); - temperatureEffectsLabel.setText(formatI18n("UI.TemperatureEffectsSpecific", (int)(reactor.getMaxHeat() * 0.4), (int)(reactor.getMaxHeat() * 0.5), (int)(reactor.getMaxHeat() * 0.7), (int)(reactor.getMaxHeat() * 0.85), (int)(reactor.getMaxHeat() * 1.0))); - lockCode = true; - codeField.setText(null); - lockCode = false;*/ - } - - + private static final HashMap> sSlotPositions = + new HashMap>(); + + static { + int aSlot = 4; + for (int column = 0; column < 6; column++) { + for (int row = 0; row < 9; row++) { + sSlotPositions.put(aSlot++, new Pair(row, column)); + } + } + } + + private final Reactor reactor = new Reactor(); + + public AutomationSimulator simulator = null; + /** + * The reactor that was last simulated. + */ + public Reactor simulatedReactor = null; + + private String currentReactorCode = null; + + private String currentReactorOldCode = null; + + private ArrayList output = new ArrayList(); + + private final GT_TileEntity_ComputerCube mTile; + + public GT_Computercube_Simulator(GT_TileEntity_ComputerCube aTile) { + mTile = aTile; + } + + public void slotClick(int aSlot, GT_ItemStack aStack) { + + /*if (selection != null) { + componentToPlace = ComponentFactory.createComponent(selection.getActionCommand()); + if (componentToPlace != null) { + componentToPlace.setInitialHeat(((Number)componentHeatSpinner.getValue()).intValue()); + componentToPlace.setAutomationThreshold(((Number)placingThresholdSpinner.getValue()).intValue()); + componentToPlace.setReactorPause(((Number)placingReactorPauseSpinner.getValue()).intValue()); + } + }*/ + if (aSlot >= 4 && aSlot < 58) { + Pair aSpot = sSlotPositions.get(aSlot); + ReactorItem aItem; + if (aStack == null) { + aItem = null; + } else { + + Logger.INFO("Using lookup key: " + ItemUtils.getModId(aStack.toStack()) + "." + + aStack.mItem.getUnlocalizedName() + "." + aStack.mMetaData); + aItem = ReactorItem.sComponentMap.get(ItemUtils.getModId(aStack.toStack()) + "." + + aStack.mItem.getUnlocalizedName() + "." + aStack.mMetaData); + } + int aRow = aSpot.getKey(); + int aColumn = aSpot.getValue(); + Logger.INFO("Putting " + (aItem == null ? "null" : aItem.name) + " at x:" + aRow + ", y:" + aColumn); + reactor.setComponentAt(aColumn, aRow, aItem); + currentReactorCode = reactor.getCode(); + currentReactorOldCode = reactor.getOldCode(); + Logger.INFO("Code: " + currentReactorCode); + } + // maxHeatLabel.setText(formatI18n("UI.MaxHeatSpecific", reactor.getMaxHeat())); + // heatSpinnerModel.setMaximum(reactor.getMaxHeat() - 1); + // heatSpinnerModel.setValue(Math.min(((Number)heatSpinnerModel.getValue()).intValue(), reactor.getMaxHeat() - + // 1)); + // temperatureEffectsLabel.setText(formatI18n("UI.TemperatureEffectsSpecific", (int) (reactor.getMaxHeat() * + // 0.4), (int) (reactor.getMaxHeat() * 0.5), (int) (reactor.getMaxHeat() * 0.7), (int) (reactor.getMaxHeat() * + // 0.85), (int) (reactor.getMaxHeat() * 1.0))); + } + + public void simulate() { + /*if (Utils.isClient()) { + return; + }*/ + if (simulator != null && simulator.isRunning()) { + Logger.INFO("Simulator Running, Stopping."); + simulator.cancel(); + } + Logger.INFO("Starting Simulator."); + mTile.mHeat = 0; + mTile.mEU = 0; + currentReactorCode = reactor.getCode(); + currentReactorOldCode = reactor.getOldCode(); + output.clear(); + simulatedReactor = new Reactor(); + simulatedReactor.setCode(reactor.getCode()); + Logger.INFO("Making new AutomationSimulator."); + simulator = new AutomationSimulator(simulatedReactor, output, mTile); + Logger.INFO("Starting AutomationSimulator.process()."); + simulator.process(); + Logger.INFO("Done."); + + SimulationData aData = simulator.getData(); + if (aData != null && aData.totalReactorTicks > 0) { + mTile.mEU = aData.avgEUoutput * aData.totalReactorTicks; + mTile.mEUOut = aData.avgEUoutput; + mTile.mHeat = aData.avgHUoutput; + mTile.mMaxHeat = aData.maxHUoutput; + mTile.mExplosionStrength = aData.explosionPower; + mTile.mHEM = (float) aData.hullHeating; + mTile.mProgress = aData.totalReactorTicks; + } + + for (String s : output) { + Logger.INFO(" " + s); + } + } + + public ArrayList getOutputData() { + return output; + } + + private void clearGrid() { + reactor.clearGrid(); + /*for (int i = 0; i < reactorButtons.length; i++) { + for (int j = 0; j < reactorButtons[i].length; j++) { + reactorButtons[i][j].setIcon(null); + reactorButtons[i][j].setToolTipText(null); + reactorButtonPanels[i][j].setBackground(Color.LIGHT_GRAY); + } + }*/ + output.clear(); + /*materialsArea.setText(reactor.getMaterials().toString()); + componentListArea.setText(reactor.getComponentList().toString()); + maxHeatLabel.setText(formatI18n("UI.MaxHeatSpecific", reactor.getMaxHeat())); + heatSpinnerModel.setMaximum(reactor.getMaxHeat() - 1); + heatSpinnerModel.setValue(Math.min(((Number) heatSpinnerModel.getValue()).intValue(), reactor.getMaxHeat() - 1)); + temperatureEffectsLabel.setText(formatI18n("UI.TemperatureEffectsSpecific", (int)(reactor.getMaxHeat() * 0.4), (int)(reactor.getMaxHeat() * 0.5), (int)(reactor.getMaxHeat() * 0.7), (int)(reactor.getMaxHeat() * 0.85), (int)(reactor.getMaxHeat() * 1.0))); + lockCode = true; + codeField.setText(null); + lockCode = false;*/ + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java index 2fba1b0448..9e507048ed 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java @@ -15,88 +15,132 @@ import gtPlusPlus.xmod.gregtech.common.items.covers.MetaItemCoverCasings; public class CoverManager { - // ZTones - public static MetaCustomCoverItem Cover_Agon; - public static MetaCustomCoverItem Cover_Iszm; - public static MetaCustomCoverItem Cover_Korp; - public static MetaCustomCoverItem Cover_Jelt; - public static MetaCustomCoverItem Cover_Bitt; + // ZTones + public static MetaCustomCoverItem Cover_Agon; + public static MetaCustomCoverItem Cover_Iszm; + public static MetaCustomCoverItem Cover_Korp; + public static MetaCustomCoverItem Cover_Jelt; + public static MetaCustomCoverItem Cover_Bitt; - // GT - public static MetaItemCoverCasings Cover_Gt_Machine_Casing; + // GT + public static MetaItemCoverCasings Cover_Gt_Machine_Casing; - public static void generateCustomCovers() { + public static void generateCustomCovers() { - // init textures - TexturesGtCutomCovers.init(); + // init textures + TexturesGtCutomCovers.init(); - // GT Machine Casings - Cover_Gt_Machine_Casing = new MetaItemCoverCasings(); + // GT Machine Casings + Cover_Gt_Machine_Casing = new MetaItemCoverCasings(); - if (Loader.isModLoaded("Ztones")) { - String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" }; - MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp, - Cover_Jelt, Cover_Bitt }; - CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, - TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT }; - short[][][] aRGB = new short[][][] { ZTONES.RGB_AGON, ZTONES.RGB_ISZM, ZTONES.RGB_KORP, ZTONES.RGB_JELT, - ZTONES.RGB_BITT }; - for (int y = 0; y < aZtoneCoverTextureNames.length; y++) { - aZtoneCoverItems[y] = new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y], - aRGB[y]); - } - } + if (Loader.isModLoaded("Ztones")) { + String[] aZtoneCoverTextureNames = new String[] {"agon", "iszm", "korp", "jelt", "bitt"}; + MetaCustomCoverItem[] aZtoneCoverItems = + new MetaCustomCoverItem[] {Cover_Agon, Cover_Iszm, Cover_Korp, Cover_Jelt, Cover_Bitt}; + CustomIcon[][] aArrays = new CustomIcon[][] { + TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT + }; + short[][][] aRGB = + new short[][][] {ZTONES.RGB_AGON, ZTONES.RGB_ISZM, ZTONES.RGB_KORP, ZTONES.RGB_JELT, ZTONES.RGB_BITT + }; + for (int y = 0; y < aZtoneCoverTextureNames.length; y++) { + aZtoneCoverItems[y] = + new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y], aRGB[y]); + } + } + } - } - - final static class ZTONES { - - private static final short[][] RGB_AGON = new short[][] { VanillaColours.DYE_WHITE.getAsShort(), - VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_LIME.getAsShort(), - VanillaColours.DYE_GREEN.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(), - VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(), - VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(), - VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_BROWN.getAsShort(), - VanillaColours.DYE_BLACK.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), - VanillaColours.DYE_LIGHT_GRAY.getAsShort(), }; - private static final short[][] RGB_ISZM = new short[][] { VanillaColours.DYE_LIGHT_GRAY.getAsShort(), - VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), - VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(), - VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_RED.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(), - VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_RED.getAsShort(), - VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(), - VanillaColours.DYE_DARK_PURPLE.getAsShort(), - }; - private static final short[][] RGB_KORP = new short[][] { new short[] { 125, 125, 125 }, - VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), - VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), - VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), - VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), - VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), - VanillaColours.DYE_DARK_GRAY.getAsShort(), new short[] { 22, 156, 156 }, new short[] { 22, 156, 156 }, - VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), }; - private static final short[][] RGB_JELT = new short[][] { VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_ORANGE.getAsShort(), }; - private static final short[][] RGB_BITT = new short[][] { VanillaColours.DYE_BLACK.getAsShort(), - VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(), - VanillaColours.DYE_LIME.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(), - VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(), - VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(), - VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(), - VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(), - VanillaColours.DYE_RED.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), - VanillaColours.DYE_BROWN.getAsShort(), }; - - } + static final class ZTONES { + private static final short[][] RGB_AGON = new short[][] { + VanillaColours.DYE_WHITE.getAsShort(), + VanillaColours.DYE_YELLOW.getAsShort(), + VanillaColours.DYE_LIME.getAsShort(), + VanillaColours.DYE_GREEN.getAsShort(), + VanillaColours.DYE_CYAN.getAsShort(), + VanillaColours.DYE_LIGHT_BLUE.getAsShort(), + VanillaColours.DYE_DARK_BLUE.getAsShort(), + VanillaColours.DYE_DARK_PURPLE.getAsShort(), + VanillaColours.DYE_LIGHT_PURPLE.getAsShort(), + VanillaColours.DYE_PINK.getAsShort(), + VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_BROWN.getAsShort(), + VanillaColours.DYE_BLACK.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_LIGHT_GRAY.getAsShort(), + }; + private static final short[][] RGB_ISZM = new short[][] { + VanillaColours.DYE_LIGHT_GRAY.getAsShort(), + VanillaColours.DYE_WHITE.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_BLUE.getAsShort(), + VanillaColours.DYE_YELLOW.getAsShort(), + VanillaColours.DYE_DARK_BLUE.getAsShort(), + VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_CYAN.getAsShort(), + VanillaColours.DYE_YELLOW.getAsShort(), + VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_CYAN.getAsShort(), + VanillaColours.DYE_GREEN.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_LIGHT_BLUE.getAsShort(), + VanillaColours.DYE_DARK_PURPLE.getAsShort(), + }; + private static final short[][] RGB_KORP = new short[][] { + new short[] {125, 125, 125}, + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + new short[] {22, 156, 156}, + new short[] {22, 156, 156}, + VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), + }; + private static final short[][] RGB_JELT = new short[][] { + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + }; + private static final short[][] RGB_BITT = new short[][] { + VanillaColours.DYE_BLACK.getAsShort(), + VanillaColours.DYE_WHITE.getAsShort(), + VanillaColours.DYE_YELLOW.getAsShort(), + VanillaColours.DYE_LIME.getAsShort(), + VanillaColours.DYE_GREEN.getAsShort(), + VanillaColours.DYE_CYAN.getAsShort(), + VanillaColours.DYE_LIGHT_BLUE.getAsShort(), + VanillaColours.DYE_LIGHT_BLUE.getAsShort(), + VanillaColours.DYE_DARK_BLUE.getAsShort(), + VanillaColours.DYE_DARK_PURPLE.getAsShort(), + VanillaColours.DYE_LIGHT_PURPLE.getAsShort(), + VanillaColours.DYE_PINK.getAsShort(), + VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_BROWN.getAsShort(), + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java index 072cf78c90..001b840df7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java @@ -1,7 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.covers; +import gregtech.api.enums.GT_Values; import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.minecraft.LangUtils; @@ -10,238 +13,261 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; -import gregtech.api.enums.GT_Values; -import gregtech.api.net.GT_Packet_TileEntityCover; - public class GTPP_Cover_Overflow extends GT_CoverBehavior { - public final int mTransferRate; - public final int mInitialTransferRate; - public final int mMaxTransferRate; - - public GTPP_Cover_Overflow(int aTransferRate) { - this.mTransferRate = aTransferRate * 1000 / 10; - this.mInitialTransferRate = aTransferRate; - this.mMaxTransferRate = aTransferRate * 1000; - } - - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - if (aCoverVariable == 0) { - return aCoverVariable; - } - if ((aTileEntity instanceof IFluidHandler)) { - //Logger.INFO("Trying to Void via Overflow."); - IFluidHandler tTank1; - ForgeDirection directionFrom; - directionFrom = ForgeDirection.UNKNOWN; - tTank1 = (IFluidHandler) aTileEntity; - if (tTank1 != null) { - //Logger.INFO("Found Self. "+aSide); - //FluidStack aTankStack = tTank1.drain(ForgeDirection.UNKNOWN, 1, false); - FluidStack aTankStack = tTank1.getTankInfo(directionFrom)[0].fluid; - if (aTankStack != null) { - //Logger.INFO("Found Fluid inside self - "+aTankStack.getLocalizedName()+", overflow point set at "+aCoverVariable+"L and we have "+aTankStack.amount+"L inside."); - if (aTankStack.amount > aCoverVariable) { - int aAmountToDrain = aTankStack.amount - aCoverVariable; - //Logger.INFO("There is "+aAmountToDrain+" more fluid in the tank than we would like."); - if (aAmountToDrain > 0) { - FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aAmountToDrain), true); - if (tLiquid != null) { - //Logger.INFO("Drained "+aAmountToDrain+"L."); - } - } - } - } - else { - //Logger.INFO("Could not simulate drain on self."); - } - } - } - return aCoverVariable; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable += (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); - } else { - aCoverVariable -= (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); - } - if (aCoverVariable > mMaxTransferRate) { - aCoverVariable = mInitialTransferRate; - } - if (aCoverVariable <= 0) { - aCoverVariable = mMaxTransferRate; - } - GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L")); - return aCoverVariable; - } - - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - boolean aShift = aPlayer.isSneaking(); - int aAmount = aShift ? 128 : 8; - if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable += aAmount; - } else { - aCoverVariable -= aAmount; - } - if (aCoverVariable > mMaxTransferRate) { - aCoverVariable = mInitialTransferRate; - } - if (aCoverVariable <= 0) { - aCoverVariable = mMaxTransferRate; - } - GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L")); - aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); - return true; - } - - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return true; - } - - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return true; - } - - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return false; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return true; - } - - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return 5; - } - - //GUI - @Override - public boolean hasCoverGUI() { - return true; - } - - @Override - public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { - return new GTPP_Cover_Overflow.GUI(aSide, aCoverID, coverData, aTileEntity); - } - - private class GUI extends GT_GUICover { - private final byte side; - private final int coverID; - private GT_GuiIntegerTextBox tBox; - private int coverVariable; - - private static final int startX = 10; - private static final int startY = 25; - private static final int spaceX = 18; - private static final int spaceY = 18; - - private boolean warn = false; - - public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); - this.side = aSide; - this.coverID = aCoverID; - this.coverVariable = aCoverVariable; - - tBox = new GT_GuiIntegerTextBox(this, 2, startX + spaceX * 0, startY + spaceY * 0 + 8, spaceX * 4 - 3, 12); - tBox.setText(String.valueOf(this.coverVariable)); - tBox.setMaxStringLength(10); - } - - @Override - protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { - tBox.setFocused(true); - } - - @Override - public void drawExtras(int mouseX, int mouseY, float parTicks) { - super.drawExtras(mouseX, mouseY, parTicks); - this.getFontRenderer().drawString(trans("323", "L"), startX + spaceX * 4, 4 + startY + spaceY * 0 + 8, 0xFF555555); - if (warn) - this.getFontRenderer().drawString(trans("325","Max")+": "+coverVariable+"/"+mMaxTransferRate+" "+trans("323", "L"), startX + spaceX * 0, 4 + startY + spaceY * 1 + 6, 0xffff0000); - else - this.getFontRenderer().drawString(trans("324","Now")+": "+coverVariable+"/"+mMaxTransferRate+" "+trans("323", "L"), startX + spaceX * 0, 4 + startY + spaceY * 1 + 6, 0xFF555555); - } - @Override - public void onMouseWheel(int x, int y, int delta) { - for (GT_GuiIntegerTextBox box : textBoxes){ - if (box.isFocused()) { - int step = Math.max(1, Math.abs(delta / 120)); - step = (isShiftKeyDown() ? 50 : isCtrlKeyDown() ? 5 : 1) * (delta > 0 ? step : -step); - long i; - try { - i = Long.parseLong(box.getText()); - } catch (NumberFormatException e) { - return; - } - if (i > (Long.MAX_VALUE-1000)) - break; - - i = i + step; - if (i <= 0) - i = 0; - box.setText(String.valueOf(i)); - break; - } - } - } - - @Override - public void applyTextBox(GT_GuiIntegerTextBox box) { - long i; - String s = box.getText().trim(); - try { - i = Long.parseLong(s); - } catch (NumberFormatException e) { - resetTextBox(box); - return; - } - - warn = false; - if (box.id == 2) { - if (i > (long) mMaxTransferRate) { - i = mMaxTransferRate; - warn = true; - } else if (i < 0) { - i = 0; - } - coverVariable = (int) i; - } - box.setText(String.valueOf(i)); - GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); - } - - @Override - public void resetTextBox(GT_GuiIntegerTextBox box) { - if (box.id == 2) - box.setText(String.valueOf(coverVariable)); - } - } + public final int mTransferRate; + public final int mInitialTransferRate; + public final int mMaxTransferRate; + + public GTPP_Cover_Overflow(int aTransferRate) { + this.mTransferRate = aTransferRate * 1000 / 10; + this.mInitialTransferRate = aTransferRate; + this.mMaxTransferRate = aTransferRate * 1000; + } + + public int doCoverThings( + byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if (aCoverVariable == 0) { + return aCoverVariable; + } + if ((aTileEntity instanceof IFluidHandler)) { + // Logger.INFO("Trying to Void via Overflow."); + IFluidHandler tTank1; + ForgeDirection directionFrom; + directionFrom = ForgeDirection.UNKNOWN; + tTank1 = (IFluidHandler) aTileEntity; + if (tTank1 != null) { + // Logger.INFO("Found Self. "+aSide); + // FluidStack aTankStack = tTank1.drain(ForgeDirection.UNKNOWN, 1, false); + FluidStack aTankStack = tTank1.getTankInfo(directionFrom)[0].fluid; + if (aTankStack != null) { + // Logger.INFO("Found Fluid inside self - "+aTankStack.getLocalizedName()+", overflow point set at + // "+aCoverVariable+"L and we have "+aTankStack.amount+"L inside."); + if (aTankStack.amount > aCoverVariable) { + int aAmountToDrain = aTankStack.amount - aCoverVariable; + // Logger.INFO("There is "+aAmountToDrain+" more fluid in the tank than we would like."); + if (aAmountToDrain > 0) { + FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aAmountToDrain), true); + if (tLiquid != null) { + // Logger.INFO("Drained "+aAmountToDrain+"L."); + } + } + } + } else { + // Logger.INFO("Could not simulate drain on self."); + } + } + } + return aCoverVariable; + } + + public int onCoverScrewdriverclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } else { + aCoverVariable -= (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } + if (aCoverVariable > mMaxTransferRate) { + aCoverVariable = mInitialTransferRate; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxTransferRate; + } + GT_Utility.sendChatToPlayer( + aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L")); + return aCoverVariable; + } + + public boolean onCoverRightclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + boolean aShift = aPlayer.isSneaking(); + int aAmount = aShift ? 128 : 8; + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += aAmount; + } else { + aCoverVariable -= aAmount; + } + if (aCoverVariable > mMaxTransferRate) { + aCoverVariable = mInitialTransferRate; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxTransferRate; + } + GT_Utility.sendChatToPlayer( + aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L")); + aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); + return true; + } + + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return false; + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; + } + + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 5; + } + + // GUI + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GTPP_Cover_Overflow.GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private GT_GuiIntegerTextBox tBox; + private int coverVariable; + + private static final int startX = 10; + private static final int startY = 25; + private static final int spaceX = 18; + private static final int spaceY = 18; + + private boolean warn = false; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + tBox = new GT_GuiIntegerTextBox(this, 2, startX + spaceX * 0, startY + spaceY * 0 + 8, spaceX * 4 - 3, 12); + tBox.setText(String.valueOf(this.coverVariable)); + tBox.setMaxStringLength(10); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + tBox.setFocused(true); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + this.getFontRenderer() + .drawString(trans("323", "L"), startX + spaceX * 4, 4 + startY + spaceY * 0 + 8, 0xFF555555); + if (warn) + this.getFontRenderer() + .drawString( + trans("325", "Max") + ": " + coverVariable + "/" + mMaxTransferRate + " " + + trans("323", "L"), + startX + spaceX * 0, + 4 + startY + spaceY * 1 + 6, + 0xffff0000); + else + this.getFontRenderer() + .drawString( + trans("324", "Now") + ": " + coverVariable + "/" + mMaxTransferRate + " " + + trans("323", "L"), + startX + spaceX * 0, + 4 + startY + spaceY * 1 + 6, + 0xFF555555); + } + + @Override + public void onMouseWheel(int x, int y, int delta) { + for (GT_GuiIntegerTextBox box : textBoxes) { + if (box.isFocused()) { + int step = Math.max(1, Math.abs(delta / 120)); + step = (isShiftKeyDown() ? 50 : isCtrlKeyDown() ? 5 : 1) * (delta > 0 ? step : -step); + long i; + try { + i = Long.parseLong(box.getText()); + } catch (NumberFormatException e) { + return; + } + if (i > (Long.MAX_VALUE - 1000)) break; + + i = i + step; + if (i <= 0) i = 0; + box.setText(String.valueOf(i)); + break; + } + } + } + + @Override + public void applyTextBox(GT_GuiIntegerTextBox box) { + long i; + String s = box.getText().trim(); + try { + i = Long.parseLong(s); + } catch (NumberFormatException e) { + resetTextBox(box); + return; + } + + warn = false; + if (box.id == 2) { + if (i > (long) mMaxTransferRate) { + i = mMaxTransferRate; + warn = true; + } else if (i < 0) { + i = 0; + } + coverVariable = (int) i; + } + box.setText(String.valueOf(i)); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + + @Override + public void resetTextBox(GT_GuiIntegerTextBox box) { + if (box.id == 2) box.setText(String.valueOf(coverVariable)); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java index 0299447694..16369f570f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.covers; -import java.lang.reflect.Field; -import java.util.HashMap; - import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -11,172 +8,189 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.LangUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; +import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; public class GTPP_Cover_Overflow_Item extends GT_CoverBehavior { - public final int mInitialCapacity; - public final int mMaxItemCapacity; - - public static final Class sQuantumChest; - public static final Class sSuperChestGTPP; - public static final Class sSuperChestGTNH; - public static HashMap mItemAmountFields = new HashMap(); - public static HashMap mItemTypeFields = new HashMap(); - - static { - sQuantumChest = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest"); - sSuperChestGTPP = ReflectionUtils.getClass("gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest"); - if (CORE.GTNH) { - sSuperChestGTNH = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest"); - } - else { - sSuperChestGTNH = null; - } - if (sQuantumChest != null) { - mItemAmountFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemCount")); - mItemTypeFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemStack")); - } - if (sSuperChestGTPP != null) { - mItemAmountFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemCount")); - mItemTypeFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemStack")); - } - if (sSuperChestGTNH != null) { - mItemAmountFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemCount")); - mItemTypeFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemStack")); - } - } - - public GTPP_Cover_Overflow_Item(int aCapacity) { - this.mInitialCapacity = aCapacity; - this.mMaxItemCapacity = aCapacity * 1000; - } - - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - if (aCoverVariable == 0) { - return aCoverVariable; - } - - // Get the IGTTile - IGregTechTileEntity aGtTileEntity = aTileEntity.getIGregTechTileEntity(aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord()); - if (aGtTileEntity == null) { - return aCoverVariable; - } - - // Get the MetaTile - final IMetaTileEntity aMetaTileEntity = aGtTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return aCoverVariable; - } - boolean didHandle = false; - // Special Case for everything I want to support. /facepalm - if (sQuantumChest != null && sQuantumChest.isInstance(aMetaTileEntity)) { - didHandle = handleDigitalChest(aMetaTileEntity, 0); - } - else if (sSuperChestGTPP.isInstance(aMetaTileEntity)) { - didHandle = handleDigitalChest(aMetaTileEntity, 1); - - } - else if (CORE.GTNH && sSuperChestGTNH != null && sSuperChestGTNH.isInstance(aMetaTileEntity)) { - didHandle = handleDigitalChest(aMetaTileEntity, 2); - } - + public final int mInitialCapacity; + public final int mMaxItemCapacity; + + public static final Class sQuantumChest; + public static final Class sSuperChestGTPP; + public static final Class sSuperChestGTNH; + public static HashMap mItemAmountFields = new HashMap(); + public static HashMap mItemTypeFields = new HashMap(); + + static { + sQuantumChest = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest"); + sSuperChestGTPP = ReflectionUtils.getClass( + "gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest"); + if (CORE.GTNH) { + sSuperChestGTNH = + ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest"); + } else { + sSuperChestGTNH = null; + } + if (sQuantumChest != null) { + mItemAmountFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemCount")); + mItemTypeFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemStack")); + } + if (sSuperChestGTPP != null) { + mItemAmountFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemCount")); + mItemTypeFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemStack")); + } + if (sSuperChestGTNH != null) { + mItemAmountFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemCount")); + mItemTypeFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemStack")); + } + } + + public GTPP_Cover_Overflow_Item(int aCapacity) { + this.mInitialCapacity = aCapacity; + this.mMaxItemCapacity = aCapacity * 1000; + } + + public int doCoverThings( + byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if (aCoverVariable == 0) { + return aCoverVariable; + } + + // Get the IGTTile + IGregTechTileEntity aGtTileEntity = aTileEntity.getIGregTechTileEntity( + aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord()); + if (aGtTileEntity == null) { + return aCoverVariable; + } + + // Get the MetaTile + final IMetaTileEntity aMetaTileEntity = aGtTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return aCoverVariable; + } + boolean didHandle = false; + // Special Case for everything I want to support. /facepalm + if (sQuantumChest != null && sQuantumChest.isInstance(aMetaTileEntity)) { + didHandle = handleDigitalChest(aMetaTileEntity, 0); + } else if (sSuperChestGTPP.isInstance(aMetaTileEntity)) { + didHandle = handleDigitalChest(aMetaTileEntity, 1); + + } else if (CORE.GTNH && sSuperChestGTNH != null && sSuperChestGTNH.isInstance(aMetaTileEntity)) { + didHandle = handleDigitalChest(aMetaTileEntity, 2); + } + + return aCoverVariable; + } + + private boolean handleDigitalChest(IMetaTileEntity aTile, int aType) { + int aItemAmount = (int) ReflectionUtils.getFieldValue(mItemAmountFields.get(aType), aTile); + ItemStack aItemType = (ItemStack) ReflectionUtils.getFieldValue(mItemTypeFields.get(aType), aTile); + + if (aItemType == null || aItemAmount <= 0) { + return false; + } else { + if (aItemAmount > mInitialCapacity) { + int aNewItemAmount = mInitialCapacity; + ReflectionUtils.setField(aTile, mItemAmountFields.get(aType), aNewItemAmount); + } + } + return true; + } + + public int onCoverScrewdriverclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += (mMaxItemCapacity * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } else { + aCoverVariable -= (mMaxItemCapacity * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } + if (aCoverVariable > mMaxItemCapacity) { + aCoverVariable = mInitialCapacity; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxItemCapacity; + } + GT_Utility.sendChatToPlayer( + aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); return aCoverVariable; - } - - private boolean handleDigitalChest(IMetaTileEntity aTile, int aType) { - int aItemAmount = (int) ReflectionUtils.getFieldValue(mItemAmountFields.get(aType), aTile); - ItemStack aItemType = (ItemStack) ReflectionUtils.getFieldValue(mItemTypeFields.get(aType), aTile); - - if (aItemType == null || aItemAmount <= 0) { - return false; - } - else { - if (aItemAmount > mInitialCapacity) { - int aNewItemAmount = mInitialCapacity; - ReflectionUtils.setField(aTile, mItemAmountFields.get(aType), aNewItemAmount); - } - } - return true; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable += (mMaxItemCapacity * (aPlayer.isSneaking() ? 0.1f : 0.01f)); - } else { - aCoverVariable -= (mMaxItemCapacity * (aPlayer.isSneaking() ? 0.1f : 0.01f)); - } - if (aCoverVariable > mMaxItemCapacity) { - aCoverVariable = mInitialCapacity; - } - if (aCoverVariable <= 0) { - aCoverVariable = mMaxItemCapacity; - } - GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); - return aCoverVariable; - } - - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - boolean aShift = aPlayer.isSneaking(); - int aAmount = aShift ? 128 : 8; - if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable += aAmount; - } else { - aCoverVariable -= aAmount; - } - if (aCoverVariable > mMaxItemCapacity) { - aCoverVariable = mInitialCapacity; - } - if (aCoverVariable <= 0) { - aCoverVariable = mMaxItemCapacity; - } - GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); - aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); - return true; - } - - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return true; - } - - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return true; - } - - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return false; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return true; - } - - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return 5; - } + } + + public boolean onCoverRightclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + boolean aShift = aPlayer.isSneaking(); + int aAmount = aShift ? 128 : 8; + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += aAmount; + } else { + aCoverVariable -= aAmount; + } + if (aCoverVariable > mMaxItemCapacity) { + aCoverVariable = mInitialCapacity; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxItemCapacity; + } + GT_Utility.sendChatToPlayer( + aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); + aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); + return true; + } + + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return false; + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; + } + + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 5; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java index 65b59ce151..b8b130e987 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.covers; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_CoverBehavior; @@ -11,6 +8,8 @@ import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.minecraft.LangUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -19,168 +18,182 @@ import net.minecraftforge.fluids.Fluid; public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { - private static final Map sConnectionStateForEntityMap = new ConcurrentHashMap(); - private static final Map sPrefixMap = new ConcurrentHashMap(); - private static final int VALUE_OFF = 0; - private static final int VALUE_ON = 1; - - public static String generateUniqueKey(byte aSide, ICoverable aEntity) { - try { - BlockPos aPos = new BlockPos(aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord())); - ForgeDirection aDir = ForgeDirection.getOrientation(aSide); - String s = aEntity.getInventoryName()+"."+aPos.getUniqueIdentifier()+aDir.name(); - return s; - } - catch (Throwable t) {} - XSTR x = new XSTR(); - return "ERROR."+x.getSeed()+x.hashCode()+x.nextDouble()+".ID"; - } - - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - PlayerUtils.messagePlayer(aPlayer, LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); - return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - return super.onCoverScrewdriverclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); - } - - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return 1; - } - - @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - try { - String aKey = generateUniqueKey(aSide, aTileEntity); - Integer b = sConnectionStateForEntityMap.get(aKey); - //Logger.INFO("Val: "+aCoverVariable); - if (b != null && aCoverVariable != b) { - aCoverVariable = b; - } - if (b == null) { - b = aCoverVariable; - sConnectionStateForEntityMap.put(aKey, b); - trySetState(aSide, b == VALUE_ON ? VALUE_ON : VALUE_OFF, aTileEntity); - } - } - catch (Throwable t) { - - } - return aCoverVariable; - } - - @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return super.alwaysLookConnected(aSide, aCoverID, aCoverVariable, aTileEntity); - } - - @Override - public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { - if (!getConnectionState(aCoverVariable)) { - return 0; - } - return super.getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity); - } - - @Override - public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { - String aKey = generateUniqueKey(aSide, aTileEntity); - boolean state = getCoverConnections(aCover); - sPrefixMap.put(aKey, aCover.getUnlocalizedName()); - Logger.INFO("Mapping key "+aKey+" to "+state); - sConnectionStateForEntityMap.put(aKey, state ? VALUE_ON : VALUE_OFF); - Logger.INFO("Key Value: "+(state ? VALUE_ON : VALUE_OFF)); - //Try set cover state directly - //trySetState(aSide, state ? VALUE_ON : VALUE_OFF, aTileEntity); - super.placeCover(aSide, aCover, aTileEntity); - } - - @Override - public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - boolean aForced) { - String aKey = generateUniqueKey(aSide, aTileEntity); - sConnectionStateForEntityMap.remove(aKey); - //Logger.INFO("Unmapping key "+aKey+"."); - return true; - } - - public static boolean getConnectionState(int aCoverVar) { - return aCoverVar == VALUE_ON; - } - - private static final void trySetState(byte aSide, int aState, ICoverable aTile) { - //Try set cover state directly - if (aTile instanceof IGregTechTileEntity) { - IGregTechTileEntity gTileEntity = (IGregTechTileEntity) aTile; - if (gTileEntity != null) { - gTileEntity.setCoverDataAtSide(aSide, aState); - } - } - } - - - public static boolean getConnectionState(byte aSide, ICoverable aTile) { - String aKey = generateUniqueKey(aSide, aTile); - return getConnectionState(aKey); - } - - public static boolean getConnectionState(String aKey) { - Integer b = sConnectionStateForEntityMap.get(aKey); - //Logger.INFO("Get State: "+b+" | "+aKey); - return b != null ? b == VALUE_ON : false; - } - - public static final boolean getCoverConnections(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("CustomCoverMeta"); - if (aNBT != null) { - return aNBT.getBoolean("AllowConnections"); - } - } - return false; - } -} \ No newline at end of file + private static final Map sConnectionStateForEntityMap = new ConcurrentHashMap(); + private static final Map sPrefixMap = new ConcurrentHashMap(); + private static final int VALUE_OFF = 0; + private static final int VALUE_ON = 1; + + public static String generateUniqueKey(byte aSide, ICoverable aEntity) { + try { + BlockPos aPos = new BlockPos( + aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord())); + ForgeDirection aDir = ForgeDirection.getOrientation(aSide); + String s = aEntity.getInventoryName() + "." + aPos.getUniqueIdentifier() + aDir.name(); + return s; + } catch (Throwable t) { + } + XSTR x = new XSTR(); + return "ERROR." + x.getSeed() + x.hashCode() + x.nextDouble() + ".ID"; + } + + public boolean onCoverRightclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + PlayerUtils.messagePlayer( + aPlayer, LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); + return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + } + + public int onCoverScrewdriverclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + return super.onCoverScrewdriverclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + } + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 1; + } + + @Override + public int doCoverThings( + byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + try { + String aKey = generateUniqueKey(aSide, aTileEntity); + Integer b = sConnectionStateForEntityMap.get(aKey); + // Logger.INFO("Val: "+aCoverVariable); + if (b != null && aCoverVariable != b) { + aCoverVariable = b; + } + if (b == null) { + b = aCoverVariable; + sConnectionStateForEntityMap.put(aKey, b); + trySetState(aSide, b == VALUE_ON ? VALUE_ON : VALUE_OFF, aTileEntity); + } + } catch (Throwable t) { + + } + return aCoverVariable; + } + + @Override + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + @Override + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + @Override + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return super.alwaysLookConnected(aSide, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public byte getRedstoneInput( + byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + if (!getConnectionState(aCoverVariable)) { + return 0; + } + return super.getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { + String aKey = generateUniqueKey(aSide, aTileEntity); + boolean state = getCoverConnections(aCover); + sPrefixMap.put(aKey, aCover.getUnlocalizedName()); + Logger.INFO("Mapping key " + aKey + " to " + state); + sConnectionStateForEntityMap.put(aKey, state ? VALUE_ON : VALUE_OFF); + Logger.INFO("Key Value: " + (state ? VALUE_ON : VALUE_OFF)); + // Try set cover state directly + // trySetState(aSide, state ? VALUE_ON : VALUE_OFF, aTileEntity); + super.placeCover(aSide, aCover, aTileEntity); + } + + @Override + public boolean onCoverRemoval( + byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { + String aKey = generateUniqueKey(aSide, aTileEntity); + sConnectionStateForEntityMap.remove(aKey); + // Logger.INFO("Unmapping key "+aKey+"."); + return true; + } + + public static boolean getConnectionState(int aCoverVar) { + return aCoverVar == VALUE_ON; + } + + private static final void trySetState(byte aSide, int aState, ICoverable aTile) { + // Try set cover state directly + if (aTile instanceof IGregTechTileEntity) { + IGregTechTileEntity gTileEntity = (IGregTechTileEntity) aTile; + if (gTileEntity != null) { + gTileEntity.setCoverDataAtSide(aSide, aState); + } + } + } + + public static boolean getConnectionState(byte aSide, ICoverable aTile) { + String aKey = generateUniqueKey(aSide, aTile); + return getConnectionState(aKey); + } + + public static boolean getConnectionState(String aKey) { + Integer b = sConnectionStateForEntityMap.get(aKey); + // Logger.INFO("Get State: "+b+" | "+aKey); + return b != null ? b == VALUE_ON : false; + } + + public static final boolean getCoverConnections(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + return aNBT.getBoolean("AllowConnections"); + } + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 69dd5ac9e9..a55cae39ea 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -1,8 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; +import static gregtech.api.GregTech_API.mEUtoRF; import cofh.api.energy.IEnergyContainerItem; import cpw.mods.fml.common.eventhandler.EventPriority; @@ -12,7 +10,6 @@ import gregtech.api.util.GT_ModHandler; import gregtech.common.items.GT_MetaGenerated_Item_01; import gregtech.common.items.GT_MetaGenerated_Item_02; import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -24,425 +21,440 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; -import static gregtech.api.GregTech_API.mEUtoRF; - public class ChargingHelper { - private static Map> mValidPlayers = new HashMap>(); - protected static Map mChargerMap = new HashMap(); - private int mTickTimer = 0; - private final int mTickMultiplier = 20; - - //Called whenever the player is updated or ticked. - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPlayerTick(LivingUpdateEvent event) { - try { - if (event.entity != null && event.entityLiving != null){ - if (event.entityLiving instanceof EntityPlayer){ - EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; - - - if (mPlayerMan != null){ - //Utils.LOG_WARNING("Found Player."); - - if (Utils.isServer()){ - //Utils.LOG_WARNING("Found Server-Side."); - - mTickTimer++; - if (mTickTimer % mTickMultiplier == 0){ - - long mVoltage = 0; - long mEuStored = 0; - - if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan.getDisplayName())){ - InventoryPlayer mPlayerInventory = mPlayerMan.inventory; - ItemStack[] mArmourContents = mPlayerInventory.armorInventory.clone(); - ItemStack[] mInventoryContents = mPlayerInventory.mainInventory.clone(); - - for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()){ - if (mEntityTemp != null){ - if (mEntityTemp.getBaseMetaTileEntity() == null || !mEntityTemp.getBaseMetaTileEntity().isAllowedToWork()) continue; - if (mPlayerMan.getEntityWorld().provider.dimensionId == mEntityTemp.getDimensionID()){ - mVoltage = mEntityTemp.maxEUInput(); - mEuStored = mEntityTemp.getEUVar(); - if (mVoltage > 0 && mEuStored >= mVoltage){ - - Map LR = mEntityTemp.getLongRangeMap(); - Map LO = mEntityTemp.getLocalMap(); - - long mStartingEu = mEntityTemp.getEUVar(); - long mCurrentEu = mEntityTemp.getEUVar(); - long mEuUsed = 0; - if (mEntityTemp.getMode() == 0){ - if (!LR.isEmpty() && LR.containsKey(mPlayerMan.getDisplayName())){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - } - else if (mEntityTemp.getMode() == 1){ - if (!LO.isEmpty() && LO.containsKey(mPlayerMan.getDisplayName())){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - } - else { - if (!LR.isEmpty() && LR.containsKey(mPlayerMan.getDisplayName())){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - if (!LO.isEmpty() && LO.containsKey(mPlayerMan.getDisplayName())){ - mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); - mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } - } - - if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0 && mEntityTemp != null){ - long mMaxDistance; - if (mEntityTemp.getMode() == 0){ - mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]); - } - else if (mEntityTemp.getMode() == 1){ - mMaxDistance = (mEntityTemp.getTier()*10); - } - else { - mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]/2); - } - double mDistance = calculateDistance(mEntityTemp, mPlayerMan); - long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); - - if (mVoltageCost > 0){ - if (mVoltageCost > mEntityTemp.maxEUInput()){ - mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mEntityTemp.maxEUInput())); - } - else { - mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mVoltageCost)); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - - catch (Throwable t){ - //Utils.LOG_WARNING("State of Wireless Charger changed in an invalid way, this prevented a crash."); - if (!mChargerMap.isEmpty()){ - for (BlockPos aPos : mChargerMap.keySet()) { - GregtechMetaWirelessCharger r = mChargerMap.get(aPos); - if (r == null || r.getBaseMetaTileEntity().isInvalidTileEntity()){ - mChargerMap.remove(aPos); - } - } - } - //t.printStackTrace(); - } - - - } - - public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ - if (mEntity == null){ - return false; - } - if (!mChargerMap.containsKey(mPos)){ - if (mChargerMap.put(mPos, mEntity) == null){ - return true; - } - else { - return false; - } - } - else { - return true; - } - } - - public static boolean removeEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ - if (mEntity == null){ - return false; - } - if (mChargerMap.containsKey(mPos)){ - if (mChargerMap.remove(mPos, mEntity)){ - return true; - } - else { - return false; - } - } - else { - return false; - } - } - - public static boolean addValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ - if (mEntity == null){ - return false; - } - Logger.WARNING("trying to map new player"); - if (mValidPlayers.containsKey(mPlayer.getDisplayName())){ - Logger.WARNING("Key contains player already?"); - return false; - } - else { - Logger.WARNING("key not found, adding"); - Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); - if (mValidPlayers.put(mPlayer.getDisplayName(), mEntry) == null){ - Logger.WARNING("Added a Player to the Tick Map."); - return true; - } - else { - Logger.WARNING("Tried to add player but it was already there?"); - return false; - } - } - } - - public static boolean removeValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ - if (mEntity == null){ - return false; - } - Logger.WARNING("trying to remove player from map"); - if (mValidPlayers.containsKey(mPlayer.getDisplayName())){ - Logger.WARNING("key found, removing"); - Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); - if (mValidPlayers.remove(mPlayer, mEntry)){ - Logger.WARNING("Removed a Player to the Tick Map."); - return true; - } - else { - Logger.WARNING("Tried to remove player but it was not there?"); - return false; - } - } - else { - Logger.WARNING("Key does not contain player?"); - return false; - } - } - - public double calculateDistance(GregtechMetaWirelessCharger mEntityTemp, EntityPlayer mPlayerMan){ - if (mEntityTemp == null || mPlayerMan == null){ - return 0; - } - return mEntityTemp.getDistanceBetweenTwoPositions(mEntityTemp.getTileEntityPosition(), mEntityTemp.getPositionOfEntity(mPlayerMan)); - } - - public long chargeItems(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ - if (mEntity == null){ - return -100; - } - if (mItems == null || mItems.length == 0){ - return mEntity.getEUVar(); - } - long mInitialValue = mEntity.getEUVar(); - long mReturnValue = chargeItemsEx(mEntity, mItems, mPlayer); - return ((mReturnValue < mInitialValue) ? mReturnValue : mInitialValue); - } - - public long chargeItemsEx(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ - - //Bad Entity - if (mEntity == null){ - return -100; - } - //Bad Inventory - if (mItems == null || mItems.length == 0){ - return mEntity.getEUVar(); - } - //Set Variables to Charge - int mChargedItems = 0; - final int mTier = mEntity.getTier(); - final long mVoltage = mEntity.maxEUInput(); - long mEuStored = mEntity.getEUVar(); - final long mEuStoredOriginal = mEntity.getEUVar(); - //For Inventory Contents - - int mItemSlot = 0; - - for (ItemStack mTemp : mItems){ - mItemSlot++; - if (mTemp != null){ - Logger.WARNING("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); - } - //Is item Electrical - if (isItemValid(mTemp)){ - Logger.WARNING("1"); - - //Transfer Limit - double mItemEuTLimit = ((IElectricItem) mTemp.getItem()).getTransferLimit(mTemp); - //Check if Tile has more or equal EU to what can be transferred into the item. - if (mEuStored >= mItemEuTLimit){ - Logger.WARNING("2"); - - double mItemMaxCharge = ((IElectricItem) mTemp.getItem()).getMaxCharge(mTemp); - double mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); - - if (mitemCurrentCharge >= mItemMaxCharge){ - continue; - } - - //Try get charge direct from NBT for GT and IC2 stacks - Logger.WARNING("3"); - if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 - || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 - || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 - || ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) - || mTemp.getItem().getClass().getName().toLowerCase().equals(("gregtech.common.items.GT_MetaGenerated_Tool_01").toLowerCase())){ - if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")){ - if (!mTemp.getDisplayName().toLowerCase().contains("battery")){ - if (!GT_ModHandler.isElectricItem(mTemp)){ - continue; - } - } - else { - mitemCurrentCharge = 0; - } - } - else { - mitemCurrentCharge = NBTUtils.getLong(mTemp, "GT.ItemCharge"); - } - } - else if (mTemp.getItem() instanceof IElectricItem){ - mitemCurrentCharge = NBTUtils.getLong(mTemp, "charge"); - } - - double mVoltageIncrease; - if (mItemEuTLimit >= mVoltage){ - mVoltageIncrease = mVoltage; - } - else if (mItemEuTLimit < mVoltage){ - mVoltageIncrease = mItemEuTLimit; - } - else { - mVoltageIncrease = mItemEuTLimit; - } - - Logger.WARNING("4"); - - int mMulti; - if ((mitemCurrentCharge + (mVoltageIncrease*20)) <= (mItemMaxCharge - (mVoltageIncrease*20))){ - mMulti = 20; - } - else if ((mitemCurrentCharge + (mVoltageIncrease*10)) <= (mItemMaxCharge - (mVoltageIncrease*10))){ - mMulti = 10; - } - else if ((mitemCurrentCharge + (mVoltageIncrease*5)) <= (mItemMaxCharge - (mVoltageIncrease*5))){ - mMulti = 5; - } - else { - mMulti = 1; - } - Logger.WARNING("5"); - - - int mMultiVoltage = (int) (mMulti*mVoltageIncrease); - - if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge){ - Logger.WARNING("6"); - int g = 0; - if ((g = GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, Integer.MAX_VALUE, true, false)) > 0){ - Logger.WARNING("6.5 - "+g+" - "+mMulti); - for (int i=0; i 0){ - continue; - } - } - } - if (ElectricItem.manager.getCharge(mTemp) > mitemCurrentCharge){ - Logger.WARNING("7"); - mEntity.setEUVar(mEuStored-(mVoltage*mMulti)); - mEuStored = mEntity.getEUVar(); - Logger.WARNING("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); - mChargedItems++; - } - } - - //Try top up Item Chrage - mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); - if (mitemCurrentCharge < mItemMaxCharge && mitemCurrentCharge >= (mItemMaxCharge-mVoltage)){ - int xDif = (int) (mItemMaxCharge - mitemCurrentCharge); - Logger.WARNING("8 - "+xDif); - int g = 0; - if ((g = GT_ModHandler.chargeElectricItem(mTemp, xDif, Integer.MAX_VALUE, true, false)) >= 0){ - Logger.WARNING("8.5 - "+g); - if (ElectricItem.manager.getCharge(mTemp) >= mItemMaxCharge){ - Logger.WARNING("9"); - mEntity.setEUVar(mEntity.getEUVar()-(xDif)); - mEuStored = mEntity.getEUVar(); - Logger.WARNING("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); - mChargedItems++; - } - } - } - - - } - } - else if (isItemValidRF(mTemp)) { - try { - IEnergyContainerItem rfItem = (IEnergyContainerItem)mTemp.getItem(); - long chargedPower = Math.min(rfItem.getMaxEnergyStored(mTemp) - rfItem.getEnergyStored(mTemp), mEntity.getEUVar() * mEUtoRF / 100L); - chargedPower = rfItem.receiveEnergy(mTemp, chargedPower > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) chargedPower, false); - chargedPower = chargedPower * 100L / mEUtoRF; - mEntity.setEUVar(Math.max(mEntity.getEUVar() - chargedPower, 0)); - mChargedItems++; - mEuStored = mEntity.getEUVar(); - } catch (Exception e) { - Logger.WARNING("Failed charging of RF-Tool"); - } - } - else { - if (mTemp != null){ - Logger.WARNING("Found Non-Valid item. "+mTemp.getDisplayName()); - } - } - } - - //Return Values - if (mChargedItems < 1){ - return mEuStoredOriginal; - } - - return mEntity.getEUVar(); - } - - public static boolean isItemValid(final ItemStack itemstack) { - if (itemstack == null){ - return false; - } - if (GT_ModHandler.isElectricItem(itemstack)){ - return true; - } - if ((accepts(itemstack)) || (itemstack.getItem() instanceof IElectricItem)) { - return true; - } - return false; - } - - public static boolean isItemValidRF(final ItemStack itemStack) { - return itemStack != null && LoadedMods.CoFHCore && itemStack.getItem() instanceof IEnergyContainerItem; - } - - public static boolean accepts(final ItemStack stack) { - if (stack == null) { - return false; - } - else { - return false; - } - //return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); - } - + private static Map> mValidPlayers = + new HashMap>(); + protected static Map mChargerMap = + new HashMap(); + private int mTickTimer = 0; + private final int mTickMultiplier = 20; + + // Called whenever the player is updated or ticked. + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerTick(LivingUpdateEvent event) { + try { + if (event.entity != null && event.entityLiving != null) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; + + if (mPlayerMan != null) { + // Utils.LOG_WARNING("Found Player."); + + if (Utils.isServer()) { + // Utils.LOG_WARNING("Found Server-Side."); + + mTickTimer++; + if (mTickTimer % mTickMultiplier == 0) { + + long mVoltage = 0; + long mEuStored = 0; + + if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan.getDisplayName())) { + InventoryPlayer mPlayerInventory = mPlayerMan.inventory; + ItemStack[] mArmourContents = mPlayerInventory.armorInventory.clone(); + ItemStack[] mInventoryContents = mPlayerInventory.mainInventory.clone(); + + for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()) { + if (mEntityTemp != null) { + if (mEntityTemp.getBaseMetaTileEntity() == null + || !mEntityTemp + .getBaseMetaTileEntity() + .isAllowedToWork()) continue; + if (mPlayerMan.getEntityWorld().provider.dimensionId + == mEntityTemp.getDimensionID()) { + mVoltage = mEntityTemp.maxEUInput(); + mEuStored = mEntityTemp.getEUVar(); + if (mVoltage > 0 && mEuStored >= mVoltage) { + + Map LR = mEntityTemp.getLongRangeMap(); + Map LO = mEntityTemp.getLocalMap(); + + long mStartingEu = mEntityTemp.getEUVar(); + long mCurrentEu = mEntityTemp.getEUVar(); + long mEuUsed = 0; + if (mEntityTemp.getMode() == 0) { + if (!LR.isEmpty() + && LR.containsKey(mPlayerMan.getDisplayName())) { + mCurrentEu = chargeItems( + mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems( + mEntityTemp, mInventoryContents, mPlayerMan); + } + } else if (mEntityTemp.getMode() == 1) { + if (!LO.isEmpty() + && LO.containsKey(mPlayerMan.getDisplayName())) { + mCurrentEu = chargeItems( + mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems( + mEntityTemp, mInventoryContents, mPlayerMan); + } + } else { + if (!LR.isEmpty() + && LR.containsKey(mPlayerMan.getDisplayName())) { + mCurrentEu = chargeItems( + mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems( + mEntityTemp, mInventoryContents, mPlayerMan); + } + if (!LO.isEmpty() + && LO.containsKey(mPlayerMan.getDisplayName())) { + mCurrentEu = chargeItems( + mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems( + mEntityTemp, mInventoryContents, mPlayerMan); + } + } + + if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0 + && mEntityTemp != null) { + long mMaxDistance; + if (mEntityTemp.getMode() == 0) { + mMaxDistance = (4 * GT_Values.V[mEntityTemp.getTier()]); + } else if (mEntityTemp.getMode() == 1) { + mMaxDistance = (mEntityTemp.getTier() * 10); + } else { + mMaxDistance = (4 * GT_Values.V[mEntityTemp.getTier()] / 2); + } + double mDistance = calculateDistance(mEntityTemp, mPlayerMan); + long mVoltageCost = MathUtils.findPercentageOfInt( + mMaxDistance, (float) mDistance); + + if (mVoltageCost > 0) { + if (mVoltageCost > mEntityTemp.maxEUInput()) { + mEntityTemp.setEUVar((mEntityTemp.getEUVar() + - mEntityTemp.maxEUInput())); + } else { + mEntityTemp.setEUVar( + (mEntityTemp.getEUVar() - mVoltageCost)); + } + } + } + } + } + } + } + } + } + } + } + } + } + } catch (Throwable t) { + // Utils.LOG_WARNING("State of Wireless Charger changed in an invalid way, this prevented a crash."); + if (!mChargerMap.isEmpty()) { + for (BlockPos aPos : mChargerMap.keySet()) { + GregtechMetaWirelessCharger r = mChargerMap.get(aPos); + if (r == null || r.getBaseMetaTileEntity().isInvalidTileEntity()) { + mChargerMap.remove(aPos); + } + } + } + // t.printStackTrace(); + } + } + + public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity) { + if (mEntity == null) { + return false; + } + if (!mChargerMap.containsKey(mPos)) { + if (mChargerMap.put(mPos, mEntity) == null) { + return true; + } else { + return false; + } + } else { + return true; + } + } + + public static boolean removeEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity) { + if (mEntity == null) { + return false; + } + if (mChargerMap.containsKey(mPos)) { + if (mChargerMap.remove(mPos, mEntity)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + public static boolean addValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity) { + if (mEntity == null) { + return false; + } + Logger.WARNING("trying to map new player"); + if (mValidPlayers.containsKey(mPlayer.getDisplayName())) { + Logger.WARNING("Key contains player already?"); + return false; + } else { + Logger.WARNING("key not found, adding"); + Pair mEntry = + new Pair(mEntity, (byte) mEntity.getMode()); + if (mValidPlayers.put(mPlayer.getDisplayName(), mEntry) == null) { + Logger.WARNING("Added a Player to the Tick Map."); + return true; + } else { + Logger.WARNING("Tried to add player but it was already there?"); + return false; + } + } + } + + public static boolean removeValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity) { + if (mEntity == null) { + return false; + } + Logger.WARNING("trying to remove player from map"); + if (mValidPlayers.containsKey(mPlayer.getDisplayName())) { + Logger.WARNING("key found, removing"); + Pair mEntry = + new Pair(mEntity, (byte) mEntity.getMode()); + if (mValidPlayers.remove(mPlayer, mEntry)) { + Logger.WARNING("Removed a Player to the Tick Map."); + return true; + } else { + Logger.WARNING("Tried to remove player but it was not there?"); + return false; + } + } else { + Logger.WARNING("Key does not contain player?"); + return false; + } + } + + public double calculateDistance(GregtechMetaWirelessCharger mEntityTemp, EntityPlayer mPlayerMan) { + if (mEntityTemp == null || mPlayerMan == null) { + return 0; + } + return mEntityTemp.getDistanceBetweenTwoPositions( + mEntityTemp.getTileEntityPosition(), mEntityTemp.getPositionOfEntity(mPlayerMan)); + } + + public long chargeItems(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer) { + if (mEntity == null) { + return -100; + } + if (mItems == null || mItems.length == 0) { + return mEntity.getEUVar(); + } + long mInitialValue = mEntity.getEUVar(); + long mReturnValue = chargeItemsEx(mEntity, mItems, mPlayer); + return ((mReturnValue < mInitialValue) ? mReturnValue : mInitialValue); + } + + public long chargeItemsEx(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer) { + + // Bad Entity + if (mEntity == null) { + return -100; + } + // Bad Inventory + if (mItems == null || mItems.length == 0) { + return mEntity.getEUVar(); + } + // Set Variables to Charge + int mChargedItems = 0; + final int mTier = mEntity.getTier(); + final long mVoltage = mEntity.maxEUInput(); + long mEuStored = mEntity.getEUVar(); + final long mEuStoredOriginal = mEntity.getEUVar(); + // For Inventory Contents + + int mItemSlot = 0; + + for (ItemStack mTemp : mItems) { + mItemSlot++; + if (mTemp != null) { + Logger.WARNING("Slot " + mItemSlot + " contains " + mTemp.getDisplayName()); + } + // Is item Electrical + if (isItemValid(mTemp)) { + Logger.WARNING("1"); + + // Transfer Limit + double mItemEuTLimit = ((IElectricItem) mTemp.getItem()).getTransferLimit(mTemp); + // Check if Tile has more or equal EU to what can be transferred into the item. + if (mEuStored >= mItemEuTLimit) { + Logger.WARNING("2"); + + double mItemMaxCharge = ((IElectricItem) mTemp.getItem()).getMaxCharge(mTemp); + double mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); + + if (mitemCurrentCharge >= mItemMaxCharge) { + continue; + } + + // Try get charge direct from NBT for GT and IC2 stacks + Logger.WARNING("3"); + if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 + || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 + || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 + || ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03") + .isInstance(mTemp.getItem()) + || mTemp.getItem() + .getClass() + .getName() + .toLowerCase() + .equals(("gregtech.common.items.GT_MetaGenerated_Tool_01").toLowerCase())) { + if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")) { + if (!mTemp.getDisplayName().toLowerCase().contains("battery")) { + if (!GT_ModHandler.isElectricItem(mTemp)) { + continue; + } + } else { + mitemCurrentCharge = 0; + } + } else { + mitemCurrentCharge = NBTUtils.getLong(mTemp, "GT.ItemCharge"); + } + } else if (mTemp.getItem() instanceof IElectricItem) { + mitemCurrentCharge = NBTUtils.getLong(mTemp, "charge"); + } + + double mVoltageIncrease; + if (mItemEuTLimit >= mVoltage) { + mVoltageIncrease = mVoltage; + } else if (mItemEuTLimit < mVoltage) { + mVoltageIncrease = mItemEuTLimit; + } else { + mVoltageIncrease = mItemEuTLimit; + } + + Logger.WARNING("4"); + + int mMulti; + if ((mitemCurrentCharge + (mVoltageIncrease * 20)) <= (mItemMaxCharge - (mVoltageIncrease * 20))) { + mMulti = 20; + } else if ((mitemCurrentCharge + (mVoltageIncrease * 10)) + <= (mItemMaxCharge - (mVoltageIncrease * 10))) { + mMulti = 10; + } else if ((mitemCurrentCharge + (mVoltageIncrease * 5)) + <= (mItemMaxCharge - (mVoltageIncrease * 5))) { + mMulti = 5; + } else { + mMulti = 1; + } + Logger.WARNING("5"); + + int mMultiVoltage = (int) (mMulti * mVoltageIncrease); + + if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge) { + Logger.WARNING("6"); + int g = 0; + if ((g = GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, Integer.MAX_VALUE, true, false)) + > 0) { + Logger.WARNING("6.5 - " + g + " - " + mMulti); + for (int i = 0; i < mMulti; i++) { + if (ElectricItem.manager.charge( + mTemp, mVoltageIncrease, Integer.MAX_VALUE, false, false) + > 0) { + continue; + } + } + } + if (ElectricItem.manager.getCharge(mTemp) > mitemCurrentCharge) { + Logger.WARNING("7"); + mEntity.setEUVar(mEuStored - (mVoltage * mMulti)); + mEuStored = mEntity.getEUVar(); + Logger.WARNING("Charged " + mTemp.getDisplayName() + " | Slot: " + mItemSlot + + " | EU Multiplier: " + mMulti + " | EU/t input: " + mVoltageIncrease + + " | EU/t consumed by Tile: " + mVoltage + " | Item Max Charge: " + mItemMaxCharge + + " | Item Start Charge: " + mitemCurrentCharge + " | Item New Charge" + + ElectricItem.manager.getCharge(mTemp)); + mChargedItems++; + } + } + + // Try top up Item Chrage + mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); + if (mitemCurrentCharge < mItemMaxCharge && mitemCurrentCharge >= (mItemMaxCharge - mVoltage)) { + int xDif = (int) (mItemMaxCharge - mitemCurrentCharge); + Logger.WARNING("8 - " + xDif); + int g = 0; + if ((g = GT_ModHandler.chargeElectricItem(mTemp, xDif, Integer.MAX_VALUE, true, false)) >= 0) { + Logger.WARNING("8.5 - " + g); + if (ElectricItem.manager.getCharge(mTemp) >= mItemMaxCharge) { + Logger.WARNING("9"); + mEntity.setEUVar(mEntity.getEUVar() - (xDif)); + mEuStored = mEntity.getEUVar(); + Logger.WARNING("Charged " + mTemp.getDisplayName() + " | Slot: " + mItemSlot + + " | EU Multiplier: " + mMulti + " | EU/t input: " + mVoltageIncrease + + " | EU/t consumed by Tile: " + mVoltage + " | Item Max Charge: " + + mItemMaxCharge + " | Item Start Charge: " + mitemCurrentCharge + + " | Item New Charge" + ElectricItem.manager.getCharge(mTemp)); + mChargedItems++; + } + } + } + } + } else if (isItemValidRF(mTemp)) { + try { + IEnergyContainerItem rfItem = (IEnergyContainerItem) mTemp.getItem(); + long chargedPower = Math.min( + rfItem.getMaxEnergyStored(mTemp) - rfItem.getEnergyStored(mTemp), + mEntity.getEUVar() * mEUtoRF / 100L); + chargedPower = rfItem.receiveEnergy( + mTemp, chargedPower > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) chargedPower, false); + chargedPower = chargedPower * 100L / mEUtoRF; + mEntity.setEUVar(Math.max(mEntity.getEUVar() - chargedPower, 0)); + mChargedItems++; + mEuStored = mEntity.getEUVar(); + } catch (Exception e) { + Logger.WARNING("Failed charging of RF-Tool"); + } + } else { + if (mTemp != null) { + Logger.WARNING("Found Non-Valid item. " + mTemp.getDisplayName()); + } + } + } + + // Return Values + if (mChargedItems < 1) { + return mEuStoredOriginal; + } + + return mEntity.getEUVar(); + } + + public static boolean isItemValid(final ItemStack itemstack) { + if (itemstack == null) { + return false; + } + if (GT_ModHandler.isElectricItem(itemstack)) { + return true; + } + if ((accepts(itemstack)) || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } + + public static boolean isItemValidRF(final ItemStack itemStack) { + return itemStack != null && LoadedMods.CoFHCore && itemStack.getItem() instanceof IEnergyContainerItem; + } + + public static boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } else { + return false; + } + // return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) || (ElectricItem.manager.discharge(stack, (1.0D / + // 0.0D), 4, true, true, true) > 0.0D); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/CraftingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/CraftingHelper.java index e06636e168..bb81c349a0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/CraftingHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/CraftingHelper.java @@ -1,42 +1,38 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.common.helpers.autocrafter.AC_Helper_Container; import gtPlusPlus.xmod.gregtech.common.helpers.autocrafter.AC_Helper_Utils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; -import net.minecraftforge.common.util.FakePlayerFactory; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; -public class CraftingHelper{ +public class CraftingHelper { - public final String mInventoryName; - public final int mPosX; - public final int mPosY; - public final int mPosZ; - public final GT4Entity_AutoCrafter crafter; - public final World world; - public final EntityPlayerMP player; - public final AC_Helper_Container inventory; + public final String mInventoryName; + public final int mPosX; + public final int mPosY; + public final int mPosZ; + public final GT4Entity_AutoCrafter crafter; + public final World world; + public final EntityPlayerMP player; + public final AC_Helper_Container inventory; - public CraftingHelper(GT4Entity_AutoCrafter AC){ - Logger.INFO("[A-C] Created a crafting helper."); - crafter = AC; - AC_Helper_Utils.addCrafter(AC); - //Get some variables. - world = AC.getBaseMetaTileEntity().getWorld(); - mPosX = AC.getBaseMetaTileEntity().getXCoord(); - mPosY = AC.getBaseMetaTileEntity().getYCoord(); - mPosZ = AC.getBaseMetaTileEntity().getZCoord(); - //Create Fake player to handle crating. - - player = CORE.getFakePlayer(world); - //Set storage container - inventory = new AC_Helper_Container(player.inventory, world, mPosX, mPosY, mPosZ); - mInventoryName = inventory.getMatrix().getInventoryName(); + public CraftingHelper(GT4Entity_AutoCrafter AC) { + Logger.INFO("[A-C] Created a crafting helper."); + crafter = AC; + AC_Helper_Utils.addCrafter(AC); + // Get some variables. + world = AC.getBaseMetaTileEntity().getWorld(); + mPosX = AC.getBaseMetaTileEntity().getXCoord(); + mPosY = AC.getBaseMetaTileEntity().getYCoord(); + mPosZ = AC.getBaseMetaTileEntity().getZCoord(); + // Create Fake player to handle crating. - } -} \ No newline at end of file + player = CORE.getFakePlayer(world); + // Set storage container + inventory = new AC_Helper_Container(player.inventory, world, mPosX, mPosY, mPosZ); + mInventoryName = inventory.getMatrix().getInventoryName(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java index 8a2c82535f..bb8dac49d7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java @@ -1,63 +1,60 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import java.util.HashMap; - import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.sys.Log; import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix; +import java.util.HashMap; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class FlotationRecipeHandler { - private static final HashMap sMaterialMap = new HashMap(); - private static final HashMap sMilledMap = new HashMap(); - - public static boolean registerOreType(Material aMaterial) { - String aMaterialKey = aMaterial.getUnlocalizedName(); - if (sMaterialMap.containsKey(aMaterialKey)) { - Log.warn("Tried to register a Flotation material already in use. Material: "+aMaterialKey); - return false; - } - else { - sMaterialMap.put(aMaterialKey, aMaterial); - sMilledMap.put(aMaterialKey, aMaterial.getMilled(1)); - } - return true; - } - - public static Material getMaterialOfMilledProduct(ItemStack aMilled) { - for (String aKey : sMilledMap.keySet()) { - ItemStack aTempMilledStack = sMilledMap.get(aKey); - if (GT_Utility.areStacksEqual(aTempMilledStack, aMilled, true)) { - return sMaterialMap.get(aKey); - } - } - return null; - } - - public static ItemStack findMilledStack(GT_Recipe aRecipe) { - if (aRecipe == null || aRecipe.mInputs == null || aRecipe.mInputs.length <= 0) { - return null; - } - return findMilledStack(aRecipe.mInputs); - } - - public static ItemStack findMilledStack(ItemStack[] aInputs) { - if (aInputs == null || aInputs.length <= 0) { - return null; - } - for (ItemStack aStack : aInputs) { - for (int oredictID : OreDictionary.getOreIDs(aStack)) { - String oredict = OreDictionary.getOreName(oredictID); - if (oredict.startsWith(CustomOrePrefix.milled.toString())) { - return aStack; - } - } - } - return null; - } - + private static final HashMap sMaterialMap = new HashMap(); + private static final HashMap sMilledMap = new HashMap(); + + public static boolean registerOreType(Material aMaterial) { + String aMaterialKey = aMaterial.getUnlocalizedName(); + if (sMaterialMap.containsKey(aMaterialKey)) { + Log.warn("Tried to register a Flotation material already in use. Material: " + aMaterialKey); + return false; + } else { + sMaterialMap.put(aMaterialKey, aMaterial); + sMilledMap.put(aMaterialKey, aMaterial.getMilled(1)); + } + return true; + } + + public static Material getMaterialOfMilledProduct(ItemStack aMilled) { + for (String aKey : sMilledMap.keySet()) { + ItemStack aTempMilledStack = sMilledMap.get(aKey); + if (GT_Utility.areStacksEqual(aTempMilledStack, aMilled, true)) { + return sMaterialMap.get(aKey); + } + } + return null; + } + + public static ItemStack findMilledStack(GT_Recipe aRecipe) { + if (aRecipe == null || aRecipe.mInputs == null || aRecipe.mInputs.length <= 0) { + return null; + } + return findMilledStack(aRecipe.mInputs); + } + + public static ItemStack findMilledStack(ItemStack[] aInputs) { + if (aInputs == null || aInputs.length <= 0) { + return null; + } + for (ItemStack aStack : aInputs) { + for (int oredictID : OreDictionary.getOreIDs(aStack)) { + String oredict = OreDictionary.getOreName(oredictID); + if (oredict.startsWith(CustomOrePrefix.milled.toString())) { + return aStack; + } + } + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java index d51107bbf0..0b60e057f4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java @@ -1,80 +1,80 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; public class GT_MethodHelper { - private static final Method mGetTexture; - private static final Class mITexturedTileEntity; - - static { - Class clazz = null; - Method aMeth = null; - if (ReflectionUtils.doesClassExist("gregtech.api.interfaces.tileentity.ITexturedTileEntity")) { - clazz = ReflectionUtils.getClass("gregtech.api.interfaces.tileentity.ITexturedTileEntity"); - aMeth = ReflectionUtils.getMethod(clazz, "getTexture", Block.class, byte.class); - } - mITexturedTileEntity = clazz; - mGetTexture = aMeth; - } - + private static final Method mGetTexture; + private static final Class mITexturedTileEntity; - public static ITexture[] getTexture(TileEntity tTileEntity, Block aBlock, byte aSide) { + static { + Class clazz = null; + Method aMeth = null; + if (ReflectionUtils.doesClassExist("gregtech.api.interfaces.tileentity.ITexturedTileEntity")) { + clazz = ReflectionUtils.getClass("gregtech.api.interfaces.tileentity.ITexturedTileEntity"); + aMeth = ReflectionUtils.getMethod(clazz, "getTexture", Block.class, byte.class); + } + mITexturedTileEntity = clazz; + mGetTexture = aMeth; + } - if (mITexturedTileEntity.isInstance(tTileEntity)) { + public static ITexture[] getTexture(TileEntity tTileEntity, Block aBlock, byte aSide) { - if (mGetTexture != null) { - try { - mGetTexture.invoke(tTileEntity, aBlock, aSide); - } - catch (IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - e.printStackTrace(); - } - } - else { - if (tTileEntity instanceof BaseMetaTileEntity) { - try { - BaseMetaTileEntity aTile = (BaseMetaTileEntity) tTileEntity; - ITexture rIcon = aTile.getCoverTexture(aSide); - Field aFacing = ReflectionUtils.getField(BaseMetaTileEntity.class, "mFacing"); - Field aColor = ReflectionUtils.getField(BaseMetaTileEntity.class, "mColor"); - Field aActive = ReflectionUtils.getField(BaseMetaTileEntity.class, "mActive"); - Field aMetaTile = ReflectionUtils.getField(BaseMetaTileEntity.class, "mMetaTileEntity"); - Method aHasValidTile = ReflectionUtils.getMethod(BaseMetaTileEntity.class, "hasValidMetaTileEntity", new Class[] {}); + if (mITexturedTileEntity.isInstance(tTileEntity)) { - boolean hasValidTileObj = (boolean) aHasValidTile.invoke(aTile, new Object[] {}); - boolean aActiveObj = aActive.getBoolean(aTile); - byte aFacingObj = aFacing.getByte(aTile); - byte aColorObj = aColor.getByte(aTile);; - MetaTileEntity aMetaTileObj = (MetaTileEntity) aMetaTile.get(aTile); + if (mGetTexture != null) { + try { + mGetTexture.invoke(tTileEntity, aBlock, aSide); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } else { + if (tTileEntity instanceof BaseMetaTileEntity) { + try { + BaseMetaTileEntity aTile = (BaseMetaTileEntity) tTileEntity; + ITexture rIcon = aTile.getCoverTexture(aSide); + Field aFacing = ReflectionUtils.getField(BaseMetaTileEntity.class, "mFacing"); + Field aColor = ReflectionUtils.getField(BaseMetaTileEntity.class, "mColor"); + Field aActive = ReflectionUtils.getField(BaseMetaTileEntity.class, "mActive"); + Field aMetaTile = ReflectionUtils.getField(BaseMetaTileEntity.class, "mMetaTileEntity"); + Method aHasValidTile = ReflectionUtils.getMethod( + BaseMetaTileEntity.class, "hasValidMetaTileEntity", new Class[] {}); - if (rIcon != null) { - return new ITexture[]{rIcon}; - } else { - return hasValidTileObj - ? aMetaTileObj.getTexture(aTile, aSide, aFacingObj, (byte) (aColorObj - 1), aActiveObj, - aTile.getOutputRedstoneSignal(aSide) > 0) - : BlockIcons.ERROR_RENDERING; - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - } - } - return BlockIcons.ERROR_RENDERING; - } + boolean hasValidTileObj = (boolean) aHasValidTile.invoke(aTile, new Object[] {}); + boolean aActiveObj = aActive.getBoolean(aTile); + byte aFacingObj = aFacing.getByte(aTile); + byte aColorObj = aColor.getByte(aTile); + ; + MetaTileEntity aMetaTileObj = (MetaTileEntity) aMetaTile.get(aTile); + if (rIcon != null) { + return new ITexture[] {rIcon}; + } else { + return hasValidTileObj + ? aMetaTileObj.getTexture( + aTile, + aSide, + aFacingObj, + (byte) (aColorObj - 1), + aActiveObj, + aTile.getOutputRedstoneSignal(aSide) > 0) + : BlockIcons.ERROR_RENDERING; + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + } + return BlockIcons.ERROR_RENDERING; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java index 0b52560e0d..8263243474 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java @@ -1,42 +1,39 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import java.util.HashMap; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.GregTech_API; +import java.util.HashMap; import net.minecraft.block.Block; import net.minecraftforge.event.world.BlockEvent; public class MachineUpdateHandler { - private static final HashMap mBlockCache = new HashMap(); - - public static void registerBlockToCauseMachineUpdate(String aUnlocalName, Block aBlock) { - mBlockCache.put(aUnlocalName, aBlock); - } - + private static final HashMap mBlockCache = new HashMap(); + + public static void registerBlockToCauseMachineUpdate(String aUnlocalName, Block aBlock) { + mBlockCache.put(aUnlocalName, aBlock); + } + @SubscribeEvent public void onBlockEvent(BlockEvent event) { - Block aBlock = event.block; - String aUnlocalName = aBlock != null ? aBlock.getUnlocalizedName() : "NULL"; - boolean aDoUpdate = false; - if (aBlock != null && aUnlocalName != null && !aUnlocalName.equals("NULL")) { - for (String aCachedName : mBlockCache.keySet()) { - if (aCachedName.equals(aUnlocalName)) { - aDoUpdate = true; - break; - } - else { - if (aBlock == mBlockCache.get(aCachedName)) { - aDoUpdate = true; - break; - } - } - } - if (aDoUpdate) { - GregTech_API.causeMachineUpdate(event.world, event.x, event.y, event.z); - } - } + Block aBlock = event.block; + String aUnlocalName = aBlock != null ? aBlock.getUnlocalizedName() : "NULL"; + boolean aDoUpdate = false; + if (aBlock != null && aUnlocalName != null && !aUnlocalName.equals("NULL")) { + for (String aCachedName : mBlockCache.keySet()) { + if (aCachedName.equals(aUnlocalName)) { + aDoUpdate = true; + break; + } else { + if (aBlock == mBlockCache.get(aCachedName)) { + aDoUpdate = true; + break; + } + } + } + if (aDoUpdate) { + GregTech_API.causeMachineUpdate(event.world, event.x, event.y, event.z); + } + } } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 1ab479a2d5..d054e5da3b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -1,5 +1,7 @@ package gtPlusPlus.xmod.gregtech.common.helpers; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles; + import com.google.common.collect.Lists; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Optional; @@ -28,6 +30,15 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.particles.BlockBreakParticles; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Queue; +import java.util.Set; +import java.util.Stack; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.IGrowable; @@ -47,224 +58,215 @@ import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import java.util.Stack; -import java.util.concurrent.ConcurrentHashMap; +public class TreeFarmHelper { -import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles; + public static final FluidStack fertT1 = FluidUtils.getFluidStack("fluid.fertiliser", 3); + public static final FluidStack fertT2 = FluidUtils.getFluidStack("fluid.un18fertiliser", 2); + public static final FluidStack fertT3 = FluidUtils.getFluidStack("fluid.un32fertiliser", 1); + private static final int sawOreId = OreDictionary.getOreID(ToolDictNames.craftingToolSaw.name()); + + public static ITexture[][][] getTextureSet() { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = TreeFarmHelper.getFront(i); + rTextures[1][i + 1] = TreeFarmHelper.getBack(i); + rTextures[2][i + 1] = TreeFarmHelper.getBottom(i); + rTextures[3][i + 1] = TreeFarmHelper.getTop(i); + rTextures[4][i + 1] = TreeFarmHelper.getSides(i); + rTextures[5][i + 1] = TreeFarmHelper.getFrontActive(i); + rTextures[6][i + 1] = TreeFarmHelper.getBackActive(i); + rTextures[7][i + 1] = TreeFarmHelper.getBottomActive(i); + rTextures[8][i + 1] = TreeFarmHelper.getTopActive(i); + rTextures[9][i + 1] = TreeFarmHelper.getSidesActive(i); + } + return rTextures; + } -public class TreeFarmHelper { + public static ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } - public static final FluidStack fertT1 = FluidUtils.getFluidStack("fluid.fertiliser", 3); - public static final FluidStack fertT2 = FluidUtils.getFluidStack("fluid.un18fertiliser", 2); - public static final FluidStack fertT3 = FluidUtils.getFluidStack("fluid.un32fertiliser", 1); - private static final int sawOreId = OreDictionary.getOreID(ToolDictNames.craftingToolSaw.name()); - - public static ITexture[][][] getTextureSet() { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = TreeFarmHelper.getFront(i); - rTextures[1][i + 1] = TreeFarmHelper.getBack(i); - rTextures[2][i + 1] = TreeFarmHelper.getBottom(i); - rTextures[3][i + 1] = TreeFarmHelper.getTop(i); - rTextures[4][i + 1] = TreeFarmHelper.getSides(i); - rTextures[5][i + 1] = TreeFarmHelper.getFrontActive(i); - rTextures[6][i + 1] = TreeFarmHelper.getBackActive(i); - rTextures[7][i + 1] = TreeFarmHelper.getBottomActive(i); - rTextures[8][i + 1] = TreeFarmHelper.getTopActive(i); - rTextures[9][i + 1] = TreeFarmHelper.getSidesActive(i); - } - return rTextures; - } - - public static ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public static ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public static ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public static ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public static ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public static ITexture[] getFrontActive(final byte aColor) { - return getFront(aColor); - } - - public static ITexture[] getBackActive(final byte aColor) { - return getBack(aColor); - } - - public static ITexture[] getBottomActive(final byte aColor) { - return getBottom(aColor); - } - - public static ITexture[] getTopActive(final byte aColor) { - return getTop(aColor); - } - - public static ITexture[] getSidesActive(final byte aColor) { - return getSides(aColor); - } - - public static boolean applyBonemeal(final EntityPlayer player, final World world, final int intX, final int intY, final int intZ, final short multiplier){ - final Block block = world.getBlock(intX, intY, intZ); - - - int roll; - int rollNeeded; - - if (multiplier==1){ - roll = MathUtils.randInt(1, 15); - rollNeeded = 15; - } - else if (multiplier==2){ - roll = MathUtils.randInt(1, 10); - rollNeeded = 10; - } - else { - roll = MathUtils.randInt(1, 5); - rollNeeded = 5; - } - - if (roll != rollNeeded){ - return false; - } - - //EntityPlayer player = FakePlayerFactory.getMinecraft((WorldServer)world); - if (!world.isRemote){ - if (enableTreeFarmerParticles){ - world.playAuxSFX(2005, intX, intY, intZ, 0); - } - } - final BonemealEvent event = new BonemealEvent(player, world, block, intX, intY, intZ); - if (MinecraftForge.EVENT_BUS.post(event)){ - Logger.MACHINE_INFO("Not sure why this returned false"); - return false; - } - if (event.getResult() == Result.ALLOW){ - if (!world.isRemote){ - world.playAuxSFX(2005, intX, intY, intZ, 0); - } - return true; - } - if (block instanceof IGrowable){ - final IGrowable igrowable = (IGrowable)block; - if (igrowable.func_149851_a(world, intX, intY, intZ, world.isRemote)){ - if (!world.isRemote){ - if (igrowable.func_149852_a(world, CORE.RANDOM, intX, intY, intZ)){ - igrowable.func_149853_b(world, CORE.RANDOM, intX, intY, intZ); - } - } - return true; - } - } - return false; - } - - public static boolean cleanUp(final IGregTechTileEntity aBaseMetaTileEntity){ - Logger.MACHINE_INFO("called cleanUp()"); - int cleanedUp = 0; - final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 11; - final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 11; - - for (int h=1;h<175;h++){ - for (int i = -11; i <= 11; i++) { - for (int j = -11; j <= 11; j++) { - - final Block testBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - - - if - (( - ((i == -8) || (i == 8)) || - ((i == -9) || (i == 9)) || - ((i == -10) || (i == 10)) || - ((i == -11) || (i == 11)) - ) - && - ( - ((j == -8) || (j == 8)) || - ((j == -9) || (j == 9)) || - ((j == -10) || (j == 10)) || - ((j == -11) || (j == 11)) - )){ - - if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { - //Logger.WARNING("5:"+testBlock.getUnlocalizedName()); - } else { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord()+xDir+i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir+j, Blocks.bookshelf); - } - } - - - //If not in the middle - don't know how else to check this one without lots of != - if ( - (i != 7) && (i != -7) && (j != 7) && (j != -7) && - (i != 6) && (i != -6) && (j != 6) && (j != -6) && - (i != 5) && (i != -5) && (j != 5) && (j != -5) && - (i != 4) && (i != -4) && (j != 4) && (j != -4) && - (i != 3) && (i != -3) && (j != 3) && (j != -3) && - (i != 2) && (i != -2) && (j != 2) && (j != -2) && - (i != 1) && (i != -1) && (j != 1) && (j != -1) && - (i != 0) && (j != 0) - ){ - - if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { - //Logger.WARNING("0:"+testBlock.getUnlocalizedName()); - } else { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord()+xDir+i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir+j, Blocks.melon_block); - } - - - if (isLeaves(testBlock) || isWoodLog(testBlock)){ - //Logger.WARNING("1:"+testBlock.getUnlocalizedName()); - int posiX, posiY, posiZ; - posiX = aBaseMetaTileEntity.getXCoord()+xDir+i; - posiY = aBaseMetaTileEntity.getYCoord()+h; - posiZ = aBaseMetaTileEntity.getZCoord()+zDir+j; - //Utils.LOG_MACHINE_INFO("Cleaning Up some leftovers."); - cleanedUp++; - aBaseMetaTileEntity.getWorld().setBlockToAir(posiX, posiY, posiZ); - new BlockBreakParticles(aBaseMetaTileEntity.getWorld(), posiX, posiY, posiZ, Blocks.dirt); - } - else { - //Utils.LOG_WARNING("2:"+testBlock.getUnlocalizedName()); - } - } - else { - //Utils.LOG_WARNING("1"); - } - - - } - - } - } - Logger.MACHINE_INFO("cleaning up | "+cleanedUp ); - return true; - } - - - public static boolean isValidForGUI(final ItemStack aStack) { - return isCorrectMachinePart(aStack) != SAWTOOL.NONE; - } + public static ITexture[] getBack(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getBottom(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getTop(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getFrontActive(final byte aColor) { + return getFront(aColor); + } + + public static ITexture[] getBackActive(final byte aColor) { + return getBack(aColor); + } + + public static ITexture[] getBottomActive(final byte aColor) { + return getBottom(aColor); + } + + public static ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } + + public static ITexture[] getSidesActive(final byte aColor) { + return getSides(aColor); + } + + public static boolean applyBonemeal( + final EntityPlayer player, + final World world, + final int intX, + final int intY, + final int intZ, + final short multiplier) { + final Block block = world.getBlock(intX, intY, intZ); + + int roll; + int rollNeeded; + + if (multiplier == 1) { + roll = MathUtils.randInt(1, 15); + rollNeeded = 15; + } else if (multiplier == 2) { + roll = MathUtils.randInt(1, 10); + rollNeeded = 10; + } else { + roll = MathUtils.randInt(1, 5); + rollNeeded = 5; + } + + if (roll != rollNeeded) { + return false; + } + + // EntityPlayer player = FakePlayerFactory.getMinecraft((WorldServer)world); + if (!world.isRemote) { + if (enableTreeFarmerParticles) { + world.playAuxSFX(2005, intX, intY, intZ, 0); + } + } + final BonemealEvent event = new BonemealEvent(player, world, block, intX, intY, intZ); + if (MinecraftForge.EVENT_BUS.post(event)) { + Logger.MACHINE_INFO("Not sure why this returned false"); + return false; + } + if (event.getResult() == Result.ALLOW) { + if (!world.isRemote) { + world.playAuxSFX(2005, intX, intY, intZ, 0); + } + return true; + } + if (block instanceof IGrowable) { + final IGrowable igrowable = (IGrowable) block; + if (igrowable.func_149851_a(world, intX, intY, intZ, world.isRemote)) { + if (!world.isRemote) { + if (igrowable.func_149852_a(world, CORE.RANDOM, intX, intY, intZ)) { + igrowable.func_149853_b(world, CORE.RANDOM, intX, intY, intZ); + } + } + return true; + } + } + return false; + } + + public static boolean cleanUp(final IGregTechTileEntity aBaseMetaTileEntity) { + Logger.MACHINE_INFO("called cleanUp()"); + int cleanedUp = 0; + final int xDir = + net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()) + .offsetX + * 11; + final int zDir = + net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()) + .offsetZ + * 11; + + for (int h = 1; h < 175; h++) { + for (int i = -11; i <= 11; i++) { + for (int j = -11; j <= 11; j++) { + + final Block testBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + + if ((((i == -8) || (i == 8)) + || ((i == -9) || (i == 9)) + || ((i == -10) || (i == 10)) + || ((i == -11) || (i == 11))) + && (((j == -8) || (j == 8)) + || ((j == -9) || (j == 9)) + || ((j == -10) || (j == 10)) + || ((j == -11) || (j == 11)))) { + + if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") + || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { + // Logger.WARNING("5:"+testBlock.getUnlocalizedName()); + } else { + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + Blocks.bookshelf); + } + } + + // If not in the middle - don't know how else to check this one without lots of != + if ((i != 7) && (i != -7) && (j != 7) && (j != -7) && (i != 6) && (i != -6) && (j != 6) && (j != -6) + && (i != 5) && (i != -5) && (j != 5) && (j != -5) && (i != 4) && (i != -4) && (j != 4) + && (j != -4) && (i != 3) && (i != -3) && (j != 3) && (j != -3) && (i != 2) && (i != -2) + && (j != 2) && (j != -2) && (i != 1) && (i != -1) && (j != 1) && (j != -1) && (i != 0) + && (j != 0)) { + + if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") + || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { + // Logger.WARNING("0:"+testBlock.getUnlocalizedName()); + } else { + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + Blocks.melon_block); + } + + if (isLeaves(testBlock) || isWoodLog(testBlock)) { + // Logger.WARNING("1:"+testBlock.getUnlocalizedName()); + int posiX, posiY, posiZ; + posiX = aBaseMetaTileEntity.getXCoord() + xDir + i; + posiY = aBaseMetaTileEntity.getYCoord() + h; + posiZ = aBaseMetaTileEntity.getZCoord() + zDir + j; + // Utils.LOG_MACHINE_INFO("Cleaning Up some leftovers."); + cleanedUp++; + aBaseMetaTileEntity.getWorld().setBlockToAir(posiX, posiY, posiZ); + new BlockBreakParticles(aBaseMetaTileEntity.getWorld(), posiX, posiY, posiZ, Blocks.dirt); + } else { + // Utils.LOG_WARNING("2:"+testBlock.getUnlocalizedName()); + } + } else { + // Utils.LOG_WARNING("1"); + } + } + } + } + Logger.MACHINE_INFO("cleaning up | " + cleanedUp); + return true; + } + + public static boolean isValidForGUI(final ItemStack aStack) { + return isCorrectMachinePart(aStack) != SAWTOOL.NONE; + } public static SAWTOOL isCorrectMachinePart(final ItemStack aStack) { if (aStack != null && aStack.getItem() instanceof GT_MetaGenerated_Tool_01) { @@ -283,747 +285,766 @@ public class TreeFarmHelper { } return SAWTOOL.NONE; } - - public static ToolType getPartType(final ItemStack aStack) { - if (aStack != null){ - //Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot."); - - if (aStack.getItem() == MetaGeneratedGregtechItems.INSTANCE) { - int aDmg = aStack.getItemDamage(); - if (aDmg >= 32120 && aDmg <= 32128) { - return ToolType.Unbreakable; - } - Logger.INFO("bad Tool in Slot 2 | "+aStack.getUnlocalizedName().toLowerCase() + " | "+aDmg); - return null; - } - - if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { - if (Arrays.stream(OreDictionary.getOreIDs(aStack)).anyMatch(i -> i == sawOreId)) - return ToolType.Breakable; - } - } - Logger.INFO("bad Tool in Slot 4"); - return null; - } - - public static boolean isHumusLoaded = false; - public static boolean isForestryLogsLoaded = false; - public static boolean isForestryFenceLoaded = false; - public static boolean isForestrySaplingsLoaded = false; - public static boolean isForestryLeavesLoaded = false; - public static Block blockHumus; - - public static boolean isForestryValid(){ - if (!LoadedMods.Forestry){ - return false; - } - if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ - isHumusLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){ - isForestryLogsLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){ - isForestryFenceLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){ - isForestrySaplingsLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){ - isForestryLeavesLoaded = true; - } - return true; - } - - @Optional.Method(modid = "Forestry") - public static Block getHumus(){ - if(blockHumus != null){ - return blockHumus; - } - else if (isHumusLoaded){ - final Class humusClass = ReflectionUtils.getClass("forestry.core.blocks.BlockSoil"); - final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); - if (humusClass != null){ - blockHumus = Block.getBlockFromItem(humusStack.getItem()); - return Block.getBlockFromItem(humusStack.getItem()); - } - } - return null; - } - - public static boolean isWoodLog(final Block log){ - final String tTool = log.getHarvestTool(0); - - if ((log == Blocks.log) || (log == Blocks.log2)){ - return true; - } - - //Forestry/General Compat - if (log.getClass().getName().toLowerCase().contains("blocklog")){ - return true; - } - - //IC2 Rubber Tree Compat - if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){ - return true; - } - - return (OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe")))) || (log.getMaterial() != Material.wood) ? false : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true); - } - - public static boolean isLeaves(final Block log){ - if (log.getUnlocalizedName().toLowerCase().contains("leaf")){ - return true; - } - if (log.getUnlocalizedName().toLowerCase().contains("leaves")){ - return true; - } - if (log.getLocalizedName().toLowerCase().contains("leaf")){ - return true; - } - if (log.getLocalizedName().toLowerCase().contains("leaves")){ - return true; - } - return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.leaves || OrePrefixes.treeLeaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.vine || OrePrefixes.mushroom.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.cactus; - } - - public static boolean isSapling(final Block log){ - if (log != null){ - if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){ - //Logger.WARNING(""+log.getLocalizedName()); - } - if (log.getLocalizedName().toLowerCase().contains("sapling")){ - //Logger.WARNING(""+log.getLocalizedName()); - return true; - } - } - return OrePrefixes.sapling.contains(new ItemStack(log, 1)); - } - - public static boolean isDirtBlock(final Block dirt){ - return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false)))); - } - - public static boolean isFenceBlock(final Block fence){ - return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false)))); - } - - public static boolean isAirBlock(final Block air){ - if (air.getLocalizedName().toLowerCase().contains("air")){ - return true; - } - if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){ - return true; - } - return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false)); - } - - /*public static boolean isSaplingBlock(Block sapling){ - return (sapling == Blocks.sapling ? true : (sapling == Blocks.)) - }*/ - - public static BlockPos checkForLogsInGrowArea(final IGregTechTileEntity aBaseMetaTileEntity) { - final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7; - final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7; - for (int i = -7; i <= 7; i++) { - for (int j = -7; j <= 7; j++) { - for (int h = 0; h <= 1; h++) { - //Farm Floor inner 14x14 - if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) { - if (h == 1) { - if (TreeFarmHelper.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - Logger.INFO("Found a Log"); - return new BlockPos(aBaseMetaTileEntity.getXCoord()+xDir + i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir + j, aBaseMetaTileEntity.getWorld()); - } - } - } - } - } - } - return null; - } - - public static ItemStack[] findTreeFromBase(World world, BlockPos h) { - int HARD_LIMIT = 10000; - int mCount = 0; - Logger.INFO("Finding Rest of Tree."); - BlockPos mFirstSpot = h; - Set mSearchedSpaces = new HashSet(); - Set mTreeSet = getConnectedBlocks(world, mFirstSpot, mSearchedSpaces); - Set> mTreeSet2 = new HashSet>(); - Set mFinalTree = new HashSet(); - Iterator it = mTreeSet.iterator(); - - - Logger.INFO("Running first iteration."); - while(it.hasNext()){ - BlockPos G = it.next(); - mSearchedSpaces.add(G); - mTreeSet2.add(getConnectedBlocks(world, G, mSearchedSpaces)); - mCount++; - Logger.INFO("First Search: "+G.getLocationString()); - if (mCount > HARD_LIMIT) { - break; - } - } - - mCount = 0; - Iterator> it2 = mTreeSet2.iterator(); - Iterator it3; - Logger.INFO("Running second iteration."); - while(it2.hasNext()){ - Set G = it2.next(); - it3 = G.iterator(); - while(it3.hasNext()){ - BlockPos G2 = it3.next(); - mSearchedSpaces.add(G2); - mFinalTree.add(G2); - mCount++; - Logger.INFO("Second Search: "+G2.getLocationString()); - if (mCount > HARD_LIMIT) { - break; - } - } - if (mCount > HARD_LIMIT) { - break; - } - } - - - if (mFinalTree.size() > 0) { - Logger.INFO("Queuing "+mFinalTree.size()+" to Harvest Manager."); - TreeCutter harvestManager = new TreeCutter(world); - - Iterator ith = mFinalTree.iterator(); - while(ith.hasNext()){ - BlockPos G = ith.next(); - harvestManager.queue(G); - mCount++; - Logger.INFO("Queued: "+G.getLocationString()); - if (mCount > HARD_LIMIT) { - break; - } - } - - if (harvestManager.isValid) { - ItemStack[] loot = harvestManager.getDrops(); - if (loot.length > 0) { - //Logger.INFO("Returning Drops from harvestManager Queue."); - return loot; - } - } - } - return new ItemStack[] {}; - } - - - public static Set getConnectedBlocks(World W, BlockPos P, Set checkedSpaces) { - int HARD_LIMIT = 1000; - int mCount = 0; - Logger.INFO("Finding blocks connected to "+P.getLocationString()+"."); - Set mCheckedSpaces = checkedSpaces; - Set mStartSearch = searchSixFaces(W, P, mCheckedSpaces, false); - Set mSecondSearch = new HashSet(); - Set mThirdSearch = new HashSet(); - Iterator it = mStartSearch.iterator(); - while(it.hasNext()){ - Logger.INFO("Running first iteration. [II]"); - BlockPos G = it.next(); - mCheckedSpaces.add(G); - Set mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); - Iterator it2 = mBranchSearch.iterator(); - while(it2.hasNext()){ - Logger.INFO("Running second iteration. [II]"); - BlockPos G2 = it2.next(); - mCheckedSpaces.add(G2); - mSecondSearch.add(G2); - mCount++; - if (mCount > HARD_LIMIT) { - break; - } - } - if (mCount > HARD_LIMIT) { - break; - } - } - mCount = 0; - Iterator itx = mSecondSearch.iterator(); - while(itx.hasNext()){ - BlockPos G = itx.next(); - mCheckedSpaces.add(G); - Set mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); - Iterator it2 = mBranchSearch.iterator(); - while(it2.hasNext()){ - BlockPos G2 = it2.next(); - mCheckedSpaces.add(G2); - mThirdSearch.add(G2); - mCount++; - if (mCount > HARD_LIMIT) { - break; - } - } - if (mCount > HARD_LIMIT) { - break; - } - } - return mThirdSearch; - } - - public static Set searchSixFaces(World W, BlockPos P, Set checkedSpaces, boolean checkLeaves) { - Set mConnected = new HashSet(); - int x = P.xPos; - int y = P.yPos; - int z = P.zPos; - if (checkLeaves) { - if (isWoodLog(W.getBlock(x-1, y, z)) || isLeaves(W.getBlock(x-1, y, z))) { - BlockPos L = new BlockPos(x-1, y, z, W); - if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - } - } - if (isWoodLog(W.getBlock(x+1, y, z)) || isLeaves(W.getBlock(x+1, y, z))) { - BlockPos L = new BlockPos(x+1, y, z, W); - if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - } - } - if (isWoodLog(W.getBlock(x, y-1, z)) || isLeaves(W.getBlock(x, y-1, z))) { - BlockPos L = new BlockPos(x, y-1, z, W); - if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - } - } - if (isWoodLog(W.getBlock(x, y+1, z)) || isLeaves(W.getBlock(x, y+1, z))) { - BlockPos L = new BlockPos(x, y+1, z, W); - if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - } - } - if (isWoodLog(W.getBlock(x, y, z-1)) || isLeaves(W.getBlock(x, y, z-1))) { - BlockPos L = new BlockPos(x, y, z-1, W); - if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - } - } - if (isWoodLog(W.getBlock(x, y, z+1)) || isLeaves(W.getBlock(x, y, z+1))) { - BlockPos L = new BlockPos(x, y, z+1, W); - if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - } - } - } - else { - if (isWoodLog(W.getBlock(x-1, y, z))) { - BlockPos L = new BlockPos(x-1, y, z, W); - //if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - //} - } - if (isWoodLog(W.getBlock(x+1, y, z))) { - BlockPos L = new BlockPos(x+1, y, z, W); - //if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - //} - } - if (isWoodLog(W.getBlock(x, y-1, z))) { - BlockPos L = new BlockPos(x, y-1, z, W); - //if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - //} - } - if (isWoodLog(W.getBlock(x, y+1, z))) { - BlockPos L = new BlockPos(x, y+1, z, W); - //if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - //} - } - if (isWoodLog(W.getBlock(x, y, z-1))) { - BlockPos L = new BlockPos(x, y, z-1, W); - //if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - //} - } - if (isWoodLog(W.getBlock(x, y, z+1))) { - BlockPos L = new BlockPos(x, y, z+1, W); - //if (!checkedSpaces.contains(L)) { - mConnected.add(L); - Logger.INFO("Found Connected. [III]"); - //} - } - } - return mConnected; - } - - - public enum ToolType { - Unbreakable, - Breakable - } - - - /** - * Tree Cutting - */ - - public static class TreeCutter { - - private final World mWorld; - private Map mQueue = new ConcurrentHashMap(); - private AutoMap mDrops = new AutoMap(); - private boolean isValid = true; - - public TreeCutter(World world) { - this.mWorld = world; - } - - public boolean queue(BlockPos pos) { - if (isValid && pos != null) { - //Logger.INFO("Queued: "+pos.getLocationString()); - String hash = Utils.calculateChecksumMD5(pos); - if (hash != null && !mQueue.containsKey(hash)) { - mQueue.put(hash, pos); - return true; - } - } - return false; - } - - private boolean emptyQueue() { - if (isValid) { - Logger.INFO("Emptying Queue."); - if (this.mQueue.size() > 0) { - int totalRemoved = 0; - for (BlockPos h : mQueue.values()) { - final Block block = mWorld.getBlock(h.xPos, h.yPos, h.zPos); - if (block != null) { - final int dropMeta = mWorld.getBlockMetadata(h.xPos, h.yPos, h.zPos); - final ArrayList blockDrops = block.getDrops(mWorld, h.xPos, h.yPos, h.zPos, dropMeta, 0); - final ItemStack[] drops = ItemUtils.getBlockDrops(blockDrops); - mDrops.put(drops); - //Remove drop that was added to the bus. - mWorld.setBlockToAir(h.xPos, h.yPos, h.zPos); - //new BlockBreakParticles(mWorld, h.xPos, h.yPos, h.zPos, block); - totalRemoved++; - } - } - if (totalRemoved > 0 && mDrops.size() > 0) { - return true; - } - } - } - return false; - } - - public ItemStack[] getDrops() { - //If Queue is successfully cleared and drops are created, let us continue. - if (isValid && emptyQueue()) { - AutoMap mCollective = new AutoMap(); - //Iterate ALL of the arrays, add output to a collective. - for (ItemStack[] i : this.mDrops) { - //Array is not null. - if (i != null) { - //Iterate this array. - for (int d=0;d 0) { - mCollective.put(i[d]); - } - } - } - } - //Build an ItemStack array. - ItemStack[] drops = new ItemStack[mCollective.size()]; - for (int m=0;m 0) { - isValid = false; - return drops; - } - } - //Invalid or no drops, return empty array. - isValid = false; - return new ItemStack[] {}; - } - - } - - - /** - * Farm AI - */ - private static EntityPlayerMP farmerAI; - public EntityPlayerMP getFakePlayer(World world) { - return farmerAI = checkFakePlayer(world); - } - - public static EntityPlayerMP checkFakePlayer(World world) { - if (farmerAI == null) { - return new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(world.provider.dimensionId)); - } - return farmerAI; - } - - public static boolean onBlockStartBreak (int x, int y, int z, World world){ - final Block wood = world.getBlock(x, y, z); - if (wood == null){ - return false; - } - if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge) - if(detectTree(world, x,y,z)) { - TreeChopTask chopper = new TreeChopTask(new ChunkPosition(x, y, z), checkFakePlayer(world), 128); - FMLCommonHandler.instance().bus().register(chopper); - // custom block breaking code, don't call vanilla code - return true; - } - //return onBlockStartBreak(stack, x, y, z, player); - return false; - } - - public static boolean detectTree(World world, int pX, int pY, int pZ) { - ChunkPosition pos = null; - Stack candidates = new Stack<>(); - candidates.add(new ChunkPosition(pX, pY, pZ)); - - while (!candidates.isEmpty()) { - ChunkPosition candidate = candidates.pop(); - int curX = candidate.chunkPosX, curY = candidate.chunkPosY, curZ = candidate.chunkPosZ; - - Block block = world.getBlock(curX, curY, curZ); - if ((pos == null || candidate.chunkPosY > pos.chunkPosY) && block.isWood(world, curX, curY, curZ)) { - pos = new ChunkPosition(curX, candidate.chunkPosY + 1, curZ); - // go up - while (world.getBlock(curX, pos.chunkPosY, curZ).isWood(world, curX, pos.chunkPosY, curZ)) { - pos = new ChunkPosition(curX, pos.chunkPosY + 1, curZ); - } - // check if we still have a way diagonally up - candidates.add(new ChunkPosition(curX + 1, pos.chunkPosY + 1, curZ )); - candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ + 1)); - candidates.add(new ChunkPosition(curX - 1, pos.chunkPosY + 1, curZ )); - candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ - 1)); - } - } - - // not even one match, so there were no logs. - if (pos == null) { - return false; - } - - // check if there were enough leaves around the last position - // pos now contains the block above the topmost log - // we want at least 5 leaves in the surrounding 26 blocks - int d = 3; - int leaves = 0; - for (int offX = 0; offX < d; offX++) { - for (int offY = 0; offY < d; offY++) { - for (int offZ = 0; offZ < d; offZ++) { - int xPos = pos.chunkPosX -1 + offX, yPos = pos.chunkPosY - 1 + offY, zPos = pos.chunkPosZ - 1 + offZ; - Block leaf = world.getBlock(xPos, yPos, zPos); - if (leaf != null && leaf.isLeaves(world, xPos, yPos, zPos)) { - if (++leaves >= 5) { - return true; - } - } - } - } - } - - // not enough leaves. sorreh - return false; - } - - public static class TreeChopTask { - - public final World world; - public final EntityPlayer player; - public final int blocksPerTick; - - public Queue blocks = Lists.newLinkedList(); - public Set visited = new THashSet<>(); - - public TreeChopTask(ChunkPosition start, EntityPlayer player, int blocksPerTick) { - this.world = player.getEntityWorld(); - this.player = player; - this.blocksPerTick = blocksPerTick; - - this.blocks.add(start); - } - - private void queueCoordinate(int x, int y, int z) { - ChunkPosition pos = new ChunkPosition(x, y, z); - if (!visited.contains(pos)) { - blocks.add(pos); - } - } - - @SubscribeEvent - public void onWorldTick(TickEvent.WorldTickEvent event) { - if (event.side.isClient()) { - finish(); - return; - } - // only if same dimension - if (event.world.provider.dimensionId != world.provider.dimensionId) { - return; - } - - // setup - int left = blocksPerTick; - //NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); - - // continue running - ChunkPosition pos; - while (left > 0) { - // completely done or can't do our job anymore?! - if (blocks.isEmpty()/* || tags.getBoolean("Broken")*/) { - finish(); - return; - } - - pos = blocks.remove(); - if (!visited.add(pos)) { - continue; - } - int x = pos.chunkPosX, y = pos.chunkPosY, z = pos.chunkPosZ; - - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - // can we harvest the block and is effective? - if (!block.isWood(world, x, y, z) || !isWoodLog(block)) { - continue; - } - - // save its neighbors - queueCoordinate(x + 1, y, z ); - queueCoordinate(x, y, z + 1); - queueCoordinate(x - 1, y, z ); - queueCoordinate(x, y, z - 1); - - // also add the layer above.. stupid acacia trees - for (int offX = 0; offX < 3; offX++) { - for (int offZ = 0; offZ < 3; offZ++) { - queueCoordinate(x - 1 + offX, y + 1, z - 1 + offZ); - } - } - - // break it, wooo! - breakExtraBlock(player.worldObj, x, y, z, 0, player, x, y, z); - left--; - } - } - - private void finish() { - // goodbye cruel world - FMLCommonHandler.instance().bus().unregister(this); - } - } - - - public static void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) { - // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events - if (world.isAirBlock(x, y, z)) - return; - - // what? - if(!(playerEntity instanceof EntityPlayerMP)) - return; - EntityPlayerMP player = (EntityPlayerMP) playerEntity; - - // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian - // or precious ores you can't harvest while mining stone - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - // only effective materials - if (!isWoodLog(block)) - return; - - Block refBlock = world.getBlock(refX, refY, refZ); - float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ); - float strength = ForgeHooks.blockStrength(block, player, world, x,y,z); - - // only harvestable blocks that aren't impossibly slow to harvest - if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f) - return; - - // send the blockbreak event - BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z); - if(event.isCanceled()) - return; - - if (player.capabilities.isCreativeMode) { - block.onBlockHarvested(world, x, y, z, meta, player); - if (block.removedByPlayer(world, player, x, y, z, false)) - block.onBlockDestroyedByPlayer(world, x, y, z, meta); - - // send update to client - if (!world.isRemote) { - player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - } - return; - } - - // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. - player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player); - - // server sided handling - if (!world.isRemote) { - // serverside we reproduce ItemInWorldManager.tryHarvestBlock - - // ItemInWorldManager.removeBlock - block.onBlockHarvested(world, x,y,z, meta, player); - - if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above - { - block.onBlockDestroyedByPlayer( world, x,y,z, meta); - block.harvestBlock(world, player, x,y,z, meta); - block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop()); - } - - // always send block update to client - player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - } - // client sided handling - else { - //PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController; - // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets - // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy. - - // following code can be found in PlayerControllerMP.onPlayerDestroyBlock - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - if(block.removedByPlayer(world, player, x,y,z, true)) - { - block.onBlockDestroyedByPlayer(world, x,y,z, meta); - } - // callback to the tool - ItemStack itemstack = player.getCurrentEquippedItem(); - if (itemstack != null) - { - itemstack.func_150999_a(world, block, x, y, z, player); - - if (itemstack.stackSize == 0) - { - player.destroyCurrentEquippedItem(); - } - } - - // send an update to the server, so we get an update back - //if(PHConstruct.extraBlockUpdates) - //Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit)); - } - } + public static ToolType getPartType(final ItemStack aStack) { + if (aStack != null) { + // Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot."); + + if (aStack.getItem() == MetaGeneratedGregtechItems.INSTANCE) { + int aDmg = aStack.getItemDamage(); + if (aDmg >= 32120 && aDmg <= 32128) { + return ToolType.Unbreakable; + } + Logger.INFO( + "bad Tool in Slot 2 | " + aStack.getUnlocalizedName().toLowerCase() + " | " + aDmg); + return null; + } + + if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { + if (Arrays.stream(OreDictionary.getOreIDs(aStack)).anyMatch(i -> i == sawOreId)) + return ToolType.Breakable; + } + } + Logger.INFO("bad Tool in Slot 4"); + return null; + } + + public static boolean isHumusLoaded = false; + public static boolean isForestryLogsLoaded = false; + public static boolean isForestryFenceLoaded = false; + public static boolean isForestrySaplingsLoaded = false; + public static boolean isForestryLeavesLoaded = false; + public static Block blockHumus; + + public static boolean isForestryValid() { + if (!LoadedMods.Forestry) { + return false; + } + if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")) { + isHumusLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")) { + isForestryLogsLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")) { + isForestryFenceLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")) { + isForestrySaplingsLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")) { + isForestryLeavesLoaded = true; + } + return true; + } + + @Optional.Method(modid = "Forestry") + public static Block getHumus() { + if (blockHumus != null) { + return blockHumus; + } else if (isHumusLoaded) { + final Class humusClass = ReflectionUtils.getClass("forestry.core.blocks.BlockSoil"); + final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); + if (humusClass != null) { + blockHumus = Block.getBlockFromItem(humusStack.getItem()); + return Block.getBlockFromItem(humusStack.getItem()); + } + } + return null; + } + + public static boolean isWoodLog(final Block log) { + final String tTool = log.getHarvestTool(0); + + if ((log == Blocks.log) || (log == Blocks.log2)) { + return true; + } + + // Forestry/General Compat + if (log.getClass().getName().toLowerCase().contains("blocklog")) { + return true; + } + + // IC2 Rubber Tree Compat + if (log.getClass().getName().toLowerCase().contains("rubwood") + || log.getClass().getName().toLowerCase().contains("rubleaves")) { + return true; + } + + return (OrePrefixes.log.contains(new ItemStack(log, 1)) && ((tTool != null) && (tTool.equals("axe")))) + || (log.getMaterial() != Material.wood) + ? false + : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true); + } + + public static boolean isLeaves(final Block log) { + if (log.getUnlocalizedName().toLowerCase().contains("leaf")) { + return true; + } + if (log.getUnlocalizedName().toLowerCase().contains("leaves")) { + return true; + } + if (log.getLocalizedName().toLowerCase().contains("leaf")) { + return true; + } + if (log.getLocalizedName().toLowerCase().contains("leaves")) { + return true; + } + return OrePrefixes.leaves.contains(new ItemStack(log, 1)) + || log.getMaterial() == Material.leaves + || OrePrefixes.treeLeaves.contains(new ItemStack(log, 1)) + || log.getMaterial() == Material.vine + || OrePrefixes.mushroom.contains(new ItemStack(log, 1)) + || log.getMaterial() == Material.cactus; + } + + public static boolean isSapling(final Block log) { + if (log != null) { + if (OrePrefixes.sapling.contains(new ItemStack(log, 1))) { + // Logger.WARNING(""+log.getLocalizedName()); + } + if (log.getLocalizedName().toLowerCase().contains("sapling")) { + // Logger.WARNING(""+log.getLocalizedName()); + return true; + } + } + return OrePrefixes.sapling.contains(new ItemStack(log, 1)); + } + + public static boolean isDirtBlock(final Block dirt) { + return (dirt == Blocks.dirt + ? true + : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false)))); + } + + public static boolean isFenceBlock(final Block fence) { + return (fence == Blocks.fence + ? true + : (fence == Blocks.fence_gate + ? true + : (fence == Blocks.nether_brick_fence + ? true + : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false)))); + } + + public static boolean isAirBlock(final Block air) { + if (air.getLocalizedName().toLowerCase().contains("air")) { + return true; + } + if (air.getClass().getName().toLowerCase().contains("residual") + || air.getClass().getName().toLowerCase().contains("heat")) { + return true; + } + return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false)); + } + + /*public static boolean isSaplingBlock(Block sapling){ + return (sapling == Blocks.sapling ? true : (sapling == Blocks.)) + }*/ + + public static BlockPos checkForLogsInGrowArea(final IGregTechTileEntity aBaseMetaTileEntity) { + final int xDir = + net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()) + .offsetX + * 7; + final int zDir = + net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()) + .offsetZ + * 7; + for (int i = -7; i <= 7; i++) { + for (int j = -7; j <= 7; j++) { + for (int h = 0; h <= 1; h++) { + // Farm Floor inner 14x14 + if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) { + if (h == 1) { + if (TreeFarmHelper.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { + Logger.INFO("Found a Log"); + return new BlockPos( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + aBaseMetaTileEntity.getWorld()); + } + } + } + } + } + } + return null; + } + + public static ItemStack[] findTreeFromBase(World world, BlockPos h) { + int HARD_LIMIT = 10000; + int mCount = 0; + Logger.INFO("Finding Rest of Tree."); + BlockPos mFirstSpot = h; + Set mSearchedSpaces = new HashSet(); + Set mTreeSet = getConnectedBlocks(world, mFirstSpot, mSearchedSpaces); + Set> mTreeSet2 = new HashSet>(); + Set mFinalTree = new HashSet(); + Iterator it = mTreeSet.iterator(); + + Logger.INFO("Running first iteration."); + while (it.hasNext()) { + BlockPos G = it.next(); + mSearchedSpaces.add(G); + mTreeSet2.add(getConnectedBlocks(world, G, mSearchedSpaces)); + mCount++; + Logger.INFO("First Search: " + G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + + mCount = 0; + Iterator> it2 = mTreeSet2.iterator(); + Iterator it3; + Logger.INFO("Running second iteration."); + while (it2.hasNext()) { + Set G = it2.next(); + it3 = G.iterator(); + while (it3.hasNext()) { + BlockPos G2 = it3.next(); + mSearchedSpaces.add(G2); + mFinalTree.add(G2); + mCount++; + Logger.INFO("Second Search: " + G2.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + + if (mFinalTree.size() > 0) { + Logger.INFO("Queuing " + mFinalTree.size() + " to Harvest Manager."); + TreeCutter harvestManager = new TreeCutter(world); + + Iterator ith = mFinalTree.iterator(); + while (ith.hasNext()) { + BlockPos G = ith.next(); + harvestManager.queue(G); + mCount++; + Logger.INFO("Queued: " + G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + + if (harvestManager.isValid) { + ItemStack[] loot = harvestManager.getDrops(); + if (loot.length > 0) { + // Logger.INFO("Returning Drops from harvestManager Queue."); + return loot; + } + } + } + return new ItemStack[] {}; + } + + public static Set getConnectedBlocks(World W, BlockPos P, Set checkedSpaces) { + int HARD_LIMIT = 1000; + int mCount = 0; + Logger.INFO("Finding blocks connected to " + P.getLocationString() + "."); + Set mCheckedSpaces = checkedSpaces; + Set mStartSearch = searchSixFaces(W, P, mCheckedSpaces, false); + Set mSecondSearch = new HashSet(); + Set mThirdSearch = new HashSet(); + Iterator it = mStartSearch.iterator(); + while (it.hasNext()) { + Logger.INFO("Running first iteration. [II]"); + BlockPos G = it.next(); + mCheckedSpaces.add(G); + Set mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator it2 = mBranchSearch.iterator(); + while (it2.hasNext()) { + Logger.INFO("Running second iteration. [II]"); + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mSecondSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + mCount = 0; + Iterator itx = mSecondSearch.iterator(); + while (itx.hasNext()) { + BlockPos G = itx.next(); + mCheckedSpaces.add(G); + Set mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator it2 = mBranchSearch.iterator(); + while (it2.hasNext()) { + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mThirdSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + return mThirdSearch; + } + + public static Set searchSixFaces(World W, BlockPos P, Set checkedSpaces, boolean checkLeaves) { + Set mConnected = new HashSet(); + int x = P.xPos; + int y = P.yPos; + int z = P.zPos; + if (checkLeaves) { + if (isWoodLog(W.getBlock(x - 1, y, z)) || isLeaves(W.getBlock(x - 1, y, z))) { + BlockPos L = new BlockPos(x - 1, y, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x + 1, y, z)) || isLeaves(W.getBlock(x + 1, y, z))) { + BlockPos L = new BlockPos(x + 1, y, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y - 1, z)) || isLeaves(W.getBlock(x, y - 1, z))) { + BlockPos L = new BlockPos(x, y - 1, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y + 1, z)) || isLeaves(W.getBlock(x, y + 1, z))) { + BlockPos L = new BlockPos(x, y + 1, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z - 1)) || isLeaves(W.getBlock(x, y, z - 1))) { + BlockPos L = new BlockPos(x, y, z - 1, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z + 1)) || isLeaves(W.getBlock(x, y, z + 1))) { + BlockPos L = new BlockPos(x, y, z + 1, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + } else { + if (isWoodLog(W.getBlock(x - 1, y, z))) { + BlockPos L = new BlockPos(x - 1, y, z, W); + // if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + // } + } + if (isWoodLog(W.getBlock(x + 1, y, z))) { + BlockPos L = new BlockPos(x + 1, y, z, W); + // if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + // } + } + if (isWoodLog(W.getBlock(x, y - 1, z))) { + BlockPos L = new BlockPos(x, y - 1, z, W); + // if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + // } + } + if (isWoodLog(W.getBlock(x, y + 1, z))) { + BlockPos L = new BlockPos(x, y + 1, z, W); + // if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + // } + } + if (isWoodLog(W.getBlock(x, y, z - 1))) { + BlockPos L = new BlockPos(x, y, z - 1, W); + // if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + // } + } + if (isWoodLog(W.getBlock(x, y, z + 1))) { + BlockPos L = new BlockPos(x, y, z + 1, W); + // if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + // } + } + } + return mConnected; + } + + public enum ToolType { + Unbreakable, + Breakable + } + + /** + * Tree Cutting + */ + public static class TreeCutter { + + private final World mWorld; + private Map mQueue = new ConcurrentHashMap(); + private AutoMap mDrops = new AutoMap(); + private boolean isValid = true; + + public TreeCutter(World world) { + this.mWorld = world; + } + + public boolean queue(BlockPos pos) { + if (isValid && pos != null) { + // Logger.INFO("Queued: "+pos.getLocationString()); + String hash = Utils.calculateChecksumMD5(pos); + if (hash != null && !mQueue.containsKey(hash)) { + mQueue.put(hash, pos); + return true; + } + } + return false; + } + + private boolean emptyQueue() { + if (isValid) { + Logger.INFO("Emptying Queue."); + if (this.mQueue.size() > 0) { + int totalRemoved = 0; + for (BlockPos h : mQueue.values()) { + final Block block = mWorld.getBlock(h.xPos, h.yPos, h.zPos); + if (block != null) { + final int dropMeta = mWorld.getBlockMetadata(h.xPos, h.yPos, h.zPos); + final ArrayList blockDrops = + block.getDrops(mWorld, h.xPos, h.yPos, h.zPos, dropMeta, 0); + final ItemStack[] drops = ItemUtils.getBlockDrops(blockDrops); + mDrops.put(drops); + // Remove drop that was added to the bus. + mWorld.setBlockToAir(h.xPos, h.yPos, h.zPos); + // new BlockBreakParticles(mWorld, h.xPos, h.yPos, h.zPos, block); + totalRemoved++; + } + } + if (totalRemoved > 0 && mDrops.size() > 0) { + return true; + } + } + } + return false; + } + + public ItemStack[] getDrops() { + // If Queue is successfully cleared and drops are created, let us continue. + if (isValid && emptyQueue()) { + AutoMap mCollective = new AutoMap(); + // Iterate ALL of the arrays, add output to a collective. + for (ItemStack[] i : this.mDrops) { + // Array is not null. + if (i != null) { + // Iterate this array. + for (int d = 0; d < i.length; d++) { + // Put Output into collective if valid + if (i[d] != null && i[d].stackSize > 0) { + mCollective.put(i[d]); + } + } + } + } + // Build an ItemStack array. + ItemStack[] drops = new ItemStack[mCollective.size()]; + for (int m = 0; m < drops.length; m++) { + drops[m] = mCollective.get(m); + } + // Return drops array if it's valid. + if (drops.length > 0) { + isValid = false; + return drops; + } + } + // Invalid or no drops, return empty array. + isValid = false; + return new ItemStack[] {}; + } + } + + /** + * Farm AI + */ + private static EntityPlayerMP farmerAI; + + public EntityPlayerMP getFakePlayer(World world) { + return farmerAI = checkFakePlayer(world); + } + + public static EntityPlayerMP checkFakePlayer(World world) { + if (farmerAI == null) { + return new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(world.provider.dimensionId)); + } + return farmerAI; + } + + public static boolean onBlockStartBreak(int x, int y, int z, World world) { + final Block wood = world.getBlock(x, y, z); + if (wood == null) { + return false; + } + if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge) + if (detectTree(world, x, y, z)) { + TreeChopTask chopper = new TreeChopTask(new ChunkPosition(x, y, z), checkFakePlayer(world), 128); + FMLCommonHandler.instance().bus().register(chopper); + // custom block breaking code, don't call vanilla code + return true; + } + // return onBlockStartBreak(stack, x, y, z, player); + return false; + } + + public static boolean detectTree(World world, int pX, int pY, int pZ) { + ChunkPosition pos = null; + Stack candidates = new Stack<>(); + candidates.add(new ChunkPosition(pX, pY, pZ)); + + while (!candidates.isEmpty()) { + ChunkPosition candidate = candidates.pop(); + int curX = candidate.chunkPosX, curY = candidate.chunkPosY, curZ = candidate.chunkPosZ; + + Block block = world.getBlock(curX, curY, curZ); + if ((pos == null || candidate.chunkPosY > pos.chunkPosY) && block.isWood(world, curX, curY, curZ)) { + pos = new ChunkPosition(curX, candidate.chunkPosY + 1, curZ); + // go up + while (world.getBlock(curX, pos.chunkPosY, curZ).isWood(world, curX, pos.chunkPosY, curZ)) { + pos = new ChunkPosition(curX, pos.chunkPosY + 1, curZ); + } + // check if we still have a way diagonally up + candidates.add(new ChunkPosition(curX + 1, pos.chunkPosY + 1, curZ)); + candidates.add(new ChunkPosition(curX, pos.chunkPosY + 1, curZ + 1)); + candidates.add(new ChunkPosition(curX - 1, pos.chunkPosY + 1, curZ)); + candidates.add(new ChunkPosition(curX, pos.chunkPosY + 1, curZ - 1)); + } + } + + // not even one match, so there were no logs. + if (pos == null) { + return false; + } + + // check if there were enough leaves around the last position + // pos now contains the block above the topmost log + // we want at least 5 leaves in the surrounding 26 blocks + int d = 3; + int leaves = 0; + for (int offX = 0; offX < d; offX++) { + for (int offY = 0; offY < d; offY++) { + for (int offZ = 0; offZ < d; offZ++) { + int xPos = pos.chunkPosX - 1 + offX, + yPos = pos.chunkPosY - 1 + offY, + zPos = pos.chunkPosZ - 1 + offZ; + Block leaf = world.getBlock(xPos, yPos, zPos); + if (leaf != null && leaf.isLeaves(world, xPos, yPos, zPos)) { + if (++leaves >= 5) { + return true; + } + } + } + } + } + + // not enough leaves. sorreh + return false; + } + + public static class TreeChopTask { + + public final World world; + public final EntityPlayer player; + public final int blocksPerTick; + + public Queue blocks = Lists.newLinkedList(); + public Set visited = new THashSet<>(); + + public TreeChopTask(ChunkPosition start, EntityPlayer player, int blocksPerTick) { + this.world = player.getEntityWorld(); + this.player = player; + this.blocksPerTick = blocksPerTick; + + this.blocks.add(start); + } + + private void queueCoordinate(int x, int y, int z) { + ChunkPosition pos = new ChunkPosition(x, y, z); + if (!visited.contains(pos)) { + blocks.add(pos); + } + } + + @SubscribeEvent + public void onWorldTick(TickEvent.WorldTickEvent event) { + if (event.side.isClient()) { + finish(); + return; + } + // only if same dimension + if (event.world.provider.dimensionId != world.provider.dimensionId) { + return; + } + + // setup + int left = blocksPerTick; + // NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + + // continue running + ChunkPosition pos; + while (left > 0) { + // completely done or can't do our job anymore?! + if (blocks.isEmpty() /* || tags.getBoolean("Broken")*/) { + finish(); + return; + } + + pos = blocks.remove(); + if (!visited.add(pos)) { + continue; + } + int x = pos.chunkPosX, y = pos.chunkPosY, z = pos.chunkPosZ; + + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + // can we harvest the block and is effective? + if (!block.isWood(world, x, y, z) || !isWoodLog(block)) { + continue; + } + + // save its neighbors + queueCoordinate(x + 1, y, z); + queueCoordinate(x, y, z + 1); + queueCoordinate(x - 1, y, z); + queueCoordinate(x, y, z - 1); + + // also add the layer above.. stupid acacia trees + for (int offX = 0; offX < 3; offX++) { + for (int offZ = 0; offZ < 3; offZ++) { + queueCoordinate(x - 1 + offX, y + 1, z - 1 + offZ); + } + } + + // break it, wooo! + breakExtraBlock(player.worldObj, x, y, z, 0, player, x, y, z); + left--; + } + } + + private void finish() { + // goodbye cruel world + FMLCommonHandler.instance().bus().unregister(this); + } + } + + public static void breakExtraBlock( + World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) { + // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events + if (world.isAirBlock(x, y, z)) return; + + // what? + if (!(playerEntity instanceof EntityPlayerMP)) return; + EntityPlayerMP player = (EntityPlayerMP) playerEntity; + + // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian + // or precious ores you can't harvest while mining stone + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + // only effective materials + if (!isWoodLog(block)) return; + + Block refBlock = world.getBlock(refX, refY, refZ); + float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ); + float strength = ForgeHooks.blockStrength(block, player, world, x, y, z); + + // only harvestable blocks that aren't impossibly slow to harvest + if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength / strength > 10f) return; + + // send the blockbreak event + BlockEvent.BreakEvent event = + ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z); + if (event.isCanceled()) return; + + if (player.capabilities.isCreativeMode) { + block.onBlockHarvested(world, x, y, z, meta, player); + if (block.removedByPlayer(world, player, x, y, z, false)) + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + + // send update to client + if (!world.isRemote) { + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + return; + } + + // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. + player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player); + + // server sided handling + if (!world.isRemote) { + // serverside we reproduce ItemInWorldManager.tryHarvestBlock + + // ItemInWorldManager.removeBlock + block.onBlockHarvested(world, x, y, z, meta, player); + + if (block.removedByPlayer( + world, player, x, y, z, true)) // boolean is if block can be harvested, checked above + { + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + block.harvestBlock(world, player, x, y, z, meta); + block.dropXpOnBlockBreak(world, x, y, z, event.getExpToDrop()); + } + + // always send block update to client + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + // client sided handling + else { + // PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController; + // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send + // any new packets + // the code above, executed on the server, sends a block-updates that give us the correct state of the block + // we destroy. + + // following code can be found in PlayerControllerMP.onPlayerDestroyBlock + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + if (block.removedByPlayer(world, player, x, y, z, true)) { + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + } + // callback to the tool + ItemStack itemstack = player.getCurrentEquippedItem(); + if (itemstack != null) { + itemstack.func_150999_a(world, block, x, y, z, player); + + if (itemstack.stackSize == 0) { + player.destroyCurrentEquippedItem(); + } + } + + // send an update to the server, so we get an update back + // if(PHConstruct.extraBlockUpdates) + // Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, + // Minecraft.getMinecraft().objectMouseOver.sideHit)); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java index 575e094696..72d6111b8a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -1,14 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -16,146 +14,142 @@ import net.minecraftforge.fluids.FluidStack; public class VolumetricFlaskHelper { - private static final Class sClassVolumetricFlask; - private static final Method sMethodGetFlaskMaxCapacity; - private static Item mFlask; - - static { - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - sClassVolumetricFlask = ReflectionUtils.getClass("gregtech.common.items.GT_VolumetricFlask"); - Method aMaxCapacity = null; - try { - aMaxCapacity = sClassVolumetricFlask.getDeclaredMethod("getMaxCapacity", new Class[] {}); - } - catch (NoSuchMethodException e) { - e.printStackTrace(); - CORE.crash("Secondary Error Obtaining instance of 'getMaxCapacity' from 'GT_VolumetricFlask'. Crashing."); - } - sMethodGetFlaskMaxCapacity = aMaxCapacity; - } - else { - sClassVolumetricFlask = null; - sMethodGetFlaskMaxCapacity = null; - } - } - - public static ItemStack getVolumetricFlask(int aAmount) { - ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", aAmount, (ItemStack) null); - return aFlask; - } - - public static ItemStack getLargeVolumetricFlask(int aAmount) { - ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_8k.get(aAmount); - return aFlask; - } - - public static ItemStack getGiganticVolumetricFlask(int aAmount) { - ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_32k.get(aAmount); - return aFlask; - } - - public static boolean isVolumetricFlask(ItemStack aStack) { - if (isNormalVolumetricFlask(aStack) || isLargeVolumetricFlask(aStack) || isGiganticVolumetricFlask(aStack)) { - return true; - } - return false; - } - - public static boolean isNormalVolumetricFlask(ItemStack aStack) { - if (mFlask == null) { - ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); - if (aFlask != null) { - mFlask = aFlask.getItem(); - } - } - if (aStack.getItem() == mFlask) { - return true; - } - return false; - } - - public static boolean isLargeVolumetricFlask(ItemStack aStack) { - if (GregtechItemList.VOLUMETRIC_FLASK_8k.getItem() == aStack.getItem()) { - return true; - } - return false; - } - - public static boolean isGiganticVolumetricFlask(ItemStack aStack) { - if (GregtechItemList.VOLUMETRIC_FLASK_32k.getItem() == aStack.getItem()) { - return true; - } - return false; - } - - public static int getMaxFlaskCapacity(ItemStack aStack) { - if (aStack != null && sMethodGetFlaskMaxCapacity != null) { - Item aItem = aStack.getItem(); - if (sClassVolumetricFlask.isInstance(aItem)) { - int aMaxCapacity = (int) ReflectionUtils.invokeNonBool(aItem, sMethodGetFlaskMaxCapacity, new Object[] {}); - return aMaxCapacity; - } - } - return 0; - } - - public static boolean isFlaskEmpty(ItemStack aStack) { - return getFlaskFluid(aStack) == null; - } - - public static FluidStack getFlaskFluid(ItemStack aStack) { - if (aStack.hasTagCompound()) { - NBTTagCompound nbt = aStack.getTagCompound(); - if (nbt.hasKey("Fluid", 10)) - return FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("Fluid")); - } - return null; - } - - public static void setFluid(ItemStack stack, FluidStack fluidStack) { - boolean removeFluid = (fluidStack == null) || (fluidStack.amount <= 0); - NBTTagCompound nbt = stack.getTagCompound(); - if (nbt == null) { - if (removeFluid) - return; - stack.setTagCompound(nbt = new NBTTagCompound()); - } - if (removeFluid) { - nbt.removeTag("Fluid"); - if (nbt.hasNoTags()) { - stack.setTagCompound(null); - } - } else { - nbt.setTag("Fluid", fluidStack.writeToNBT(new NBTTagCompound())); - } - } - - public static int getFlaskCapacity(ItemStack aStack) { - int capacity = 1000; - if (aStack.hasTagCompound()) { - NBTTagCompound nbt = aStack.getTagCompound(); - if (nbt.hasKey("Capacity", 3)) - capacity = nbt.getInteger("Capacity"); - } - return Math.min(getMaxFlaskCapacity(aStack), capacity); - } - - public static boolean setNewFlaskCapacity(ItemStack aStack, int aCapacity) { - if (aStack == null || aCapacity <= 0) { - return false; - } - aCapacity = Math.min(aCapacity, getMaxFlaskCapacity(aStack)); - NBTTagCompound nbt = aStack.getTagCompound(); - if (nbt == null) { - aStack.setTagCompound(nbt = new NBTTagCompound()); - } - nbt.setInteger("Capacity", aCapacity); - return true; - } - + private static final Class sClassVolumetricFlask; + private static final Method sMethodGetFlaskMaxCapacity; + private static Item mFlask; + + static { + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + sClassVolumetricFlask = ReflectionUtils.getClass("gregtech.common.items.GT_VolumetricFlask"); + Method aMaxCapacity = null; + try { + aMaxCapacity = sClassVolumetricFlask.getDeclaredMethod("getMaxCapacity", new Class[] {}); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + CORE.crash( + "Secondary Error Obtaining instance of 'getMaxCapacity' from 'GT_VolumetricFlask'. Crashing."); + } + sMethodGetFlaskMaxCapacity = aMaxCapacity; + } else { + sClassVolumetricFlask = null; + sMethodGetFlaskMaxCapacity = null; + } + } + + public static ItemStack getVolumetricFlask(int aAmount) { + ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", aAmount, (ItemStack) null); + return aFlask; + } + + public static ItemStack getLargeVolumetricFlask(int aAmount) { + ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_8k.get(aAmount); + return aFlask; + } + + public static ItemStack getGiganticVolumetricFlask(int aAmount) { + ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_32k.get(aAmount); + return aFlask; + } + + public static boolean isVolumetricFlask(ItemStack aStack) { + if (isNormalVolumetricFlask(aStack) || isLargeVolumetricFlask(aStack) || isGiganticVolumetricFlask(aStack)) { + return true; + } + return false; + } + + public static boolean isNormalVolumetricFlask(ItemStack aStack) { + if (mFlask == null) { + ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); + if (aFlask != null) { + mFlask = aFlask.getItem(); + } + } + if (aStack.getItem() == mFlask) { + return true; + } + return false; + } + + public static boolean isLargeVolumetricFlask(ItemStack aStack) { + if (GregtechItemList.VOLUMETRIC_FLASK_8k.getItem() == aStack.getItem()) { + return true; + } + return false; + } + + public static boolean isGiganticVolumetricFlask(ItemStack aStack) { + if (GregtechItemList.VOLUMETRIC_FLASK_32k.getItem() == aStack.getItem()) { + return true; + } + return false; + } + + public static int getMaxFlaskCapacity(ItemStack aStack) { + if (aStack != null && sMethodGetFlaskMaxCapacity != null) { + Item aItem = aStack.getItem(); + if (sClassVolumetricFlask.isInstance(aItem)) { + int aMaxCapacity = + (int) ReflectionUtils.invokeNonBool(aItem, sMethodGetFlaskMaxCapacity, new Object[] {}); + return aMaxCapacity; + } + } + return 0; + } + + public static boolean isFlaskEmpty(ItemStack aStack) { + return getFlaskFluid(aStack) == null; + } + + public static FluidStack getFlaskFluid(ItemStack aStack) { + if (aStack.hasTagCompound()) { + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt.hasKey("Fluid", 10)) return FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("Fluid")); + } + return null; + } + + public static void setFluid(ItemStack stack, FluidStack fluidStack) { + boolean removeFluid = (fluidStack == null) || (fluidStack.amount <= 0); + NBTTagCompound nbt = stack.getTagCompound(); + if (nbt == null) { + if (removeFluid) return; + stack.setTagCompound(nbt = new NBTTagCompound()); + } + if (removeFluid) { + nbt.removeTag("Fluid"); + if (nbt.hasNoTags()) { + stack.setTagCompound(null); + } + } else { + nbt.setTag("Fluid", fluidStack.writeToNBT(new NBTTagCompound())); + } + } + + public static int getFlaskCapacity(ItemStack aStack) { + int capacity = 1000; + if (aStack.hasTagCompound()) { + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt.hasKey("Capacity", 3)) capacity = nbt.getInteger("Capacity"); + } + return Math.min(getMaxFlaskCapacity(aStack), capacity); + } + + public static boolean setNewFlaskCapacity(ItemStack aStack, int aCapacity) { + if (aStack == null || aCapacity <= 0) { + return false; + } + aCapacity = Math.min(aCapacity, getMaxFlaskCapacity(aStack)); + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt == null) { + aStack.setTagCompound(nbt = new NBTTagCompound()); + } + nbt.setInteger("Capacity", aCapacity); + return true; + } + public static int fillFlask(ItemStack stack, FluidStack resource, boolean doFill) { - if (stack.stackSize != 1) - return 0; + if (stack.stackSize != 1) return 0; if ((resource == null) || (resource.amount <= 0)) { return 0; } @@ -173,16 +167,17 @@ public class VolumetricFlaskHelper { return amount; } - public static Item generateNewFlask(String unlocalized, String english, int maxCapacity) { - Constructor aFlask = ReflectionUtils.getConstructor(sClassVolumetricFlask, new Class[] {String.class, String.class, int.class}); - if (aFlask != null) { - Object aInstance = ReflectionUtils.createNewInstanceFromConstructor(aFlask, new Object[] {unlocalized, english, maxCapacity}); - if (aInstance != null && aInstance instanceof Item) { - Item aNewFlaskItem = (Item) aInstance; - return aNewFlaskItem; - } - } - return null; - } - + public static Item generateNewFlask(String unlocalized, String english, int maxCapacity) { + Constructor aFlask = ReflectionUtils.getConstructor( + sClassVolumetricFlask, new Class[] {String.class, String.class, int.class}); + if (aFlask != null) { + Object aInstance = ReflectionUtils.createNewInstanceFromConstructor( + aFlask, new Object[] {unlocalized, english, maxCapacity}); + if (aInstance != null && aInstance instanceof Item) { + Item aNewFlaskItem = (Item) aInstance; + return aNewFlaskItem; + } + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java index 29dabaf084..165941b1d2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.helpers.autocrafter; +import gtPlusPlus.api.objects.Logger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.*; @@ -7,112 +8,98 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; +public class AC_Helper_Container extends Container { + /** The crafting matrix inventory (3x3). */ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + + public IInventory craftResult = new InventoryCraftResult(); + private World worldObj; + + public InventoryCrafting getMatrix() { + return this.craftMatrix; + } + + public boolean putItemsIntoGrid(ItemStack[] inputs) { + if (inputs.length < 9) { + return false; + } + for (int i = 0; i < 9; i++) { + this.putStackInSlot(i, inputs[i]); + } + this.onCraftMatrixChanged(this.craftMatrix); + return true; + } + + public AC_Helper_Container(InventoryPlayer playerInventory, World world, int x, int y, int z) { + this.worldObj = world; + this.addSlotToContainer( + new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35)); + int l; + int i1; + + for (l = 0; l < 3; ++l) { + for (i1 = 0; i1 < 3; ++i1) { + this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); + } + } + + for (l = 0; l < 3; ++l) { + for (i1 = 0; i1 < 9; ++i1) { + this.addSlotToContainer(new Slot(playerInventory, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); + } + } + + for (l = 0; l < 9; ++l) { + this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142)); + } + + this.onCraftMatrixChanged(this.craftMatrix); + } + + /** + * Callback for when the crafting matrix is changed. + */ + @Override + public void onCraftMatrixChanged(IInventory p_75130_1_) { + this.craftResult.setInventorySlotContents( + 0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); + Logger.INFO("Crafted " + this.craftResult.getStackInSlot(0)); + } + + /** + * Called when the container is closed. + */ + @Override + public void onContainerClosed(EntityPlayer p_75134_1_) { + super.onContainerClosed(p_75134_1_); + + if (!this.worldObj.isRemote) { + for (int i = 0; i < 9; ++i) { + ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); + + if (itemstack != null) { + p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + } + + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + ItemStack itemstack = null; + return itemstack; + } -public class AC_Helper_Container extends Container -{ - /** The crafting matrix inventory (3x3). */ - public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); - public IInventory craftResult = new InventoryCraftResult(); - private World worldObj; - - public InventoryCrafting getMatrix(){ - return this.craftMatrix; - } - - public boolean putItemsIntoGrid(ItemStack[] inputs){ - if (inputs.length < 9){ - return false; - } - for (int i=0;i<9;i++){ - this.putStackInSlot(i, inputs[i]); - } - this.onCraftMatrixChanged(this.craftMatrix); - return true; - } - - public AC_Helper_Container(InventoryPlayer playerInventory, World world, int x, int y, int z) - { - this.worldObj = world; - this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35)); - int l; - int i1; - - for (l = 0; l < 3; ++l) - { - for (i1 = 0; i1 < 3; ++i1) - { - this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); - } - } - - for (l = 0; l < 3; ++l) - { - for (i1 = 0; i1 < 9; ++i1) - { - this.addSlotToContainer(new Slot(playerInventory, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); - } - } - - for (l = 0; l < 9; ++l) - { - this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142)); - } - - this.onCraftMatrixChanged(this.craftMatrix); - } - - /** - * Callback for when the crafting matrix is changed. - */ - @Override - public void onCraftMatrixChanged(IInventory p_75130_1_) - { - this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); - Logger.INFO("Crafted "+this.craftResult.getStackInSlot(0)); - - } - - /** - * Called when the container is closed. - */ - @Override - public void onContainerClosed(EntityPlayer p_75134_1_) - { - super.onContainerClosed(p_75134_1_); - - if (!this.worldObj.isRemote) - { - for (int i = 0; i < 9; ++i) - { - ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); - - if (itemstack != null) - { - p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); - } - } - } - } - - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) - { - return true; - } - - /** - * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. - */ - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_){ - ItemStack itemstack = null; - return itemstack; - } - - @Override - public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) - { - return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); - } -} \ No newline at end of file + @Override + public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) { + return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Utils.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Utils.java index 772ece96aa..6b8452eeed 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Utils.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Utils.java @@ -1,80 +1,78 @@ package gtPlusPlus.xmod.gregtech.common.helpers.autocrafter; -import java.util.*; -import java.util.Map.Entry; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; +import java.util.*; +import java.util.Map.Entry; public class AC_Helper_Utils { - //AC maps - public static final Map sAutocrafterMap = new HashMap(); - - //Add Crafter - public final static int addCrafter(GT4Entity_AutoCrafter AC) { - if (!sAutocrafterMap.containsValue(AC)){ - int increase = sAutocrafterMap.size()+1; - sAutocrafterMap.put(increase, AC); - Logger.INFO("[A-C] "+"Added Auto-Crafter to index on position "+increase+"."); - return increase; - } - else { - Logger.INFO("[A-C] Tried adding an Auto-Crafter to Index, but found one already there."); - } - return 0; - } + // AC maps + public static final Map sAutocrafterMap = + new HashMap(); - //Remove Crafter - public final static boolean removeCrafter(int frequency) { - if (!sAutocrafterMap.isEmpty()){ - if (sAutocrafterMap.containsKey(frequency)){ - sAutocrafterMap.remove(frequency); - return true; - } - } - return false; - } + // Add Crafter + public static final int addCrafter(GT4Entity_AutoCrafter AC) { + if (!sAutocrafterMap.containsValue(AC)) { + int increase = sAutocrafterMap.size() + 1; + sAutocrafterMap.put(increase, AC); + Logger.INFO("[A-C] " + "Added Auto-Crafter to index on position " + increase + "."); + return increase; + } else { + Logger.INFO("[A-C] Tried adding an Auto-Crafter to Index, but found one already there."); + } + return 0; + } - public final static boolean removeCrafter(GT4Entity_AutoCrafter AC) { - if (!sAutocrafterMap.isEmpty()){ - if (sAutocrafterMap.containsValue(AC)){ - sAutocrafterMap.remove(getIDByCrafter(AC)); - return true; - } - } - return false; - } + // Remove Crafter + public static final boolean removeCrafter(int frequency) { + if (!sAutocrafterMap.isEmpty()) { + if (sAutocrafterMap.containsKey(frequency)) { + sAutocrafterMap.remove(frequency); + return true; + } + } + return false; + } - //Get Crafter - public final static GT4Entity_AutoCrafter getCrafterByID(int ID) { - if (!sAutocrafterMap.isEmpty()) { - Set> players = sAutocrafterMap.entrySet(); - Iterator> i = players.iterator(); - while (i.hasNext()) { - Entry current = i.next(); - if (current.getKey().equals(ID)) { - return current.getValue(); - } - } - } - Logger.WARNING("Failed. [getCrafterByID]"); - return null; - } + public static final boolean removeCrafter(GT4Entity_AutoCrafter AC) { + if (!sAutocrafterMap.isEmpty()) { + if (sAutocrafterMap.containsValue(AC)) { + sAutocrafterMap.remove(getIDByCrafter(AC)); + return true; + } + } + return false; + } - public final static int getIDByCrafter(GT4Entity_AutoCrafter AC) { - if (!sAutocrafterMap.isEmpty()) { - Set> players = sAutocrafterMap.entrySet(); - Iterator> i = players.iterator(); - while (i.hasNext()) { - Entry current = i.next(); - if (current.getValue().equals(AC)) { - return current.getKey(); - } - } - } - Logger.WARNING("Failed. [getIDByCrafter]"); - return 0; - } + // Get Crafter + public static final GT4Entity_AutoCrafter getCrafterByID(int ID) { + if (!sAutocrafterMap.isEmpty()) { + Set> players = sAutocrafterMap.entrySet(); + Iterator> i = players.iterator(); + while (i.hasNext()) { + Entry current = i.next(); + if (current.getKey().equals(ID)) { + return current.getValue(); + } + } + } + Logger.WARNING("Failed. [getCrafterByID]"); + return null; + } + public static final int getIDByCrafter(GT4Entity_AutoCrafter AC) { + if (!sAutocrafterMap.isEmpty()) { + Set> players = sAutocrafterMap.entrySet(); + Iterator> i = players.iterator(); + while (i.hasNext()) { + Entry current = i.next(); + if (current.getValue().equals(AC)) { + return current.getKey(); + } + } + } + Logger.WARNING("Failed. [getIDByCrafter]"); + return 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java index a3a116fea6..f4eb274179 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java @@ -2,262 +2,256 @@ package gtPlusPlus.xmod.gregtech.common.helpers.tesseract; import static gtPlusPlus.core.lib.CORE.*; -import java.util.*; -import java.util.Map.Entry; - -import net.minecraft.entity.player.EntityPlayer; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; +import java.util.*; +import java.util.Map.Entry; +import net.minecraft.entity.player.EntityPlayer; public class TesseractHelper { - /** - * Tesseract Generator Helpers - * - * @param player - * @return - */ - - //Checks if a Generator is owned by a player. - public final static boolean isGeneratorOwnedByPlayer(EntityPlayer player, - GT_MetaTileEntity_TesseractGenerator generator) { - if (player == null){ - Logger.WARNING("Failed. [isGeneratorOwnedByPlayer]"); - return false; - } - //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 1"); - UUID playerIdentifier = player.getUniqueID(); - if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { - //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 2"); - Map generators = getGeneratorOwnershipByPlayer(player); - Set> players = generators.entrySet(); - Iterator> i = players.iterator(); - while (i.hasNext()) { - //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 3"); - Entry current = i.next(); - if (current.getValue().equals(generator)) { - //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 4"); - return true; - } - } - } - Logger.WARNING("Failed. [isGeneratorOwnedByPlayer]"); - return false; - } - - //Saves A Generator to the Players UUID map along with the Freq. - public final static boolean setGeneratorOwnershipByPlayer(EntityPlayer player, int freq, - GT_MetaTileEntity_TesseractGenerator generator) { - if (player == null){ - return false; - } - UUID playerIdentifier = player.getUniqueID(); - Logger.WARNING("Setting Generator on "+freq+" for "+player.getDisplayName()+"."); - if (playerIdentifier != null) { - Map playerOwned = sTesseractGeneratorOwnershipMap - .get(playerIdentifier); - if (playerOwned == null || playerOwned.isEmpty()) { - Map newOwnershipMap = new HashMap(); - newOwnershipMap.put(freq, generator); - sTesseractGeneratorOwnershipMap.put(playerIdentifier, newOwnershipMap); - Logger.WARNING("Success! [Empty Map]"); - return true; - } else if (sTesseractGeneratorOwnershipMap.containsKey(playerIdentifier)) { - Map ownershipMap = sTesseractGeneratorOwnershipMap - .get(playerIdentifier); - if (!ownershipMap.containsKey(freq)){ - ownershipMap.put(freq, generator); - } - ownershipMap.put(freq, generator); - sTesseractGeneratorOwnershipMap.put(playerIdentifier, ownershipMap); - Logger.WARNING("Success!"); - return true; - } - } - Logger.WARNING("Failed. [setGeneratorOwnershipByPlayer]"); - return false; - } - - //Gets Generator based on Frequency. - public final static GT_MetaTileEntity_TesseractGenerator getGeneratorByFrequency(EntityPlayer player, - int freq) { - if (player == null){ - return null; - } - UUID playerIdentifier = player.getUniqueID(); - Logger.WARNING("Getting Generator on "+freq+" for "+player.getDisplayName()+"."); - if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { - //Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 1"); - Map generators = getGeneratorOwnershipByPlayer(player); - Set> players = generators.entrySet(); - Iterator> i = players.iterator(); - while (i.hasNext()) { - //Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 2"); - Entry current = i.next(); - if (current.getKey().equals(freq)) { - //Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 3"); - Logger.WARNING("Success!"); - return current.getValue(); - } - } - } - Logger.WARNING("Failed. [getGeneratorByFrequency]"); - return null; - } - - //Remove Tesseract Generator - public final static boolean removeGenerator(EntityPlayer player, int frequency) { - if (player == null){ - return false; - } - UUID playerIdentifier = player.getUniqueID(); - if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { - sTesseractGeneratorOwnershipMap.get(playerIdentifier).remove(frequency); - return true; - } - return false; - } + /** + * Tesseract Generator Helpers + * + * @param player + * @return + */ - /** - * - * Tesseract Terminal Helpers - * - * @param player - * @return - */ + // Checks if a Generator is owned by a player. + public static final boolean isGeneratorOwnedByPlayer( + EntityPlayer player, GT_MetaTileEntity_TesseractGenerator generator) { + if (player == null) { + Logger.WARNING("Failed. [isGeneratorOwnedByPlayer]"); + return false; + } + // Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 1"); + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + // Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 2"); + Map generators = getGeneratorOwnershipByPlayer(player); + Set> players = generators.entrySet(); + Iterator> i = players.iterator(); + while (i.hasNext()) { + // Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 3"); + Entry current = i.next(); + if (current.getValue().equals(generator)) { + // Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 4"); + return true; + } + } + } + Logger.WARNING("Failed. [isGeneratorOwnedByPlayer]"); + return false; + } - //Checks if a Terminal is owned by a player. - public final static boolean isTerminalOwnedByPlayer(EntityPlayer player, - GT_MetaTileEntity_TesseractTerminal generator) { - if (player == null){ - return false; - } - UUID playerIdentifier = player.getUniqueID(); - if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { - Map generators = getTerminalOwnershipByPlayer(player); - Set> players = generators.entrySet(); - Iterator> i = players.iterator(); - while (i.hasNext()) { - Entry current = i.next(); - if (current.getValue().equals(generator)) { - return true; - } - } - } - return false; - } + // Saves A Generator to the Players UUID map along with the Freq. + public static final boolean setGeneratorOwnershipByPlayer( + EntityPlayer player, int freq, GT_MetaTileEntity_TesseractGenerator generator) { + if (player == null) { + return false; + } + UUID playerIdentifier = player.getUniqueID(); + Logger.WARNING("Setting Generator on " + freq + " for " + player.getDisplayName() + "."); + if (playerIdentifier != null) { + Map playerOwned = + sTesseractGeneratorOwnershipMap.get(playerIdentifier); + if (playerOwned == null || playerOwned.isEmpty()) { + Map newOwnershipMap = + new HashMap(); + newOwnershipMap.put(freq, generator); + sTesseractGeneratorOwnershipMap.put(playerIdentifier, newOwnershipMap); + Logger.WARNING("Success! [Empty Map]"); + return true; + } else if (sTesseractGeneratorOwnershipMap.containsKey(playerIdentifier)) { + Map ownershipMap = + sTesseractGeneratorOwnershipMap.get(playerIdentifier); + if (!ownershipMap.containsKey(freq)) { + ownershipMap.put(freq, generator); + } + ownershipMap.put(freq, generator); + sTesseractGeneratorOwnershipMap.put(playerIdentifier, ownershipMap); + Logger.WARNING("Success!"); + return true; + } + } + Logger.WARNING("Failed. [setGeneratorOwnershipByPlayer]"); + return false; + } - //Saves A Terminal to the Players UUID map along with the Freq. - public final static boolean setTerminalOwnershipByPlayer(EntityPlayer player, int freq, - GT_MetaTileEntity_TesseractTerminal generator) { - if (player == null){ - return false; - } - UUID playerIdentifier = player.getUniqueID(); - if (playerIdentifier != null) { - Logger.WARNING("Setting Terminal on "+freq+" for "+player.getDisplayName()+"."); - Map playerOwned = sTesseractTerminalOwnershipMap - .get(playerIdentifier); - if (playerOwned == null || playerOwned.isEmpty()) { - Map newOwnershipMap = new HashMap(); - newOwnershipMap.put(freq, generator); - sTesseractTerminalOwnershipMap.put(playerIdentifier, newOwnershipMap); - Logger.WARNING("Success! [Empty Map]"); - return true; - } else if (sTesseractTerminalOwnershipMap.containsKey(playerIdentifier)) { - Map ownershipMap = sTesseractTerminalOwnershipMap - .get(playerIdentifier); - if (!ownershipMap.containsKey(freq)){ - ownershipMap.put(freq, generator); - } - sTesseractTerminalOwnershipMap.put(playerIdentifier, ownershipMap); - Logger.WARNING("Success!"); - return true; - } - } - Logger.WARNING("Failed. [setTerminalOwnershipByPlayer]"); - return false; - } + // Gets Generator based on Frequency. + public static final GT_MetaTileEntity_TesseractGenerator getGeneratorByFrequency(EntityPlayer player, int freq) { + if (player == null) { + return null; + } + UUID playerIdentifier = player.getUniqueID(); + Logger.WARNING("Getting Generator on " + freq + " for " + player.getDisplayName() + "."); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + // Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 1"); + Map generators = getGeneratorOwnershipByPlayer(player); + Set> players = generators.entrySet(); + Iterator> i = players.iterator(); + while (i.hasNext()) { + // Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 2"); + Entry current = i.next(); + if (current.getKey().equals(freq)) { + // Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 3"); + Logger.WARNING("Success!"); + return current.getValue(); + } + } + } + Logger.WARNING("Failed. [getGeneratorByFrequency]"); + return null; + } - //Gets Terminal based on Frequency. - public final static GT_MetaTileEntity_TesseractTerminal getTerminalByFrequency(EntityPlayer player, - int freq) { - if (player == null){ - return null; - } - UUID playerIdentifier = player.getUniqueID(); - Logger.WARNING("Getting Terminal on "+freq+" for "+player.getDisplayName()+"."); - if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { - Map generators = getTerminalOwnershipByPlayer(player); - Set> players = generators.entrySet(); - Iterator> i = players.iterator(); - while (i.hasNext()) { - Entry current = i.next(); - if (current.getKey().equals(freq)) { - Logger.WARNING("Success!"); - return current.getValue(); - } - } - } - Logger.WARNING("Failed. [getTerminalByFrequency]"); - return null; - } + // Remove Tesseract Generator + public static final boolean removeGenerator(EntityPlayer player, int frequency) { + if (player == null) { + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + sTesseractGeneratorOwnershipMap.get(playerIdentifier).remove(frequency); + return true; + } + return false; + } - //Remove Tesseract Terminal - public final static boolean removeTerminal(EntityPlayer player, int frequency) { - if (player == null){ - return false; - } - UUID playerIdentifier = player.getUniqueID(); - if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { - sTesseractTerminalOwnershipMap.get(playerIdentifier).remove(frequency); - return true; - } - return false; - } + /** + * + * Tesseract Terminal Helpers + * + * @param player + * @return + */ - /** - * - * Internal Methods - * - */ + // Checks if a Terminal is owned by a player. + public static final boolean isTerminalOwnedByPlayer( + EntityPlayer player, GT_MetaTileEntity_TesseractTerminal generator) { + if (player == null) { + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + Map generators = getTerminalOwnershipByPlayer(player); + Set> players = generators.entrySet(); + Iterator> i = players.iterator(); + while (i.hasNext()) { + Entry current = i.next(); + if (current.getValue().equals(generator)) { + return true; + } + } + } + return false; + } - private final static Map getGeneratorOwnershipByPlayer( - EntityPlayer player) { - UUID playerIdentifier = player.getUniqueID(); - if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { - Set>> players = sTesseractGeneratorOwnershipMap - .entrySet(); - Iterator>> i = players.iterator(); - while (i.hasNext()) { - Entry> current = i.next(); - if (current.getKey().compareTo(playerIdentifier) == 0) { - return current.getValue(); - } + // Saves A Terminal to the Players UUID map along with the Freq. + public static final boolean setTerminalOwnershipByPlayer( + EntityPlayer player, int freq, GT_MetaTileEntity_TesseractTerminal generator) { + if (player == null) { + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (playerIdentifier != null) { + Logger.WARNING("Setting Terminal on " + freq + " for " + player.getDisplayName() + "."); + Map playerOwned = + sTesseractTerminalOwnershipMap.get(playerIdentifier); + if (playerOwned == null || playerOwned.isEmpty()) { + Map newOwnershipMap = + new HashMap(); + newOwnershipMap.put(freq, generator); + sTesseractTerminalOwnershipMap.put(playerIdentifier, newOwnershipMap); + Logger.WARNING("Success! [Empty Map]"); + return true; + } else if (sTesseractTerminalOwnershipMap.containsKey(playerIdentifier)) { + Map ownershipMap = + sTesseractTerminalOwnershipMap.get(playerIdentifier); + if (!ownershipMap.containsKey(freq)) { + ownershipMap.put(freq, generator); + } + sTesseractTerminalOwnershipMap.put(playerIdentifier, ownershipMap); + Logger.WARNING("Success!"); + return true; + } + } + Logger.WARNING("Failed. [setTerminalOwnershipByPlayer]"); + return false; + } - } - } - return null; - } + // Gets Terminal based on Frequency. + public static final GT_MetaTileEntity_TesseractTerminal getTerminalByFrequency(EntityPlayer player, int freq) { + if (player == null) { + return null; + } + UUID playerIdentifier = player.getUniqueID(); + Logger.WARNING("Getting Terminal on " + freq + " for " + player.getDisplayName() + "."); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + Map generators = getTerminalOwnershipByPlayer(player); + Set> players = generators.entrySet(); + Iterator> i = players.iterator(); + while (i.hasNext()) { + Entry current = i.next(); + if (current.getKey().equals(freq)) { + Logger.WARNING("Success!"); + return current.getValue(); + } + } + } + Logger.WARNING("Failed. [getTerminalByFrequency]"); + return null; + } - private final static Map getTerminalOwnershipByPlayer( - EntityPlayer player) { - UUID playerIdentifier = player.getUniqueID(); - if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { - Set>> players = sTesseractTerminalOwnershipMap - .entrySet(); - Iterator>> i = players.iterator(); - while (i.hasNext()) { - Entry> current = i.next(); - if (current.getKey().compareTo(playerIdentifier) == 0) { - return current.getValue(); - } + // Remove Tesseract Terminal + public static final boolean removeTerminal(EntityPlayer player, int frequency) { + if (player == null) { + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + sTesseractTerminalOwnershipMap.get(playerIdentifier).remove(frequency); + return true; + } + return false; + } - } - } - return null; - } + /** + * + * Internal Methods + * + */ + private static final Map getGeneratorOwnershipByPlayer( + EntityPlayer player) { + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + Set>> players = + sTesseractGeneratorOwnershipMap.entrySet(); + Iterator>> i = players.iterator(); + while (i.hasNext()) { + Entry> current = i.next(); + if (current.getKey().compareTo(playerIdentifier) == 0) { + return current.getValue(); + } + } + } + return null; + } + private static final Map getTerminalOwnershipByPlayer( + EntityPlayer player) { + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + Set>> players = + sTesseractTerminalOwnershipMap.entrySet(); + Iterator>> i = players.iterator(); + while (i.hasNext()) { + Entry> current = i.next(); + if (current.getKey().compareTo(playerIdentifier) == 0) { + return current.getValue(); + } + } + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java index bb40c9b379..1e45b7c60b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java @@ -1,13 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.helpers.treefarm; -import java.util.Random; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.FakeBlockPos; import gtPlusPlus.api.objects.minecraft.FakeWorld; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockSapling; import net.minecraft.block.material.Material; @@ -20,367 +19,353 @@ import net.minecraftforge.common.util.ForgeDirection; public class TreeGenerator { - private static final FakeTreeInFakeWorldGenerator mTreeData; - - static { - Logger.WARNING("Created Fake Tree Generator."); - mTreeData = new FakeTreeInFakeWorldGenerator(); - } - - - public TreeGenerator() { - if (!mTreeData.hasGenerated) { - mTreeData.generate(null, CORE.RANDOM, 0, 0, 0); - } - } - - public AutoMap generateOutput(int aTreeSize){ - AutoMap aOutputMap = mTreeData.getOutputFromTree(); - if (aOutputMap != null && aOutputMap.size() > 0) { - Logger.WARNING("Valid tree data output"); - return aOutputMap; - } - Logger.WARNING("Invalid tree data output"); - return new AutoMap(); - } - - public static class FakeTreeInFakeWorldGenerator extends WorldGenAbstractTree - { - /** The minimum height of a generated tree. */ - private final int minTreeHeight; - /** True if this tree should grow Vines. */ - private final boolean vinesGrow; - /** The metadata value of the wood to use in tree generation. */ - private final int metaWood; - /** The metadata value of the leaves to use in tree generation. */ - private final int metaLeaves; - - private final AutoMap mFakeWorld; - private final int mTreesToGenerate; - - private int mCurrentGeneratorIteration = 0; - - private boolean hasGenerated = false; - private AutoMap aOutputsFromGenerator = new AutoMap(); - - public FakeTreeInFakeWorldGenerator() - { - this(4, 0, 0, false, 5000); - } - - public FakeTreeInFakeWorldGenerator(int aMinHeight, int aWoodMeta, int aLeafMeta, boolean aVines, int aTreeCount) - { - super(false); - this.minTreeHeight = aMinHeight; - this.metaWood = aWoodMeta; - this.metaLeaves = aLeafMeta; - this.vinesGrow = aVines; - this.mFakeWorld = new AutoMap(); - this.mTreesToGenerate = aTreeCount; - Logger.WARNING("Created Fake Tree In Fake World Instance."); - } - - - public AutoMap getOutputFromTree(){ - if (!hasGenerated) { - Logger.WARNING("Generating Tree sample data"); - generate(null, CORE.RANDOM, 0, 0, 0); - } - AutoMap aOutputMap = new AutoMap(); - int aRandomTreeID = MathUtils.randInt(0, this.mFakeWorld.size()-1); - FakeWorld aWorld = this.mFakeWorld.get(aRandomTreeID); - if (aWorld != null) { - //Logger.WARNING("Getting all block data from fake world"); - aOutputMap = aWorld.getAllBlocksStoredInFakeWorld(); - } - return aOutputMap; - - } - - @Override - protected boolean func_150523_a(Block p_150523_1_) - { - return p_150523_1_.getMaterial() == Material.air || p_150523_1_.getMaterial() == Material.leaves || p_150523_1_ == Blocks.grass || p_150523_1_ == Blocks.dirt || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.log2 || p_150523_1_ == Blocks.sapling || p_150523_1_ == Blocks.vine; - } - - @Override - protected boolean isReplaceable(World world, int x, int y, int z) - { - FakeWorld aWorld = getWorld(); - Block block = aWorld.getBlock(x, y, z); - return block.isAir(null, x, y, z) || block.isLeaves(null, x, y, z) || block.isWood(null, x, y, z) || func_150523_a(block); - } - - @Override - public boolean generate(World world, Random aRand, int aWorldX, int aWorldRealY, int aWorldZ){ - //Only Generate Once - This object is Cached - if (hasGenerated) { - return hasGenerated; - } - else { - for (int yy=0;yy 0) { - for (FakeWorld aWorld : this.mFakeWorld) { - for (ItemStack aBlockInFakeWorld : aWorld.getAllBlocksStoredInFakeWorld()) { - aOutputsFromGenerator.add(aBlockInFakeWorld); - } - } - return true; - } - else { - return false; - } - } - } - - private FakeWorld aFakeWorld; - - public FakeWorld getWorld() { - FakeWorld aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); - if (aWorld == null) { - this.mFakeWorld.set(mCurrentGeneratorIteration, new FakeWorld(200)); - aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); - } - return aWorld; - } - - public boolean generateTree(int aWorldX, int aWorldRealY, int aWorldZ) { - FakeWorld aWorld = getWorld(); - - //Set some static values - - Logger.WARNING("Stepping through generateTree [0]"); - //Dummy Value - int aWorldY = 10; - - int l = CORE.RANDOM.nextInt(3) + this.minTreeHeight; - boolean flag = true; - - if (aWorldY >= 1 && aWorldY + l + 1 <= 256) - { - Logger.WARNING("Stepping through generateTree [1]"); - byte b0; - int k1; - Block block; - - for (int i1 = aWorldY; i1 <= aWorldY + 1 + l; ++i1) - { - b0 = 1; - - if (i1 == aWorldY) - { - b0 = 0; - } - - if (i1 >= aWorldY + 1 + l - 2) - { - b0 = 2; - } - - for (int j1 = aWorldX - b0; j1 <= aWorldX + b0 && flag; ++j1) - { - for (k1 = aWorldZ - b0; k1 <= aWorldZ + b0 && flag; ++k1) - { - if (i1 >= 0 && i1 < 256) - { - block = aWorld.getBlock(j1, i1, k1); - - if (!this.isReplaceable(null, j1, i1, k1)) - { - flag = false; - } - } - else - { - flag = false; - } - } - } - } - - if (!flag) - { - Logger.WARNING("Stepping through generateTree [2]"); - return false; - } - else - { - Logger.WARNING("Stepping through generateTree [3]"); - Block block2 = aWorld.getBlock(aWorldX, aWorldY - 1, aWorldZ); - FakeBlockPos aBlockToGrowPlantOn = aWorld.getBlockAtCoords(aWorldX, aWorldY-1, aWorldZ); - - boolean isSoil = block2.canSustainPlant(aWorld, aWorldX, aWorldY - 1, aWorldZ, ForgeDirection.UP, (BlockSapling)Blocks.sapling); - if (/*isSoil &&*/ aWorldY < 256 - l - 1) - { - Logger.WARNING("Stepping through generateTree [4]"); - aBlockToGrowPlantOn.onPlantGrow(aWorld, aWorldX, aWorldY - 1, aWorldZ, aWorldX, aWorldY, aWorldZ); - b0 = 3; - byte b1 = 0; - int l1; - int i2; - int j2; - int i3; - - for (k1 = aWorldY - b0 + l; k1 <= aWorldY + l; ++k1) - { - i3 = k1 - (aWorldY + l); - l1 = b1 + 1 - i3 / 2; - - for (i2 = aWorldX - l1; i2 <= aWorldX + l1; ++i2) - { - j2 = i2 - aWorldX; - - for (int k2 = aWorldZ - l1; k2 <= aWorldZ + l1; ++k2) - { - int l2 = k2 - aWorldZ; - - if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || CORE.RANDOM.nextInt(2) != 0 && i3 != 0) - { - Block block1 = aWorld.getBlock(i2, k1, k2); - - if (block1.isAir(null, i2, k1, k2) || block1.isLeaves(null, i2, k1, k2)) - { - this.setBlockAndNotifyAdequately(aWorld, i2, k1, k2, Blocks.leaves, this.metaLeaves); - } - } - } - } - } - Logger.WARNING("Stepping through generateTree [5]"); - - for (k1 = 0; k1 < l; ++k1) - { - block = aWorld.getBlock(aWorldX, aWorldY + k1, aWorldZ); - - if (block.isAir(null, aWorldX, aWorldY + k1, aWorldZ) || block.isLeaves(null, aWorldX, aWorldY + k1, aWorldZ)) - { - this.setBlockAndNotifyAdequately(aWorld, aWorldX, aWorldY + k1, aWorldZ, Blocks.log, this.metaWood); - - if (this.vinesGrow && k1 > 0) - { - if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX - 1, aWorldY + k1, aWorldZ)) - { - this.setBlockAndNotifyAdequately(aWorld, aWorldX - 1, aWorldY + k1, aWorldZ, Blocks.vine, 8); - } - - if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX + 1, aWorldY + k1, aWorldZ)) - { - this.setBlockAndNotifyAdequately(aWorld, aWorldX + 1, aWorldY + k1, aWorldZ, Blocks.vine, 2); - } - - if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX, aWorldY + k1, aWorldZ - 1)) - { - this.setBlockAndNotifyAdequately(aWorld, aWorldX, aWorldY + k1, aWorldZ - 1, Blocks.vine, 1); - } - - if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX, aWorldY + k1, aWorldZ + 1)) - { - this.setBlockAndNotifyAdequately(aWorld, aWorldX, aWorldY + k1, aWorldZ + 1, Blocks.vine, 4); - } - } - } - } - Logger.WARNING("Stepping through generateTree [6]"); - - if (this.vinesGrow) - { - Logger.WARNING("Stepping through generateTree [7]"); - for (k1 = aWorldY - 3 + l; k1 <= aWorldY + l; ++k1) - { - i3 = k1 - (aWorldY + l); - l1 = 2 - i3 / 2; - - for (i2 = aWorldX - l1; i2 <= aWorldX + l1; ++i2) - { - for (j2 = aWorldZ - l1; j2 <= aWorldZ + l1; ++j2) - { - if (aWorld.getBlock(i2, k1, j2).isLeaves(null, i2, k1, j2)) - { - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 - 1, k1, j2).isAir(null, i2 - 1, k1, j2)) - { - this.growVines(aWorld, i2 - 1, k1, j2, 8); - } - - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 + 1, k1, j2).isAir(null, i2 + 1, k1, j2)) - { - this.growVines(aWorld, i2 + 1, k1, j2, 2); - } - - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 - 1).isAir(null, i2, k1, j2 - 1)) - { - this.growVines(aWorld, i2, k1, j2 - 1, 1); - } - - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 + 1).isAir(null, i2, k1, j2 + 1)) - { - this.growVines(aWorld, i2, k1, j2 + 1, 4); - } - } - } - } - } - Logger.WARNING("Stepping through generateTree [8]"); - - if (CORE.RANDOM.nextInt(5) == 0 && l > 5) - { - for (k1 = 0; k1 < 2; ++k1) - { - for (i3 = 0; i3 < 4; ++i3) - { - if (CORE.RANDOM.nextInt(4 - k1) == 0) - { - l1 = CORE.RANDOM.nextInt(3); - this.setBlockAndNotifyAdequately(aWorld, aWorldX + Direction.offsetX[Direction.rotateOpposite[i3]], aWorldY + l - 5 + k1, aWorldZ + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3); - } - } - } - } - } - Logger.WARNING("Stepping through generateTree [9]"); - return true; - } - else - { - Logger.WARNING("Stepping through generateTree [10]"); - return false; - } - } - } - else - { - Logger.WARNING("Stepping through generateTree [11]"); - return false; - } - } - - /** - * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length - */ - private void growVines(FakeWorld aWorld, int aX, int aY, int aZ, int aMeta) - { - int aLoopSize = vinesGrow ? MathUtils.randInt(0, 4) : 0; - for (int i=0;i= 0 && aMeta <= Short.MAX_VALUE)) { - Logger.WARNING("Setting block "+aX+", "+aY+", "+aZ+" | "+aBlock.getLocalizedName()+" | "+aMeta); - aWorld.setBlockAtCoords(aX, aY, aZ, aBlock, aMeta); - //aOutputsFromGenerator.put(ItemUtils.simpleMetaStack(aBlock, aMeta, 1)); - } - } - } - - + private static final FakeTreeInFakeWorldGenerator mTreeData; + + static { + Logger.WARNING("Created Fake Tree Generator."); + mTreeData = new FakeTreeInFakeWorldGenerator(); + } + + public TreeGenerator() { + if (!mTreeData.hasGenerated) { + mTreeData.generate(null, CORE.RANDOM, 0, 0, 0); + } + } + + public AutoMap generateOutput(int aTreeSize) { + AutoMap aOutputMap = mTreeData.getOutputFromTree(); + if (aOutputMap != null && aOutputMap.size() > 0) { + Logger.WARNING("Valid tree data output"); + return aOutputMap; + } + Logger.WARNING("Invalid tree data output"); + return new AutoMap(); + } + + public static class FakeTreeInFakeWorldGenerator extends WorldGenAbstractTree { + /** The minimum height of a generated tree. */ + private final int minTreeHeight; + /** True if this tree should grow Vines. */ + private final boolean vinesGrow; + /** The metadata value of the wood to use in tree generation. */ + private final int metaWood; + /** The metadata value of the leaves to use in tree generation. */ + private final int metaLeaves; + + private final AutoMap mFakeWorld; + private final int mTreesToGenerate; + + private int mCurrentGeneratorIteration = 0; + + private boolean hasGenerated = false; + private AutoMap aOutputsFromGenerator = new AutoMap(); + + public FakeTreeInFakeWorldGenerator() { + this(4, 0, 0, false, 5000); + } + + public FakeTreeInFakeWorldGenerator( + int aMinHeight, int aWoodMeta, int aLeafMeta, boolean aVines, int aTreeCount) { + super(false); + this.minTreeHeight = aMinHeight; + this.metaWood = aWoodMeta; + this.metaLeaves = aLeafMeta; + this.vinesGrow = aVines; + this.mFakeWorld = new AutoMap(); + this.mTreesToGenerate = aTreeCount; + Logger.WARNING("Created Fake Tree In Fake World Instance."); + } + + public AutoMap getOutputFromTree() { + if (!hasGenerated) { + Logger.WARNING("Generating Tree sample data"); + generate(null, CORE.RANDOM, 0, 0, 0); + } + AutoMap aOutputMap = new AutoMap(); + int aRandomTreeID = MathUtils.randInt(0, this.mFakeWorld.size() - 1); + FakeWorld aWorld = this.mFakeWorld.get(aRandomTreeID); + if (aWorld != null) { + // Logger.WARNING("Getting all block data from fake world"); + aOutputMap = aWorld.getAllBlocksStoredInFakeWorld(); + } + return aOutputMap; + } + + @Override + protected boolean func_150523_a(Block p_150523_1_) { + return p_150523_1_.getMaterial() == Material.air + || p_150523_1_.getMaterial() == Material.leaves + || p_150523_1_ == Blocks.grass + || p_150523_1_ == Blocks.dirt + || p_150523_1_ == Blocks.log + || p_150523_1_ == Blocks.log2 + || p_150523_1_ == Blocks.sapling + || p_150523_1_ == Blocks.vine; + } + + @Override + protected boolean isReplaceable(World world, int x, int y, int z) { + FakeWorld aWorld = getWorld(); + Block block = aWorld.getBlock(x, y, z); + return block.isAir(null, x, y, z) + || block.isLeaves(null, x, y, z) + || block.isWood(null, x, y, z) + || func_150523_a(block); + } + + @Override + public boolean generate(World world, Random aRand, int aWorldX, int aWorldRealY, int aWorldZ) { + // Only Generate Once - This object is Cached + if (hasGenerated) { + return hasGenerated; + } else { + for (int yy = 0; yy < mTreesToGenerate; yy++) { + generateTree(0, 0, 0); + mCurrentGeneratorIteration++; + } + hasGenerated = true; + if (this.mFakeWorld.size() > 0) { + for (FakeWorld aWorld : this.mFakeWorld) { + for (ItemStack aBlockInFakeWorld : aWorld.getAllBlocksStoredInFakeWorld()) { + aOutputsFromGenerator.add(aBlockInFakeWorld); + } + } + return true; + } else { + return false; + } + } + } + + private FakeWorld aFakeWorld; + + public FakeWorld getWorld() { + FakeWorld aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); + if (aWorld == null) { + this.mFakeWorld.set(mCurrentGeneratorIteration, new FakeWorld(200)); + aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); + } + return aWorld; + } + + public boolean generateTree(int aWorldX, int aWorldRealY, int aWorldZ) { + FakeWorld aWorld = getWorld(); + + // Set some static values + + Logger.WARNING("Stepping through generateTree [0]"); + // Dummy Value + int aWorldY = 10; + + int l = CORE.RANDOM.nextInt(3) + this.minTreeHeight; + boolean flag = true; + + if (aWorldY >= 1 && aWorldY + l + 1 <= 256) { + Logger.WARNING("Stepping through generateTree [1]"); + byte b0; + int k1; + Block block; + + for (int i1 = aWorldY; i1 <= aWorldY + 1 + l; ++i1) { + b0 = 1; + + if (i1 == aWorldY) { + b0 = 0; + } + + if (i1 >= aWorldY + 1 + l - 2) { + b0 = 2; + } + + for (int j1 = aWorldX - b0; j1 <= aWorldX + b0 && flag; ++j1) { + for (k1 = aWorldZ - b0; k1 <= aWorldZ + b0 && flag; ++k1) { + if (i1 >= 0 && i1 < 256) { + block = aWorld.getBlock(j1, i1, k1); + + if (!this.isReplaceable(null, j1, i1, k1)) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + Logger.WARNING("Stepping through generateTree [2]"); + return false; + } else { + Logger.WARNING("Stepping through generateTree [3]"); + Block block2 = aWorld.getBlock(aWorldX, aWorldY - 1, aWorldZ); + FakeBlockPos aBlockToGrowPlantOn = aWorld.getBlockAtCoords(aWorldX, aWorldY - 1, aWorldZ); + + boolean isSoil = block2.canSustainPlant( + aWorld, aWorldX, aWorldY - 1, aWorldZ, ForgeDirection.UP, (BlockSapling) Blocks.sapling); + if ( + /*isSoil &&*/ aWorldY < 256 - l - 1) { + Logger.WARNING("Stepping through generateTree [4]"); + aBlockToGrowPlantOn.onPlantGrow( + aWorld, aWorldX, aWorldY - 1, aWorldZ, aWorldX, aWorldY, aWorldZ); + b0 = 3; + byte b1 = 0; + int l1; + int i2; + int j2; + int i3; + + for (k1 = aWorldY - b0 + l; k1 <= aWorldY + l; ++k1) { + i3 = k1 - (aWorldY + l); + l1 = b1 + 1 - i3 / 2; + + for (i2 = aWorldX - l1; i2 <= aWorldX + l1; ++i2) { + j2 = i2 - aWorldX; + + for (int k2 = aWorldZ - l1; k2 <= aWorldZ + l1; ++k2) { + int l2 = k2 - aWorldZ; + + if (Math.abs(j2) != l1 + || Math.abs(l2) != l1 + || CORE.RANDOM.nextInt(2) != 0 && i3 != 0) { + Block block1 = aWorld.getBlock(i2, k1, k2); + + if (block1.isAir(null, i2, k1, k2) || block1.isLeaves(null, i2, k1, k2)) { + this.setBlockAndNotifyAdequately( + aWorld, i2, k1, k2, Blocks.leaves, this.metaLeaves); + } + } + } + } + } + Logger.WARNING("Stepping through generateTree [5]"); + + for (k1 = 0; k1 < l; ++k1) { + block = aWorld.getBlock(aWorldX, aWorldY + k1, aWorldZ); + + if (block.isAir(null, aWorldX, aWorldY + k1, aWorldZ) + || block.isLeaves(null, aWorldX, aWorldY + k1, aWorldZ)) { + this.setBlockAndNotifyAdequately( + aWorld, aWorldX, aWorldY + k1, aWorldZ, Blocks.log, this.metaWood); + + if (this.vinesGrow && k1 > 0) { + if (CORE.RANDOM.nextInt(3) > 0 + && aWorld.isAirBlock(aWorldX - 1, aWorldY + k1, aWorldZ)) { + this.setBlockAndNotifyAdequately( + aWorld, aWorldX - 1, aWorldY + k1, aWorldZ, Blocks.vine, 8); + } + + if (CORE.RANDOM.nextInt(3) > 0 + && aWorld.isAirBlock(aWorldX + 1, aWorldY + k1, aWorldZ)) { + this.setBlockAndNotifyAdequately( + aWorld, aWorldX + 1, aWorldY + k1, aWorldZ, Blocks.vine, 2); + } + + if (CORE.RANDOM.nextInt(3) > 0 + && aWorld.isAirBlock(aWorldX, aWorldY + k1, aWorldZ - 1)) { + this.setBlockAndNotifyAdequately( + aWorld, aWorldX, aWorldY + k1, aWorldZ - 1, Blocks.vine, 1); + } + + if (CORE.RANDOM.nextInt(3) > 0 + && aWorld.isAirBlock(aWorldX, aWorldY + k1, aWorldZ + 1)) { + this.setBlockAndNotifyAdequately( + aWorld, aWorldX, aWorldY + k1, aWorldZ + 1, Blocks.vine, 4); + } + } + } + } + Logger.WARNING("Stepping through generateTree [6]"); + + if (this.vinesGrow) { + Logger.WARNING("Stepping through generateTree [7]"); + for (k1 = aWorldY - 3 + l; k1 <= aWorldY + l; ++k1) { + i3 = k1 - (aWorldY + l); + l1 = 2 - i3 / 2; + + for (i2 = aWorldX - l1; i2 <= aWorldX + l1; ++i2) { + for (j2 = aWorldZ - l1; j2 <= aWorldZ + l1; ++j2) { + if (aWorld.getBlock(i2, k1, j2).isLeaves(null, i2, k1, j2)) { + if (CORE.RANDOM.nextInt(4) == 0 + && aWorld.getBlock(i2 - 1, k1, j2) + .isAir(null, i2 - 1, k1, j2)) { + this.growVines(aWorld, i2 - 1, k1, j2, 8); + } + + if (CORE.RANDOM.nextInt(4) == 0 + && aWorld.getBlock(i2 + 1, k1, j2) + .isAir(null, i2 + 1, k1, j2)) { + this.growVines(aWorld, i2 + 1, k1, j2, 2); + } + + if (CORE.RANDOM.nextInt(4) == 0 + && aWorld.getBlock(i2, k1, j2 - 1) + .isAir(null, i2, k1, j2 - 1)) { + this.growVines(aWorld, i2, k1, j2 - 1, 1); + } + + if (CORE.RANDOM.nextInt(4) == 0 + && aWorld.getBlock(i2, k1, j2 + 1) + .isAir(null, i2, k1, j2 + 1)) { + this.growVines(aWorld, i2, k1, j2 + 1, 4); + } + } + } + } + } + Logger.WARNING("Stepping through generateTree [8]"); + + if (CORE.RANDOM.nextInt(5) == 0 && l > 5) { + for (k1 = 0; k1 < 2; ++k1) { + for (i3 = 0; i3 < 4; ++i3) { + if (CORE.RANDOM.nextInt(4 - k1) == 0) { + l1 = CORE.RANDOM.nextInt(3); + this.setBlockAndNotifyAdequately( + aWorld, + aWorldX + Direction.offsetX[Direction.rotateOpposite[i3]], + aWorldY + l - 5 + k1, + aWorldZ + Direction.offsetZ[Direction.rotateOpposite[i3]], + Blocks.cocoa, + l1 << 2 | i3); + } + } + } + } + } + Logger.WARNING("Stepping through generateTree [9]"); + return true; + } else { + Logger.WARNING("Stepping through generateTree [10]"); + return false; + } + } + } else { + Logger.WARNING("Stepping through generateTree [11]"); + return false; + } + } + + /** + * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length + */ + private void growVines(FakeWorld aWorld, int aX, int aY, int aZ, int aMeta) { + int aLoopSize = vinesGrow ? MathUtils.randInt(0, 4) : 0; + for (int i = 0; i < aLoopSize; i++) { + this.setBlockAndNotifyAdequately(aWorld, aX, aY, aZ, Blocks.vine, aMeta); + } + } + + @Override + protected void setBlockAndNotifyAdequately(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + setBlockAndNotifyAdequately(getWorld(), aX, aY, aZ, aBlock, aMeta); + } + + protected void setBlockAndNotifyAdequately(FakeWorld aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + if (aBlock != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)) { + Logger.WARNING("Setting block " + aX + ", " + aY + ", " + aZ + " | " + aBlock.getLocalizedName() + " | " + + aMeta); + aWorld.setBlockAtCoords(aX, aY, aZ, aBlock, aMeta); + // aOutputsFromGenerator.put(ItemUtils.simpleMetaStack(aBlock, aMeta, 1)); + } + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java index 7c3f764794..7012f6d0f7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java @@ -1,10 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.items; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; - -import cofh.core.render.IconRegistry; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.interfaces.IIconContainer; @@ -12,17 +7,13 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.objects.GT_MultiTexture; import gregtech.api.objects.GT_RenderedTexture; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer; -import gtPlusPlus.core.common.CommonProxy; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_ToggleVisual; -import net.minecraft.client.renderer.texture.IIconRegister; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -31,195 +22,195 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import org.apache.commons.lang3.StringUtils; public class MetaCustomCoverItem extends Item { - protected final IIcon[] icons; - private final String mModID; - private final String mTextureSetName; - protected final IIconContainer[] mTextures; - private final short[][] mRGB; - - public MetaCustomCoverItem(String aModId, int aTextureCount, String aTextureSetName, IIconContainer[] aTextures, short[][] aRGB) { - super(); - icons = new IIcon[aTextureCount]; - mModID = aModId; - mTextureSetName = Utils.sanitizeString(aTextureSetName); - mTextures = aTextures; - mRGB = aRGB; - this.setTextureName(CORE.MODID + ":" + "itemPlate"); - this.setHasSubtypes(true); - String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setMaxStackSize(1); - GameRegistry.registerItem(this, unlocalizedName); - registerCover(); - Logger.INFO("[Covers] Generated Custom covers for "+mModID+" using "+aTextureCount+" textures from "+mTextureSetName+"."); - } - - public boolean hide() { - return true; - } - - private final void registerCover() { - //CommonProxy.registerItemRendererGlobal(this, new CustomItemBlockRenderer()); - for (int i=0;i 0 && hide()) { - ItemUtils.hideItemFromNEI(thisStack); - } - GregTech_API.registerCover( - thisStack, - new GT_MultiTexture( - new ITexture[]{ - new GT_RenderedTexture(mTextures[i]) - }), - new GTPP_Cover_ToggleVisual()); - } - } - - /* - * @Override public void registerIcons(IIconRegister reg) { for (int i = 0; i < - * icons.length; i++) { this.icons[i] = mTextures[i].getIcon(); } } - * - * @Override public IIcon getIconFromDamage(int meta) { return this.icons[meta]; - * } - */ - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < icons.length; i++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - return StringUtils.capitalize(mTextureSetName) + " (" + tItem.getItemDamage() + ")"; //super.getItemStackDisplayName(tItem); - } - - private static boolean createNBT(ItemStack rStack) { - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Damage", 0); - tagNBT.setBoolean("AllowConnections", false); - tagMain.setTag("CustomCoverMeta", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static final long getCoverDamage(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("CustomCoverMeta"); - if (aNBT != null) { - return aNBT.getLong("Damage"); - } - } else { - createNBT(aStack); - } - return 0L; - } - - public static final boolean setCoverDamage(final ItemStack aStack, final long aDamage) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("CustomCoverMeta"); - if (aNBT != null) { - aNBT.setLong("Damage", aDamage); - return true; - } - } - return false; - } - - public static final boolean getCoverConnections(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("CustomCoverMeta"); - if (aNBT != null) { - return aNBT.getBoolean("AllowConnections"); - } - } else { - createNBT(aStack); - } - return false; - } - - public static final boolean setCoverConnections(final ItemStack aStack, final boolean aConnections) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("CustomCoverMeta"); - if (aNBT != null) { - aNBT.setBoolean("AllowConnections", aConnections); - return true; - } - } - return false; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null) { - createNBT(stack); - } - double currentDamage = getCoverDamage(stack); - double meta = stack.getItemDamage() == 0 ? 50 : 2500; - double durabilitypercent = currentDamage / meta; - return durabilitypercent; - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (KeyboardUtils.isShiftKeyDown()) { - boolean con = getCoverConnections(stack); - if (con) { - setCoverConnections(stack, false); - } else { - setCoverConnections(stack, true); - } - } - return stack; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - boolean cons = getCoverConnections(stack); - list.add(EnumChatFormatting.GRAY + "Allows Connections: "+cons); - list.add(EnumChatFormatting.GRAY + "Shift Rmb to change state before applying"); - super.addInformation(stack, player, list, bool); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override - public Item setFull3D() { - // TODO Auto-generated method stub - return super.setFull3D(); - } - - @Override - public boolean isFull3D() { - // TODO Auto-generated method stub - return super.isFull3D(); - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.mRGB == null){ - return super.getColorFromItemStack(stack, HEX_OxFFFFFF); - } - int aMeta = stack.getItemDamage(); - return Utils.rgbtoHexValue(mRGB[aMeta][0], mRGB[aMeta][1], mRGB[aMeta][2]); - } - -} \ No newline at end of file + protected final IIcon[] icons; + private final String mModID; + private final String mTextureSetName; + protected final IIconContainer[] mTextures; + private final short[][] mRGB; + + public MetaCustomCoverItem( + String aModId, int aTextureCount, String aTextureSetName, IIconContainer[] aTextures, short[][] aRGB) { + super(); + icons = new IIcon[aTextureCount]; + mModID = aModId; + mTextureSetName = Utils.sanitizeString(aTextureSetName); + mTextures = aTextures; + mRGB = aRGB; + this.setTextureName(CORE.MODID + ":" + "itemPlate"); + this.setHasSubtypes(true); + String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + registerCover(); + Logger.INFO("[Covers] Generated Custom covers for " + mModID + " using " + aTextureCount + " textures from " + + mTextureSetName + "."); + } + + public boolean hide() { + return true; + } + + private final void registerCover() { + // CommonProxy.registerItemRendererGlobal(this, new CustomItemBlockRenderer()); + for (int i = 0; i < icons.length; i++) { + ItemStack thisStack = ItemUtils.simpleMetaStack(this, i, 1); + if (i > 0 && hide()) { + ItemUtils.hideItemFromNEI(thisStack); + } + GregTech_API.registerCover( + thisStack, + new GT_MultiTexture(new ITexture[] {new GT_RenderedTexture(mTextures[i])}), + new GTPP_Cover_ToggleVisual()); + } + } + + /* + * @Override public void registerIcons(IIconRegister reg) { for (int i = 0; i < + * icons.length; i++) { this.icons[i] = mTextures[i].getIcon(); } } + * + * @Override public IIcon getIconFromDamage(int meta) { return this.icons[meta]; + * } + */ + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < icons.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + return StringUtils.capitalize(mTextureSetName) + " (" + tItem.getItemDamage() + + ")"; // super.getItemStackDisplayName(tItem); + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setBoolean("AllowConnections", false); + tagMain.setTag("CustomCoverMeta", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getCoverDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setCoverDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } + return false; + } + + public static final boolean getCoverConnections(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + return aNBT.getBoolean("AllowConnections"); + } + } else { + createNBT(aStack); + } + return false; + } + + public static final boolean setCoverConnections(final ItemStack aStack, final boolean aConnections) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + aNBT.setBoolean("AllowConnections", aConnections); + return true; + } + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double currentDamage = getCoverDamage(stack); + double meta = stack.getItemDamage() == 0 ? 50 : 2500; + double durabilitypercent = currentDamage / meta; + return durabilitypercent; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (KeyboardUtils.isShiftKeyDown()) { + boolean con = getCoverConnections(stack); + if (con) { + setCoverConnections(stack, false); + } else { + setCoverConnections(stack, true); + } + } + return stack; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + boolean cons = getCoverConnections(stack); + list.add(EnumChatFormatting.GRAY + "Allows Connections: " + cons); + list.add(EnumChatFormatting.GRAY + "Shift Rmb to change state before applying"); + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public Item setFull3D() { + // TODO Auto-generated method stub + return super.setFull3D(); + } + + @Override + public boolean isFull3D() { + // TODO Auto-generated method stub + return super.isFull3D(); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.mRGB == null) { + return super.getColorFromItemStack(stack, HEX_OxFFFFFF); + } + int aMeta = stack.getItemDamage(); + return Utils.rgbtoHexValue(mRGB[aMeta][0], mRGB[aMeta][1], mRGB[aMeta][2]); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index ce8b6eaf62..9ff348ddcc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -16,7 +16,6 @@ import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.GT_FoodStat; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GTPP_Recipe; import gregtech.common.covers.GT_Cover_Arm; import gregtech.common.covers.GT_Cover_Conveyor; import gregtech.common.covers.GT_Cover_Pump; @@ -35,419 +34,1201 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_X32; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow; -import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow_Item; import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_ToggleVisual; import net.minecraft.item.EnumAction; -import net.minecraft.item.ItemStack; public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { - public final static MetaGeneratedGregtechItems INSTANCE; - - static { - INSTANCE = new MetaGeneratedGregtechItems(); - } - - public MetaGeneratedGregtechItems() { - super("MU-metaitem.01", new OrePrefixes[]{null}); - } - - public void generateMetaItems() { - int tLastID = 0; - - registerCustomCircuits(); - OldCircuitHandler.addCircuitItems(); - - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - Logger.INFO("Gregtech 5.09 not found, using fallback components. (I like how I have to add compat to something I added first and had stolen.)"); - GregtechItemList.Electric_Pump_LuV.set(this.addItem(tLastID = 0, "Electric Pump (LuV)", "163920 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Electric_Pump_ZPM.set(this.addItem(tLastID = 1, "Electric Pump (ZPM)", "655680 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.ITER, 2L), getTcAspectStack(TC_Aspects.AQUA, 2L)})); - GregtechItemList.Electric_Pump_UV.set(this.addItem(tLastID = 2, "Electric Pump (UV)", "2622720 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.ITER, 4L), getTcAspectStack(TC_Aspects.AQUA, 4L)})); - GregtechItemList.Electric_Pump_MAX.set(this.addItem(tLastID = 3, "Electric Pump (MAX)", "10490880 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L), getTcAspectStack(TC_Aspects.AQUA, 8L)})); - GregTech_API.registerCover(GregtechItemList.Electric_Pump_LuV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(8196)); - GregTech_API.registerCover(GregtechItemList.Electric_Pump_ZPM.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[6][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(32768)); - GregTech_API.registerCover(GregtechItemList.Electric_Pump_UV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[7][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(131072)); - GregTech_API.registerCover(GregtechItemList.Electric_Pump_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(524288)); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Tin), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Tin), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Tin), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.Bronze)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Bronze), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Bronze), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.AnyCopper), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.Steel)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Steel), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Steel), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Gold), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.StainlessSteel)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.StainlessSteel), Character.valueOf('S'), OrePrefixes.screw.get(Materials.StainlessSteel), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Aluminium), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.Titanium)}); - tLastID = 4; - GregtechItemList.Electric_Motor_LuV.set(this.addItem(tLastID = 4, "Electric Motor (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); - GregtechItemList.Electric_Motor_ZPM.set(this.addItem(tLastID = 5, "Electric Motor (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 2L)})); - GregtechItemList.Electric_Motor_UV.set(this.addItem(tLastID = 6, "Electric Motor (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.MOTUS, 4L)})); - GregtechItemList.Electric_Motor_MAX.set(this.addItem(tLastID = 7, "Electric Motor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.IronMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.AnyIron), Character.valueOf('W'), OrePrefixes.wireGt01.get(Materials.AnyCopper), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.SteelMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('W'), OrePrefixes.wireGt01.get(Materials.Electrum), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Silver)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.SteelMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('W'), OrePrefixes.wireGt02.get(Materials.Cupronickel), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.NeodymiumMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('W'), OrePrefixes.wireGt02.get(Materials.TungstenSteel), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Nichrome)}); - - tLastID = 8; - GregtechItemList.Conveyor_Module_LuV.set(this.addItem(tLastID = 8, "Conveyor Module (LuV)", "1 Stack every 20 secs (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L)})); - GregtechItemList.Conveyor_Module_ZPM.set(this.addItem(tLastID = 9, "Conveyor Module (ZPM)", "1 Stack every 5 secs (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.ITER, 2L)})); - GregtechItemList.Conveyor_Module_UV.set(this.addItem(tLastID = 10, "Conveyor Module (UV)", "1 Stack every 1 sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.ITER, 4L)})); - GregtechItemList.Conveyor_Module_MAX.set(this.addItem(tLastID = 11, "Conveyor Module (MAX)", "1 Stack every 1/5 sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L)})); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.AnyCopper), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Aluminium), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); - GregTech_API.registerCover(GregtechItemList.Conveyor_Module_LuV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(400)); - GregTech_API.registerCover(GregtechItemList.Conveyor_Module_ZPM.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(100)); - GregTech_API.registerCover(GregtechItemList.Conveyor_Module_UV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[3][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(20)); - GregTech_API.registerCover(GregtechItemList.Conveyor_Module_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(4)); - tLastID = 12; - GregtechItemList.Electric_Piston_LuV.set(this.addItem(tLastID = 12, "Electric Piston (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); - GregtechItemList.Electric_Piston_ZPM.set(this.addItem(tLastID = 13, "Electric Piston (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.MOTUS, 2L)})); - GregtechItemList.Electric_Piston_UV.set(this.addItem(tLastID = 14, "Electric Piston (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 4L)})); - GregtechItemList.Electric_Piston_MAX.set(this.addItem(tLastID = 15, "Electric Piston (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.Steel), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Steel), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.Steel), Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.Aluminium), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.Aluminium), Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.AnyCopper)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.StainlessSteel), Character.valueOf('S'), OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.StainlessSteel), Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.Titanium), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.Titanium), Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Aluminium)}); - tLastID = 16; - GregtechItemList.Robot_Arm_LuV.set(this.addItem(tLastID = 16, "Robot Arm (LuV)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L), Utils.getTcAspectStack("COGNITIO", 1L)})); - GregtechItemList.Robot_Arm_ZPM.set(this.addItem(tLastID = 17, "Robot Arm (ZPM)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.MOTUS, 2L), getTcAspectStack("COGNITIO", 2L)})); - GregtechItemList.Robot_Arm_UV.set(this.addItem(tLastID = 18, "Robot Arm (UV)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 4L), getTcAspectStack("COGNITIO", 4L)})); - GregtechItemList.Robot_Arm_MAX.set(this.addItem(tLastID = 19, "Robot Arm (MAX)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L), getTcAspectStack("COGNITIO", 8L)})); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.Steel), Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('P'), GregtechItemList.Electric_Piston_LuV, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('P'), GregtechItemList.Electric_Piston_ZPM, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Good), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.AnyCopper)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('P'), GregtechItemList.Electric_Piston_UV, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('P'), GregtechItemList.Electric_Piston_MAX, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Aluminium)}); - GregTech_API.registerCover(GregtechItemList.Robot_Arm_LuV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(400)); - GregTech_API.registerCover(GregtechItemList.Robot_Arm_ZPM.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(100)); - GregTech_API.registerCover(GregtechItemList.Robot_Arm_UV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[3][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(20)); - GregTech_API.registerCover(GregtechItemList.Robot_Arm_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(4)); - tLastID = 20; - GregtechItemList.Field_Generator_LuV.set(this.addItem(tLastID = 20, "Field Generator (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.TUTAMEN, 1L)})); - GregtechItemList.Field_Generator_ZPM.set(this.addItem(tLastID = 21, "Field Generator (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.TUTAMEN, 2L)})); - GregtechItemList.Field_Generator_UV.set(this.addItem(tLastID = 22, "Field Generator (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.TUTAMEN, 4L)})); - GregtechItemList.Field_Generator_MAX.set(this.addItem(tLastID = 23, "Field Generator (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.TUTAMEN, 8L)})); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), OrePrefixes.wireGt01.get(Materials.Osmium)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.EnderEye), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), OrePrefixes.wireGt02.get(Materials.Osmium)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.NetherStar), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Osmium)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.NetherStar), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium)}); - tLastID = 24; - GregtechItemList.Emitter_LuV.set(this.addItem(tLastID = 24, "Emitter (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.LUX, 1L)})); - GregtechItemList.Emitter_ZPM.set(this.addItem(tLastID = 25, "Emitter (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.LUX, 2L)})); - GregtechItemList.Emitter_UV.set(this.addItem(tLastID = 26, "Emitter (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.LUX, 4L)})); - GregtechItemList.Emitter_MAX.set(this.addItem(tLastID = 27, "Emitter (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.LUX, 8L)})); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Quartzite), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Brass), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Tin)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.NetherQuartz), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Electrum), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.AnyCopper)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Emerald), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Chrome), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Gold)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Platinum), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Aluminium)}); - tLastID = 28; - GregtechItemList.Sensor_LuV.set(this.addItem(tLastID = 28, "Sensor (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.SENSUS, 1L)})); - GregtechItemList.Sensor_ZPM.set(this.addItem(tLastID = 29, "Sensor (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.SENSUS, 2L)})); - GregtechItemList.Sensor_UV.set(this.addItem(tLastID = 30, "Sensor (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.SENSUS, 4L)})); - GregtechItemList.Sensor_MAX.set(this.addItem(tLastID = 31, "Sensor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.SENSUS, 8L)})); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Quartzite), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Brass), Character.valueOf('P'), OrePrefixes.plate.get(Materials.Steel), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.NetherQuartz), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Electrum), Character.valueOf('P'), OrePrefixes.plate.get(Materials.Aluminium), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Emerald), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Chrome), Character.valueOf('P'), OrePrefixes.plate.get(Materials.StainlessSteel), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced)}); - //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Platinum), Character.valueOf('P'), OrePrefixes.plate.get(Materials.Titanium), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite)}); - - //Handler for ULV Components - registerComponents_ULV(); - - - } - - else { - //Simplify life. - registerComponents_ULV(); - registerComponents_MAX(); - } - - //Extruder Shape - GregtechItemList.Shape_Extruder_WindmillShaft.set(this.addItem(tLastID = 40, "Extruder Shape (Shaft)", "Extruder Shape for making Windmill Shafts")); - - //GTNH Already adds this. - if (!CORE.GTNH) { - GregtechItemList.Shape_Extruder_SmallGear.set(this.addItem(221, "Extruder Shape (Small Gear)", "Extruder Shape for making small gears")); - } - - //Batteries - GregtechItemList.Battery_RE_EV_Sodium.set(this.addItem(tLastID = 50, "Quad Cell Sodium Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L), getTcAspectStack(TC_Aspects.POTENTIA, 2L)})); - this.setElectricStats(32000 + tLastID, 3200000L, GT_Values.V[4], 4L, -3L, true); - - GregtechItemList.Battery_RE_EV_Cadmium.set(this.addItem(tLastID = 52, "Quad Cell Cadmium Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.METALLUM, 1L), getTcAspectStack(TC_Aspects.POTENTIA, 1L)})); - this.setElectricStats(32000 + tLastID, 4800000L, GT_Values.V[4], 4L, -3L, true); - - GregtechItemList.Battery_RE_EV_Lithium.set(this.addItem(tLastID = 54, "Quad Cell Lithium Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 3L), getTcAspectStack(TC_Aspects.METALLUM, 3L), getTcAspectStack(TC_Aspects.POTENTIA, 3L)})); - this.setElectricStats(32000 + tLastID, 6400000L, GT_Values.V[4], 4L, -3L, true); - - /** - * Power Gems - */ - - GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Proton Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 24L), getTcAspectStack(TC_Aspects.POTENTIA, 16L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[6] * 20 * 300 / 4, GT_Values.V[6], 6L, -3L, false); - GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Electron Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.METALLUM, 32L), getTcAspectStack(TC_Aspects.POTENTIA, 32L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[7] * 20 * 300 / 4, GT_Values.V[7], 7L, -3L, false); - GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Quark Entanglement", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 32L), getTcAspectStack(TC_Aspects.METALLUM, 48L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[8] * 20 * 300 / 4, GT_Values.V[8], 8L, -3L, false); - //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_1.get(1), "batteryFutureBasic"); - //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_2.get(1), "batteryFutureGood"); - //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_3.get(1), "batteryFutureAdvanced"); - - - /*GregtechItemList.Battery_RE_EV_Sodium.set(addItem(tLastID = 50, "Quad Cell Acid Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.METALLUM, 1L), getTcAspectStack(TC_Aspects.POTENTIA, 1L)})); + public static final MetaGeneratedGregtechItems INSTANCE; + + static { + INSTANCE = new MetaGeneratedGregtechItems(); + } + + public MetaGeneratedGregtechItems() { + super("MU-metaitem.01", new OrePrefixes[] {null}); + } + + public void generateMetaItems() { + int tLastID = 0; + + registerCustomCircuits(); + OldCircuitHandler.addCircuitItems(); + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + Logger.INFO( + "Gregtech 5.09 not found, using fallback components. (I like how I have to add compat to something I added first and had stolen.)"); + GregtechItemList.Electric_Pump_LuV.set( + this.addItem(tLastID = 0, "Electric Pump (LuV)", "163920 L/sec (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + GregtechItemList.Electric_Pump_ZPM.set( + this.addItem(tLastID = 1, "Electric Pump (ZPM)", "655680 L/sec (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.ITER, 2L), + getTcAspectStack(TC_Aspects.AQUA, 2L) + })); + GregtechItemList.Electric_Pump_UV.set( + this.addItem(tLastID = 2, "Electric Pump (UV)", "2622720 L/sec (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.ITER, 4L), + getTcAspectStack(TC_Aspects.AQUA, 4L) + })); + GregtechItemList.Electric_Pump_MAX.set( + this.addItem(tLastID = 3, "Electric Pump (MAX)", "10490880 L/sec (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.ITER, 8L), + getTcAspectStack(TC_Aspects.AQUA, 8L) + })); + GregTech_API.registerCover( + GregtechItemList.Electric_Pump_LuV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[5][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP) + }), + new GT_Cover_Pump(8196)); + GregTech_API.registerCover( + GregtechItemList.Electric_Pump_ZPM.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[6][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP) + }), + new GT_Cover_Pump(32768)); + GregTech_API.registerCover( + GregtechItemList.Electric_Pump_UV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[7][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP) + }), + new GT_Cover_Pump(131072)); + GregTech_API.registerCover( + GregtechItemList.Electric_Pump_MAX.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[8][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP) + }), + new GT_Cover_Pump(524288)); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_LuV, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), + // Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Tin), Character.valueOf('S'), + // OrePrefixes.screw.get(Materials.Tin), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Tin), + // Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.Bronze)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_ZPM, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), + // Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Bronze), Character.valueOf('S'), + // OrePrefixes.screw.get(Materials.Bronze), Character.valueOf('W'), + // OrePrefixes.cableGt01.get(Materials.AnyCopper), Character.valueOf('P'), + // OrePrefixes.pipeMedium.get(Materials.Steel)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_UV, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), + // Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Steel), Character.valueOf('S'), + // OrePrefixes.screw.get(Materials.Steel), Character.valueOf('W'), + // OrePrefixes.cableGt01.get(Materials.Gold), Character.valueOf('P'), + // OrePrefixes.pipeMedium.get(Materials.StainlessSteel)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_MAX, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), + // Character.valueOf('X'), OrePrefixes.rotor.get(Materials.StainlessSteel), Character.valueOf('S'), + // OrePrefixes.screw.get(Materials.StainlessSteel), Character.valueOf('W'), + // OrePrefixes.cableGt01.get(Materials.Aluminium), Character.valueOf('P'), + // OrePrefixes.pipeMedium.get(Materials.Titanium)}); + tLastID = 4; + GregtechItemList.Electric_Motor_LuV.set(this.addItem(tLastID = 4, "Electric Motor (LuV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.MOTUS, 1L) + })); + GregtechItemList.Electric_Motor_ZPM.set(this.addItem(tLastID = 5, "Electric Motor (ZPM)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.MOTUS, 2L) + })); + GregtechItemList.Electric_Motor_UV.set(this.addItem(tLastID = 6, "Electric Motor (UV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.MOTUS, 4L) + })); + GregtechItemList.Electric_Motor_MAX.set(this.addItem(tLastID = 7, "Electric Motor (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.MOTUS, 8L) + })); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), + // OrePrefixes.stick.get(Materials.IronMagnetic), Character.valueOf('R'), + // OrePrefixes.stick.get(Materials.AnyIron), Character.valueOf('W'), + // OrePrefixes.wireGt01.get(Materials.AnyCopper), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Tin)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), + // OrePrefixes.stick.get(Materials.SteelMagnetic), Character.valueOf('R'), + // OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('W'), + // OrePrefixes.wireGt01.get(Materials.Electrum), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Silver)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), + // OrePrefixes.stick.get(Materials.SteelMagnetic), Character.valueOf('R'), + // OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('W'), + // OrePrefixes.wireGt02.get(Materials.Cupronickel), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Gold)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), + // OrePrefixes.stick.get(Materials.NeodymiumMagnetic), Character.valueOf('R'), + // OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('W'), + // OrePrefixes.wireGt02.get(Materials.TungstenSteel), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Nichrome)}); + + tLastID = 8; + GregtechItemList.Conveyor_Module_LuV.set(this.addItem( + tLastID = 8, "Conveyor Module (LuV)", "1 Stack every 20 secs (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L) + })); + GregtechItemList.Conveyor_Module_ZPM.set( + this.addItem(tLastID = 9, "Conveyor Module (ZPM)", "1 Stack every 5 secs (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.ITER, 2L) + })); + GregtechItemList.Conveyor_Module_UV.set( + this.addItem(tLastID = 10, "Conveyor Module (UV)", "1 Stack every 1 sec (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.ITER, 4L) + })); + GregtechItemList.Conveyor_Module_MAX.set(this.addItem( + tLastID = 11, "Conveyor Module (MAX)", "1 Stack every 1/5 sec (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.ITER, 8L) + })); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_LuV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin), + // Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_ZPM, Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.AnyCopper), Character.valueOf('R'), + // OrePrefixes.plate.get(Materials.Rubber)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_UV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold), + // Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), + // GregtechItemList.Electric_Motor_MAX, Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Aluminium), Character.valueOf('R'), + // OrePrefixes.plate.get(Materials.Rubber)}); + GregTech_API.registerCover( + GregtechItemList.Conveyor_Module_LuV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[1][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR) + }), + new GT_Cover_Conveyor(400)); + GregTech_API.registerCover( + GregtechItemList.Conveyor_Module_ZPM.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[2][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR) + }), + new GT_Cover_Conveyor(100)); + GregTech_API.registerCover( + GregtechItemList.Conveyor_Module_UV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[3][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR) + }), + new GT_Cover_Conveyor(20)); + GregTech_API.registerCover( + GregtechItemList.Conveyor_Module_MAX.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[4][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR) + }), + new GT_Cover_Conveyor(4)); + tLastID = 12; + GregtechItemList.Electric_Piston_LuV.set( + this.addItem(tLastID = 12, "Electric Piston (LuV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.MOTUS, 1L) + })); + GregtechItemList.Electric_Piston_ZPM.set( + this.addItem(tLastID = 13, "Electric Piston (ZPM)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.MOTUS, 2L) + })); + GregtechItemList.Electric_Piston_UV.set( + this.addItem(tLastID = 14, "Electric Piston (UV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.MOTUS, 4L) + })); + GregtechItemList.Electric_Piston_MAX.set( + this.addItem(tLastID = 15, "Electric Piston (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 16L), + getTcAspectStack(TC_Aspects.MOTUS, 8L) + })); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), + // OrePrefixes.plate.get(Materials.Steel), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Steel), + // Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.Steel), Character.valueOf('M'), + // GregtechItemList.Electric_Motor_LuV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), + // OrePrefixes.plate.get(Materials.Aluminium), Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('G'), + // OrePrefixes.gearGtSmall.get(Materials.Aluminium), Character.valueOf('M'), + // GregtechItemList.Electric_Motor_ZPM, Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.AnyCopper)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), + // OrePrefixes.plate.get(Materials.StainlessSteel), Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('G'), + // OrePrefixes.gearGtSmall.get(Materials.StainlessSteel), Character.valueOf('M'), + // GregtechItemList.Electric_Motor_UV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), + // OrePrefixes.plate.get(Materials.Titanium), Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('G'), + // OrePrefixes.gearGtSmall.get(Materials.Titanium), Character.valueOf('M'), + // GregtechItemList.Electric_Motor_MAX, Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Aluminium)}); + tLastID = 16; + GregtechItemList.Robot_Arm_LuV.set(this.addItem( + tLastID = 16, "Robot Arm (LuV)", "Inserts into specific Slots (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.MOTUS, 1L), + Utils.getTcAspectStack("COGNITIO", 1L) + })); + GregtechItemList.Robot_Arm_ZPM.set(this.addItem( + tLastID = 17, "Robot Arm (ZPM)", "Inserts into specific Slots (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.MOTUS, 2L), + getTcAspectStack("COGNITIO", 2L) + })); + GregtechItemList.Robot_Arm_UV.set(this.addItem( + tLastID = 18, "Robot Arm (UV)", "Inserts into specific Slots (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.MOTUS, 4L), + getTcAspectStack("COGNITIO", 4L) + })); + GregtechItemList.Robot_Arm_MAX.set(this.addItem( + tLastID = 19, "Robot Arm (MAX)", "Inserts into specific Slots (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 16L), + getTcAspectStack(TC_Aspects.MOTUS, 8L), + getTcAspectStack("COGNITIO", 8L) + })); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Steel), Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, + // Character.valueOf('P'), GregtechItemList.Electric_Piston_LuV, Character.valueOf('E'), + // OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Tin)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, + // Character.valueOf('P'), GregtechItemList.Electric_Piston_ZPM, Character.valueOf('E'), + // OrePrefixes.circuit.get(Materials.Good), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.AnyCopper)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('M'), + // GregtechItemList.Electric_Motor_UV, Character.valueOf('P'), GregtechItemList.Electric_Piston_UV, + // Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Gold)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, + // Character.valueOf('P'), GregtechItemList.Electric_Piston_MAX, Character.valueOf('E'), + // OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('C'), + // OrePrefixes.cableGt01.get(Materials.Aluminium)}); + GregTech_API.registerCover( + GregtechItemList.Robot_Arm_LuV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[1][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM) + }), + new GT_Cover_Arm(400)); + GregTech_API.registerCover( + GregtechItemList.Robot_Arm_ZPM.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[2][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM) + }), + new GT_Cover_Arm(100)); + GregTech_API.registerCover( + GregtechItemList.Robot_Arm_UV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[3][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM) + }), + new GT_Cover_Arm(20)); + GregTech_API.registerCover( + GregtechItemList.Robot_Arm_MAX.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[4][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM) + }), + new GT_Cover_Arm(4)); + tLastID = 20; + GregtechItemList.Field_Generator_LuV.set( + this.addItem(tLastID = 20, "Field Generator (LuV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.TUTAMEN, 1L) + })); + GregtechItemList.Field_Generator_ZPM.set( + this.addItem(tLastID = 21, "Field Generator (ZPM)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.TUTAMEN, 2L) + })); + GregtechItemList.Field_Generator_UV.set( + this.addItem(tLastID = 22, "Field Generator (UV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.TUTAMEN, 4L) + })); + GregtechItemList.Field_Generator_MAX.set( + this.addItem(tLastID = 23, "Field Generator (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 16L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.TUTAMEN, 8L) + })); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), + // OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), + // OrePrefixes.wireGt01.get(Materials.Osmium)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), + // OrePrefixes.gem.get(Materials.EnderEye), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good), + // Character.valueOf('W'), OrePrefixes.wireGt02.get(Materials.Osmium)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), + // OrePrefixes.gem.get(Materials.NetherStar), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), + // OrePrefixes.wireGt04.get(Materials.Osmium)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), + // OrePrefixes.gem.get(Materials.NetherStar), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), + // OrePrefixes.wireGt08.get(Materials.Osmium)}); + tLastID = 24; + GregtechItemList.Emitter_LuV.set(this.addItem(tLastID = 24, "Emitter (LuV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.LUX, 1L) + })); + GregtechItemList.Emitter_ZPM.set(this.addItem(tLastID = 25, "Emitter (ZPM)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.LUX, 2L) + })); + GregtechItemList.Emitter_UV.set(this.addItem(tLastID = 26, "Emitter (UV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.LUX, 4L) + })); + GregtechItemList.Emitter_MAX.set(this.addItem(tLastID = 27, "Emitter (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.LUX, 8L) + })); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.Quartzite), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Brass), + // Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), + // OrePrefixes.cableGt01.get(Materials.Tin)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.NetherQuartz), Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Electrum), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), + // OrePrefixes.cableGt01.get(Materials.AnyCopper)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.Emerald), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Chrome), + // Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), + // OrePrefixes.cableGt01.get(Materials.Gold)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Platinum), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), + // OrePrefixes.cableGt01.get(Materials.Aluminium)}); + tLastID = 28; + GregtechItemList.Sensor_LuV.set(this.addItem(tLastID = 28, "Sensor (LuV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.SENSUS, 1L) + })); + GregtechItemList.Sensor_ZPM.set(this.addItem(tLastID = 29, "Sensor (ZPM)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.SENSUS, 2L) + })); + GregtechItemList.Sensor_UV.set(this.addItem(tLastID = 30, "Sensor (UV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 4L), + getTcAspectStack(TC_Aspects.MACHINA, 4L), + getTcAspectStack(TC_Aspects.SENSUS, 4L) + })); + GregtechItemList.Sensor_MAX.set(this.addItem(tLastID = 31, "Sensor (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.SENSUS, 8L) + })); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_LuV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.Quartzite), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Brass), + // Character.valueOf('P'), OrePrefixes.plate.get(Materials.Steel), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Basic)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_ZPM.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.NetherQuartz), Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Electrum), Character.valueOf('P'), + // OrePrefixes.plate.get(Materials.Aluminium), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Good)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_UV.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.Emerald), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Chrome), + // Character.valueOf('P'), OrePrefixes.plate.get(Materials.StainlessSteel), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Advanced)}); + // GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_MAX.get(1L), + // //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | + // //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), + // OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('S'), + // OrePrefixes.stick.get(Materials.Platinum), Character.valueOf('P'), + // OrePrefixes.plate.get(Materials.Titanium), Character.valueOf('C'), + // OrePrefixes.circuit.get(Materials.Elite)}); + + // Handler for ULV Components + registerComponents_ULV(); + + } else { + // Simplify life. + registerComponents_ULV(); + registerComponents_MAX(); + } + + // Extruder Shape + GregtechItemList.Shape_Extruder_WindmillShaft.set( + this.addItem(tLastID = 40, "Extruder Shape (Shaft)", "Extruder Shape for making Windmill Shafts")); + + // GTNH Already adds this. + if (!CORE.GTNH) { + GregtechItemList.Shape_Extruder_SmallGear.set( + this.addItem(221, "Extruder Shape (Small Gear)", "Extruder Shape for making small gears")); + } + + // Batteries + GregtechItemList.Battery_RE_EV_Sodium.set( + this.addItem(tLastID = 50, "Quad Cell Sodium Battery", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.METALLUM, 2L), + getTcAspectStack(TC_Aspects.POTENTIA, 2L) + })); + this.setElectricStats(32000 + tLastID, 3200000L, GT_Values.V[4], 4L, -3L, true); + + GregtechItemList.Battery_RE_EV_Cadmium.set( + this.addItem(tLastID = 52, "Quad Cell Cadmium Battery", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.METALLUM, 1L), + getTcAspectStack(TC_Aspects.POTENTIA, 1L) + })); + this.setElectricStats(32000 + tLastID, 4800000L, GT_Values.V[4], 4L, -3L, true); + + GregtechItemList.Battery_RE_EV_Lithium.set( + this.addItem(tLastID = 54, "Quad Cell Lithium Battery", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 3L), + getTcAspectStack(TC_Aspects.METALLUM, 3L), + getTcAspectStack(TC_Aspects.POTENTIA, 3L) + })); + this.setElectricStats(32000 + tLastID, 6400000L, GT_Values.V[4], 4L, -3L, true); + + /** + * Power Gems + */ + GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Proton Cell", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.METALLUM, 24L), + getTcAspectStack(TC_Aspects.POTENTIA, 16L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[6] * 20 * 300 / 4, GT_Values.V[6], 6L, -3L, false); + GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Electron Cell", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 16L), + getTcAspectStack(TC_Aspects.METALLUM, 32L), + getTcAspectStack(TC_Aspects.POTENTIA, 32L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[7] * 20 * 300 / 4, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Quark Entanglement", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 32L), + getTcAspectStack(TC_Aspects.METALLUM, 48L), + getTcAspectStack(TC_Aspects.POTENTIA, 64L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[8] * 20 * 300 / 4, GT_Values.V[8], 8L, -3L, false); + // ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_1.get(1), "batteryFutureBasic"); + // ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_2.get(1), "batteryFutureGood"); + // ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_3.get(1), "batteryFutureAdvanced"); + + /*GregtechItemList.Battery_RE_EV_Sodium.set(addItem(tLastID = 50, "Quad Cell Acid Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.METALLUM, 1L), getTcAspectStack(TC_Aspects.POTENTIA, 1L)})); setElectricStats(32000 + tLastID, 5000000L, GT_Values.V[2], 4L, -3L, true); GregtechItemList.Battery_RE_EV_Sodium.set(addItem(tLastID = 50, "Quad Cell Mercury Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.METALLUM, 1L), getTcAspectStack(TC_Aspects.POTENTIA, 1L)})); setElectricStats(32000 + tLastID, 5000000L, GT_Values.V[2], 4L, -3L, true);*/ - //RTG Pellet - GregtechItemList.Pellet_RTG_PU238.set(this.addItem(41, StringUtils.superscript("238")+"Pu Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); - GregtechItemList.Pellet_RTG_SR90.set(this.addItem(42, StringUtils.superscript("90")+"Sr Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); - GregtechItemList.Pellet_RTG_PO210.set(this.addItem(43, StringUtils.superscript("210")+"Po Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); - GregtechItemList.Pellet_RTG_AM241.set(this.addItem(44, StringUtils.superscript("241")+"Am Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); - - CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PU238.get(1), MathUtils.roundToClosestInt(87.7f), 64); - CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_SR90.get(1), MathUtils.roundToClosestInt(28.8f), 32); - CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PO210.get(1), 1, 512); - CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_AM241.get(1), MathUtils.roundToClosestInt(432/2), 16); - CORE.RA.addFuelForRTG(GT_ModHandler.getIC2Item("RTGPellets", 1), MathUtils.roundToClosestInt(2.6f), 8); - - //Computer Cube - GregtechItemList.Gregtech_Computer_Cube.set(this.addItem(tLastID = 55, "Gregtech Computer Cube", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[6]* 10 * 60 * 20, GT_Values.V[5], 5L, -3L, true); - - //FOOOOOOOOOOOOOOD - GregtechItemList.Food_Baked_Raisin_Bread.set(this.addItem(tLastID = 60, "Raisin Bread", "Extra Raisins, Just for ImQ009", new Object[]{new GT_FoodStat(5, 0.5F, EnumAction.eat, null, false, true, false, new int[0]), getTcAspectStack(TC_Aspects.CORPUS, 1L), getTcAspectStack(TC_Aspects.FAMES, 1L), getTcAspectStack(TC_Aspects.IGNIS, 1L)})); - - if (!CORE.GTNH) { - GregtechItemList.Fluid_Cell_144L.set(this.addItem(tLastID = 61, "144L Invar Fluid Cell", "Holds exactly one dust worth of liquid.", new Object[]{new ItemData(Materials.Invar, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - this.setFluidContainerStats(32000 + tLastID, 144L, 64L); - - GregtechItemList.Fluid_Cell_36L.set(this.addItem(tLastID = 62, "36L Brass Fluid Cell", "Holds exactly one small dust worth of liquid.", new Object[]{new ItemData(Materials.Brass, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - this.setFluidContainerStats(32000 + tLastID, 36L, 64L); - - GregtechItemList.Fluid_Cell_16L.set(this.addItem(tLastID = 63, "16L Bronze Fluid Cell", "Holds exactly one tiny dust / nugget worth of liquid.", new Object[]{new ItemData(Materials.Bronze, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - this.setFluidContainerStats(32000 + tLastID, 16L, 64L); - - GregtechItemList.Fluid_Cell_1L.set(this.addItem(tLastID = 64, "1L Wrought Iron Fluid Cell", "Holds exactly one litre worth of liquid.", new Object[]{new ItemData(Materials.WroughtIron, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - this.setFluidContainerStats(32000 + tLastID, 1L, 64L); - } - - - - GregtechItemList.Cover_Overflow_ULV.set(this.addItem(71, "Overflow Valve (ULV)", "Maximum void amount: 8000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_LV.set(this.addItem(72, "Overflow Valve (LV)", "Maximum void amount: 64000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_MV.set(this.addItem(73, "Overflow Valve (MV)", "Maximum void amount: 512000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_HV.set(this.addItem(74, "Overflow Valve (HV)", "Maximum void amount: 4096000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_EV.set(this.addItem(75, "Overflow Valve (EV)", "Maximum void amount: 32768000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_IV.set(this.addItem(76, "Overflow Valve (IV)", "Maximum void amount: 262144000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(8)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_LV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(64)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_MV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(512)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_HV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(4096)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_EV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(32768)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_IV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(262144)); - - //Fusion Reactor MK4 Singularity - GregtechItemList.Compressed_Fusion_Reactor.set(this.addItem(100, "Hypervisor Matrix (Fusion)", "A memory unit containing an RI (Restricted Intelligence)")); - - - //NanoTubes - GregtechItemList.NanoTube_Base_Substrate.set(this.addItem(101, "Silicon Base Substrate", "Used in the production of Carbon Nanotubes")); - GregtechItemList.NanoTube_Finished.set(this.addItem(102, "Carbon Nanotubes", "Multi-walled Zigzag nanotubes, possibly Carbon's final form")); - GregtechItemList.Carbyne_Tube_Finished.set(this.addItem(103, "Linear Acetylenic Carbon (LAC/Carbyne)", "LAC chains grown inside Multi-walled Carbon Nanotubes, highly stable")); - GregtechItemList.Carbyne_Sheet_Finished.set(this.addItem(104, "Carbyne Composite Panel", "Nanotubes which contain LAC, arranged side by side and compressed further")); - GregtechItemList.Laser_Lens_Special.set(this.addItem(105, "Quantum Anomaly", "Probably should shoot it with lasers")); - - GregtechItemList.Battery_Casing_Gem_1.set(this.addItem(106, "Containment Unit I", "Used in crafting")); - GregtechItemList.Battery_Casing_Gem_2.set(this.addItem(107, "Containment Unit II", "Used in crafting")); - GregtechItemList.Battery_Casing_Gem_3.set(this.addItem(108, "Advanced Containment Unit", "Used in crafting")); - GregtechItemList.Battery_Casing_Gem_4.set(this.addItem(109, "Exotic Containment Unit", "Used in crafting")); - - GregtechItemList.Battery_Gem_4.set(this.addItem(tLastID = 110, "Graviton Anomaly", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 64L), getTcAspectStack(TC_Aspects.METALLUM, 64L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); - this.setElectricStats(32000 + tLastID, (64000000000L*16), GT_Values.V[9], 9L, -3L, false); - - - - /* - * Bombs - */ - GregtechItemList.Bomb_Cast.set(this.addItem(111, "Bomb Cast", "Used in the production of Bombs")); - GregtechItemList.Bomb_Cast_Molten.set(this.addItem(112, "Bomb Cast (Hot)", "Consider cooling this off")); - GregtechItemList.Bomb_Cast_Set.set(this.addItem(113, "Bomb Cast (Set)", "Break it open for the goodies inside!")); - GregtechItemList.Bomb_Cast_Broken.set(this.addItem(114, "Bomb Cast (Broken)", "This is probably just junk")); - GregtechItemList.Bomb_Cast_Mold.set(this.addItem(115, "Mold (Bomb Cast)", "Used in the production of Bombs")); - - /* - * High Tier 'Saws' for the tree Farm - */ - GregtechItemList.Farm_Processor_EV.set(this.addItem(tLastID = 120, "Farm Processor [EV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[5]* 10 * 60 * 20, GT_Values.V[4], 4L, -3L, false); - GregtechItemList.Farm_Processor_IV.set(this.addItem(tLastID = 122, "Farm Processor [IV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[6]* 10 * 60 * 20, GT_Values.V[5], 5L, -3L, false); - GregtechItemList.Farm_Processor_LuV.set(this.addItem(tLastID = 124, "Farm Processor [LuV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[7]* 10 * 60 * 20, GT_Values.V[6], 6L, -3L, false); - GregtechItemList.Farm_Processor_ZPM.set(this.addItem(tLastID = 126, "Farm Processor [ZPM]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[8]* 10 * 60 * 20, GT_Values.V[7], 7L, -3L, false); - GregtechItemList.Farm_Processor_UV.set(this.addItem(tLastID = 128, "Farm Processor [UV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); - this.setElectricStats(32000 + tLastID, GT_Values.V[9]* 10 * 60 * 20, GT_Values.V[8], 8L, -3L, false); - - String aTierName; + // RTG Pellet + GregtechItemList.Pellet_RTG_PU238.set( + this.addItem(41, StringUtils.superscript("238") + "Pu Pellet", "", new Object[] { + getTcAspectStack(TC_Aspects.RADIO, 4L), + getTcAspectStack(TC_Aspects.POTENTIA, 2L), + getTcAspectStack(TC_Aspects.METALLUM, 2L) + })); + GregtechItemList.Pellet_RTG_SR90.set( + this.addItem(42, StringUtils.superscript("90") + "Sr Pellet", "", new Object[] { + getTcAspectStack(TC_Aspects.RADIO, 4L), + getTcAspectStack(TC_Aspects.POTENTIA, 2L), + getTcAspectStack(TC_Aspects.METALLUM, 2L) + })); + GregtechItemList.Pellet_RTG_PO210.set( + this.addItem(43, StringUtils.superscript("210") + "Po Pellet", "", new Object[] { + getTcAspectStack(TC_Aspects.RADIO, 4L), + getTcAspectStack(TC_Aspects.POTENTIA, 2L), + getTcAspectStack(TC_Aspects.METALLUM, 2L) + })); + GregtechItemList.Pellet_RTG_AM241.set( + this.addItem(44, StringUtils.superscript("241") + "Am Pellet", "", new Object[] { + getTcAspectStack(TC_Aspects.RADIO, 4L), + getTcAspectStack(TC_Aspects.POTENTIA, 2L), + getTcAspectStack(TC_Aspects.METALLUM, 2L) + })); + + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PU238.get(1), MathUtils.roundToClosestInt(87.7f), 64); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_SR90.get(1), MathUtils.roundToClosestInt(28.8f), 32); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PO210.get(1), 1, 512); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_AM241.get(1), MathUtils.roundToClosestInt(432 / 2), 16); + CORE.RA.addFuelForRTG(GT_ModHandler.getIC2Item("RTGPellets", 1), MathUtils.roundToClosestInt(2.6f), 8); + + // Computer Cube + GregtechItemList.Gregtech_Computer_Cube.set( + this.addItem(tLastID = 55, "Gregtech Computer Cube", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.METALLUM, 8L), + getTcAspectStack(TC_Aspects.POTENTIA, 8L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[6] * 10 * 60 * 20, GT_Values.V[5], 5L, -3L, true); + + // FOOOOOOOOOOOOOOD + GregtechItemList.Food_Baked_Raisin_Bread.set( + this.addItem(tLastID = 60, "Raisin Bread", "Extra Raisins, Just for ImQ009", new Object[] { + new GT_FoodStat(5, 0.5F, EnumAction.eat, null, false, true, false, new int[0]), + getTcAspectStack(TC_Aspects.CORPUS, 1L), + getTcAspectStack(TC_Aspects.FAMES, 1L), + getTcAspectStack(TC_Aspects.IGNIS, 1L) + })); + + if (!CORE.GTNH) { + GregtechItemList.Fluid_Cell_144L.set(this.addItem( + tLastID = 61, "144L Invar Fluid Cell", "Holds exactly one dust worth of liquid.", new Object[] { + new ItemData( + Materials.Invar, + (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), + new MaterialStack[0]), + getTcAspectStack(TC_Aspects.VACUOS, 2L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + this.setFluidContainerStats(32000 + tLastID, 144L, 64L); + + GregtechItemList.Fluid_Cell_36L.set(this.addItem( + tLastID = 62, + "36L Brass Fluid Cell", + "Holds exactly one small dust worth of liquid.", + new Object[] { + new ItemData( + Materials.Brass, + (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), + new MaterialStack[0]), + getTcAspectStack(TC_Aspects.VACUOS, 2L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + this.setFluidContainerStats(32000 + tLastID, 36L, 64L); + + GregtechItemList.Fluid_Cell_16L.set(this.addItem( + tLastID = 63, + "16L Bronze Fluid Cell", + "Holds exactly one tiny dust / nugget worth of liquid.", + new Object[] { + new ItemData( + Materials.Bronze, + (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), + new MaterialStack[0]), + getTcAspectStack(TC_Aspects.VACUOS, 2L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + this.setFluidContainerStats(32000 + tLastID, 16L, 64L); + + GregtechItemList.Fluid_Cell_1L.set(this.addItem( + tLastID = 64, + "1L Wrought Iron Fluid Cell", + "Holds exactly one litre worth of liquid.", + new Object[] { + new ItemData( + Materials.WroughtIron, + (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), + new MaterialStack[0]), + getTcAspectStack(TC_Aspects.VACUOS, 2L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + this.setFluidContainerStats(32000 + tLastID, 1L, 64L); + } + + GregtechItemList.Cover_Overflow_ULV.set( + this.addItem(71, "Overflow Valve (ULV)", "Maximum void amount: 8000", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + GregtechItemList.Cover_Overflow_LV.set( + this.addItem(72, "Overflow Valve (LV)", "Maximum void amount: 64000", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + GregtechItemList.Cover_Overflow_MV.set( + this.addItem(73, "Overflow Valve (MV)", "Maximum void amount: 512000", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + GregtechItemList.Cover_Overflow_HV.set( + this.addItem(74, "Overflow Valve (HV)", "Maximum void amount: 4096000", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + GregtechItemList.Cover_Overflow_EV.set( + this.addItem(75, "Overflow Valve (EV)", "Maximum void amount: 32768000", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + GregtechItemList.Cover_Overflow_IV.set( + this.addItem(76, "Overflow Valve (IV)", "Maximum void amount: 262144000", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + + GregTech_API.registerCover( + GregtechItemList.Cover_Overflow_ULV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[4][0], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve) + }), + new GTPP_Cover_Overflow(8)); + GregTech_API.registerCover( + GregtechItemList.Cover_Overflow_LV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[4][0], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve) + }), + new GTPP_Cover_Overflow(64)); + GregTech_API.registerCover( + GregtechItemList.Cover_Overflow_MV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[5][0], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve) + }), + new GTPP_Cover_Overflow(512)); + GregTech_API.registerCover( + GregtechItemList.Cover_Overflow_HV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[5][0], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve) + }), + new GTPP_Cover_Overflow(4096)); + GregTech_API.registerCover( + GregtechItemList.Cover_Overflow_EV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[8][0], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve) + }), + new GTPP_Cover_Overflow(32768)); + GregTech_API.registerCover( + GregtechItemList.Cover_Overflow_IV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[8][0], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve) + }), + new GTPP_Cover_Overflow(262144)); + + // Fusion Reactor MK4 Singularity + GregtechItemList.Compressed_Fusion_Reactor.set(this.addItem( + 100, "Hypervisor Matrix (Fusion)", "A memory unit containing an RI (Restricted Intelligence)")); + + // NanoTubes + GregtechItemList.NanoTube_Base_Substrate.set( + this.addItem(101, "Silicon Base Substrate", "Used in the production of Carbon Nanotubes")); + GregtechItemList.NanoTube_Finished.set( + this.addItem(102, "Carbon Nanotubes", "Multi-walled Zigzag nanotubes, possibly Carbon's final form")); + GregtechItemList.Carbyne_Tube_Finished.set(this.addItem( + 103, + "Linear Acetylenic Carbon (LAC/Carbyne)", + "LAC chains grown inside Multi-walled Carbon Nanotubes, highly stable")); + GregtechItemList.Carbyne_Sheet_Finished.set(this.addItem( + 104, + "Carbyne Composite Panel", + "Nanotubes which contain LAC, arranged side by side and compressed further")); + GregtechItemList.Laser_Lens_Special.set( + this.addItem(105, "Quantum Anomaly", "Probably should shoot it with lasers")); + + GregtechItemList.Battery_Casing_Gem_1.set(this.addItem(106, "Containment Unit I", "Used in crafting")); + GregtechItemList.Battery_Casing_Gem_2.set(this.addItem(107, "Containment Unit II", "Used in crafting")); + GregtechItemList.Battery_Casing_Gem_3.set(this.addItem(108, "Advanced Containment Unit", "Used in crafting")); + GregtechItemList.Battery_Casing_Gem_4.set(this.addItem(109, "Exotic Containment Unit", "Used in crafting")); + + GregtechItemList.Battery_Gem_4.set(this.addItem(tLastID = 110, "Graviton Anomaly", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 64L), + getTcAspectStack(TC_Aspects.METALLUM, 64L), + getTcAspectStack(TC_Aspects.POTENTIA, 64L) + })); + this.setElectricStats(32000 + tLastID, (64000000000L * 16), GT_Values.V[9], 9L, -3L, false); + + /* + * Bombs + */ + GregtechItemList.Bomb_Cast.set(this.addItem(111, "Bomb Cast", "Used in the production of Bombs")); + GregtechItemList.Bomb_Cast_Molten.set(this.addItem(112, "Bomb Cast (Hot)", "Consider cooling this off")); + GregtechItemList.Bomb_Cast_Set.set( + this.addItem(113, "Bomb Cast (Set)", "Break it open for the goodies inside!")); + GregtechItemList.Bomb_Cast_Broken.set(this.addItem(114, "Bomb Cast (Broken)", "This is probably just junk")); + GregtechItemList.Bomb_Cast_Mold.set(this.addItem(115, "Mold (Bomb Cast)", "Used in the production of Bombs")); + + /* + * High Tier 'Saws' for the tree Farm + */ + GregtechItemList.Farm_Processor_EV.set( + this.addItem(tLastID = 120, "Farm Processor [EV]", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.METALLUM, 8L), + getTcAspectStack(TC_Aspects.POTENTIA, 8L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[5] * 10 * 60 * 20, GT_Values.V[4], 4L, -3L, false); + GregtechItemList.Farm_Processor_IV.set( + this.addItem(tLastID = 122, "Farm Processor [IV]", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.METALLUM, 8L), + getTcAspectStack(TC_Aspects.POTENTIA, 8L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[6] * 10 * 60 * 20, GT_Values.V[5], 5L, -3L, false); + GregtechItemList.Farm_Processor_LuV.set( + this.addItem(tLastID = 124, "Farm Processor [LuV]", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.METALLUM, 8L), + getTcAspectStack(TC_Aspects.POTENTIA, 8L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[7] * 10 * 60 * 20, GT_Values.V[6], 6L, -3L, false); + GregtechItemList.Farm_Processor_ZPM.set( + this.addItem(tLastID = 126, "Farm Processor [ZPM]", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.METALLUM, 8L), + getTcAspectStack(TC_Aspects.POTENTIA, 8L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[8] * 10 * 60 * 20, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Farm_Processor_UV.set( + this.addItem(tLastID = 128, "Farm Processor [UV]", "Reusable", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.METALLUM, 8L), + getTcAspectStack(TC_Aspects.POTENTIA, 8L) + })); + this.setElectricStats(32000 + tLastID, GT_Values.V[9] * 10 * 60 * 20, GT_Values.V[8], 8L, -3L, false); + + String aTierName; int aFirstMachineCasingID = 130; GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { - GregtechItemList.FakeMachineCasingPlate_ULV, - GregtechItemList.FakeMachineCasingPlate_LV, - GregtechItemList.FakeMachineCasingPlate_MV, - GregtechItemList.FakeMachineCasingPlate_HV, - GregtechItemList.FakeMachineCasingPlate_EV, - GregtechItemList.FakeMachineCasingPlate_IV, - GregtechItemList.FakeMachineCasingPlate_LuV, - GregtechItemList.FakeMachineCasingPlate_ZPM, - GregtechItemList.FakeMachineCasingPlate_UV, - GregtechItemList.FakeMachineCasingPlate_MAX, + GregtechItemList.FakeMachineCasingPlate_ULV, + GregtechItemList.FakeMachineCasingPlate_LV, + GregtechItemList.FakeMachineCasingPlate_MV, + GregtechItemList.FakeMachineCasingPlate_HV, + GregtechItemList.FakeMachineCasingPlate_EV, + GregtechItemList.FakeMachineCasingPlate_IV, + GregtechItemList.FakeMachineCasingPlate_LuV, + GregtechItemList.FakeMachineCasingPlate_ZPM, + GregtechItemList.FakeMachineCasingPlate_UV, + GregtechItemList.FakeMachineCasingPlate_MAX, }; - for (int i=0;i<10;i++) { - if (i==10) { + for (int i = 0; i < 10; i++) { + if (i == 10) { break; - } - else { + } else { aTierName = GT_Values.VN[i]; - mMachineCasingCovers[i].set(this.addItem(aFirstMachineCasingID++, aTierName+" Machine Plate Cover", "Deprecated - Shapeless Craft to new version", new Object[]{})); - GregTech_API.registerCover(mMachineCasingCovers[i].get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[i][0]}), new GTPP_Cover_ToggleVisual()); - } + mMachineCasingCovers[i].set(this.addItem( + aFirstMachineCasingID++, + aTierName + " Machine Plate Cover", + "Deprecated - Shapeless Craft to new version", + new Object[] {})); + GregTech_API.registerCover( + mMachineCasingCovers[i].get(1L), + new GT_MultiTexture(new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[i][0]}), + new GTPP_Cover_ToggleVisual()); + } } - GregtechItemList.Laser_Lens_WoodsGlass.set(this.addItem(140, "Wood's Glass Lens", "Allows UV & IF to pass through, blocks visible light spectrums")); - + GregtechItemList.Laser_Lens_WoodsGlass.set(this.addItem( + 140, "Wood's Glass Lens", "Allows UV & IF to pass through, blocks visible light spectrums")); + int aStartID = 141; GregtechItemList[] aTransParts = new GregtechItemList[] { - GregtechItemList.TransmissionComponent_ULV, - GregtechItemList.TransmissionComponent_LV, - GregtechItemList.TransmissionComponent_MV, - GregtechItemList.TransmissionComponent_HV, - GregtechItemList.TransmissionComponent_EV, - GregtechItemList.TransmissionComponent_IV, - GregtechItemList.TransmissionComponent_LuV, - GregtechItemList.TransmissionComponent_ZPM, - GregtechItemList.TransmissionComponent_UV, - GregtechItemList.TransmissionComponent_MAX, + GregtechItemList.TransmissionComponent_ULV, + GregtechItemList.TransmissionComponent_LV, + GregtechItemList.TransmissionComponent_MV, + GregtechItemList.TransmissionComponent_HV, + GregtechItemList.TransmissionComponent_EV, + GregtechItemList.TransmissionComponent_IV, + GregtechItemList.TransmissionComponent_LuV, + GregtechItemList.TransmissionComponent_ZPM, + GregtechItemList.TransmissionComponent_UV, + GregtechItemList.TransmissionComponent_MAX, }; - for (int aIndex=0;aIndex<10;aIndex++){ - aTransParts[aIndex].set(this.addItem(aStartID++, "Transmission Component ("+GT_Values.VN[aIndex]+")", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, aIndex), getTcAspectStack(TC_Aspects.MACHINA, aIndex), getTcAspectStack(TC_Aspects.MAGNETO, aIndex)})); + for (int aIndex = 0; aIndex < 10; aIndex++) { + aTransParts[aIndex].set( + this.addItem(aStartID++, "Transmission Component (" + GT_Values.VN[aIndex] + ")", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, aIndex), + getTcAspectStack(TC_Aspects.MACHINA, aIndex), + getTcAspectStack(TC_Aspects.MAGNETO, aIndex) + })); } - + // Distillus Chip - GregtechItemList.Distillus_Upgrade_Chip.set(this.addItem(151, "Upgrade Chip", "Used to upgrade Distillus to Tier 2")); - - - GregtechItemList.Chip_MultiNerf_NoOutputBonus.set(this.addItem(160, "No-Bonus Chip", "You won't like using this")); - GregtechItemList.Chip_MultiNerf_NoSpeedBonus.set(this.addItem(161, "No-Bonus Chip", "You won't like using this")); - GregtechItemList.Chip_MultiNerf_NoEuBonus.set(this.addItem(162, "No-Bonus Chip", "You won't like using this")); - - - /* - GregtechItemList.Cover_Overflow_Item_ULV.set(this.addItem(165, "Item Overflow Valve (ULV)", "Maximum void amount: 8000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_Item_LV.set(this.addItem(166, "Item Overflow Valve (LV)", "Maximum void amount: 64000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_Item_MV.set(this.addItem(167, "Item Overflow Valve (MV)", "Maximum void amount: 512000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_Item_HV.set(this.addItem(168, "Item Overflow Valve (HV)", "Maximum void amount: 4096000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_Item_EV.set(this.addItem(169, "Item Overflow Valve (EV)", "Maximum void amount: 32768000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Cover_Overflow_Item_IV.set(this.addItem(170, "Item Overflow Valve (IV)", "Maximum void amount: 262144000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(8)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_LV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(64)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_MV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(512)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_HV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(4096)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_EV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(32768)); - GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_IV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(262144)); - */ - } - - private boolean registerComponents_ULV(){ - GregtechItemList.Electric_Pump_ULV.set(this.addItem(32, "Electric Pump (ULV)", "160 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); - GregtechItemList.Electric_Motor_ULV.set(this.addItem(33, "Electric Motor (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); - GregtechItemList.Conveyor_Module_ULV.set(this.addItem(34, "Conveyor Module (ULV)", "1 Stack every 80 secs (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L)})); - GregtechItemList.Electric_Piston_ULV.set(this.addItem(35, "Electric Piston (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); - GregtechItemList.Robot_Arm_ULV.set(this.addItem(36, "Robot Arm (ULV)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L), Utils.getTcAspectStack("COGNITIO", 1L)})); - GregtechItemList.Field_Generator_ULV.set(this.addItem(37, "Field Generator (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.TUTAMEN, 1L)})); - GregtechItemList.Emitter_ULV.set(this.addItem(38, "Emitter (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.LUX, 1L)})); - GregtechItemList.Sensor_ULV.set(this.addItem(39, "Sensor (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.SENSUS, 1L)})); - - GregTech_API.registerCover(GregtechItemList.Electric_Pump_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(8)); - GregTech_API.registerCover(GregtechItemList.Conveyor_Module_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(1600)); - GregTech_API.registerCover(GregtechItemList.Robot_Arm_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(1600)); - - return true; - } - - private boolean registerComponents_MAX(){ - GregtechItemList.Electric_Pump_MAX.set(this.addItem(3, "Electric Pump (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L), getTcAspectStack(TC_Aspects.AQUA, 8L)})); - GregtechItemList.Electric_Motor_MAX.set(this.addItem(7, "Electric Motor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); - GregtechItemList.Conveyor_Module_MAX.set(this.addItem(11, "Conveyor Module (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L)})); - GregtechItemList.Electric_Piston_MAX.set(this.addItem(15, "Electric Piston (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); - GregtechItemList.Robot_Arm_MAX.set(this.addItem(19, "Robot Arm (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L), getTcAspectStack("COGNITIO", 8L)})); - GregtechItemList.Field_Generator_MAX.set(this.addItem(23, "Field Generator (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.TUTAMEN, 8L)})); - GregtechItemList.Emitter_MAX.set(this.addItem(27, "Emitter (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.LUX, 8L)})); - GregtechItemList.Sensor_MAX.set(this.addItem(31, "Sensor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.SENSUS, 8L)})); - - GregTech_API.registerCover(GregtechItemList.Electric_Pump_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(524288)); - GregTech_API.registerCover(GregtechItemList.Conveyor_Module_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(4)); - GregTech_API.registerCover(GregtechItemList.Robot_Arm_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(4)); - - - return true; - } - - public boolean registerOldCircuits(){ - //Enable Old Circuits - Logger.INFO("[Old Feature - Circuits] Enabling Pre-5.09.28 Circuits and Data Storage."); - - GregtechItemList.Old_Circuit_Primitive.set(this.addItem(200, "NAND Chip", "A very simple Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Primitive)})); - GregtechItemList.Old_Circuit_Basic.set(this.addItem(201, "Basic Electronic Circuit", "A basic Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Basic)})); - GregtechItemList.Old_Circuit_Good.set(this.addItem(202, "Good Electronic Circuit", "A good Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Good)})); - GregtechItemList.Old_Circuit_Advanced.set(this.addItem(203, "Advanced Circuit", "An advanced Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Advanced)})); - GregtechItemList.Old_Circuit_Data.set(this.addItem(204, "Data Storage Circuit", "A Data Storage Chip", new Object[]{OrePrefixes.circuit.get(Materials.Data)})); - GregtechItemList.Old_Circuit_Elite.set(this.addItem(205, "Data Control Circuit", "A Processor", new Object[]{OrePrefixes.circuit.get(Materials.Elite)})); - GregtechItemList.Old_Circuit_Master.set(this.addItem(206, "Energy Flow Circuit", "A High Voltage Processor", new Object[]{OrePrefixes.circuit.get(Materials.Master)})); - - GregtechItemList.Old_Tool_DataOrb.set(this.addItem(207, "Data Orb [GT++]", "A High Capacity Data Storage", new Object[]{OrePrefixes.circuit.get(Materials.Ultimate), SubTag.NO_UNIFICATION, new Behaviour_DataOrb()})); - GregtechItemList.Old_Circuit_Ultimate.set(GregtechItemList.Old_Tool_DataOrb.get(1L)); - GT_ModHandler.addShapelessCraftingRecipe(GregtechItemList.Old_Tool_DataOrb.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{GregtechItemList.Old_Tool_DataOrb.get(1L)}); - - GregtechItemList.Old_Tool_DataStick.set(this.addItem(208, "Data Stick [GT++]", "A Low Capacity Data Storage", new Object[]{OrePrefixes.circuit.get(Materials.Data), SubTag.NO_UNIFICATION, new Behaviour_DataStick()})); - GT_ModHandler.addShapelessCraftingRecipe(GregtechItemList.Old_Tool_DataStick.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{GregtechItemList.Old_Tool_DataStick.get(1L)}); - - GregtechItemList.Old_Circuit_Board_Basic.set(this.addItem(210, "Basic Circuit Board", "A basic Board")); - GregtechItemList.Old_Circuit_Board_Advanced.set(this.addItem(211, "Advanced Circuit Board", "An advanced Board")); - GregtechItemList.Old_Circuit_Board_Elite.set(this.addItem(212, "Processor Board", "A Processor Board")); - GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.set(this.addItem(213, "Engraved Crystal Chip", "Needed for Circuits")); - GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.set(this.addItem(214, "Engraved Lapotron Chip", "Needed for Circuits")); - GregtechItemList.Old_Circuit_Parts_Advanced.set(this.addItem(215, "Advanced Circuit Parts", "Advanced Circuit Parts")); - GregtechItemList.Old_Circuit_Parts_Wiring_Basic.set(this.addItem(216, "Etched Medium Voltage Wiring", "Part of Circuit Boards")); - GregtechItemList.Old_Circuit_Parts_Wiring_Advanced.set(this.addItem(217, "Etched High Voltage Wiring", "Part of Circuit Boards")); - GregtechItemList.Old_Circuit_Parts_Wiring_Elite.set(this.addItem(218, "Etched Extreme Voltage Wiring", "Part of Circuit Boards")); - GregtechItemList.Old_Empty_Board_Basic.set(this.addItem(219, "Empty Circuit Board", "A Board Part")); - GregtechItemList.Old_Empty_Board_Elite.set(this.addItem(220, "Empty Processor Board", "A Processor Board Part")); - - return true; - } - - public boolean registerCustomCircuits() { - if (CORE.ConfigSwitches.enableCustomCircuits){ - GregtechItemList.Circuit_IV.set(this.addItem(704, "Symbiotic Circuit (IV)", "A Symbiotic Data Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Symbiotic)})); - GregtechItemList.Circuit_LuV.set(this.addItem(705, "Neutronic Circuit (LuV)", "A Neutron Particle Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Neutronic)})); - GregtechItemList.Circuit_ZPM.set(this.addItem(706, "Quantum Circuit (ZPM)", "A Singlularity Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Quantum)})); - GregtechItemList.Circuit_Board_IV.set(this.addItem(710, "IV Circuit Board", "An IV Voltage Rated Circuit Board")); - GregtechItemList.Circuit_Board_LuV.set(this.addItem(711, "LuV Circuit Board", "An LuV Voltage Rated Circuit Board")); - GregtechItemList.Circuit_Board_ZPM.set(this.addItem(712, "ZPM Processor Board", "A ZPM Voltage Rated Processor Board")); - GregtechItemList.Circuit_Parts_Crystal_Chip_IV.set(this.addItem(713, "(IV) Energized Crystal Chip", "Needed for Circuits")); - GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.set(this.addItem(714, "(LuV) Neutron based Microchip", "Needed for Circuits")); - GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.set(this.addItem(715, "(ZPM) Quantum Chip", "Needed for Circuits")); - GregtechItemList.Circuit_Parts_IV.set(this.addItem(716, "(IV) Energized Circuit Parts", "Circuit Parts")); - GregtechItemList.Circuit_Parts_LuV.set(this.addItem(717, "(LuV) Neutron-based Circuit Parts", "Circuit Parts")); - GregtechItemList.Circuit_Parts_ZPM.set(this.addItem(718, "(ZPM) Quantum Circuit Parts", "Circuit Parts")); - GregtechItemList.Circuit_Parts_Wiring_IV.set(this.addItem(719, "Etched IV Voltage Wiring", "Part of Circuit Boards")); - GregtechItemList.Circuit_Parts_Wiring_LuV.set(this.addItem(720, "Etched LuV Voltage Wiring", "Part of Circuit Boards")); - GregtechItemList.Circuit_Parts_Wiring_ZPM.set(this.addItem(721, "Etched ZPM Voltage Wiring", "Part of Circuit Boards")); - ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_IV.get(1), "circuitSuperconductor"); - ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_LuV.get(1), "circuitInfinite"); - return true; - } - return false; - } + GregtechItemList.Distillus_Upgrade_Chip.set( + this.addItem(151, "Upgrade Chip", "Used to upgrade Distillus to Tier 2")); + + GregtechItemList.Chip_MultiNerf_NoOutputBonus.set( + this.addItem(160, "No-Bonus Chip", "You won't like using this")); + GregtechItemList.Chip_MultiNerf_NoSpeedBonus.set( + this.addItem(161, "No-Bonus Chip", "You won't like using this")); + GregtechItemList.Chip_MultiNerf_NoEuBonus.set(this.addItem(162, "No-Bonus Chip", "You won't like using this")); + + /* + GregtechItemList.Cover_Overflow_Item_ULV.set(this.addItem(165, "Item Overflow Valve (ULV)", "Maximum void amount: 8000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_LV.set(this.addItem(166, "Item Overflow Valve (LV)", "Maximum void amount: 64000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_MV.set(this.addItem(167, "Item Overflow Valve (MV)", "Maximum void amount: 512000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_HV.set(this.addItem(168, "Item Overflow Valve (HV)", "Maximum void amount: 4096000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_EV.set(this.addItem(169, "Item Overflow Valve (EV)", "Maximum void amount: 32768000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_IV.set(this.addItem(170, "Item Overflow Valve (IV)", "Maximum void amount: 262144000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(8)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_LV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(64)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_MV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(512)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_HV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(4096)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_EV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(32768)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_IV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(262144)); + */ + } + + private boolean registerComponents_ULV() { + GregtechItemList.Electric_Pump_ULV.set( + this.addItem(32, "Electric Pump (ULV)", "160 L/sec (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L), + getTcAspectStack(TC_Aspects.AQUA, 1L) + })); + GregtechItemList.Electric_Motor_ULV.set(this.addItem(33, "Electric Motor (ULV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.MOTUS, 1L) + })); + GregtechItemList.Conveyor_Module_ULV.set( + this.addItem(34, "Conveyor Module (ULV)", "1 Stack every 80 secs (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.ITER, 1L) + })); + GregtechItemList.Electric_Piston_ULV.set(this.addItem(35, "Electric Piston (ULV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.MOTUS, 1L) + })); + GregtechItemList.Robot_Arm_ULV.set( + this.addItem(36, "Robot Arm (ULV)", "Inserts into specific Slots (as Cover)", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 2L), + getTcAspectStack(TC_Aspects.MOTUS, 1L), + Utils.getTcAspectStack("COGNITIO", 1L) + })); + GregtechItemList.Field_Generator_ULV.set(this.addItem(37, "Field Generator (ULV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 2L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.TUTAMEN, 1L) + })); + GregtechItemList.Emitter_ULV.set(this.addItem(38, "Emitter (ULV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.LUX, 1L) + })); + GregtechItemList.Sensor_ULV.set(this.addItem(39, "Sensor (ULV)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 1L), + getTcAspectStack(TC_Aspects.MACHINA, 1L), + getTcAspectStack(TC_Aspects.SENSUS, 1L) + })); + + GregTech_API.registerCover( + GregtechItemList.Electric_Pump_ULV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP) + }), + new GT_Cover_Pump(8)); + GregTech_API.registerCover( + GregtechItemList.Conveyor_Module_ULV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[1][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR) + }), + new GT_Cover_Conveyor(1600)); + GregTech_API.registerCover( + GregtechItemList.Robot_Arm_ULV.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM) + }), + new GT_Cover_Arm(1600)); + + return true; + } + + private boolean registerComponents_MAX() { + GregtechItemList.Electric_Pump_MAX.set(this.addItem(3, "Electric Pump (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.ITER, 8L), + getTcAspectStack(TC_Aspects.AQUA, 8L) + })); + GregtechItemList.Electric_Motor_MAX.set(this.addItem(7, "Electric Motor (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.MOTUS, 8L) + })); + GregtechItemList.Conveyor_Module_MAX.set(this.addItem(11, "Conveyor Module (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.ITER, 8L) + })); + GregtechItemList.Electric_Piston_MAX.set(this.addItem(15, "Electric Piston (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 16L), + getTcAspectStack(TC_Aspects.MOTUS, 8L) + })); + GregtechItemList.Robot_Arm_MAX.set(this.addItem(19, "Robot Arm (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 16L), + getTcAspectStack(TC_Aspects.MOTUS, 8L), + getTcAspectStack("COGNITIO", 8L) + })); + GregtechItemList.Field_Generator_MAX.set(this.addItem(23, "Field Generator (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 16L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.TUTAMEN, 8L) + })); + GregtechItemList.Emitter_MAX.set(this.addItem(27, "Emitter (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.LUX, 8L) + })); + GregtechItemList.Sensor_MAX.set(this.addItem(31, "Sensor (MAX)", "", new Object[] { + getTcAspectStack(TC_Aspects.ELECTRUM, 8L), + getTcAspectStack(TC_Aspects.MACHINA, 8L), + getTcAspectStack(TC_Aspects.SENSUS, 8L) + })); + + GregTech_API.registerCover( + GregtechItemList.Electric_Pump_MAX.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP) + }), + new GT_Cover_Pump(524288)); + GregTech_API.registerCover( + GregtechItemList.Conveyor_Module_MAX.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[4][0], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR) + }), + new GT_Cover_Conveyor(4)); + GregTech_API.registerCover( + GregtechItemList.Robot_Arm_MAX.get(1L), + new GT_MultiTexture(new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM) + }), + new GT_Cover_Arm(4)); + + return true; + } + + public boolean registerOldCircuits() { + // Enable Old Circuits + Logger.INFO("[Old Feature - Circuits] Enabling Pre-5.09.28 Circuits and Data Storage."); + + GregtechItemList.Old_Circuit_Primitive.set(this.addItem( + 200, "NAND Chip", "A very simple Circuit", new Object[] {OrePrefixes.circuit.get(Materials.Primitive) + })); + GregtechItemList.Old_Circuit_Basic.set( + this.addItem(201, "Basic Electronic Circuit", "A basic Circuit", new Object[] { + OrePrefixes.circuit.get(Materials.Basic) + })); + GregtechItemList.Old_Circuit_Good.set(this.addItem( + 202, "Good Electronic Circuit", "A good Circuit", new Object[] {OrePrefixes.circuit.get(Materials.Good) + })); + GregtechItemList.Old_Circuit_Advanced.set( + this.addItem(203, "Advanced Circuit", "An advanced Circuit", new Object[] { + OrePrefixes.circuit.get(Materials.Advanced) + })); + GregtechItemList.Old_Circuit_Data.set( + this.addItem(204, "Data Storage Circuit", "A Data Storage Chip", new Object[] { + OrePrefixes.circuit.get(Materials.Data) + })); + GregtechItemList.Old_Circuit_Elite.set(this.addItem( + 205, "Data Control Circuit", "A Processor", new Object[] {OrePrefixes.circuit.get(Materials.Elite)})); + GregtechItemList.Old_Circuit_Master.set( + this.addItem(206, "Energy Flow Circuit", "A High Voltage Processor", new Object[] { + OrePrefixes.circuit.get(Materials.Master) + })); + + GregtechItemList.Old_Tool_DataOrb.set( + this.addItem(207, "Data Orb [GT++]", "A High Capacity Data Storage", new Object[] { + OrePrefixes.circuit.get(Materials.Ultimate), SubTag.NO_UNIFICATION, new Behaviour_DataOrb() + })); + GregtechItemList.Old_Circuit_Ultimate.set(GregtechItemList.Old_Tool_DataOrb.get(1L)); + GT_ModHandler.addShapelessCraftingRecipe( + GregtechItemList.Old_Tool_DataOrb.get(1L), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] {GregtechItemList.Old_Tool_DataOrb.get(1L)}); + + GregtechItemList.Old_Tool_DataStick.set( + this.addItem(208, "Data Stick [GT++]", "A Low Capacity Data Storage", new Object[] { + OrePrefixes.circuit.get(Materials.Data), SubTag.NO_UNIFICATION, new Behaviour_DataStick() + })); + GT_ModHandler.addShapelessCraftingRecipe( + GregtechItemList.Old_Tool_DataStick.get(1L), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] {GregtechItemList.Old_Tool_DataStick.get(1L)}); + + GregtechItemList.Old_Circuit_Board_Basic.set(this.addItem(210, "Basic Circuit Board", "A basic Board")); + GregtechItemList.Old_Circuit_Board_Advanced.set( + this.addItem(211, "Advanced Circuit Board", "An advanced Board")); + GregtechItemList.Old_Circuit_Board_Elite.set(this.addItem(212, "Processor Board", "A Processor Board")); + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.set( + this.addItem(213, "Engraved Crystal Chip", "Needed for Circuits")); + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.set( + this.addItem(214, "Engraved Lapotron Chip", "Needed for Circuits")); + GregtechItemList.Old_Circuit_Parts_Advanced.set( + this.addItem(215, "Advanced Circuit Parts", "Advanced Circuit Parts")); + GregtechItemList.Old_Circuit_Parts_Wiring_Basic.set( + this.addItem(216, "Etched Medium Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Old_Circuit_Parts_Wiring_Advanced.set( + this.addItem(217, "Etched High Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Old_Circuit_Parts_Wiring_Elite.set( + this.addItem(218, "Etched Extreme Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Old_Empty_Board_Basic.set(this.addItem(219, "Empty Circuit Board", "A Board Part")); + GregtechItemList.Old_Empty_Board_Elite.set( + this.addItem(220, "Empty Processor Board", "A Processor Board Part")); + + return true; + } + + public boolean registerCustomCircuits() { + if (CORE.ConfigSwitches.enableCustomCircuits) { + GregtechItemList.Circuit_IV.set( + this.addItem(704, "Symbiotic Circuit (IV)", "A Symbiotic Data Processor", new Object[] { + GregtechOrePrefixes.circuit.get(GT_Materials.Symbiotic) + })); + GregtechItemList.Circuit_LuV.set( + this.addItem(705, "Neutronic Circuit (LuV)", "A Neutron Particle Processor", new Object[] { + GregtechOrePrefixes.circuit.get(GT_Materials.Neutronic) + })); + GregtechItemList.Circuit_ZPM.set( + this.addItem(706, "Quantum Circuit (ZPM)", "A Singlularity Processor", new Object[] { + GregtechOrePrefixes.circuit.get(GT_Materials.Quantum) + })); + GregtechItemList.Circuit_Board_IV.set( + this.addItem(710, "IV Circuit Board", "An IV Voltage Rated Circuit Board")); + GregtechItemList.Circuit_Board_LuV.set( + this.addItem(711, "LuV Circuit Board", "An LuV Voltage Rated Circuit Board")); + GregtechItemList.Circuit_Board_ZPM.set( + this.addItem(712, "ZPM Processor Board", "A ZPM Voltage Rated Processor Board")); + GregtechItemList.Circuit_Parts_Crystal_Chip_IV.set( + this.addItem(713, "(IV) Energized Crystal Chip", "Needed for Circuits")); + GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.set( + this.addItem(714, "(LuV) Neutron based Microchip", "Needed for Circuits")); + GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.set( + this.addItem(715, "(ZPM) Quantum Chip", "Needed for Circuits")); + GregtechItemList.Circuit_Parts_IV.set(this.addItem(716, "(IV) Energized Circuit Parts", "Circuit Parts")); + GregtechItemList.Circuit_Parts_LuV.set( + this.addItem(717, "(LuV) Neutron-based Circuit Parts", "Circuit Parts")); + GregtechItemList.Circuit_Parts_ZPM.set(this.addItem(718, "(ZPM) Quantum Circuit Parts", "Circuit Parts")); + GregtechItemList.Circuit_Parts_Wiring_IV.set( + this.addItem(719, "Etched IV Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Circuit_Parts_Wiring_LuV.set( + this.addItem(720, "Etched LuV Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Circuit_Parts_Wiring_ZPM.set( + this.addItem(721, "Etched ZPM Voltage Wiring", "Part of Circuit Boards")); + ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_IV.get(1), "circuitSuperconductor"); + ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_LuV.get(1), "circuitInfinite"); + return true; + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java index 14100d1599..0e937a9485 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.items; -import java.lang.reflect.Field; - import gregtech.api.GregTech_API; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.ToolDictNames; @@ -15,87 +13,112 @@ import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_Choocher; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_ElectricButcherKnife; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_ElectricLighter; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_ElectricSnips; +import java.lang.reflect.Field; public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { - public static final short ELECTRIC_LIGHTER = 7534; - public static final short ELECTRIC_BUTCHER_KNIFE = 7634; - public static final short SKOOKUM_CHOOCHER = 7734; - public static final short ANGLE_GRINDER = 7834; - public static final short ELECTRIC_SNIPS = 7934; - public static GT_MetaGenerated_Tool INSTANCE; - - static { - INSTANCE = new MetaGeneratedGregtechTools(); - } - - public static GT_MetaGenerated_Tool getInstance() { - return INSTANCE; - } - + public static final short ELECTRIC_LIGHTER = 7534; + public static final short ELECTRIC_BUTCHER_KNIFE = 7634; + public static final short SKOOKUM_CHOOCHER = 7734; + public static final short ANGLE_GRINDER = 7834; + public static final short ELECTRIC_SNIPS = 7934; + public static GT_MetaGenerated_Tool INSTANCE; + + static { + INSTANCE = new MetaGeneratedGregtechTools(); + } - private MetaGeneratedGregtechTools() { - super("plusplus.metatool.01"); - // Skookum Choocher - GregTech_API.registerTool(this.addTool(SKOOKUM_CHOOCHER, "Skookum Choocher", - "Can Really Chooch. Does a Skookum job at Hammering and Wrenching stuff.", new TOOL_Gregtech_Choocher(), - new Object[] { GregtechToolDictNames.craftingToolSkookumChoocher, ToolDictNames.craftingToolHardHammer, - ToolDictNames.craftingToolWrench, new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }), - GregTech_API.sWrenchList); + public static GT_MetaGenerated_Tool getInstance() { + return INSTANCE; + } - // Electric File - this.addTool(ANGLE_GRINDER, "Angle Grinder", "Hand-held electric filing device", - new TOOL_Gregtech_AngleGrinder(), - new Object[] { GregtechToolDictNames.craftingToolAngleGrinder, ToolDictNames.craftingToolFile, - new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); + private MetaGeneratedGregtechTools() { + super("plusplus.metatool.01"); + // Skookum Choocher + GregTech_API.registerTool( + this.addTool( + SKOOKUM_CHOOCHER, + "Skookum Choocher", + "Can Really Chooch. Does a Skookum job at Hammering and Wrenching stuff.", + new TOOL_Gregtech_Choocher(), + new Object[] { + GregtechToolDictNames.craftingToolSkookumChoocher, + ToolDictNames.craftingToolHardHammer, + ToolDictNames.craftingToolWrench, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) + }), + GregTech_API.sWrenchList); - GT_HashSet aWireCutterList = new GT_HashSet(); - //Does not exist prior to 5.09.32, use an empty field if we can't find the existing one. - if (ReflectionUtils.doesFieldExist(GregTech_API.class, "sWireCutterList")) { - Field sWireCutterList = ReflectionUtils.getField(GregTech_API.class, "sWireCutterList"); - try { - if (sWireCutterList != null) { - Object val = sWireCutterList.get(null); - if (val != null && val instanceof GT_HashSet) { - aWireCutterList = (GT_HashSet) val; - } - } - - } - catch (IllegalArgumentException | IllegalAccessException e) { - // Not found, so it's GT 5.09.31 or earlier. - } - } + // Electric File + this.addTool( + ANGLE_GRINDER, + "Angle Grinder", + "Hand-held electric filing device", + new TOOL_Gregtech_AngleGrinder(), + new Object[] { + GregtechToolDictNames.craftingToolAngleGrinder, + ToolDictNames.craftingToolFile, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) + }); - // Electric Wire Cutter - GregTech_API.registerTool( - this.addTool(ELECTRIC_SNIPS, "Automatic Snips", "Hand-held electric wire cutter", - new TOOL_Gregtech_ElectricSnips(), - new Object[] { GregtechToolDictNames.craftingToolElectricSnips, ToolDictNames.craftingToolWireCutter, - new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 4L), - new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 4L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L) }), aWireCutterList); + GT_HashSet aWireCutterList = new GT_HashSet(); + // Does not exist prior to 5.09.32, use an empty field if we can't find the existing one. + if (ReflectionUtils.doesFieldExist(GregTech_API.class, "sWireCutterList")) { + Field sWireCutterList = ReflectionUtils.getField(GregTech_API.class, "sWireCutterList"); + try { + if (sWireCutterList != null) { + Object val = sWireCutterList.get(null); + if (val != null && val instanceof GT_HashSet) { + aWireCutterList = (GT_HashSet) val; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + // Not found, so it's GT 5.09.31 or earlier. + } + } - // Electric Lighter - this.addTool(ELECTRIC_LIGHTER, "Pyromatic 9k", "Electric Fire!", - new TOOL_Gregtech_ElectricLighter(), - new Object[] { GregtechToolDictNames.craftingToolElectricLighter, - new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); + // Electric Wire Cutter + GregTech_API.registerTool( + this.addTool( + ELECTRIC_SNIPS, + "Automatic Snips", + "Hand-held electric wire cutter", + new TOOL_Gregtech_ElectricSnips(), + new Object[] { + GregtechToolDictNames.craftingToolElectricSnips, + ToolDictNames.craftingToolWireCutter, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 4L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 4L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L) + }), + aWireCutterList); - // Electric Butcher Knife - this.addTool(ELECTRIC_BUTCHER_KNIFE, "Meat-o-matic", "Electric butcher knife", - new TOOL_Gregtech_ElectricButcherKnife(), - new Object[] { GregtechToolDictNames.craftingToolElectricButcherKnife, ToolDictNames.craftingToolKnife, - new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 1L), - new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); - } + // Electric Lighter + this.addTool( + ELECTRIC_LIGHTER, "Pyromatic 9k", "Electric Fire!", new TOOL_Gregtech_ElectricLighter(), new Object[] { + GregtechToolDictNames.craftingToolElectricLighter, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) + }); + // Electric Butcher Knife + this.addTool( + ELECTRIC_BUTCHER_KNIFE, + "Meat-o-matic", + "Electric butcher knife", + new TOOL_Gregtech_ElectricButcherKnife(), + new Object[] { + GregtechToolDictNames.craftingToolElectricButcherKnife, + ToolDictNames.craftingToolKnife, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 1L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) + }); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java index f82e0e5cb0..ef72c5edd4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java @@ -1,11 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.items.behaviours; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_LanguageManager; import gregtech.common.items.behaviors.Behaviour_None; @@ -13,76 +7,89 @@ import gregtech.common.items.behaviors.Behaviour_Wrench; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class Behaviour_Choocher extends Behaviour_None { + private boolean isWrench = true; + private final Behaviour_Wrench wrench = new Behaviour_Wrench(150); + private final Behaviour_Prospecting_Ex prospecting = new Behaviour_Prospecting_Ex(10, 1250); + private final String mTooltip1 = + GT_LanguageManager.addStringLocalization("gt.behaviour.choochering1", "Current tool mode: "); + private final String mTooltip2 = GT_LanguageManager.addStringLocalization( + "gt.behaviour.choochering2", "Change tool mode using Shift+Rightclick."); + private final String mTooltipH = GT_LanguageManager.addStringLocalization( + "gt.behaviour.prospectingEx", "Usable for Prospecting large areas."); + private final String mTooltipW = + GT_LanguageManager.addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick."); -public class Behaviour_Choocher -extends Behaviour_None { - private boolean isWrench = true; - private final Behaviour_Wrench wrench = new Behaviour_Wrench(150); - private final Behaviour_Prospecting_Ex prospecting = new Behaviour_Prospecting_Ex(10, 1250); - private final String mTooltip1 = GT_LanguageManager.addStringLocalization("gt.behaviour.choochering1", "Current tool mode: "); - private final String mTooltip2 = GT_LanguageManager.addStringLocalization("gt.behaviour.choochering2", "Change tool mode using Shift+Rightclick."); - private final String mTooltipH = GT_LanguageManager.addStringLocalization("gt.behaviour.prospectingEx", "Usable for Prospecting large areas."); - private final String mTooltipW = GT_LanguageManager.addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick."); + public Behaviour_Choocher() {} - public Behaviour_Choocher() { + @Override + public boolean onItemUseFirst( + final GT_MetaBase_Item aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + if (aWorld.isRemote) { + return false; + } - } + boolean inWrenchMode; + if (NBTUtils.hasKey(aStack, "aMode")) { + inWrenchMode = NBTUtils.getBoolean(aStack, "aMode"); + } else { + aStack.getTagCompound().setBoolean("aMode", true); + inWrenchMode = true; + } - @Override - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - - boolean inWrenchMode; - if (NBTUtils.hasKey(aStack, "aMode")) { - inWrenchMode = NBTUtils.getBoolean(aStack, "aMode"); - } - else { - aStack.getTagCompound().setBoolean("aMode", true); - inWrenchMode = true; - } - - if (aPlayer.isSneaking()){ - boolean aModeNew = Utils.invertBoolean(inWrenchMode); - aStack.getTagCompound().setBoolean("aMode", aModeNew); - PlayerUtils.messagePlayer(aPlayer, "Mode: "+(aModeNew ? "Wrench" : "Hammer")); - return true; - } - else { - if (inWrenchMode){ - return this.wrench.onItemUseFirst(aItem, aStack, aPlayer, aWorld, aSide, aSide, aSide, aSide, hitZ, hitZ, hitZ); - } - else { - return this.prospecting.onItemUseFirst(aItem, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); - } - } - } + if (aPlayer.isSneaking()) { + boolean aModeNew = Utils.invertBoolean(inWrenchMode); + aStack.getTagCompound().setBoolean("aMode", aModeNew); + PlayerUtils.messagePlayer(aPlayer, "Mode: " + (aModeNew ? "Wrench" : "Hammer")); + return true; + } else { + if (inWrenchMode) { + return this.wrench.onItemUseFirst( + aItem, aStack, aPlayer, aWorld, aSide, aSide, aSide, aSide, hitZ, hitZ, hitZ); + } else { + return this.prospecting.onItemUseFirst( + aItem, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + } + } + } - @Override - public List getAdditionalToolTips(final GT_MetaBase_Item aItem, final List aList, final ItemStack aStack) { + @Override + public List getAdditionalToolTips( + final GT_MetaBase_Item aItem, final List aList, final ItemStack aStack) { - boolean inWrenchMode; - if (NBTUtils.hasKey(aStack, "aMode")) { - inWrenchMode = NBTUtils.getBoolean(aStack, "aMode"); - } - else { - NBTUtils.setBoolean(aStack, "aMode", true); - aStack.getTagCompound().setBoolean("aMode", true); - inWrenchMode = true; - } - + boolean inWrenchMode; + if (NBTUtils.hasKey(aStack, "aMode")) { + inWrenchMode = NBTUtils.getBoolean(aStack, "aMode"); + } else { + NBTUtils.setBoolean(aStack, "aMode", true); + aStack.getTagCompound().setBoolean("aMode", true); + inWrenchMode = true; + } - if (inWrenchMode){ - aList.add(this.mTooltip1+"Wrench"); - aList.add(this.mTooltipW); - } - else { - aList.add(this.mTooltip1+"Prospecting"); - aList.add(this.mTooltipH); - } - aList.add(this.mTooltip2); + if (inWrenchMode) { + aList.add(this.mTooltip1 + "Wrench"); + aList.add(this.mTooltipW); + } else { + aList.add(this.mTooltip1 + "Prospecting"); + aList.add(this.mTooltipH); + } + aList.add(this.mTooltip2); - return aList; - } + return aList; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java index 422a29c34e..922c09c1eb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.items.behaviours; -import java.util.List; - import codechicken.lib.math.MathHelper; import gregtech.api.GregTech_API; import gregtech.api.items.GT_MetaBase_Item; @@ -17,6 +15,7 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import ic2.api.item.IElectricItemManager; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.player.EntityPlayer; @@ -28,193 +27,214 @@ import net.minecraftforge.common.util.ForgeDirection; public class Behaviour_Electric_Lighter extends Behaviour_None { - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.tooltip", - "Can light things on Fire"); - private final String mTooltipUses = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.uses", - "Remaining Uses:"); - private final String mTooltipUnstackable = GT_LanguageManager.addStringLocalization("gt.behaviour.unstackable", - "Not usable when stacked!"); - - public Behaviour_Electric_Lighter() { - - } + private final String mTooltip = + GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.tooltip", "Can light things on Fire"); + private final String mTooltipUses = + GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.uses", "Remaining Uses:"); + private final String mTooltipUnstackable = + GT_LanguageManager.addStringLocalization("gt.behaviour.unstackable", "Not usable when stacked!"); - public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { - if (!aPlayer.worldObj.isRemote && aStack != null && aStack.stackSize == 1) { - boolean rOutput = false; - if (aEntity instanceof EntityCreeper) { - if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { - GT_Utility.sendSoundToPlayers(aPlayer.worldObj, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, - MathHelper.floor_double(aEntity.posX), MathHelper.floor_double(aEntity.posY), - MathHelper.floor_double(aEntity.posZ)); - ((EntityCreeper) aEntity).func_146079_cb(); - rOutput = true; - } - } - return rOutput; - } else { - return false; - } - } + public Behaviour_Electric_Lighter() {} - public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { - if (aPlayer.isSneaking()) { - Logger.INFO("Changing Mode"); - boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); - Logger.INFO("Is currently in Fireball mode? "+aCurrentMode); - boolean aNewMode = Utils.invertBoolean(aCurrentMode); - Logger.INFO("Is now set to Fireball mode? "+aNewMode); - aStack.getTagCompound().setBoolean("aFireballMod", aNewMode); - //NBTUtils.setBoolean(aStack, "aFireballMode", aNewMode); - PlayerUtils.messagePlayer(aPlayer, "Current Mode: "+EnumChatFormatting.RED+(aNewMode ? "Projectile" : "Fire Starter")); - } - else { - boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); - if (aCurrentMode) { - //Shoot Lightning Attack - aWorld.playSoundAtEntity(aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); - if (!aWorld.isRemote) { - aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); - } - } - else { - //Lights Fires Mode - Logger.WARNING("Preparing Lighter a"); - boolean rOutput = false; - ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); - aX += tDirection.offsetX; - aY += tDirection.offsetY; - aZ += tDirection.offsetZ; - if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { - Logger.WARNING("Preparing Lighter b"); - if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { - Logger.WARNING("Preparing Lighter c"); - GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, aX, aY, - aZ); - aWorld.setBlock(aX, aY, aZ, Blocks.fire); - rOutput = true; - // ItemNBT.setLighterFuel(aStack, tFuelAmount); - return rOutput; - } - } - } - } - } - Logger.WARNING("Preparing Lighter z"); - return false; - } + public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { + if (!aPlayer.worldObj.isRemote && aStack != null && aStack.stackSize == 1) { + boolean rOutput = false; + if (aEntity instanceof EntityCreeper) { + if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { + GT_Utility.sendSoundToPlayers( + aPlayer.worldObj, + (String) GregTech_API.sSoundList.get(6), + 1.0F, + 1.0F, + MathHelper.floor_double(aEntity.posX), + MathHelper.floor_double(aEntity.posY), + MathHelper.floor_double(aEntity.posZ)); + ((EntityCreeper) aEntity).func_146079_cb(); + rOutput = true; + } + } + return rOutput; + } else { + return false; + } + } - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { - if (aPlayer.isSneaking()) { - Logger.INFO("Changing Mode"); - boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); - Logger.INFO("Is currently in Fireball mode? "+aCurrentMode); - boolean aNewMode = Utils.invertBoolean(aCurrentMode); - Logger.INFO("Is now set to Fireball mode? "+aNewMode); - aStack.getTagCompound().setBoolean("aFireballMode", aNewMode); - //NBTUtils.setBoolean(aStack, "aFireballMode", aNewMode); - PlayerUtils.messagePlayer(aPlayer, "Current Mode: "+EnumChatFormatting.RED+(aNewMode ? "Projectile" : "Fire Starter")); - } - else { - boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); - if (aCurrentMode) { - //Shoot Lightning Attack - aWorld.playSoundAtEntity(aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); - if (!aWorld.isRemote) { - aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); - } - } - else { - //Lights Fires Mode - Logger.WARNING("Preparing Lighter a"); - boolean rOutput = false; - ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); - aX += tDirection.offsetX; - aY += tDirection.offsetY; - aZ += tDirection.offsetZ; - if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { - Logger.WARNING("Preparing Lighter b"); - if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { - Logger.WARNING("Preparing Lighter c"); - GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, aX, aY, - aZ); - aWorld.setBlock(aX, aY, aZ, Blocks.fire); - rOutput = true; - // ItemNBT.setLighterFuel(aStack, tFuelAmount); - return rOutput; - } - } - } - } - } - Logger.WARNING("Preparing Lighter z"); - return false; - } + public boolean onItemUse( + GT_MetaBase_Item aItem, + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int aX, + int aY, + int aZ, + int aSide, + float hitX, + float hitY, + float hitZ) { + if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { + if (aPlayer.isSneaking()) { + Logger.INFO("Changing Mode"); + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + Logger.INFO("Is currently in Fireball mode? " + aCurrentMode); + boolean aNewMode = Utils.invertBoolean(aCurrentMode); + Logger.INFO("Is now set to Fireball mode? " + aNewMode); + aStack.getTagCompound().setBoolean("aFireballMod", aNewMode); + // NBTUtils.setBoolean(aStack, "aFireballMode", aNewMode); + PlayerUtils.messagePlayer( + aPlayer, + "Current Mode: " + EnumChatFormatting.RED + (aNewMode ? "Projectile" : "Fire Starter")); + } else { + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + if (aCurrentMode) { + // Shoot Lightning Attack + aWorld.playSoundAtEntity( + aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); + if (!aWorld.isRemote) { + aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); + } + } else { + // Lights Fires Mode + Logger.WARNING("Preparing Lighter a"); + boolean rOutput = false; + ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); + aX += tDirection.offsetX; + aY += tDirection.offsetY; + aZ += tDirection.offsetZ; + if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { + Logger.WARNING("Preparing Lighter b"); + if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { + Logger.WARNING("Preparing Lighter c"); + GT_Utility.sendSoundToPlayers( + aWorld, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, aX, aY, aZ); + aWorld.setBlock(aX, aY, aZ, Blocks.fire); + rOutput = true; + // ItemNBT.setLighterFuel(aStack, tFuelAmount); + return rOutput; + } + } + } + } + } + Logger.WARNING("Preparing Lighter z"); + return false; + } - private boolean prepare(ItemStack aStack) { - if (aStack != null) { - Logger.WARNING("Preparing Lighter 1"); - if (aStack.getItem() instanceof MetaGeneratedGregtechTools) { - Logger.WARNING("Preparing Lighter 2"); - if (ChargingHelper.isItemValid(aStack)) { - Logger.WARNING("Preparing Lighter 3"); - if (aStack.getItem() instanceof IElectricItemManager) { - Logger.WARNING("Preparing Lighter 4"); - IElectricItemManager aItemElec = (IElectricItemManager) aStack.getItem(); - double aCharge = aItemElec.getCharge(aStack); - long aEuCost = 4096 * 2; - if (aCharge >= aEuCost) { - Logger.WARNING("Preparing Lighter 5"); - aItemElec.discharge(aStack, aEuCost, 3, true, true, false); - return true; - } - } - } - } - } - Logger.WARNING("Preparing Lighter 0"); - return false; - } + public boolean onItemUseFirst( + GT_MetaBase_Item aItem, + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int aX, + int aY, + int aZ, + int aSide, + float hitX, + float hitY, + float hitZ) { + if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { + if (aPlayer.isSneaking()) { + Logger.INFO("Changing Mode"); + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + Logger.INFO("Is currently in Fireball mode? " + aCurrentMode); + boolean aNewMode = Utils.invertBoolean(aCurrentMode); + Logger.INFO("Is now set to Fireball mode? " + aNewMode); + aStack.getTagCompound().setBoolean("aFireballMode", aNewMode); + // NBTUtils.setBoolean(aStack, "aFireballMode", aNewMode); + PlayerUtils.messagePlayer( + aPlayer, + "Current Mode: " + EnumChatFormatting.RED + (aNewMode ? "Projectile" : "Fire Starter")); + } else { + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + if (aCurrentMode) { + // Shoot Lightning Attack + aWorld.playSoundAtEntity( + aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); + if (!aWorld.isRemote) { + aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); + } + } else { + // Lights Fires Mode + Logger.WARNING("Preparing Lighter a"); + boolean rOutput = false; + ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); + aX += tDirection.offsetX; + aY += tDirection.offsetY; + aZ += tDirection.offsetZ; + if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { + Logger.WARNING("Preparing Lighter b"); + if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { + Logger.WARNING("Preparing Lighter c"); + GT_Utility.sendSoundToPlayers( + aWorld, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, aX, aY, aZ); + aWorld.setBlock(aX, aY, aZ, Blocks.fire); + rOutput = true; + // ItemNBT.setLighterFuel(aStack, tFuelAmount); + return rOutput; + } + } + } + } + } + Logger.WARNING("Preparing Lighter z"); + return false; + } - private void useUp(ItemStack aStack) { + private boolean prepare(ItemStack aStack) { + if (aStack != null) { + Logger.WARNING("Preparing Lighter 1"); + if (aStack.getItem() instanceof MetaGeneratedGregtechTools) { + Logger.WARNING("Preparing Lighter 2"); + if (ChargingHelper.isItemValid(aStack)) { + Logger.WARNING("Preparing Lighter 3"); + if (aStack.getItem() instanceof IElectricItemManager) { + Logger.WARNING("Preparing Lighter 4"); + IElectricItemManager aItemElec = (IElectricItemManager) aStack.getItem(); + double aCharge = aItemElec.getCharge(aStack); + long aEuCost = 4096 * 2; + if (aCharge >= aEuCost) { + Logger.WARNING("Preparing Lighter 5"); + aItemElec.discharge(aStack, aEuCost, 3, true, true, false); + return true; + } + } + } + } + } + Logger.WARNING("Preparing Lighter 0"); + return false; + } - } + private void useUp(ItemStack aStack) {} - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { - aList.add(this.mTooltip); - int aUses = 0; - if (aStack != null) { - if (aStack.getItem() instanceof MetaGeneratedGregtechTools) { - if (ChargingHelper.isItemValid(aStack)) { - if (aStack.getItem() instanceof IElectricItemManager) { - IElectricItemManager aItemElec = (IElectricItemManager) aStack.getItem(); - double aCharge = aItemElec.getCharge(aStack); - long aEuCost = 4096 * 2; - aUses = (int) (aCharge / aEuCost); - } - } - boolean aCurrentMode; - if (!NBTUtils.hasTagCompound(aStack)) { - NBTUtils.createEmptyTagCompound(aStack); - } - if (NBTUtils.hasKey(aStack, "aFireballMode")) { - aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); - } - else { - aStack.getTagCompound().setBoolean("aFireballMode", false); - aCurrentMode = false; - } - aList.add("Current Mode: "+EnumChatFormatting.RED+(aCurrentMode ? "Projectile" : "Fire Starter")); - } - - } + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + aList.add(this.mTooltip); + int aUses = 0; + if (aStack != null) { + if (aStack.getItem() instanceof MetaGeneratedGregtechTools) { + if (ChargingHelper.isItemValid(aStack)) { + if (aStack.getItem() instanceof IElectricItemManager) { + IElectricItemManager aItemElec = (IElectricItemManager) aStack.getItem(); + double aCharge = aItemElec.getCharge(aStack); + long aEuCost = 4096 * 2; + aUses = (int) (aCharge / aEuCost); + } + } + boolean aCurrentMode; + if (!NBTUtils.hasTagCompound(aStack)) { + NBTUtils.createEmptyTagCompound(aStack); + } + if (NBTUtils.hasKey(aStack, "aFireballMode")) { + aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + } else { + aStack.getTagCompound().setBoolean("aFireballMode", false); + aCurrentMode = false; + } + aList.add("Current Mode: " + EnumChatFormatting.RED + (aCurrentMode ? "Projectile" : "Fire Starter")); + } + } - aList.add(this.mTooltipUses + " " + aUses); - aList.add(this.mTooltipUnstackable); - return aList; - } -} \ No newline at end of file + aList.add(this.mTooltipUses + " " + aUses); + aList.add(this.mTooltipUnstackable); + return aList; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Grinder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Grinder.java index 9012bb8cd8..a2106fe679 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Grinder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Grinder.java @@ -1,10 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.items.behaviours; -import java.util.List; - import gregtech.api.enums.SubTag; import gregtech.api.interfaces.IItemBehaviour; import gregtech.api.items.GT_MetaBase_Item; +import java.util.List; import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -15,80 +14,99 @@ import net.minecraft.world.World; public class Behaviour_Grinder implements IItemBehaviour { - @Override - public boolean onLeftClickEntity(GT_MetaBase_Item var1, ItemStack var2, EntityPlayer var3, Entity var4) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean onItemUse(GT_MetaBase_Item var1, ItemStack var2, EntityPlayer var3, World var4, int var5, int var6, - int var7, int var8, float var9, float var10, float var11) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean onItemUseFirst(GT_MetaBase_Item var1, ItemStack var2, EntityPlayer var3, World var4, int var5, - int var6, int var7, int var8, float var9, float var10, float var11) { - // TODO Auto-generated method stub - return false; - } - - @Override - public ItemStack onItemRightClick(GT_MetaBase_Item var1, ItemStack var2, World var3, EntityPlayer var4) { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getAdditionalToolTips(GT_MetaBase_Item var1, List var2, ItemStack var3) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void onUpdate(GT_MetaBase_Item var1, ItemStack var2, World var3, Entity var4, int var5, boolean var6) { - // TODO Auto-generated method stub - - } - - @Override - public boolean isItemStackUsable(GT_MetaBase_Item var1, ItemStack var2) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean canDispense(GT_MetaBase_Item var1, IBlockSource var2, ItemStack var3) { - // TODO Auto-generated method stub - return false; - } - - @Override - public ItemStack onDispense(GT_MetaBase_Item var1, IBlockSource var2, ItemStack var3) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean hasProjectile(GT_MetaBase_Item var1, SubTag var2, ItemStack var3) { - // TODO Auto-generated method stub - return false; - } - - @Override - public EntityArrow getProjectile(GT_MetaBase_Item var1, SubTag var2, ItemStack var3, World var4, double var5, - double var7, double var9) { - // TODO Auto-generated method stub - return null; - } - - @Override - public EntityArrow getProjectile(GT_MetaBase_Item var1, SubTag var2, ItemStack var3, World var4, - EntityLivingBase var5, float var6) { - // TODO Auto-generated method stub - return null; - } - + @Override + public boolean onLeftClickEntity(GT_MetaBase_Item var1, ItemStack var2, EntityPlayer var3, Entity var4) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean onItemUse( + GT_MetaBase_Item var1, + ItemStack var2, + EntityPlayer var3, + World var4, + int var5, + int var6, + int var7, + int var8, + float var9, + float var10, + float var11) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean onItemUseFirst( + GT_MetaBase_Item var1, + ItemStack var2, + EntityPlayer var3, + World var4, + int var5, + int var6, + int var7, + int var8, + float var9, + float var10, + float var11) { + // TODO Auto-generated method stub + return false; + } + + @Override + public ItemStack onItemRightClick(GT_MetaBase_Item var1, ItemStack var2, World var3, EntityPlayer var4) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getAdditionalToolTips(GT_MetaBase_Item var1, List var2, ItemStack var3) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void onUpdate(GT_MetaBase_Item var1, ItemStack var2, World var3, Entity var4, int var5, boolean var6) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isItemStackUsable(GT_MetaBase_Item var1, ItemStack var2) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean canDispense(GT_MetaBase_Item var1, IBlockSource var2, ItemStack var3) { + // TODO Auto-generated method stub + return false; + } + + @Override + public ItemStack onDispense(GT_MetaBase_Item var1, IBlockSource var2, ItemStack var3) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasProjectile(GT_MetaBase_Item var1, SubTag var2, ItemStack var3) { + // TODO Auto-generated method stub + return false; + } + + @Override + public EntityArrow getProjectile( + GT_MetaBase_Item var1, SubTag var2, ItemStack var3, World var4, double var5, double var7, double var9) { + // TODO Auto-generated method stub + return null; + } + + @Override + public EntityArrow getProjectile( + GT_MetaBase_Item var1, SubTag var2, ItemStack var3, World var4, EntityLivingBase var5, float var6) { + // TODO Auto-generated method stub + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java index f320bfc77d..514e1070ac 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java @@ -1,14 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.items.behaviours; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.items.GT_MetaBase_Item; @@ -20,104 +11,137 @@ import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Block_Ores; import gregtech.common.blocks.GT_TileEntity_Ores; import gregtech.common.items.behaviors.Behaviour_Prospecting; - +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidBlock; -public class Behaviour_Prospecting_Ex -extends Behaviour_Prospecting { - private final int mVanillaCosts; - private final int mEUCosts; - - public Behaviour_Prospecting_Ex(final int aVanillaCosts, final int aEUCosts) { - super(aVanillaCosts, aEUCosts); - this.mVanillaCosts = aVanillaCosts; - this.mEUCosts = aEUCosts; - } +public class Behaviour_Prospecting_Ex extends Behaviour_Prospecting { + private final int mVanillaCosts; + private final int mEUCosts; - @Override - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + public Behaviour_Prospecting_Ex(final int aVanillaCosts, final int aEUCosts) { + super(aVanillaCosts, aEUCosts); + this.mVanillaCosts = aVanillaCosts; + this.mEUCosts = aEUCosts; + } + @Override + public boolean onItemUseFirst( + final GT_MetaBase_Item aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); - if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { - GT_Utility.sendChatToPlayer(aPlayer, "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); - return true; - } - if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt)) ||(aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.grass)) ) { - if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); - int tX = aX; - int tY = aY; - int tZ = aZ; - int tMetaID = 0; - final int tQuality = ((aItem instanceof GT_MetaGenerated_Tool) ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") : 0)*3; + ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer( + aPlayer, "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + return true; + } + if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.grass))) { + if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + int tX = aX; + int tY = aY; + int tZ = aZ; + int tMetaID = 0; + final int tQuality = ((aItem instanceof GT_MetaGenerated_Tool) + ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") + : 0) + * 3; - int i = 0; - for (final int j = 6 + tQuality; i < j; i++) { - tX -= ForgeDirection.getOrientation(aSide).offsetX; - tY -= ForgeDirection.getOrientation(aSide).offsetY; - tZ -= ForgeDirection.getOrientation(aSide).offsetZ; + int i = 0; + for (final int j = 6 + tQuality; i < j; i++) { + tX -= ForgeDirection.getOrientation(aSide).offsetX; + tY -= ForgeDirection.getOrientation(aSide).offsetY; + tZ -= ForgeDirection.getOrientation(aSide).offsetZ; - final Block tBlock = aWorld.getBlock(tX, tY, tZ); - if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { - GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Block."); - break; - } - if ((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) || ((tBlock instanceof IFluidBlock))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Block."); - break; - } - if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Block."); - break; - } - if (tBlock != aBlock) { - if (i >= 4) { - break; - } - GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Block."); - break; - } - } - final Random tRandom = new Random(aX ^ aY ^ aZ ^ aSide); - i = 0; - for (final int j = 9 + (2 * tQuality); i < j; i++) { - tX = (aX - 4 - tQuality) + tRandom.nextInt(j); - tY = (aY - 4 - tQuality) + tRandom.nextInt(j); - tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); - final Block tBlock = aWorld.getBlock(tX, tY, tZ); - if ((tBlock instanceof GT_Block_Ores)) { - final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); - if ((tTileEntity instanceof GT_TileEntity_Ores)) { - final Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; - if ((tMaterial != null) && (tMaterial != Materials._NULL)) { - GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); - return true; - } - } - } else { - tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); - tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); - if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { - GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); - return true; - } - } - } - GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); - } - return true; - } - return false; - } + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { + GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Block."); + break; + } + if ((tBlock == Blocks.water) + || (tBlock == Blocks.flowing_water) + || ((tBlock instanceof IFluidBlock))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Block."); + break; + } + if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Block."); + break; + } + if (tBlock != aBlock) { + if (i >= 4) { + break; + } + GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Block."); + break; + } + } + final Random tRandom = new Random(aX ^ aY ^ aZ ^ aSide); + i = 0; + for (final int j = 9 + (2 * tQuality); i < j; i++) { + tX = (aX - 4 - tQuality) + tRandom.nextInt(j); + tY = (aY - 4 - tQuality) + tRandom.nextInt(j); + tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock instanceof GT_Block_Ores)) { + final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[ + (((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; + if ((tMaterial != null) && (tMaterial != Materials._NULL)) { + GT_Utility.sendChatToPlayer( + aPlayer, "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } else { + tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); + tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); + if ((tAssotiation != null) + && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer( + aPlayer, + "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } + GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); + } + return true; + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java index 7af057bc59..b1f2309b69 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java @@ -12,29 +12,36 @@ import net.minecraft.util.IIcon; public class MetaItemCoverCasings extends MetaCustomCoverItem { - public MetaItemCoverCasings() { - super(CORE.MODID, Textures.BlockIcons.MACHINECASINGS_SIDE.length, "Gt Machine Casings", Textures.BlockIcons.MACHINECASINGS_SIDE, null); - } - - @Override - public void registerIcons(IIconRegister reg) { - for (int i = 0; i < icons.length; i++) { - this.icons[i] = reg.registerIcon(CORE.MODID+":"+"covers/"+i); - } - } - - public boolean hide() { - return false; - } - - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[MathUtils.balance(meta, 0, 15)]; - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - return EnumChatFormatting.LIGHT_PURPLE + GT_Values.VOLTAGE_NAMES[MathUtils.balance(tItem.getItemDamage(), 0, GT_Values.VOLTAGE_NAMES.length-1)]+" Machine Plate Cover"; //super.getItemStackDisplayName(tItem); - } - + public MetaItemCoverCasings() { + super( + CORE.MODID, + Textures.BlockIcons.MACHINECASINGS_SIDE.length, + "Gt Machine Casings", + Textures.BlockIcons.MACHINECASINGS_SIDE, + null); + } + + @Override + public void registerIcons(IIconRegister reg) { + for (int i = 0; i < icons.length; i++) { + this.icons[i] = reg.registerIcon(CORE.MODID + ":" + "covers/" + i); + } + } + + public boolean hide() { + return false; + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[MathUtils.balance(meta, 0, 15)]; + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + return EnumChatFormatting.LIGHT_PURPLE + + GT_Values.VOLTAGE_NAMES[ + MathUtils.balance(tItem.getItemDamage(), 0, GT_Values.VOLTAGE_NAMES.length - 1)] + + " Machine Plate Cover"; // super.getItemStackDisplayName(tItem); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 49537ab559..384e264dcb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -1,16 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.render; -import java.io.*; -import java.net.URL; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import org.apache.commons.io.IOUtils; -import org.lwjgl.opengl.GL11; - import com.mojang.authlib.GameProfile; - import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -21,6 +11,11 @@ import gtPlusPlus.core.proxy.ClientProxy; import gtPlusPlus.core.util.data.AES; import gtPlusPlus.core.util.data.FileUtils; import gtPlusPlus.core.util.math.MathUtils; +import java.io.*; +import java.net.URL; +import java.util.Date; +import java.util.List; +import java.util.UUID; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderManager; @@ -30,488 +25,505 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderPlayerEvent; +import org.apache.commons.io.IOUtils; +import org.lwjgl.opengl.GL11; public class GTPP_CapeRenderer extends RenderPlayer { - private static final ResourceLocation[] mCapes = { - new ResourceLocation("miscutils:textures/OrangeHD.png"), - new ResourceLocation("miscutils:textures/FancyCapeHD.png"), - new ResourceLocation("miscutils:textures/TesterCapeHD.png"), - new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), - new ResourceLocation("miscutils:textures/DevCapeHD.png"), - }; - - private final boolean mInit; - - public GTPP_CapeRenderer() { - mInit = init(); - } - - private final boolean init() { - if (mInit) { - return false; - } - return CapeUtils.init(); - } - - private static boolean hasResourceChecked = false; - private static boolean hasSetRenderer = false; - private boolean hasCape = false; - private ResourceLocation tResource = null; - - public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { - - // Check we have set Render Manager - if (this.renderManager == null) { - hasSetRenderer = false; - } - - // Set Render Manager - if (!hasSetRenderer) { - if (RenderManager.instance != null) { - setRenderManager(RenderManager.instance); - hasSetRenderer = true; - } - } - - // Actually Render - if (hasSetRenderer) { - - // We have capes turned off, so let's not render. - if (!ConfigSwitches.enableCustomCapes) { - return; - } - - // We have already checked if this player has a cape, but since they do not, we best not render. - if (hasResourceChecked) { - if (!hasCape && !CORE.DEVENV) { - return; - } - } - - // Allocate client player object - AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; - - // Make sure we don't keep checking on clients who dont have capes. - if (!hasResourceChecked) { - - // Get players UUID - String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile().getId().toString() : "BAD"; - - // If for whatever reason this fails, we just exit early. - if (aPlayerUUID.equals("BAD")) { - return; - } - - // Automatically allocate a Dev cape while in Dev mode. - if (tResource == null && CORE.DEVENV) { - tResource = mCapes[4]; - hasCape = true; - } - - String aPlayerName = ClientProxy.playerName; - - // Check cape lists for the cape this player owns. - if (!hasCape) { - for (Pair aData : CapeUtils.mOrangeCapes) { - if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { - tResource = mCapes[0]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mMiscCapes) { - if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { - tResource = mCapes[1]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mBetaTestCapes) { - if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { - tResource = mCapes[2]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mPatreonCapes) { - if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { - tResource = mCapes[3]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mDevCapes) { - if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { - tResource = mCapes[4]; - hasCape = true; - break; - } - } - } - hasResourceChecked = true; - } - - if (hasResourceChecked) { - // We have met all the conditions, let's render that cape. - renderCapeOnPlayer(aEvent, aPlayer); - } - } - - } - - private final boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { - float aPartialTicks = aEvent.partialRenderTick; - try { - if (tResource == null && CORE.DEVENV) { - tResource = mCapes[3]; - } - - // If player is invisible, don't render. - if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() - || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { - aEvent.setCanceled(true); - return false; - } - - if ((tResource != null) && (!aPlayer.getHideCape())) { - bindTexture(tResource); - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, 0.125F); - double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks - - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); - double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks - - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks); - double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks - - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks); - float f6 = aPlayer.prevRenderYawOffset - + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks; - double d3 = MathHelper.sin(f6 * CORE.PI / 180.0F); - double d4 = -MathHelper.cos(f6 * CORE.PI / 180.0F); - float f7 = (float) d1 * 10.0F; - float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; - float f9 = (float) (d0 * d4 - d2 * d3) * 100.0F; - if (f7 < -6.0F) { - f7 = -6.0F; - } - if (f7 > 32.0F) { - f7 = 32.0F; - } - if (f8 < 0.0F) { - f8 = 0.0F; - } - float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks; - f7 += MathHelper.sin((aPlayer.prevDistanceWalkedModified - + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F) - * 32.0F * f10; - if (aPlayer.isSneaking()) { - f7 += 25.0F; - } - GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - ((ModelBiped) this.mainModel).renderCloak(0.0625F); - GL11.glPopMatrix(); - return true; - } - } catch (Throwable e) { - - } - return false; - } - - @SuppressWarnings("unused") - @Deprecated - /** - * Should be able to get the username from a UUID - * @param name - Players Name - * @param uuid - Players known UUID - * @return - The newest Player name - */ - private String getPlayerName(String name, String uuid) { - try { - Logger.WORLD("[Capes++] Trying to UUID check " + name + "."); - if (uuid != null) { - if (uuid.length() > 0) { - UUID g = UUID.fromString(uuid); - if (g != null) { - Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); - GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); - if (profile != null) { - Logger.WARNING("[Capes++] Found for UUID check: " + profile.getName() + "."); - return profile.getName(); - } - } else { - g = UUID.fromString(uuid.replace("-", "")); - if (g != null) { - Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); - GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); - if (profile != null) { - Logger.WARNING("[Capes++] Found for UUID check 2: " + profile.getName() + "."); - return profile.getName(); - } - } - } - } - } - if (name != null) { - if (name.length() > 0) { - Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); - GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name); - if (profile != null) { - Logger.WARNING("[Capes++] Found for name check: " + profile.getName() + "."); - return profile.getName(); - } - } - } - Logger.WORLD("[Capes++] Failed UUID check for " + name + "."); - } catch (Throwable t) { - } - return name; - } - - - - private static class CapeUtils { - - private static char SPLIT_CHARACTER = '§'; - private static AES sAES; - - // UUID - Username - private static final AutoMap> mOrangeCapes = new AutoMap>(); - private static final AutoMap> mMiscCapes = new AutoMap>(); - private static final AutoMap> mBetaTestCapes = new AutoMap>(); - private static final AutoMap> mPatreonCapes = new AutoMap>(); - private static final AutoMap> mDevCapes = new AutoMap>(); - - private static final boolean init() { - CapeUtils.handleOldCapeCache(); - if (CORE.DEVENV) { - return true; - } - try { - if (shouldDownloadCapeList()) { - downloadCapeList(); - } - } - catch (Exception e) { - return false; - } - writeCacheToMaps(); - return true; - } - - - private static boolean shouldDownloadCapeList() { - if (!doesCapeCacheExistLocally()) { - return true; - } - if (isCapeCacheWeekOld()) { - return true; - } - return false; - } - - private static final boolean isCapeCacheWeekOld() { - if (!doesCapeCacheExistLocally()) { - return true; - } - else { - File dat = CapeUtils.getCapeCache(); - Date dateLastMod = new Date(dat.lastModified()); - Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); - if (dateLastMod.before(dateNow)) { - return true; - } - } - return false; - } - - private static final void downloadCapeList() { - try { - File dat = getCapeCache(); - File temp = allocateTempFile(); - InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); - FileOutputStream fileOS = new FileOutputStream(temp); - IOUtils.copy(inputStream, fileOS); - if (isDownloadedCapeListBigger(temp)) { - fileOS = new FileOutputStream(dat); - IOUtils.copy(inputStream, fileOS); - } - } catch (Throwable t) { - Logger.INFO("Unable to download GT++ cape list."); - } - } - - private static final boolean isDownloadedCapeListBigger(File aFile) { - double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); - double aNewFileSize = aFile.length(); - if (aNewFileSize > aExistingFileSize) { - return true; - } - return false; - } - - private static void handleOldCapeCache() { - File aCacheFile = FileUtils.getFile("GTPP", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - aCacheFile.delete(); - } - } - - private static final boolean doesCapeCacheExistLocally() { - File aCacheFile = FileUtils.getFile("CapeCache", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - return true; - } - return false; - } - - private static final File getCapeCache() { - File aCacheFile = FileUtils.getFile("CapeCache", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - FileUtils.createFile(aCacheFile); - } - return aCacheFile; - } - - public static final List getDataFromCache(){ - File aCacheFile = getCapeCache(); - List aCache = FileUtils.readLines(aCacheFile); - if (aCache != null && !aCache.isEmpty()) { - return aCache; - } - return new AutoMap(); - } - - private static final File allocateTempFile() { - File tempFile = null; - try { - tempFile = File.createTempFile("gtpp-", null); - } - catch (IOException e) { - e.printStackTrace(); - } - if (tempFile == null) { - tempFile = FileUtils.createFile("", "gtpp-"+MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE/2)), "tmp"); - } - tempFile.deleteOnExit(); - return tempFile; - } - - - public static final void writeCacheToMaps() { - List aCacheData = getDataFromCache(); - if (aCacheData != null && !aCacheData.isEmpty()) { - if (sAES == null) { - sAES = new AES(); - } - AutoMap aDecodedData = new AutoMap(); - for (String aToDecode : aCacheData) { - aDecodedData.put(sAES.decode(aToDecode)); - } - if (!aDecodedData.isEmpty()) { - AutoMap> aCapeType1 = new AutoMap>(); - AutoMap> aCapeType2 = new AutoMap>(); - AutoMap> aCapeType3 = new AutoMap>(); - AutoMap> aCapeType4 = new AutoMap>(); - AutoMap> aCapeType5 = new AutoMap>(); - boolean didProcessStringData = false; - Logger.INFO("Decoded String Count: "+aDecodedData.size()); - for (String aToSplit : aDecodedData) { - String[] aSplitData = aToSplit.split(""+SPLIT_CHARACTER); - if (aSplitData != null && aSplitData.length >= 2) { - if (aSplitData[0] != null) { - Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); - if (aCapeTypeID2 != null) { - int aCapeTypeID = aCapeTypeID2; - Pair aFinalString = new Pair("UUID: "+aSplitData[1], "Username: "+(aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] : "Not Specified")); - Logger.INFO("Cape Type: "+aCapeTypeID); - switch (aCapeTypeID) { - case 0: - aCapeType1.add(aFinalString); - Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType1.size()+" users."); - break; - case 1: - aCapeType2.add(aFinalString); - Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType2.size()+" users."); - break; - case 2: - aCapeType3.add(aFinalString); - Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType3.size()+" users."); - break; - case 3: - aCapeType4.add(aFinalString); - Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType4.size()+" users."); - break; - case 4: - aCapeType5.add(aFinalString); - Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType5.size()+" users."); - break; - default: - break; - } - } - } - } - } - if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() || !aCapeType3.isEmpty() || !aCapeType4.isEmpty() || !aCapeType5.isEmpty()) { - didProcessStringData = true; - } - else { - // did not process any data - } - if (didProcessStringData) { - if (!aCapeType1.isEmpty()) { - for (Pair aUser : aCapeType1) { - Logger.INFO("Adding Generic cape for "+aUser.getKey()); - mOrangeCapes.add(aUser); - } - } - if (!aCapeType2.isEmpty()) { - for (Pair aUser : aCapeType2) { - Logger.INFO("Adding Blue cape for "+aUser.getKey()); - mMiscCapes.add(aUser); - } - } - if (!aCapeType3.isEmpty()) { - for (Pair aUser : aCapeType3) { - Logger.INFO("Adding Beta cape for "+aUser.getKey()); - mBetaTestCapes.add(aUser); - } - } - if (!aCapeType4.isEmpty()) { - for (Pair aUser : aCapeType4) { - Logger.INFO("Adding Patreon cape for "+aUser.getKey()); - mPatreonCapes.add(aUser); - } - } - if (!aCapeType5.isEmpty()) { - for (Pair aUser : aCapeType5) { - Logger.INFO("Adding Dev cape for "+aUser.getKey()); - mDevCapes.add(aUser); - } - } - } - } - else { - // No data decoded - } - } - else { - // Nothing was cached? - } - } - } - - -} \ No newline at end of file + private static final ResourceLocation[] mCapes = { + new ResourceLocation("miscutils:textures/OrangeHD.png"), + new ResourceLocation("miscutils:textures/FancyCapeHD.png"), + new ResourceLocation("miscutils:textures/TesterCapeHD.png"), + new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), + new ResourceLocation("miscutils:textures/DevCapeHD.png"), + }; + + private final boolean mInit; + + public GTPP_CapeRenderer() { + mInit = init(); + } + + private final boolean init() { + if (mInit) { + return false; + } + return CapeUtils.init(); + } + + private static boolean hasResourceChecked = false; + private static boolean hasSetRenderer = false; + private boolean hasCape = false; + private ResourceLocation tResource = null; + + public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { + + // Check we have set Render Manager + if (this.renderManager == null) { + hasSetRenderer = false; + } + + // Set Render Manager + if (!hasSetRenderer) { + if (RenderManager.instance != null) { + setRenderManager(RenderManager.instance); + hasSetRenderer = true; + } + } + + // Actually Render + if (hasSetRenderer) { + + // We have capes turned off, so let's not render. + if (!ConfigSwitches.enableCustomCapes) { + return; + } + + // We have already checked if this player has a cape, but since they do not, we best not render. + if (hasResourceChecked) { + if (!hasCape && !CORE.DEVENV) { + return; + } + } + + // Allocate client player object + AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; + + // Make sure we don't keep checking on clients who dont have capes. + if (!hasResourceChecked) { + + // Get players UUID + String aPlayerUUID = + aPlayer != null ? aPlayer.getGameProfile().getId().toString() : "BAD"; + + // If for whatever reason this fails, we just exit early. + if (aPlayerUUID.equals("BAD")) { + return; + } + + // Automatically allocate a Dev cape while in Dev mode. + if (tResource == null && CORE.DEVENV) { + tResource = mCapes[4]; + hasCape = true; + } + + String aPlayerName = ClientProxy.playerName; + + // Check cape lists for the cape this player owns. + if (!hasCape) { + for (Pair aData : CapeUtils.mOrangeCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[0]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mMiscCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[1]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mBetaTestCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[2]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mPatreonCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[3]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mDevCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[4]; + hasCape = true; + break; + } + } + } + hasResourceChecked = true; + } + + if (hasResourceChecked) { + // We have met all the conditions, let's render that cape. + renderCapeOnPlayer(aEvent, aPlayer); + } + } + } + + private final boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { + float aPartialTicks = aEvent.partialRenderTick; + try { + if (tResource == null && CORE.DEVENV) { + tResource = mCapes[3]; + } + + // If player is invisible, don't render. + if (GT_Utility.getFullInvisibility(aPlayer) + || aPlayer.isInvisible() + || GT_Utility.getPotion( + aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { + aEvent.setCanceled(true); + return false; + } + + if ((tResource != null) && (!aPlayer.getHideCape())) { + bindTexture(tResource); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + double d0 = aPlayer.field_71091_bM + + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks + - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); + double d1 = aPlayer.field_71096_bN + + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks + - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks); + double d2 = aPlayer.field_71097_bO + + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks + - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks); + float f6 = aPlayer.prevRenderYawOffset + + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks; + double d3 = MathHelper.sin(f6 * CORE.PI / 180.0F); + double d4 = -MathHelper.cos(f6 * CORE.PI / 180.0F); + float f7 = (float) d1 * 10.0F; + float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; + float f9 = (float) (d0 * d4 - d2 * d3) * 100.0F; + if (f7 < -6.0F) { + f7 = -6.0F; + } + if (f7 > 32.0F) { + f7 = 32.0F; + } + if (f8 < 0.0F) { + f8 = 0.0F; + } + float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks; + f7 += MathHelper.sin((aPlayer.prevDistanceWalkedModified + + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) + * aPartialTicks) + * 6.0F) + * 32.0F + * f10; + if (aPlayer.isSneaking()) { + f7 += 25.0F; + } + GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + ((ModelBiped) this.mainModel).renderCloak(0.0625F); + GL11.glPopMatrix(); + return true; + } + } catch (Throwable e) { + + } + return false; + } + + @SuppressWarnings("unused") + @Deprecated + /** + * Should be able to get the username from a UUID + * @param name - Players Name + * @param uuid - Players known UUID + * @return - The newest Player name + */ + private String getPlayerName(String name, String uuid) { + try { + Logger.WORLD("[Capes++] Trying to UUID check " + name + "."); + if (uuid != null) { + if (uuid.length() > 0) { + UUID g = UUID.fromString(uuid); + if (g != null) { + Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); + GameProfile profile = + MinecraftServer.getServer().func_152358_ax().func_152652_a(g); + if (profile != null) { + Logger.WARNING("[Capes++] Found for UUID check: " + profile.getName() + "."); + return profile.getName(); + } + } else { + g = UUID.fromString(uuid.replace("-", "")); + if (g != null) { + Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); + GameProfile profile = + MinecraftServer.getServer().func_152358_ax().func_152652_a(g); + if (profile != null) { + Logger.WARNING("[Capes++] Found for UUID check 2: " + profile.getName() + "."); + return profile.getName(); + } + } + } + } + } + if (name != null) { + if (name.length() > 0) { + Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); + GameProfile profile = + MinecraftServer.getServer().func_152358_ax().func_152655_a(name); + if (profile != null) { + Logger.WARNING("[Capes++] Found for name check: " + profile.getName() + "."); + return profile.getName(); + } + } + } + Logger.WORLD("[Capes++] Failed UUID check for " + name + "."); + } catch (Throwable t) { + } + return name; + } + + private static class CapeUtils { + + private static char SPLIT_CHARACTER = '§'; + private static AES sAES; + + // UUID - Username + private static final AutoMap> mOrangeCapes = new AutoMap>(); + private static final AutoMap> mMiscCapes = new AutoMap>(); + private static final AutoMap> mBetaTestCapes = new AutoMap>(); + private static final AutoMap> mPatreonCapes = new AutoMap>(); + private static final AutoMap> mDevCapes = new AutoMap>(); + + private static final boolean init() { + CapeUtils.handleOldCapeCache(); + if (CORE.DEVENV) { + return true; + } + try { + if (shouldDownloadCapeList()) { + downloadCapeList(); + } + } catch (Exception e) { + return false; + } + writeCacheToMaps(); + return true; + } + + private static boolean shouldDownloadCapeList() { + if (!doesCapeCacheExistLocally()) { + return true; + } + if (isCapeCacheWeekOld()) { + return true; + } + return false; + } + + private static final boolean isCapeCacheWeekOld() { + if (!doesCapeCacheExistLocally()) { + return true; + } else { + File dat = CapeUtils.getCapeCache(); + Date dateLastMod = new Date(dat.lastModified()); + Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); + if (dateLastMod.before(dateNow)) { + return true; + } + } + return false; + } + + private static final void downloadCapeList() { + try { + File dat = getCapeCache(); + File temp = allocateTempFile(); + InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); + FileOutputStream fileOS = new FileOutputStream(temp); + IOUtils.copy(inputStream, fileOS); + if (isDownloadedCapeListBigger(temp)) { + fileOS = new FileOutputStream(dat); + IOUtils.copy(inputStream, fileOS); + } + } catch (Throwable t) { + Logger.INFO("Unable to download GT++ cape list."); + } + } + + private static final boolean isDownloadedCapeListBigger(File aFile) { + double aExistingFileSize = + (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); + double aNewFileSize = aFile.length(); + if (aNewFileSize > aExistingFileSize) { + return true; + } + return false; + } + + private static void handleOldCapeCache() { + File aCacheFile = FileUtils.getFile("GTPP", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + aCacheFile.delete(); + } + } + + private static final boolean doesCapeCacheExistLocally() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + return true; + } + return false; + } + + private static final File getCapeCache() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + FileUtils.createFile(aCacheFile); + } + return aCacheFile; + } + + public static final List getDataFromCache() { + File aCacheFile = getCapeCache(); + List aCache = FileUtils.readLines(aCacheFile); + if (aCache != null && !aCache.isEmpty()) { + return aCache; + } + return new AutoMap(); + } + + private static final File allocateTempFile() { + File tempFile = null; + try { + tempFile = File.createTempFile("gtpp-", null); + } catch (IOException e) { + e.printStackTrace(); + } + if (tempFile == null) { + tempFile = FileUtils.createFile( + "", "gtpp-" + MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE / 2)), "tmp"); + } + tempFile.deleteOnExit(); + return tempFile; + } + + public static final void writeCacheToMaps() { + List aCacheData = getDataFromCache(); + if (aCacheData != null && !aCacheData.isEmpty()) { + if (sAES == null) { + sAES = new AES(); + } + AutoMap aDecodedData = new AutoMap(); + for (String aToDecode : aCacheData) { + aDecodedData.put(sAES.decode(aToDecode)); + } + if (!aDecodedData.isEmpty()) { + AutoMap> aCapeType1 = new AutoMap>(); + AutoMap> aCapeType2 = new AutoMap>(); + AutoMap> aCapeType3 = new AutoMap>(); + AutoMap> aCapeType4 = new AutoMap>(); + AutoMap> aCapeType5 = new AutoMap>(); + boolean didProcessStringData = false; + Logger.INFO("Decoded String Count: " + aDecodedData.size()); + for (String aToSplit : aDecodedData) { + String[] aSplitData = aToSplit.split("" + SPLIT_CHARACTER); + if (aSplitData != null && aSplitData.length >= 2) { + if (aSplitData[0] != null) { + Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); + if (aCapeTypeID2 != null) { + int aCapeTypeID = aCapeTypeID2; + Pair aFinalString = new Pair( + "UUID: " + aSplitData[1], + "Username: " + + (aSplitData[2] != null && aSplitData[0].length() > 0 + ? aSplitData[2] + : "Not Specified")); + Logger.INFO("Cape Type: " + aCapeTypeID); + switch (aCapeTypeID) { + case 0: + aCapeType1.add(aFinalString); + Logger.INFO("Added user to map " + aCapeTypeID + ", map now holds " + + aCapeType1.size() + " users."); + break; + case 1: + aCapeType2.add(aFinalString); + Logger.INFO("Added user to map " + aCapeTypeID + ", map now holds " + + aCapeType2.size() + " users."); + break; + case 2: + aCapeType3.add(aFinalString); + Logger.INFO("Added user to map " + aCapeTypeID + ", map now holds " + + aCapeType3.size() + " users."); + break; + case 3: + aCapeType4.add(aFinalString); + Logger.INFO("Added user to map " + aCapeTypeID + ", map now holds " + + aCapeType4.size() + " users."); + break; + case 4: + aCapeType5.add(aFinalString); + Logger.INFO("Added user to map " + aCapeTypeID + ", map now holds " + + aCapeType5.size() + " users."); + break; + default: + break; + } + } + } + } + } + if (!aCapeType1.isEmpty() + || !aCapeType2.isEmpty() + || !aCapeType3.isEmpty() + || !aCapeType4.isEmpty() + || !aCapeType5.isEmpty()) { + didProcessStringData = true; + } else { + // did not process any data + } + if (didProcessStringData) { + if (!aCapeType1.isEmpty()) { + for (Pair aUser : aCapeType1) { + Logger.INFO("Adding Generic cape for " + aUser.getKey()); + mOrangeCapes.add(aUser); + } + } + if (!aCapeType2.isEmpty()) { + for (Pair aUser : aCapeType2) { + Logger.INFO("Adding Blue cape for " + aUser.getKey()); + mMiscCapes.add(aUser); + } + } + if (!aCapeType3.isEmpty()) { + for (Pair aUser : aCapeType3) { + Logger.INFO("Adding Beta cape for " + aUser.getKey()); + mBetaTestCapes.add(aUser); + } + } + if (!aCapeType4.isEmpty()) { + for (Pair aUser : aCapeType4) { + Logger.INFO("Adding Patreon cape for " + aUser.getKey()); + mPatreonCapes.add(aUser); + } + } + if (!aCapeType5.isEmpty()) { + for (Pair aUser : aCapeType5) { + Logger.INFO("Adding Dev cape for " + aUser.getKey()); + mDevCapes.add(aUser); + } + } + } + } else { + // No data decoded + } + } else { + // Nothing was cached? + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java index 1561ba9f73..1d4e367c4f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java @@ -1,7 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.render; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.ItemList; import gregtech.common.items.GT_VolumetricFlask; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import ic2.core.util.DrawUtil; @@ -18,7 +17,7 @@ import org.lwjgl.opengl.GL11; @SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) public final class GTPP_FlaskRenderer implements net.minecraftforge.client.IItemRenderer { - + public GTPP_FlaskRenderer() { MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_8k.getItem(), this); MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_32k.getItem(), this); @@ -28,14 +27,13 @@ public final class GTPP_FlaskRenderer implements net.minecraftforge.client.IItem return type != ItemRenderType.FIRST_PERSON_MAP; } - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { return type == ItemRenderType.ENTITY; } public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GT_VolumetricFlask cell = (GT_VolumetricFlask) item.getItem(); - + int aType = cell.getMaxCapacity() == 8000 ? 0 : 1; IIcon icon = item.getIconIndex(); GL11.glEnable(3042); @@ -86,9 +84,17 @@ public final class GTPP_FlaskRenderer implements net.minecraftforge.client.IItem if (type.equals(ItemRenderType.INVENTORY)) { DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { - ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + icon.getMaxU(), + icon.getMinV(), + icon.getMinU(), + icon.getMaxV(), + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F); } GL11.glDisable(3008); GL11.glDisable(3042); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java index 35d78008c5..1a5117ac2e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.render; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.client.registry.RenderingRegistry; import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; @@ -18,642 +16,767 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; public class GTPP_Render_MachineBlock extends GT_Renderer_Block { - - public static GTPP_Render_MachineBlock INSTANCE; - public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); - - public GTPP_Render_MachineBlock() { - INSTANCE = this; - RenderingRegistry.registerBlockHandler(this); - } - - private static ITexture[] getTexture(IMetaTileEntity arg0, int arg1, int arg2, int arg3, boolean arg4, boolean arg5) { - IGregTechTileEntity arg0b = arg0.getBaseMetaTileEntity(); - return arg0.getTexture(arg0b, (byte) arg1, (byte) arg2, (byte) arg3, arg4, arg5); - } - - private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { - if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length) { - IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aMeta]; - if (tMetaTileEntity != null) { - aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - if (tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity) { - float tThickness = ((IPipeRenderedTileEntity) tMetaTileEntity.getBaseMetaTileEntity()) - .getThickNess(); - float sp = (1.0F - tThickness) / 2.0F; - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 0, 9, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 1, 9, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 2, 9, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 3, 9, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 4, 9, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 5, 9, -1, true, false), - true); - Tessellator.instance.draw(); - } else { - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 0, 4, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 1, 4, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 2, 4, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 3, 4, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 4, 4, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, - getTexture(tMetaTileEntity, 5, 4, -1, true, false), - true); - Tessellator.instance.draw(); - } - - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - } - } - - public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - RenderBlocks aRenderer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - - return tTileEntity instanceof ITexturedTileEntity - ? renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, - new ITexture[][]{GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 0), - GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 1), - GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 2), - GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 3), - GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 4), - GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 5)}) - : false; - } - - public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - RenderBlocks aRenderer, ITexture[][] aTextures) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); - return true; - } - - public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { - byte aConnections = aTileEntity.getConnections(); - if ((aConnections & 192) != 0) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - float tThickness = aTileEntity.getThickNess(); - if (tThickness >= 0.99F) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - float sp = (1.0F - tThickness) / 2.0F; - byte tConnections = 0; - - for (byte tIsCovered = 0; tIsCovered < 6; ++tIsCovered) { - if ((aConnections & 1 << tIsCovered) != 0) { - tConnections = (byte) (tConnections | 1 << (tIsCovered + 2) % 6); - } - } - - boolean[] arg14 = new boolean[6]; - - for (byte tIcons = 0; tIcons < 6; ++tIcons) { - arg14[tIcons] = aTileEntity.getCoverIDAtSide(tIcons) != 0; - } - - if (arg14[0] && arg14[1] && arg14[2] && arg14[3] && arg14[4] && arg14[5]) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - ITexture[][] arg15 = new ITexture[6][]; - ITexture[][] tCovers = new ITexture[6][]; - - for (byte i = 0; i < 6; ++i) { - tCovers[i] = GT_MethodHelper.getTexture((TileEntity) aTileEntity, aBlock, i); - arg15[i] = aTileEntity.getTextureUncovered(i); - } - - if (tConnections == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - } else if (tConnections == 3) { - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - if (!arg14[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - } - - if (!arg14[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - } - } else if (tConnections == 12) { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - if (!arg14[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - } - - if (!arg14[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - } - } else if (tConnections == 48) { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - if (!arg14[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - } - - if (!arg14[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - } - } else { - if ((tConnections & 1) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - } else { - aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - if (!arg14[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - } - } - - if ((tConnections & 2) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - } else { - aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - if (!arg14[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - } - } - - if ((tConnections & 4) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - } else { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - if (!arg14[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - } - } - - if ((tConnections & 8) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - } else { - aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - if (!arg14[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - } - } - - if ((tConnections & 16) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - } else { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - if (!arg14[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); - } - } - - if ((tConnections & 32) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - } else { - aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); - if (!arg14[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); - } - } - } - - if (arg14[0]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - if (!arg14[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - - if (!arg14[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - - if (!arg14[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - - if (!arg14[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - } - - if (arg14[1]) { - aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - if (!arg14[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - - if (!arg14[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - - if (!arg14[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - - if (!arg14[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - } - - if (arg14[2]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!arg14[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - - if (!arg14[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - if (!arg14[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - - if (!arg14[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - } - - if (arg14[3]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!arg14[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - - if (!arg14[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - if (!arg14[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - - if (!arg14[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - } - - if (arg14[4]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!arg14[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - - if (!arg14[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - - if (!arg14[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - - if (!arg14[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - - if (arg14[5]) { - aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!arg14[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - - if (!arg14[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - - if (!arg14[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - - if (!arg14[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - return true; - } - } - } - } - - public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); - } - - if (aIcon != null) { - for (int i = 0; i < aIcon.length; ++i) { - if (aIcon[i] != null) { - aIcon[i].renderYNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); - } - - if (aIcon != null) { - for (int i = 0; i < aIcon.length; ++i) { - if (aIcon[i] != null) { - aIcon[i].renderYPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); - } - - aRenderer.flipTexture = !aFullBlock; - if (aIcon != null) { - for (int i = 0; i < aIcon.length; ++i) { - if (aIcon[i] != null) { - aIcon[i].renderZNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); - } - - if (aIcon != null) { - for (int i = 0; i < aIcon.length; ++i) { - if (aIcon[i] != null) { - aIcon[i].renderZPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); - } - - if (aIcon != null) { - for (int i = 0; i < aIcon.length; ++i) { - if (aIcon[i] != null) { - aIcon[i].renderXNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); - } - - aRenderer.flipTexture = !aFullBlock; - if (aIcon != null) { - for (int i = 0; i < aIcon.length; ++i) { - if (aIcon[i] != null) { - aIcon[i].renderXPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { - aMeta += 30400; - if (aBlock instanceof GT_Block_Machines || aBlock instanceof GTPP_Block_Machines) { - if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length - && GregTech_API.METATILEENTITIES[aMeta] != null - && !GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer)) { - renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); - } - } - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, - RenderBlocks aRenderer) { - TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity == null - ? false - : (aTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null - && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity().renderInWorld(aWorld, aX, aY, aZ, - aBlock, aRenderer) - ? true - : (aTileEntity instanceof IPipeRenderedTileEntity - ? renderPipeBlock(aWorld, aX, aY, aZ, aBlock, - (IPipeRenderedTileEntity) aTileEntity, aRenderer) - : renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer))); - } - - public boolean shouldRender3DInInventory(int aModel) { - return true; - } - - public int getRenderId() { - return this.mRenderID; - } -} \ No newline at end of file + + public static GTPP_Render_MachineBlock INSTANCE; + public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); + + public GTPP_Render_MachineBlock() { + INSTANCE = this; + RenderingRegistry.registerBlockHandler(this); + } + + private static ITexture[] getTexture( + IMetaTileEntity arg0, int arg1, int arg2, int arg3, boolean arg4, boolean arg5) { + IGregTechTileEntity arg0b = arg0.getBaseMetaTileEntity(); + return arg0.getTexture(arg0b, (byte) arg1, (byte) arg2, (byte) arg3, arg4, arg5); + } + + private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { + if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length) { + IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aMeta]; + if (tMetaTileEntity != null) { + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + if (tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity) { + float tThickness = + ((IPipeRenderedTileEntity) tMetaTileEntity.getBaseMetaTileEntity()).getThickNess(); + float sp = (1.0F - tThickness) / 2.0F; + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 0, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 1, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 2, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 3, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 4, 9, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 5, 9, -1, true, false), + true); + Tessellator.instance.draw(); + } else { + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 0, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 1, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 2, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 3, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 4, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing( + (IBlockAccess) null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, 5, 4, -1, true, false), + true); + Tessellator.instance.draw(); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + } + } + + public static boolean renderStandardBlock( + IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + + return tTileEntity instanceof ITexturedTileEntity + ? renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][] { + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 0), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 1), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 2), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 3), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 4), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 5) + }) + : false; + } + + public static boolean renderStandardBlock( + IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer, ITexture[][] aTextures) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); + return true; + } + + public static boolean renderPipeBlock( + IBlockAccess aWorld, + int aX, + int aY, + int aZ, + Block aBlock, + IPipeRenderedTileEntity aTileEntity, + RenderBlocks aRenderer) { + byte aConnections = aTileEntity.getConnections(); + if ((aConnections & 192) != 0) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float tThickness = aTileEntity.getThickNess(); + if (tThickness >= 0.99F) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float sp = (1.0F - tThickness) / 2.0F; + byte tConnections = 0; + + for (byte tIsCovered = 0; tIsCovered < 6; ++tIsCovered) { + if ((aConnections & 1 << tIsCovered) != 0) { + tConnections = (byte) (tConnections | 1 << (tIsCovered + 2) % 6); + } + } + + boolean[] arg14 = new boolean[6]; + + for (byte tIcons = 0; tIcons < 6; ++tIcons) { + arg14[tIcons] = aTileEntity.getCoverIDAtSide(tIcons) != 0; + } + + if (arg14[0] && arg14[1] && arg14[2] && arg14[3] && arg14[4] && arg14[5]) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + ITexture[][] arg15 = new ITexture[6][]; + ITexture[][] tCovers = new ITexture[6][]; + + for (byte i = 0; i < 6; ++i) { + tCovers[i] = GT_MethodHelper.getTexture((TileEntity) aTileEntity, aBlock, i); + arg15[i] = aTileEntity.getTextureUncovered(i); + } + + if (tConnections == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } else if (tConnections == 3) { + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } + } else if (tConnections == 12) { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + } + } else if (tConnections == 48) { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + } + } else { + if ((tConnections & 1) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + } else { + aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + } + } + + if ((tConnections & 2) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } else { + aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } + } + + if ((tConnections & 4) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + } else { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + } + } + + if ((tConnections & 8) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + } else { + aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + } + } + + if ((tConnections & 16) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + } else { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + } + } + + if ((tConnections & 32) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + } else { + aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + } + } + } + + if (arg14[0]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + } + + if (arg14[1]) { + aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + } + + if (arg14[2]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + } + + if (arg14[3]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + } + + if (arg14[4]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (arg14[5]) { + aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + return true; + } + } + } + } + + public static void renderNegativeYFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0)) { + return; + } + + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveYFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1)) { + return; + } + + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeZFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2)) { + return; + } + + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveZFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3)) { + return; + } + + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeXFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4)) { + return; + } + + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveXFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5)) { + return; + } + + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aMeta += 30400; + if (aBlock instanceof GT_Block_Machines || aBlock instanceof GTPP_Block_Machines) { + if (aMeta > 0 + && aMeta < GregTech_API.METATILEENTITIES.length + && GregTech_API.METATILEENTITIES[aMeta] != null + && !GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer)) { + renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); + } + } + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + public boolean renderWorldBlock( + IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, RenderBlocks aRenderer) { + TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return aTileEntity == null + ? false + : (aTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null + && ((IGregTechTileEntity) aTileEntity) + .getMetaTileEntity() + .renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer) + ? true + : (aTileEntity instanceof IPipeRenderedTileEntity + ? renderPipeBlock( + aWorld, aX, aY, aZ, aBlock, (IPipeRenderedTileEntity) aTileEntity, aRenderer) + : renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer))); + } + + public boolean shouldRender3DInInventory(int aModel) { + return true; + } + + public int getRenderId() { + return this.mRenderID; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java index 7b223f8245..79400b68e6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.automation; -import java.util.ArrayList; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; @@ -19,6 +17,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_Container_ElectricAutoWorkbench; import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_GUIContainer_ElectricAutoWorkbench; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -26,747 +25,844 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.oredict.OreDictionary; public class GT_MetaTileEntity_ElectricAutoWorkbench extends GT_MetaTileEntity_BasicTank { - - public int mMode = 0, mCurrentSlot = 0, mThroughPut = 0, mTicksUntilNextUpdate = 20; - public boolean mLastCraftSuccessful = false; - protected String mLocalName; - - public GT_MetaTileEntity_ElectricAutoWorkbench(final int aID, final int aTier, final String aDescription) { - super(aID, "basicmachine.automation.autoworkbench.0"+aTier, "Auto Workbench ("+GT_Values.VN[aTier]+")", aTier, 30, aDescription); - mLocalName = "Auto Workbench ("+GT_Values.VN[aTier]+")"; - } - - public GT_MetaTileEntity_ElectricAutoWorkbench(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 30, aDescription, aTextures); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_ElectricAutoWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_ElectricAutoWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex < 19; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return !isOutputFacing(aSide); - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long maxEUInput() { - return GT_Values.V[mTier]; - } - - @Override - public long maxEUOutput() { - return mThroughPut % 2 == 0 ? GT_Values.V[mTier] : 0; - } - - @Override - public long getMinimumStoredEU() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUStore() { - return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); - } - - @Override - public int getSizeInventory() { - return 30; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_ElectricAutoWorkbench(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mMode", mMode); - aNBT.setInteger("mThroughPut", mThroughPut); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mMode = aNBT.getInteger("mMode"); - mThroughPut = aNBT.getInteger("mThroughPut"); - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return aSide != getBaseMetaTileEntity().getFrontFacing() && aSide != getBaseMetaTileEntity().getBackFacing(); - } - - private static final int MAX_MODES = 10; - - public void switchModeForward() { - mMode = (mMode + 1) % MAX_MODES; - switchMode(); - } - - public void switchModeBackward() { - mMode--; - if (mMode < 0) mMode = MAX_MODES-1; - switchMode(); - } - - private void switchMode() { - mInventory[28] = null; - } - - public void switchThrough() { - mThroughPut = (mThroughPut + 1) % 4; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().getUniversalEnergyStored() >= (mMode==5||mMode==6?128:2048) && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || --mTicksUntilNextUpdate<1)) { - mTicksUntilNextUpdate = 32; - - for (byte i = 19; i < 28; i++) { - if (mInventory[i] != null && mInventory[i].isItemStackDamageable() && mInventory[i].getItem().hasContainerItem()) { - mInventory[i].setItemDamage(OreDictionary.WILDCARD_VALUE); - } - } - - if (mInventory[18] == null) { - for (byte i = 0; i < 18 && mFluid != null; i++) { - ItemStack tOutput = GT_Utility.fillFluidContainer(mFluid, mInventory[i], false, true); - if (tOutput != null) { - for (byte j = 0; j < 9; j++) { - if (mInventory[j] == null || (GT_Utility.areStacksEqual(tOutput, mInventory[j]) && mInventory[j].stackSize + tOutput.stackSize <= tOutput.getMaxStackSize())) { - mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; - getBaseMetaTileEntity().decrStackSize(i, 1); - if (mInventory[j] == null) { - mInventory[j] = tOutput; - } else { - mInventory[j].stackSize++; - } - if (mFluid.amount <= 0) mFluid = null; - break; - } - } - } - } - - ItemStack[] tRecipe = new ItemStack[9]; - ItemStack tTempStack = null, tOutput = null; - - if (mInventory[17] != null && mThroughPut < 2 && mMode != 0) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[17]; - mInventory[17] = null; - } - } else { - if (!mLastCraftSuccessful) { - mCurrentSlot = (mCurrentSlot+1)%18; - for (int i = 0; i < 17 && mInventory[mCurrentSlot] == null; i++) - mCurrentSlot = (mCurrentSlot+1)%18; - } - switch (mMode) { - case 0: - if (mInventory[mCurrentSlot] != null && !isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2 && mCurrentSlot < 8) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - for (int i = 0; i < 9; i++) { - tRecipe[i] = mInventory[i+19]; - if (tRecipe[i] != null) { - tRecipe[i] = GT_Utility.copy(tRecipe[i]); - tRecipe[i].stackSize = 1; - } - } - break; - case 1: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - tRecipe[1] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - } else break; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - tRecipe[2] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - } else break; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - break; - case 2: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - break; - case 3: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - break; - case 4: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[2] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - break; - case 5: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - - tOutput = GT_OreDictUnificator.get(true, tTempStack); - - if (tOutput != null && GT_Utility.areStacksEqual(tOutput, tTempStack)) tOutput = null; - - if (tOutput == null) { - tRecipe[0] = null; - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - break; - case 6: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } else if (OrePrefixes.dustSmall.contains(mInventory[mCurrentSlot])) { - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - } else if (OrePrefixes.dustTiny.contains(mInventory[mCurrentSlot])) { - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[2] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - } else { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - break; - case 7: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) || !OrePrefixes.nugget.contains(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[2] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - break; - case 8: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) || mInventory[mCurrentSlot].getItemDamage() <= 0 || !mInventory[mCurrentSlot].getItem().isRepairable()) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - for (int i = mCurrentSlot + 1; i < 18; i++) { - if (mInventory[i] != null && mInventory[i].getItem() == tTempStack.getItem() && mInventory[mCurrentSlot].getItemDamage()+mInventory[i].getItemDamage()>tTempStack.getMaxDamage()) { - tRecipe[0] = tTempStack; - tRecipe[1] = GT_Utility.copy(mInventory[i]); - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - break; - } - } - break; - case 9: - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - for (byte i = 0, j = 0; i < 18 && j < 9 && (j < 2 || GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null); i++) { - tRecipe[j] = mInventory[(mCurrentSlot+i)%18]; - if (tRecipe[j] != null) { - tRecipe[j] = GT_Utility.copy(tRecipe[j]); - tRecipe[j].stackSize = 1; - j++; - } - } - if (tRecipe[1] == null) tRecipe[0] = null; - break; - } - } - - if (tOutput == null) tOutput = GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe); - - if (tOutput != null || mMode == 0) mInventory[28] = tOutput; - - if (tOutput == null) { - mLastCraftSuccessful = false; - } else { - if ((tTempStack = GT_OreDictUnificator.get(true, tOutput)) != null) { - tTempStack.stackSize = tOutput.stackSize; - tOutput = tTempStack; - } - - mInventory[28] = GT_Utility.copy(tOutput); - ArrayList tList = recipeContent(tRecipe), tContent = benchContent(); - if (tList.size() > 0 && tContent.size() > 0) { - - boolean success = (mMode==6||mMode==7||mInventory[17]==null); - for (byte i = 0; i < tList.size() && success; i++) { - success = false; - for (byte j = 0; j < tContent.size() && !success; j++) { - if (GT_Utility.areStacksEqual(tList.get(i), tContent.get(j))) { - if (tList.get(i).stackSize <= tContent.get(j).stackSize) { - success = true; - } - } - } - } - - if (success) { - mLastCraftSuccessful = true; - - for (byte i = 8; i > -1; i--) { - for (byte j = 17; j > -1; j--) { - if (tRecipe[i] != null && mInventory[j] != null) { - if (GT_Utility.areStacksEqual(tRecipe[i], mInventory[j])) { - ItemStack tStack = GT_Utility.getContainerItem(mInventory[j], true); - if (tStack != null) { - getBaseMetaTileEntity().decrStackSize(j, 1); - if (!tStack.isItemStackDamageable() || tStack.getItemDamage() < tStack.getMaxDamage()) { - for (byte k = 9; k < 18; k++) { - if (mInventory[k] == null) { - mInventory[k] = GT_Utility.copy(tStack); - break; - } else if (GT_Utility.areStacksEqual(mInventory[k], tStack) && mInventory[k].stackSize + tStack.stackSize <= tStack.getMaxStackSize()) { - mInventory[k].stackSize += tStack.stackSize; - break; - } - } - } - } else { - getBaseMetaTileEntity().decrStackSize(j, 1); - } - break; - } - } - } - } - - mInventory[18] = GT_Utility.copy(tOutput); - getBaseMetaTileEntity().decreaseStoredEnergyUnits(mMode==5||mMode==6||mMode==7?128:2048, true); - mTicksUntilNextUpdate = 1; - } else { - mLastCraftSuccessful = false; - if (mInventory[mMode==0?8:17] != null && mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mMode==0?8:17]; - mInventory[mMode==0?8:17] = null; - mTicksUntilNextUpdate = 1; - } - } - } - - if (mInventory[18] == null && mThroughPut < 2) { - for (byte i = 0; i < 8; i++) { - for (byte j = i; ++j < 9;) { - if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j]) && mInventory[i].getMaxStackSize() > 8) { - mInventory[18] = mInventory[j]; - mInventory[j] = null; - mTicksUntilNextUpdate = 1; - break; - } - } - } - } - } - } - - if (mThroughPut < 2) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()), getBaseMetaTileEntity().getBackFacing(), getBaseMetaTileEntity().getFrontFacing(), null, false, (byte)64, (byte)1, (byte)64, (byte)1)*10, true); - } - } - } - - private boolean isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(ItemStack aStack) { - if (aStack == null) return true; - for (byte i = 19; i < 28; i++) { - if (mInventory[i] != null) { - if (GT_Utility.areStacksEqual(mInventory[i], aStack)) return true; - if (GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(mInventory[i], true), aStack)) return true; - } - } - return false; - } - - private ArrayList recipeContent(ItemStack[] tRecipe) { - ArrayList tList = new ArrayList(); - for (byte i = 0; i < 9; i++) { - if (tRecipe[i] != null) { - boolean temp = false; - for (byte j = 0; j < tList.size(); j++) { - if (GT_Utility.areStacksEqual(tRecipe[i], tList.get(j))) { - tList.get(j).stackSize++; - temp = true; - break; - } - } - if (!temp) tList.add(GT_Utility.copy(1, tRecipe[i])); - } - } - return tList; - } - - private ArrayList benchContent() { - ArrayList tList = new ArrayList(); - for (byte i = 0; i < 18; i++) { - if (mInventory[i] != null) { - boolean temp = false; - for (byte j = 0; j < tList.size(); j++) { - if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j])) { - tList.get(j).stackSize += mInventory[i].stackSize; - temp = true; - break; - } - } - if (!temp) tList.add(GT_Utility.copy(mInventory[i])); - } - } - return tList; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return mMode==0?aIndex>=10:aIndex>=18; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return mMode==0?aIndex<9:aIndex<18; - } - - /*@Override - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) - return 112; - if (GT_Utility.getOppositeSide(aSide) == aFacing) - return 113; - return 114; - }*/ - - @Override - public int getCapacity() { - return 16000; - } - - @Override - public int getTankPressure() { - return -100; - } - - @Override - public String[] getDescription() { - return new String[] { - "Automatic Crafting Table Mk III", - //this.mDescription, - CORE.GT_Tooltip }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getBack(i); - rTextures[7][i + 1] = this.getBottom(i); - rTextures[8][i + 1] = this.getTop(i); - rTextures[9][i + 1] = this.getSides(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return this.mTextures[0][aColorIndex + 1]; - } - else if (GT_Utility.getOppositeSide(aSide) == aFacing) { - return this.mTextures[1][aColorIndex + 1]; - } - else { - return this.mTextures[4][aColorIndex + 1]; - } - /*return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1];*/ - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay)}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay)}; - } + + public int mMode = 0, mCurrentSlot = 0, mThroughPut = 0, mTicksUntilNextUpdate = 20; + public boolean mLastCraftSuccessful = false; + protected String mLocalName; + + public GT_MetaTileEntity_ElectricAutoWorkbench(final int aID, final int aTier, final String aDescription) { + super( + aID, + "basicmachine.automation.autoworkbench.0" + aTier, + "Auto Workbench (" + GT_Values.VN[aTier] + ")", + aTier, + 30, + aDescription); + mLocalName = "Auto Workbench (" + GT_Values.VN[aTier] + ")"; + } + + public GT_MetaTileEntity_ElectricAutoWorkbench( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 30, aDescription, aTextures); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_ElectricAutoWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_ElectricAutoWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 19; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long maxEUInput() { + return GT_Values.V[mTier]; + } + + @Override + public long maxEUOutput() { + return mThroughPut % 2 == 0 ? GT_Values.V[mTier] : 0; + } + + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); + } + + @Override + public int getSizeInventory() { + return 30; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ElectricAutoWorkbench(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mMode", mMode); + aNBT.setInteger("mThroughPut", mThroughPut); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mMode = aNBT.getInteger("mMode"); + mThroughPut = aNBT.getInteger("mThroughPut"); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return aSide != getBaseMetaTileEntity().getFrontFacing() + && aSide != getBaseMetaTileEntity().getBackFacing(); + } + + private static final int MAX_MODES = 10; + + public void switchModeForward() { + mMode = (mMode + 1) % MAX_MODES; + switchMode(); + } + + public void switchModeBackward() { + mMode--; + if (mMode < 0) mMode = MAX_MODES - 1; + switchMode(); + } + + private void switchMode() { + mInventory[28] = null; + } + + public void switchThrough() { + mThroughPut = (mThroughPut + 1) % 4; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() + && getBaseMetaTileEntity().isServerSide() + && getBaseMetaTileEntity().getUniversalEnergyStored() >= (mMode == 5 || mMode == 6 ? 128 : 2048) + && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || --mTicksUntilNextUpdate < 1)) { + mTicksUntilNextUpdate = 32; + + for (byte i = 19; i < 28; i++) { + if (mInventory[i] != null + && mInventory[i].isItemStackDamageable() + && mInventory[i].getItem().hasContainerItem()) { + mInventory[i].setItemDamage(OreDictionary.WILDCARD_VALUE); + } + } + + if (mInventory[18] == null) { + for (byte i = 0; i < 18 && mFluid != null; i++) { + ItemStack tOutput = GT_Utility.fillFluidContainer(mFluid, mInventory[i], false, true); + if (tOutput != null) { + for (byte j = 0; j < 9; j++) { + if (mInventory[j] == null + || (GT_Utility.areStacksEqual(tOutput, mInventory[j]) + && mInventory[j].stackSize + tOutput.stackSize + <= tOutput.getMaxStackSize())) { + mFluid.amount -= + GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; + getBaseMetaTileEntity().decrStackSize(i, 1); + if (mInventory[j] == null) { + mInventory[j] = tOutput; + } else { + mInventory[j].stackSize++; + } + if (mFluid.amount <= 0) mFluid = null; + break; + } + } + } + } + + ItemStack[] tRecipe = new ItemStack[9]; + ItemStack tTempStack = null, tOutput = null; + + if (mInventory[17] != null && mThroughPut < 2 && mMode != 0) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[17]; + mInventory[17] = null; + } + } else { + if (!mLastCraftSuccessful) { + mCurrentSlot = (mCurrentSlot + 1) % 18; + for (int i = 0; i < 17 && mInventory[mCurrentSlot] == null; i++) + mCurrentSlot = (mCurrentSlot + 1) % 18; + } + switch (mMode) { + case 0: + if (mInventory[mCurrentSlot] != null + && !isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2 && mCurrentSlot < 8) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + for (int i = 0; i < 9; i++) { + tRecipe[i] = mInventory[i + 19]; + if (tRecipe[i] != null) { + tRecipe[i] = GT_Utility.copy(tRecipe[i]); + tRecipe[i].stackSize = 1; + } + } + break; + case 1: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + } else break; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + tRecipe[2] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + } else break; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 2: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 3: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 4: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 5: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + + tOutput = GT_OreDictUnificator.get(true, tTempStack); + + if (tOutput != null && GT_Utility.areStacksEqual(tOutput, tTempStack)) tOutput = null; + + if (tOutput == null) { + tRecipe[0] = null; + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + break; + case 6: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } else if (OrePrefixes.dustSmall.contains(mInventory[mCurrentSlot])) { + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + } else if (OrePrefixes.dustTiny.contains(mInventory[mCurrentSlot])) { + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + } else { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 7: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) + || !OrePrefixes.nugget.contains(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + break; + case 8: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) + || mInventory[mCurrentSlot].getItemDamage() <= 0 + || !mInventory[mCurrentSlot].getItem().isRepairable()) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + for (int i = mCurrentSlot + 1; i < 18; i++) { + if (mInventory[i] != null + && mInventory[i].getItem() == tTempStack.getItem() + && mInventory[mCurrentSlot].getItemDamage() + mInventory[i].getItemDamage() + > tTempStack.getMaxDamage()) { + tRecipe[0] = tTempStack; + tRecipe[1] = GT_Utility.copy(mInventory[i]); + if (GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + break; + } + } + break; + case 9: + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + for (byte i = 0, j = 0; + i < 18 + && j < 9 + && (j < 2 + || GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity() + .getWorld(), + tRecipe) + == null); + i++) { + tRecipe[j] = mInventory[(mCurrentSlot + i) % 18]; + if (tRecipe[j] != null) { + tRecipe[j] = GT_Utility.copy(tRecipe[j]); + tRecipe[j].stackSize = 1; + j++; + } + } + if (tRecipe[1] == null) tRecipe[0] = null; + break; + } + } + + if (tOutput == null) + tOutput = GT_ModHandler.getAllRecipeOutput( + getBaseMetaTileEntity().getWorld(), tRecipe); + + if (tOutput != null || mMode == 0) mInventory[28] = tOutput; + + if (tOutput == null) { + mLastCraftSuccessful = false; + } else { + if ((tTempStack = GT_OreDictUnificator.get(true, tOutput)) != null) { + tTempStack.stackSize = tOutput.stackSize; + tOutput = tTempStack; + } + + mInventory[28] = GT_Utility.copy(tOutput); + ArrayList tList = recipeContent(tRecipe), tContent = benchContent(); + if (tList.size() > 0 && tContent.size() > 0) { + + boolean success = (mMode == 6 || mMode == 7 || mInventory[17] == null); + for (byte i = 0; i < tList.size() && success; i++) { + success = false; + for (byte j = 0; j < tContent.size() && !success; j++) { + if (GT_Utility.areStacksEqual(tList.get(i), tContent.get(j))) { + if (tList.get(i).stackSize <= tContent.get(j).stackSize) { + success = true; + } + } + } + } + + if (success) { + mLastCraftSuccessful = true; + + for (byte i = 8; i > -1; i--) { + for (byte j = 17; j > -1; j--) { + if (tRecipe[i] != null && mInventory[j] != null) { + if (GT_Utility.areStacksEqual(tRecipe[i], mInventory[j])) { + ItemStack tStack = GT_Utility.getContainerItem(mInventory[j], true); + if (tStack != null) { + getBaseMetaTileEntity().decrStackSize(j, 1); + if (!tStack.isItemStackDamageable() + || tStack.getItemDamage() < tStack.getMaxDamage()) { + for (byte k = 9; k < 18; k++) { + if (mInventory[k] == null) { + mInventory[k] = GT_Utility.copy(tStack); + break; + } else if (GT_Utility.areStacksEqual(mInventory[k], tStack) + && mInventory[k].stackSize + tStack.stackSize + <= tStack.getMaxStackSize()) { + mInventory[k].stackSize += tStack.stackSize; + break; + } + } + } + } else { + getBaseMetaTileEntity().decrStackSize(j, 1); + } + break; + } + } + } + } + + mInventory[18] = GT_Utility.copy(tOutput); + getBaseMetaTileEntity() + .decreaseStoredEnergyUnits( + mMode == 5 || mMode == 6 || mMode == 7 ? 128 : 2048, true); + mTicksUntilNextUpdate = 1; + } else { + mLastCraftSuccessful = false; + if (mInventory[mMode == 0 ? 8 : 17] != null && mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mMode == 0 ? 8 : 17]; + mInventory[mMode == 0 ? 8 : 17] = null; + mTicksUntilNextUpdate = 1; + } + } + } + + if (mInventory[18] == null && mThroughPut < 2) { + for (byte i = 0; i < 8; i++) { + for (byte j = i; ++j < 9; ) { + if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j]) + && mInventory[i].getMaxStackSize() > 8) { + mInventory[18] = mInventory[j]; + mInventory[j] = null; + mTicksUntilNextUpdate = 1; + break; + } + } + } + } + } + } + + if (mThroughPut < 2) { + getBaseMetaTileEntity() + .decreaseStoredEnergyUnits( + GT_Utility.moveOneItemStack( + getBaseMetaTileEntity(), + getBaseMetaTileEntity() + .getIInventoryAtSide(getBaseMetaTileEntity() + .getBackFacing()), + getBaseMetaTileEntity().getBackFacing(), + getBaseMetaTileEntity().getFrontFacing(), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1) + * 10, + true); + } + } + } + + private boolean isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(ItemStack aStack) { + if (aStack == null) return true; + for (byte i = 19; i < 28; i++) { + if (mInventory[i] != null) { + if (GT_Utility.areStacksEqual(mInventory[i], aStack)) return true; + if (GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(mInventory[i], true), aStack)) + return true; + } + } + return false; + } + + private ArrayList recipeContent(ItemStack[] tRecipe) { + ArrayList tList = new ArrayList(); + for (byte i = 0; i < 9; i++) { + if (tRecipe[i] != null) { + boolean temp = false; + for (byte j = 0; j < tList.size(); j++) { + if (GT_Utility.areStacksEqual(tRecipe[i], tList.get(j))) { + tList.get(j).stackSize++; + temp = true; + break; + } + } + if (!temp) tList.add(GT_Utility.copy(1, tRecipe[i])); + } + } + return tList; + } + + private ArrayList benchContent() { + ArrayList tList = new ArrayList(); + for (byte i = 0; i < 18; i++) { + if (mInventory[i] != null) { + boolean temp = false; + for (byte j = 0; j < tList.size(); j++) { + if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j])) { + tList.get(j).stackSize += mInventory[i].stackSize; + temp = true; + break; + } + } + if (!temp) tList.add(GT_Utility.copy(mInventory[i])); + } + } + return tList; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return mMode == 0 ? aIndex >= 10 : aIndex >= 18; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return mMode == 0 ? aIndex < 9 : aIndex < 18; + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) + return 112; + if (GT_Utility.getOppositeSide(aSide) == aFacing) + return 113; + return 114; + }*/ + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public int getTankPressure() { + return -100; + } + + @Override + public String[] getDescription() { + return new String[] { + "Automatic Crafting Table Mk III", + // this.mDescription, + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getBack(i); + rTextures[7][i + 1] = this.getBottom(i); + rTextures[8][i + 1] = this.getTop(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return this.mTextures[0][aColorIndex + 1]; + } else if (GT_Utility.getOppositeSide(aSide) == aFacing) { + return this.mTextures[1][aColorIndex + 1]; + } else { + return this.mTextures[4][aColorIndex + 1]; + } + /*return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1];*/ + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricInventoryManager.java index 732996de71..ebce1fcec6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricInventoryManager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricInventoryManager.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.automation; -import java.util.ArrayList; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -15,437 +13,591 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_Container_ElectricInventoryManager; import gtPlusPlus.xmod.gregtech.api.gui.automation.GT_GUIContainer_ElectricInventoryManager; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; public class GT_MetaTileEntity_ElectricInventoryManager extends GT_MetaTileEntity_TieredMachineBlock { - public int[] mSlotRange = new int[4]; - public boolean mWorkedLastTick = false; - protected String mLocalName; - - public GT_MetaTileEntity_ElectricInventoryManager(final int aID, final int aTier, final String aDescription) { - super(aID, "basicmachine.automation.inventorymanager.0" + aTier, "Electric Inventory Manager (" + GT_Values.VN[aTier] + ")", aTier, 16, aDescription); - mLocalName = "Auto Workbench (" + GT_Values.VN[aTier] + ")"; - } - - public GT_MetaTileEntity_ElectricInventoryManager(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 16, aDescription, aTextures); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_ElectricInventoryManager(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_ElectricInventoryManager(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public long maxEUInput() { - return GT_Values.V[mTier]; - } - - @Override - public long maxEUOutput() { - return GT_Values.V[mTier]; - } - - @Override - public long getMinimumStoredEU() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUStore() { - return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); - } - - @Override - public long maxAmperesIn() { - return 4; - } - - @Override - public long maxAmperesOut() { - return 4; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex < 3; - } - - @Override - public boolean isInputFacing(byte aSide) { - return !isOutputFacing(aSide); - } - - @Override - public boolean isOutputFacing(byte aSide) { - for (int i = 0; i < mSlotRange.length; i++) { - if (aSide == getRangeDirection(i) && getRangeEnergy(i)) { - return true; - } - } - return false; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_ElectricInventoryManager(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mSlotRange0", mSlotRange[0]); - aNBT.setInteger("mSlotRange1", mSlotRange[1]); - aNBT.setInteger("mSlotRange2", mSlotRange[2]); - aNBT.setInteger("mSlotRange3", mSlotRange[3]); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mSlotRange[0] = aNBT.getInteger("mSlotRange0"); - mSlotRange[1] = aNBT.getInteger("mSlotRange1"); - mSlotRange[2] = aNBT.getInteger("mSlotRange2"); - mSlotRange[3] = aNBT.getInteger("mSlotRange3"); - } - - public void iterateRangeDirection(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~7) | (((mSlotRange[aIndex] & 7) + 1) % 6); - } - - public void switchRangeEnergy(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~8) | ((mSlotRange[aIndex] & 8) > 0 ? 0 : 8); - } - - public void iterateSlot1Direction(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~112) | (((((mSlotRange[aIndex] & 112) >> 4) + 1) % 6) << 4); - } - - public void iterateSlot2Direction(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~896) | (((((mSlotRange[aIndex] & 896) >> 7) + 1) % 6) << 7); - } - - public void iterateSlot3Direction(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~7168) | (((((mSlotRange[aIndex] & 7168) >> 10) + 1) % 6) << 10); - } - - public void switchSlot1InOut(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~8192) | ((mSlotRange[aIndex] & 8192) > 0 ? 0 : 8192); - } - - public void switchSlot2InOut(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~16384) | ((mSlotRange[aIndex] & 16384) > 0 ? 0 : 16384); - } - - public void switchSlot3InOut(int aIndex) { - mSlotRange[aIndex] = (mSlotRange[aIndex] & ~32768) | ((mSlotRange[aIndex] & 32768) > 0 ? 0 : 32768); - } - - public byte getRangeDirection(int aIndex) { - return (byte) (mSlotRange[aIndex] & 7); - } - - public byte getSlot1Direction(int aIndex) { - return (byte) ((mSlotRange[aIndex] & 112) >> 4); - } - - public byte getSlot2Direction(int aIndex) { - return (byte) ((mSlotRange[aIndex] & 896) >> 7); - } - - public byte getSlot3Direction(int aIndex) { - return (byte) ((mSlotRange[aIndex] & 7168) >> 10); - } - - public boolean getRangeEnergy(int aIndex) { - return (mSlotRange[aIndex] & 8) > 0; - } - - public boolean getSlot1InOut(int aIndex) { - return (mSlotRange[aIndex] & 8192) > 0; - } - - public boolean getSlot2InOut(int aIndex) { - return (mSlotRange[aIndex] & 16384) > 0; - } - - public boolean getSlot3InOut(int aIndex) { - return (mSlotRange[aIndex] & 32768) > 0; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().getUniversalEnergyStored() >= 5000 - && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || getBaseMetaTileEntity().getTimer() % 100 == 0 || mWorkedLastTick || getBaseMetaTileEntity().hasInventoryBeenModified())) { - mWorkedLastTick = false; - - IInventory[] tTileEntities = new IInventory[]{ - getBaseMetaTileEntity().getIInventoryAtSide((byte) 0), getBaseMetaTileEntity().getIInventoryAtSide((byte) 1), getBaseMetaTileEntity().getIInventoryAtSide((byte) 2), - getBaseMetaTileEntity().getIInventoryAtSide((byte) 3), getBaseMetaTileEntity().getIInventoryAtSide((byte) 4), getBaseMetaTileEntity().getIInventoryAtSide((byte) 5), null, null - }; - - int tCost = 0; - - for (int i = 0; i < 4; i++) { - if (tTileEntities[getRangeDirection(i)] != null) { - ArrayList tList = new ArrayList(); - ItemStack tStack; - tList.add(null); - - tStack = mInventory[3 + i * 3 + 0]; - if (tStack == null) { - if (getSlot1InOut(i)) - tCost += 5 - * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot1Direction(i), getSlot1Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - else - tCost += 5 - * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot1Direction(i), getSlot1Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - else { - tList.set(0, tStack); - if (getSlot1InOut(i)) - tCost += 5 - * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot1Direction(i), getSlot1Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); - else - tCost += 5 - * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot1Direction(i), getSlot1Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); - } - - tStack = mInventory[3 + i * 3 + 1]; - if (tStack == null) { - if (getSlot2InOut(i)) - tCost += 5 - * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot2Direction(i), getSlot2Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - else - tCost += 5 - * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot2Direction(i), getSlot2Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - else { - tList.set(0, tStack); - if (getSlot2InOut(i)) - tCost += 5 - * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot2Direction(i), getSlot2Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); - else - tCost += 5 - * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot2Direction(i), getSlot2Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); - } - - tStack = mInventory[3 + i * 3 + 2]; - if (tStack == null) { - if (getSlot3InOut(i)) - tCost += 5 - * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot3Direction(i), getSlot3Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - else - tCost += 5 - * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot3Direction(i), getSlot3Direction(i), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - else { - tList.set(0, tStack); - if (getSlot3InOut(i)) - tCost += 5 - * GT_Utility.moveOneItemStack(getBaseMetaTileEntity(), tTileEntities[getRangeDirection(i)], getSlot3Direction(i), getSlot3Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); - else - tCost += 5 - * GT_Utility.moveOneItemStack(tTileEntities[getRangeDirection(i)], getBaseMetaTileEntity(), getSlot3Direction(i), getSlot3Direction(i), tList, false, (byte) tStack.stackSize, (byte) 1, (byte) 64, (byte) 1); - } - } - } - - if (tCost > 0) { - mWorkedLastTick = true; - getBaseMetaTileEntity().decreaseStoredEnergyUnits(tCost, true); - } - } - } - - @Override - public String[] getDescription() { - return new String[]{ - "It's simpler than you think. I promise.", this.mDescription, CORE.GT_Tooltip - }; - } - - /*@Override - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { - switch (aSide) { - case 0: return 113 + (aRedstone?8:0); - case 1: return 112 + (aRedstone?8:0); - case 2: return 116 + (aRedstone?8:0); - case 3: return 213 + (aRedstone?8:0); - case 4: return 212 + (aRedstone?8:0); - case 5: return 117 + (aRedstone?8:0); - } - return 0; - }*/ - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[16][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getBottom(i); - rTextures[1][i + 1] = this.getTop(i); - rTextures[2][i + 1] = this.getNegativeZ(i); - rTextures[3][i + 1] = this.getPositiveZ(i); - rTextures[4][i + 1] = this.getNegativeX(i); - rTextures[5][i + 1] = this.getPositiveX(i); - rTextures[6][i + 1] = this.getBottomRedstone(i); - rTextures[7][i + 1] = this.getTopRedstone(i); - rTextures[8][i + 1] = this.getNegativeZRedstone(i); - rTextures[9][i + 1] = this.getPositiveZRedstone(i); - rTextures[10][i + 1] = this.getNegativeXRedstone(i); - rTextures[11][i + 1] = this.getPositiveXRedstone(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[!aRedstone ? aSide : aSide + 6][aColorIndex < 0 ? 0 : aColorIndex]; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red) - }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Green) - }; - } - - public ITexture[] getNegativeZ(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Blue) - }; - } - - public ITexture[] getPositiveZ(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Cyan) - }; - } - - public ITexture[] getNegativeX(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Purple) - }; - } - - public ITexture[] getPositiveX(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Yellow) - }; - } - - public ITexture[] getBottomRedstone(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone) - }; - } - - public ITexture[] getTopRedstone(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Green_Redstone) - }; - } - - public ITexture[] getNegativeZRedstone(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Blue_Redstone) - }; - } - - public ITexture[] getPositiveZRedstone(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Cyan_Redstone) - }; - } - - public ITexture[] getNegativeXRedstone(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Purple_Redstone) - }; - } - - public ITexture[] getPositiveXRedstone(final byte aColor) { - return new ITexture[]{ - Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Yellow_Redstone) - }; - } - + public int[] mSlotRange = new int[4]; + public boolean mWorkedLastTick = false; + protected String mLocalName; + + public GT_MetaTileEntity_ElectricInventoryManager(final int aID, final int aTier, final String aDescription) { + super( + aID, + "basicmachine.automation.inventorymanager.0" + aTier, + "Electric Inventory Manager (" + GT_Values.VN[aTier] + ")", + aTier, + 16, + aDescription); + mLocalName = "Auto Workbench (" + GT_Values.VN[aTier] + ")"; + } + + public GT_MetaTileEntity_ElectricInventoryManager( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_ElectricInventoryManager(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_ElectricInventoryManager(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public long maxEUInput() { + return GT_Values.V[mTier]; + } + + @Override + public long maxEUOutput() { + return GT_Values.V[mTier]; + } + + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public long maxAmperesOut() { + return 4; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 3; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(byte aSide) { + for (int i = 0; i < mSlotRange.length; i++) { + if (aSide == getRangeDirection(i) && getRangeEnergy(i)) { + return true; + } + } + return false; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ElectricInventoryManager( + this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mSlotRange0", mSlotRange[0]); + aNBT.setInteger("mSlotRange1", mSlotRange[1]); + aNBT.setInteger("mSlotRange2", mSlotRange[2]); + aNBT.setInteger("mSlotRange3", mSlotRange[3]); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mSlotRange[0] = aNBT.getInteger("mSlotRange0"); + mSlotRange[1] = aNBT.getInteger("mSlotRange1"); + mSlotRange[2] = aNBT.getInteger("mSlotRange2"); + mSlotRange[3] = aNBT.getInteger("mSlotRange3"); + } + + public void iterateRangeDirection(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~7) | (((mSlotRange[aIndex] & 7) + 1) % 6); + } + + public void switchRangeEnergy(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~8) | ((mSlotRange[aIndex] & 8) > 0 ? 0 : 8); + } + + public void iterateSlot1Direction(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~112) | (((((mSlotRange[aIndex] & 112) >> 4) + 1) % 6) << 4); + } + + public void iterateSlot2Direction(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~896) | (((((mSlotRange[aIndex] & 896) >> 7) + 1) % 6) << 7); + } + + public void iterateSlot3Direction(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~7168) | (((((mSlotRange[aIndex] & 7168) >> 10) + 1) % 6) << 10); + } + + public void switchSlot1InOut(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~8192) | ((mSlotRange[aIndex] & 8192) > 0 ? 0 : 8192); + } + + public void switchSlot2InOut(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~16384) | ((mSlotRange[aIndex] & 16384) > 0 ? 0 : 16384); + } + + public void switchSlot3InOut(int aIndex) { + mSlotRange[aIndex] = (mSlotRange[aIndex] & ~32768) | ((mSlotRange[aIndex] & 32768) > 0 ? 0 : 32768); + } + + public byte getRangeDirection(int aIndex) { + return (byte) (mSlotRange[aIndex] & 7); + } + + public byte getSlot1Direction(int aIndex) { + return (byte) ((mSlotRange[aIndex] & 112) >> 4); + } + + public byte getSlot2Direction(int aIndex) { + return (byte) ((mSlotRange[aIndex] & 896) >> 7); + } + + public byte getSlot3Direction(int aIndex) { + return (byte) ((mSlotRange[aIndex] & 7168) >> 10); + } + + public boolean getRangeEnergy(int aIndex) { + return (mSlotRange[aIndex] & 8) > 0; + } + + public boolean getSlot1InOut(int aIndex) { + return (mSlotRange[aIndex] & 8192) > 0; + } + + public boolean getSlot2InOut(int aIndex) { + return (mSlotRange[aIndex] & 16384) > 0; + } + + public boolean getSlot3InOut(int aIndex) { + return (mSlotRange[aIndex] & 32768) > 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() + && getBaseMetaTileEntity().isServerSide() + && getBaseMetaTileEntity().getUniversalEnergyStored() >= 5000 + && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() + || getBaseMetaTileEntity().getTimer() % 100 == 0 + || mWorkedLastTick + || getBaseMetaTileEntity().hasInventoryBeenModified())) { + mWorkedLastTick = false; + + IInventory[] tTileEntities = new IInventory[] { + getBaseMetaTileEntity().getIInventoryAtSide((byte) 0), + getBaseMetaTileEntity().getIInventoryAtSide((byte) 1), + getBaseMetaTileEntity().getIInventoryAtSide((byte) 2), + getBaseMetaTileEntity().getIInventoryAtSide((byte) 3), + getBaseMetaTileEntity().getIInventoryAtSide((byte) 4), + getBaseMetaTileEntity().getIInventoryAtSide((byte) 5), + null, + null + }; + + int tCost = 0; + + for (int i = 0; i < 4; i++) { + if (tTileEntities[getRangeDirection(i)] != null) { + ArrayList tList = new ArrayList(); + ItemStack tStack; + tList.add(null); + + tStack = mInventory[3 + i * 3 + 0]; + if (tStack == null) { + if (getSlot1InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack( + getBaseMetaTileEntity(), + tTileEntities[getRangeDirection(i)], + getSlot1Direction(i), + getSlot1Direction(i), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack( + tTileEntities[getRangeDirection(i)], + getBaseMetaTileEntity(), + getSlot1Direction(i), + getSlot1Direction(i), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } else { + tList.set(0, tStack); + if (getSlot1InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack( + getBaseMetaTileEntity(), + tTileEntities[getRangeDirection(i)], + getSlot1Direction(i), + getSlot1Direction(i), + tList, + false, + (byte) tStack.stackSize, + (byte) 1, + (byte) 64, + (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack( + tTileEntities[getRangeDirection(i)], + getBaseMetaTileEntity(), + getSlot1Direction(i), + getSlot1Direction(i), + tList, + false, + (byte) tStack.stackSize, + (byte) 1, + (byte) 64, + (byte) 1); + } + + tStack = mInventory[3 + i * 3 + 1]; + if (tStack == null) { + if (getSlot2InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack( + getBaseMetaTileEntity(), + tTileEntities[getRangeDirection(i)], + getSlot2Direction(i), + getSlot2Direction(i), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack( + tTileEntities[getRangeDirection(i)], + getBaseMetaTileEntity(), + getSlot2Direction(i), + getSlot2Direction(i), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } else { + tList.set(0, tStack); + if (getSlot2InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack( + getBaseMetaTileEntity(), + tTileEntities[getRangeDirection(i)], + getSlot2Direction(i), + getSlot2Direction(i), + tList, + false, + (byte) tStack.stackSize, + (byte) 1, + (byte) 64, + (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack( + tTileEntities[getRangeDirection(i)], + getBaseMetaTileEntity(), + getSlot2Direction(i), + getSlot2Direction(i), + tList, + false, + (byte) tStack.stackSize, + (byte) 1, + (byte) 64, + (byte) 1); + } + + tStack = mInventory[3 + i * 3 + 2]; + if (tStack == null) { + if (getSlot3InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack( + getBaseMetaTileEntity(), + tTileEntities[getRangeDirection(i)], + getSlot3Direction(i), + getSlot3Direction(i), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack( + tTileEntities[getRangeDirection(i)], + getBaseMetaTileEntity(), + getSlot3Direction(i), + getSlot3Direction(i), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } else { + tList.set(0, tStack); + if (getSlot3InOut(i)) + tCost += 5 + * GT_Utility.moveOneItemStack( + getBaseMetaTileEntity(), + tTileEntities[getRangeDirection(i)], + getSlot3Direction(i), + getSlot3Direction(i), + tList, + false, + (byte) tStack.stackSize, + (byte) 1, + (byte) 64, + (byte) 1); + else + tCost += 5 + * GT_Utility.moveOneItemStack( + tTileEntities[getRangeDirection(i)], + getBaseMetaTileEntity(), + getSlot3Direction(i), + getSlot3Direction(i), + tList, + false, + (byte) tStack.stackSize, + (byte) 1, + (byte) 64, + (byte) 1); + } + } + } + + if (tCost > 0) { + mWorkedLastTick = true; + getBaseMetaTileEntity().decreaseStoredEnergyUnits(tCost, true); + } + } + } + + @Override + public String[] getDescription() { + return new String[] {"It's simpler than you think. I promise.", this.mDescription, CORE.GT_Tooltip}; + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + switch (aSide) { + case 0: return 113 + (aRedstone?8:0); + case 1: return 112 + (aRedstone?8:0); + case 2: return 116 + (aRedstone?8:0); + case 3: return 213 + (aRedstone?8:0); + case 4: return 212 + (aRedstone?8:0); + case 5: return 117 + (aRedstone?8:0); + } + return 0; + }*/ + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[16][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getBottom(i); + rTextures[1][i + 1] = this.getTop(i); + rTextures[2][i + 1] = this.getNegativeZ(i); + rTextures[3][i + 1] = this.getPositiveZ(i); + rTextures[4][i + 1] = this.getNegativeX(i); + rTextures[5][i + 1] = this.getPositiveX(i); + rTextures[6][i + 1] = this.getBottomRedstone(i); + rTextures[7][i + 1] = this.getTopRedstone(i); + rTextures[8][i + 1] = this.getNegativeZRedstone(i); + rTextures[9][i + 1] = this.getPositiveZRedstone(i); + rTextures[10][i + 1] = this.getNegativeXRedstone(i); + rTextures[11][i + 1] = this.getPositiveXRedstone(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[!aRedstone ? aSide : aSide + 6][aColorIndex < 0 ? 0 : aColorIndex]; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Green) + }; + } + + public ITexture[] getNegativeZ(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Blue) + }; + } + + public ITexture[] getPositiveZ(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Cyan) + }; + } + + public ITexture[] getNegativeX(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Purple) + }; + } + + public ITexture[] getPositiveX(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Yellow) + }; + } + + public ITexture[] getBottomRedstone(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone) + }; + } + + public ITexture[] getTopRedstone(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Green_Redstone) + }; + } + + public ITexture[] getNegativeZRedstone(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Blue_Redstone) + }; + } + + public ITexture[] getPositiveZRedstone(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Cyan_Redstone) + }; + } + + public ITexture[] getNegativeXRedstone(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Purple_Redstone) + }; + } + + public ITexture[] getPositiveXRedstone(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Yellow_Redstone) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java index 9c856840b0..b990e3c55e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java @@ -2,17 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.automation; import static gtPlusPlus.core.lib.CORE.*; -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IDigitalChest; @@ -23,708 +12,752 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; +import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; public class GT_MetaTileEntity_TesseractGenerator extends GT_MetaTileEntity_BasicTank { - public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; - public static int TESSERACT_ENERGY_COST = 128; - public byte isWorking = 0; - public int oFrequency = 0; - public int mNeededEnergy = 0; - public int mFrequency = 0; - public UUID mOwner; - - public GT_MetaTileEntity_TesseractGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, 3, ""); - } - - public GT_MetaTileEntity_TesseractGenerator(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final byte aSide) { - return true; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return this.getBaseMetaTileEntity().getEUCapacity() / 2; - } - - @Override - public long maxEUInput() { - return 512; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxEUStore() { - return 512 * 32; - } - - @Override - public long maxSteamStore() { - return this.maxEUStore(); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean ownerControl() { - return true; - } - - @Override - public int getProgresstime() { - return (TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), - this.mFrequency) == this) && (this.isWorking >= 20) ? 999 : 0; - } - - @Override - public int maxProgresstime() { - return 1000; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mFrequency", this.mFrequency); - if (mOwner != null) - aNBT.setString("mOwner", mOwner.toString()); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFrequency = aNBT.getInteger("mFrequency"); - try { - this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); - } - catch (IllegalArgumentException i){ - - } - } - - @Override - public void onConfigLoad(final GT_Config aConfig) { - int J = 1; - if (CORE.GTNH) { - J = 4; - } - TESSERACT_ENERGY_COST = 128*J; - TESSERACT_ENERGY_COST_DIMENSIONAL = 512*J; - } - - @Override - public void onServerStart() { - sTesseractGeneratorOwnershipMap.clear(); - sTesseractTerminalOwnershipMap.clear(); - } - - public void onServerStop() { - sTesseractGeneratorOwnershipMap.clear(); - sTesseractTerminalOwnershipMap.clear(); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, - final byte aSide, final float aX, final float aY, final float aZ) { - - if (this.mOwner == null) { - if (this.getBaseMetaTileEntity().getOwnerName() != null - && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { - if (this.getBaseMetaTileEntity().getOwnerName().toLowerCase() - .equals(aPlayer.getDisplayName().toLowerCase())) { - this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - } - } - - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0: - Logger.WARNING("Freq. -1 | " + this.mFrequency); - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency -= 1; - - break; - case 1: - Logger.WARNING("Freq. +1 | " + this.mFrequency); - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency += 1; - default: - // Utils.LOG_WARNING("Did not click the correct place."); - break; - } - if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this){ - GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); - } - else { - GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); - } - } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0){ - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); - } - } - - return true; - } - - @Override - public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, - final float aZ) { - if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0: - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency -= 64; - break; - case 1: - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency += 64; - break; - case 2: - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency -= 512; - break; - case 3: - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency += 512; - } - if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this){ - GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); - } - else { - GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); - } - } - } else { - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); - } - } - - public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public String[] getInfoData() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) - && ((tTileEntity instanceof IGregTechDeviceInformation)) - && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) { - return ((IGregTechDeviceInformation) tTileEntity).getInfoData(); - } - return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, - (getGeneratorEntity() == this) && (this.isWorking >= 20) ? "Active" : "Inactive" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - public boolean isSendingInformation() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) - && ((tTileEntity instanceof IGregTechDeviceInformation))) { - return ((IGregTechDeviceInformation) tTileEntity).isGivingInformation(); - } - return false; - } - - @Override - public boolean isDigitalChest() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) - && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest) tTileEntity).isDigitalChest(); - } - return false; - } - - @Override - public ItemStack[] getStoredItemData() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) - && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest) tTileEntity).getStoredItemData(); - } - return new ItemStack[] {}; - } - - @Override - public void setItemCount(final int aCount) { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) - && ((tTileEntity instanceof IDigitalChest))) { - ((IDigitalChest) tTileEntity).setItemCount(aCount); - } - } - - @Override - public int getMaxItemCount() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) - && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest) tTileEntity).getMaxItemCount(); - } - return 0; - } - - @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.isItemValidForSlot(aIndex, aStack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return new int[0]; - } - if ((tTileEntity instanceof ISidedInventory)) { - return ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(aSide); - } - final int[] rArray = new int[this.getSizeInventory()]; - for (int i = 0; i < this.getSizeInventory(); i++) { - rArray[i] = i; - } - return rArray; - } - - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - if ((tTileEntity instanceof ISidedInventory)) { - return ((ISidedInventory) tTileEntity).canInsertItem(aIndex, aStack, aSide); - } - return true; - } - - @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - if ((tTileEntity instanceof ISidedInventory)) { - return ((ISidedInventory) tTileEntity).canExtractItem(aIndex, aStack, aSide); - } - return true; - } - - @Override - public int getSizeInventory() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int aIndex) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.getStackInSlot(aIndex); - } - - @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return; - } - tTileEntity.setInventorySlotContents(aIndex, aStack); - } - - @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.decrStackSize(aIndex, aAmount); - } - - @Override - public String getInventoryName() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return ""; - } - return tTileEntity.getInventoryName(); - } - - @Override - public int getInventoryStackLimit() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); - } - - @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.canFill(aSide, aFluid); - } - - @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.canDrain(aSide, aFluid); - } - - @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return new FluidTankInfo[0]; - } - return tTileEntity.getTankInfo(aSide); - } - - @Override - public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.fill(aDirection, aFluid, doFill); - } - - @Override - public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aDirection, maxDrain, doDrain); - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aSide, aFluid, doDrain); - } - - public boolean addEnergyConsumption(final GT_MetaTileEntity_TesseractTerminal aTerminal) { - if (!this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - int J = (aTerminal.getBaseMetaTileEntity().getWorld() == this.getBaseMetaTileEntity().getWorld() - ? TESSERACT_ENERGY_COST : TESSERACT_ENERGY_COST_DIMENSIONAL); - - if (CORE.GTNH) { - J *= 4; - } - - this.mNeededEnergy += J; - - return true; - } - - public boolean isValidTesseractGenerator(final String aOwnerName, final boolean aWorkIrrelevant) { - return (this.getBaseMetaTileEntity() != null) && (!this.getBaseMetaTileEntity().isInvalidTileEntity()) - && (this.getBaseMetaTileEntity().isAllowedToWork()) - && ((aOwnerName == null) || (this.getBaseMetaTileEntity().getOwnerName().equals(aOwnerName))) - && ((aWorkIrrelevant) || (this.isWorking >= 20)); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - // TODO Auto-generated method stub - super.onPreTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - //Utils.LOG_WARNING("Ticking Generator. 0"); - if (this.getBaseMetaTileEntity().isServerSide()) { - //Utils.LOG_WARNING("Ticking Generator."); - // Set owner - if (PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()) != null) { - if (this.mOwner == null) { - Logger.WARNING("Setting Generators Owner. 1"); - this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - } - - if (this.mFrequency != this.oFrequency) { - - Logger.WARNING("mFreq != oFreq"); - - if (getGeneratorEntity() == this) { - getGeneratorEntity(this.oFrequency); - this.getBaseMetaTileEntity().issueBlockUpdate(); - Logger.WARNING("this Gen == oFreq on map - do block update"); - } - Logger.WARNING("mFreq will be set to oFreq"); - this.oFrequency = this.mFrequency; - } - if ((this.getBaseMetaTileEntity().isAllowedToWork()) - && (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false))) { - //Utils.LOG_WARNING("Can Work & Has Energy"); - if ((getGeneratorEntity(Integer.valueOf(this.mFrequency)) == null) - || (!getGeneratorEntity(Integer.valueOf(this.mFrequency)).isValidTesseractGenerator(null, - true))) { - //Utils.LOG_WARNING("storing TE I think to mFreq map?"); - TesseractHelper.setGeneratorOwnershipByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), - this.mFrequency, this); - } - } else { - if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { - Logger.WARNING("this gen == mFreq on map - do block update"); - TesseractHelper.removeGenerator(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); - this.getBaseMetaTileEntity().issueBlockUpdate(); - } - this.isWorking = 0; - } - if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { - //Utils.LOG_WARNING("mFreq == this - do work related things"); - if (this.isWorking < 20) { - this.isWorking = ((byte) (this.isWorking + 1)); - } - if (this.isWorking == 20) { - this.getBaseMetaTileEntity().issueBlockUpdate(); - this.isWorking = ((byte) (this.isWorking + 1)); - } - } else { - this.isWorking = 0; - } - this.mNeededEnergy = 0; - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, - "Generates a Tesseract for the attached Inventory", - "Connect with pipes to insert items", - "Consumes "+TESSERACT_ENERGY_COST+"EU/t for same dimension transfers", - "Consumes "+TESSERACT_ENERGY_COST_DIMENSIONAL+"EU/t for cross dimensional transfers", - CORE.GT_Tooltip}; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @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[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } - : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) }; - } - - // To-Do? - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return false; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity() { - GT_MetaTileEntity_TesseractGenerator thisGenerator = TesseractHelper - .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); - if (thisGenerator != null) { - return thisGenerator; - } - return null; - } - - private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity(int frequency) { - GT_MetaTileEntity_TesseractGenerator thisGenerator = TesseractHelper - .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), frequency); - if (thisGenerator != null) { - return thisGenerator; - } - return null; - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - if (this.getBaseMetaTileEntity().getOwnerName() != null - && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { - this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - Logger.WARNING("Setting Generators Owner. 2"); - } - super.onCreated(aStack, aWorld, aPlayer); - } - - @Override - public void onRemoval() { - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - super.onRemoval(); - } + public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + public static int TESSERACT_ENERGY_COST = 128; + public byte isWorking = 0; + public int oFrequency = 0; + public int mNeededEnergy = 0; + public int mFrequency = 0; + public UUID mOwner; + + public GT_MetaTileEntity_TesseractGenerator( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public GT_MetaTileEntity_TesseractGenerator( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return this.getBaseMetaTileEntity().getEUCapacity() / 2; + } + + @Override + public long maxEUInput() { + return 512; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxEUStore() { + return 512 * 32; + } + + @Override + public long maxSteamStore() { + return this.maxEUStore(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getProgresstime() { + return (TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency) + == this) + && (this.isWorking >= 20) + ? 999 + : 0; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); + if (mOwner != null) aNBT.setString("mOwner", mOwner.toString()); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); + try { + this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); + } catch (IllegalArgumentException i) { + + } + } + + @Override + public void onConfigLoad(final GT_Config aConfig) { + int J = 1; + if (CORE.GTNH) { + J = 4; + } + TESSERACT_ENERGY_COST = 128 * J; + TESSERACT_ENERGY_COST_DIMENSIONAL = 512 * J; + } + + @Override + public void onServerStart() { + sTesseractGeneratorOwnershipMap.clear(); + sTesseractTerminalOwnershipMap.clear(); + } + + public void onServerStop() { + sTesseractGeneratorOwnershipMap.clear(); + sTesseractTerminalOwnershipMap.clear(); + } + + @Override + public boolean onRightclick( + final IGregTechTileEntity aBaseMetaTileEntity, + final EntityPlayer aPlayer, + final byte aSide, + final float aX, + final float aY, + final float aZ) { + + if (this.mOwner == null) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + if (this.getBaseMetaTileEntity() + .getOwnerName() + .toLowerCase() + .equals(aPlayer.getDisplayName().toLowerCase())) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity().getOwnerName()); + } + } + } + + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + Logger.WARNING("Freq. -1 | " + this.mFrequency); + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 1; + + break; + case 1: + Logger.WARNING("Freq. +1 | " + this.mFrequency); + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 1; + default: + // Utils.LOG_WARNING("Did not click the correct place."); + break; + } + if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this) { + GT_Utility.sendChatToPlayer( + aPlayer, "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); + } else { + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); + } + } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0) { + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); + } + } + + return true; + } + + @Override + public void onScrewdriverRightClick( + final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 64; + break; + case 1: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 64; + break; + case 2: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 512; + break; + case 3: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 512; + } + if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this) { + GT_Utility.sendChatToPlayer( + aPlayer, "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); + } else { + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); + } + } + } else { + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); + } + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public String[] getInfoData() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IGregTechDeviceInformation)) + && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) { + return ((IGregTechDeviceInformation) tTileEntity).getInfoData(); + } + return new String[] { + "Tesseract Generator", + "Freqency:", + "" + this.mFrequency, + (getGeneratorEntity() == this) && (this.isWorking >= 20) ? "Active" : "Inactive" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public boolean isSendingInformation() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IGregTechDeviceInformation))) { + return ((IGregTechDeviceInformation) tTileEntity).isGivingInformation(); + } + return false; + } + + @Override + public boolean isDigitalChest() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).isDigitalChest(); + } + return false; + } + + @Override + public ItemStack[] getStoredItemData() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).getStoredItemData(); + } + return new ItemStack[] {}; + } + + @Override + public void setItemCount(final int aCount) { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + ((IDigitalChest) tTileEntity).setItemCount(aCount); + } + } + + @Override + public int getMaxItemCount() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).getMaxItemCount(); + } + return 0; + } + + @Override + public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int aSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(aSide); + } + final int[] rArray = new int[this.getSizeInventory()]; + for (int i = 0; i < this.getSizeInventory(); i++) { + rArray[i] = i; + } + return rArray; + } + + @Override + public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).canInsertItem(aIndex, aStack, aSide); + } + return true; + } + + @Override + public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).canExtractItem(aIndex, aStack, aSide); + } + return true; + } + + @Override + public int getSizeInventory() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int aIndex) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(final int aIndex, final int aAmount) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + public boolean addEnergyConsumption(final GT_MetaTileEntity_TesseractTerminal aTerminal) { + if (!this.getBaseMetaTileEntity().isAllowedToWork()) { + return false; + } + int J = (aTerminal.getBaseMetaTileEntity().getWorld() + == this.getBaseMetaTileEntity().getWorld() + ? TESSERACT_ENERGY_COST + : TESSERACT_ENERGY_COST_DIMENSIONAL); + + if (CORE.GTNH) { + J *= 4; + } + + this.mNeededEnergy += J; + + return true; + } + + public boolean isValidTesseractGenerator(final String aOwnerName, final boolean aWorkIrrelevant) { + return (this.getBaseMetaTileEntity() != null) + && (!this.getBaseMetaTileEntity().isInvalidTileEntity()) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((aOwnerName == null) + || (this.getBaseMetaTileEntity().getOwnerName().equals(aOwnerName))) + && ((aWorkIrrelevant) || (this.isWorking >= 20)); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // TODO Auto-generated method stub + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // Utils.LOG_WARNING("Ticking Generator. 0"); + if (this.getBaseMetaTileEntity().isServerSide()) { + // Utils.LOG_WARNING("Ticking Generator."); + // Set owner + if (PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()) != null) { + if (this.mOwner == null) { + Logger.WARNING("Setting Generators Owner. 1"); + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity().getOwnerName()); + } + } + + if (this.mFrequency != this.oFrequency) { + + Logger.WARNING("mFreq != oFreq"); + + if (getGeneratorEntity() == this) { + getGeneratorEntity(this.oFrequency); + this.getBaseMetaTileEntity().issueBlockUpdate(); + Logger.WARNING("this Gen == oFreq on map - do block update"); + } + Logger.WARNING("mFreq will be set to oFreq"); + this.oFrequency = this.mFrequency; + } + if ((this.getBaseMetaTileEntity().isAllowedToWork()) + && (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false))) { + // Utils.LOG_WARNING("Can Work & Has Energy"); + if ((getGeneratorEntity(Integer.valueOf(this.mFrequency)) == null) + || (!getGeneratorEntity(Integer.valueOf(this.mFrequency)) + .isValidTesseractGenerator(null, true))) { + // Utils.LOG_WARNING("storing TE I think to mFreq map?"); + TesseractHelper.setGeneratorOwnershipByPlayer( + PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency, this); + } + } else { + if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { + Logger.WARNING("this gen == mFreq on map - do block update"); + TesseractHelper.removeGenerator(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); + this.getBaseMetaTileEntity().issueBlockUpdate(); + } + this.isWorking = 0; + } + if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { + // Utils.LOG_WARNING("mFreq == this - do work related things"); + if (this.isWorking < 20) { + this.isWorking = ((byte) (this.isWorking + 1)); + } + if (this.isWorking == 20) { + this.getBaseMetaTileEntity().issueBlockUpdate(); + this.isWorking = ((byte) (this.isWorking + 1)); + } + } else { + this.isWorking = 0; + } + this.mNeededEnergy = 0; + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Generates a Tesseract for the attached Inventory", + "Connect with pipes to insert items", + "Consumes " + TESSERACT_ENERGY_COST + "EU/t for same dimension transfers", + "Consumes " + TESSERACT_ENERGY_COST_DIMENSIONAL + "EU/t for cross dimensional transfers", + CORE.GT_Tooltip + }; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @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[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) + } + : new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(Textures.BlockIcons.VOID) + }; + } + + // To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity() { + GT_MetaTileEntity_TesseractGenerator thisGenerator = + TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); + if (thisGenerator != null) { + return thisGenerator; + } + return null; + } + + private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity(int frequency) { + GT_MetaTileEntity_TesseractGenerator thisGenerator = + TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), frequency); + if (thisGenerator != null) { + return thisGenerator; + } + return null; + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity().getOwnerName()); + Logger.WARNING("Setting Generators Owner. 2"); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public void onRemoval() { + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + super.onRemoval(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java index 088a596410..5d2a9ae009 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java @@ -1,13 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.automation; -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -16,566 +8,605 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; +import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; public class GT_MetaTileEntity_TesseractTerminal extends GT_MetaTileEntity_BasicTank { - public int mFrequency = 0; - public UUID mOwner; - public boolean mDidWork = false; - public static boolean sInterDimensionalTesseractAllowed = true; - private static int TESSERACT_ENERGY_COST = 128; - private static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; - - public GT_MetaTileEntity_TesseractTerminal(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, 3, ""); - } - - public GT_MetaTileEntity_TesseractTerminal(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractTerminal(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return (this.getBaseMetaTileEntity().getEUCapacity() / 100); - } - - @Override - public long maxEUInput() { - return TESSERACT_ENERGY_COST_DIMENSIONAL; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public long maxEUStore() { - return TESSERACT_ENERGY_COST_DIMENSIONAL * 8 * 32; - } - - @Override - public long maxSteamStore() { - return this.maxEUStore(); - } - - @Override - public boolean ownerControl() { - return true; - } - - @Override - public int getProgresstime() { - return this.getTesseract(this.mFrequency, false) != null ? 999 : 0; - } - - @Override - public int maxProgresstime() { - return 1000; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mFrequency", this.mFrequency); - aNBT.setString("mOwner", mOwner.toString()); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFrequency = aNBT.getInteger("mFrequency"); - this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); - } - - @Override - public void onConfigLoad(final GT_Config aConfig) { - sInterDimensionalTesseractAllowed = true; - if (CORE.GTNH) { - TESSERACT_ENERGY_COST = 512; - TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; - } - else { - TESSERACT_ENERGY_COST = 128; - TESSERACT_ENERGY_COST_DIMENSIONAL = 512; - } - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, - final byte aSide, final float aX, final float aY, final float aZ) { - - if (this.mOwner == null) { - if (this.getBaseMetaTileEntity().getOwnerName() != null - && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { - if (this.getBaseMetaTileEntity().getOwnerName().toLowerCase() - .equals(aPlayer.getDisplayName().toLowerCase())) { - this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - } - } - - if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0: - //Utils.LOG_WARNING("Freq. -1 | " + this.mFrequency); - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency -= 1; - break; - case 1: - //Utils.LOG_WARNING("Freq. +1 | " + this.mFrequency); - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency += 1; - default: - // Utils.LOG_WARNING("Did not click the correct place."); - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - break; - } - PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); - if (this.getTesseract(this.mFrequency, false) != null) { - PlayerUtils.messagePlayer(aPlayer, - new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString()); - } - } - } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0){ - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); - } - return true; - } - - @Override - public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, - final float aZ) { - if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0: - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency -= 64; - break; - case 1: - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency += 64; - break; - case 2: - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency -= 512; - break; - case 3: - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - this.mFrequency += 512; - } - GT_Utility.sendChatToPlayer(aPlayer, - "Frequency: " + this.mFrequency - + (this.getTesseract(this.mFrequency, false) == null ? "" - : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)") - .toString())); - } - } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0){ - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); - } - } - - public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - public GT_MetaTileEntity_TesseractGenerator getTesseract(final int aFrequency, final boolean aWorkIrrelevant) { - final GT_MetaTileEntity_TesseractGenerator rTesseract = TesseractHelper - .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), aFrequency); - if (rTesseract == null) { - return null; - } - if (!TesseractHelper.isGeneratorOwnedByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), rTesseract)) { - return null; - } - if (rTesseract.mFrequency != aFrequency) { - TesseractHelper.setTerminalOwnershipByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), - Integer.valueOf(aFrequency), null); - return null; - } - if (!rTesseract.isValidTesseractGenerator(this.getBaseMetaTileEntity().getOwnerName(), aWorkIrrelevant)) { - return null; - } - if ((!sInterDimensionalTesseractAllowed) - && (rTesseract.getBaseMetaTileEntity().getWorld() != this.getBaseMetaTileEntity().getWorld())) { - return null; - } - return rTesseract; - } - - @Override - public String[] getInfoData() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) - && (tTileEntity.isSendingInformation())) { - return tTileEntity.getInfoData(); - } - return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, - this.getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean isDigitalChest() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.isDigitalChest(); - } - - @Override - public ItemStack[] getStoredItemData() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.getStoredItemData(); - } - - @Override - public void setItemCount(final int aCount) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return; - } - tTileEntity.setItemCount(aCount); - } - - @Override - public int getMaxItemCount() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getMaxItemCount(); - } - - @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.isItemValidForSlot(aIndex, aStack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return new int[0]; - } - return tTileEntity.getAccessibleSlotsFromSide(aSide); - } - - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.canInsertItem(aIndex, aStack, aSide); - } - - @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.canExtractItem(aIndex, aStack, aSide); - } - - @Override - public int getSizeInventory() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int aIndex) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.getStackInSlot(aIndex); - } - - @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return; - } - tTileEntity.setInventorySlotContents(aIndex, aStack); - } - - @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.decrStackSize(aIndex, aAmount); - } - - @Override - public String getInventoryName() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return ""; - } - return tTileEntity.getInventoryName(); - } - - @Override - public int getInventoryStackLimit() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); - } - - @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.canFill(aSide, aFluid); - } - - @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.canDrain(aSide, aFluid); - } - - @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return new FluidTankInfo[0]; - } - return tTileEntity.getTankInfo(aSide); - } - - @Override - public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.fill(aDirection, aFluid, doFill); - } - - @Override - public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aDirection, maxDrain, doDrain); - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aSide, aFluid, doDrain); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if ((this.getBaseMetaTileEntity().isServerSide()) && (this.getBaseMetaTileEntity().isAllowedToWork())) { - // Set owner - if (PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()) != null) { - if (this.mOwner == null) { - this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - } - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, true); - if (tTileEntity != null) { - tTileEntity.addEnergyConsumption(this); - if ((!this.mDidWork) && (this.getTesseract(this.mFrequency, false) != null)) { - this.mDidWork = true; - this.getBaseMetaTileEntity().issueBlockUpdate(); - this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(128, false); - } - } else if (this.mDidWork == true) { - this.mDidWork = false; - this.getBaseMetaTileEntity().issueBlockUpdate(); - } - } - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, - "Accesses Tesseract Generators remotely", - "Connect with pipes to extract items or fluids", - "Outputs from the back face", - "Consumes "+TESSERACT_ENERGY_COST+"EU/t for same dimension transfers", - "Consumes "+TESSERACT_ENERGY_COST_DIMENSIONAL+"EU/t for cross dimensional transfers", - CORE.GT_Tooltip}; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @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[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } - : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) }; - } - - // To-Do? - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return false; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - if (this.getBaseMetaTileEntity().getOwnerName() != null - && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { - this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - super.onCreated(aStack, aWorld, aPlayer); - } - - @Override - public void onRemoval() { - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); - } catch (Throwable t) { - } - super.onRemoval(); - } - + public int mFrequency = 0; + public UUID mOwner; + public boolean mDidWork = false; + public static boolean sInterDimensionalTesseractAllowed = true; + private static int TESSERACT_ENERGY_COST = 128; + private static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + + public GT_MetaTileEntity_TesseractTerminal( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public GT_MetaTileEntity_TesseractTerminal( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractTerminal(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return (this.getBaseMetaTileEntity().getEUCapacity() / 100); + } + + @Override + public long maxEUInput() { + return TESSERACT_ENERGY_COST_DIMENSIONAL; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUStore() { + return TESSERACT_ENERGY_COST_DIMENSIONAL * 8 * 32; + } + + @Override + public long maxSteamStore() { + return this.maxEUStore(); + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getProgresstime() { + return this.getTesseract(this.mFrequency, false) != null ? 999 : 0; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); + aNBT.setString("mOwner", mOwner.toString()); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); + this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); + } + + @Override + public void onConfigLoad(final GT_Config aConfig) { + sInterDimensionalTesseractAllowed = true; + if (CORE.GTNH) { + TESSERACT_ENERGY_COST = 512; + TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + } else { + TESSERACT_ENERGY_COST = 128; + TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + } + } + + @Override + public boolean onRightclick( + final IGregTechTileEntity aBaseMetaTileEntity, + final EntityPlayer aPlayer, + final byte aSide, + final float aX, + final float aY, + final float aZ) { + + if (this.mOwner == null) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + if (this.getBaseMetaTileEntity() + .getOwnerName() + .toLowerCase() + .equals(aPlayer.getDisplayName().toLowerCase())) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity().getOwnerName()); + } + } + } + + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + // Utils.LOG_WARNING("Freq. -1 | " + this.mFrequency); + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 1; + break; + case 1: + // Utils.LOG_WARNING("Freq. +1 | " + this.mFrequency); + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 1; + default: + // Utils.LOG_WARNING("Did not click the correct place."); + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + break; + } + PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + if (this.getTesseract(this.mFrequency, false) != null) { + PlayerUtils.messagePlayer( + aPlayer, + new StringBuilder() + .append(EnumChatFormatting.GREEN) + .append(" (Connected)") + .toString()); + } + } + } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0) { + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); + } + return true; + } + + @Override + public void onScrewdriverRightClick( + final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 64; + break; + case 1: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 64; + break; + case 2: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 512; + break; + case 3: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 512; + } + GT_Utility.sendChatToPlayer( + aPlayer, + "Frequency: " + this.mFrequency + + (this.getTesseract(this.mFrequency, false) == null + ? "" + : new StringBuilder() + .append(EnumChatFormatting.GREEN) + .append(" (Connected)") + .toString())); + } + } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0) { + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); + } + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + public GT_MetaTileEntity_TesseractGenerator getTesseract(final int aFrequency, final boolean aWorkIrrelevant) { + final GT_MetaTileEntity_TesseractGenerator rTesseract = + TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), aFrequency); + if (rTesseract == null) { + return null; + } + if (!TesseractHelper.isGeneratorOwnedByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), rTesseract)) { + return null; + } + if (rTesseract.mFrequency != aFrequency) { + TesseractHelper.setTerminalOwnershipByPlayer( + PlayerUtils.getPlayerOnServerFromUUID(mOwner), Integer.valueOf(aFrequency), null); + return null; + } + if (!rTesseract.isValidTesseractGenerator(this.getBaseMetaTileEntity().getOwnerName(), aWorkIrrelevant)) { + return null; + } + if ((!sInterDimensionalTesseractAllowed) + && (rTesseract.getBaseMetaTileEntity().getWorld() + != this.getBaseMetaTileEntity().getWorld())) { + return null; + } + return rTesseract; + } + + @Override + public String[] getInfoData() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity != null) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && (tTileEntity.isSendingInformation())) { + return tTileEntity.getInfoData(); + } + return new String[] { + "Tesseract Generator", + "Freqency:", + "" + this.mFrequency, + this.getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isDigitalChest() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isDigitalChest(); + } + + @Override + public ItemStack[] getStoredItemData() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStoredItemData(); + } + + @Override + public void setItemCount(final int aCount) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setItemCount(aCount); + } + + @Override + public int getMaxItemCount() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getMaxItemCount(); + } + + @Override + public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; + } + return tTileEntity.getAccessibleSlotsFromSide(aSide); + } + + @Override + public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canInsertItem(aIndex, aStack, aSide); + } + + @Override + public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canExtractItem(aIndex, aStack, aSide); + } + + @Override + public int getSizeInventory() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int aIndex) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(final int aIndex, final int aAmount) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((this.getBaseMetaTileEntity().isServerSide()) + && (this.getBaseMetaTileEntity().isAllowedToWork())) { + // Set owner + if (PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()) != null) { + if (this.mOwner == null) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity().getOwnerName()); + } + } + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, true); + if (tTileEntity != null) { + tTileEntity.addEnergyConsumption(this); + if ((!this.mDidWork) && (this.getTesseract(this.mFrequency, false) != null)) { + this.mDidWork = true; + this.getBaseMetaTileEntity().issueBlockUpdate(); + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(128, false); + } + } else if (this.mDidWork == true) { + this.mDidWork = false; + this.getBaseMetaTileEntity().issueBlockUpdate(); + } + } + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Accesses Tesseract Generators remotely", + "Connect with pipes to extract items or fluids", + "Outputs from the back face", + "Consumes " + TESSERACT_ENERGY_COST + "EU/t for same dimension transfers", + "Consumes " + TESSERACT_ENERGY_COST_DIMENSIONAL + "EU/t for cross dimensional transfers", + CORE.GT_Tooltip + }; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @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[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) + } + : new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(Textures.BlockIcons.VOID) + }; + } + + // To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity().getOwnerName()); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public void onRemoval() { + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + super.onRemoval(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java index 4173489be6..5bd16c7fb2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java @@ -23,274 +23,287 @@ import net.minecraftforge.fluids.FluidTankInfo; public class GT_MetaTileEntity_Boiler_Base extends GT_MetaTileEntity_Boiler { - private final int steamPerSecond; - private final int tier; - - public GT_MetaTileEntity_Boiler_Base(int aID, String aNameRegional, int tier) { - super(aID, "electricboiler." + tier + ".tier.single", aNameRegional, - "Produces " + (CORE.ConfigSwitches.boilerSteamPerSecond * tier) + "L of Steam per second"); - this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * tier); - this.tier = tier; - } - - public GT_MetaTileEntity_Boiler_Base(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * aTier); - this.tier = aTier; - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Produces " + getPollution() + " pollution/sec", - "Consumes fuel only when temperature is less than 100C", - "Fuel with burn time greater than 500 is more efficient.", - "Doesn't explode if there's no water", - CORE.GT_Tooltip - }; - } - - public ITexture getOverlayIcon() { - return new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - protected GT_RenderedTexture getCasingTexture() { - if (this.tier == 1) { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); - } else if (this.tier == 2) { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); - } else { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); - } - // return new - // GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex - + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], - this.getCasingTexture() }; - } - - public ITexture[] getBack(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getBottom(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getTop(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], - this.getCasingTexture() }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean isFacingValid(final byte aSide) { - return aSide > 1; - } - - // Please find out what I do. - // I do stuff within the GUI. - // this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); - @Override - public int maxProgresstime() { - return 1000 + (250 * tier); - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public int getCapacity() { - return (16000 + (16000 * tier)); - } - - // This type of machine can have different water and steam capacities. - public int getSteamCapacity() { - return 2 * getCapacity(); - } - - @Override - protected int getProductionPerSecond() { - return steamPerSecond; - } - - @Override - protected int getMaxTemperature() { - return maxProgresstime(); - } - - @Override - protected int getEnergyConsumption() { - return 2; - } - - @Override - protected int getCooldownInterval() { - return 40; - } - - @Override - protected int getHeatUpRate() { - return 10; - } - - @Override - protected void updateFuel(IGregTechTileEntity tile, long ticks) { - ItemStack fuelStack = this.mInventory[2]; - if(fuelStack == null) return; - - int burnTime = getBurnTime(fuelStack); - if (burnTime > 0 && this.mTemperature <= 101) { - consumeFuel(tile, fuelStack, burnTime); - } - } - - @Override - protected void produceSteam(int aAmount) { - super.produceSteam(aAmount); - - if(mSteam.amount > getSteamCapacity()) { - sendSound(SOUND_EVENT_LET_OFF_EXCESS_STEAM); - - mSteam.amount = getSteamCapacity(); - } - } - - @Override - // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to - // support returning those different capacities. - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - return new FluidTankInfo[]{ - new FluidTankInfo(this.mFluid, getCapacity()), - new FluidTankInfo(this.mSteam, getSteamCapacity()) - }; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 1 || aIndex == 3; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 2; - } - - @Override - protected int getPollution() { - return (int) (CORE.ConfigSwitches.basePollutionPerSecondBoiler*CORE.ConfigSwitches.pollutionReleasedByTierBoiler[this.tier]); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity, "AdvancedBoiler.png"); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_Base(this.mName, tier, this.mDescription, this.mTextures); - } - - @Override - protected void onDangerousWaterLack(IGregTechTileEntity tile, long ticks) { - // Smart boilers don't explode! - } - - /** - * Returns burn time if the stack is a valid fuel, otherwise return 0. - */ - private static int getBurnTime(ItemStack stack) { - int burnTime = GameRegistry.getFuelValue(stack); - if (burnTime <= 0) { - burnTime = TileEntityFurnace.getItemBurnTime(stack); - } - - return burnTime; - } - - public void consumeFuel(IGregTechTileEntity tile, ItemStack fuel, int burnTime) { - this.mProcessingEnergy += burnTime / 10; - this.mTemperature += burnTime / 500; // will add bonus temperature points if the burn time is pretty high - - tile.decrStackSize(2, 1); - if (tile.getRandomNumber(3) == 0) { - if (fuel.getDisplayName().toLowerCase().contains("charcoal") - || fuel.getDisplayName().toLowerCase().contains("coke")) { - tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } else { - tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { - if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { - return true; - } - return super.allowCoverOnSide(aSide, aCover); - } + private final int steamPerSecond; + private final int tier; + + public GT_MetaTileEntity_Boiler_Base(int aID, String aNameRegional, int tier) { + super( + aID, + "electricboiler." + tier + ".tier.single", + aNameRegional, + "Produces " + (CORE.ConfigSwitches.boilerSteamPerSecond * tier) + "L of Steam per second"); + this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * tier); + this.tier = tier; + } + + public GT_MetaTileEntity_Boiler_Base(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * aTier); + this.tier = aTier; + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Produces " + getPollution() + " pollution/sec", + "Consumes fuel only when temperature is less than 100C", + "Fuel with burn time greater than 500 is more efficient.", + "Doesn't explode if there's no water", + CORE.GT_Tooltip + }; + } + + public ITexture getOverlayIcon() { + return new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + protected GT_RenderedTexture getCasingTexture() { + if (this.tier == 1) { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); + } else if (this.tier == 2) { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); + } else { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); + } + // return new + // GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], this.getCasingTexture()}; + } + + public ITexture[] getBack(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getBottom(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getTop(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], this.getCasingTexture()}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + // Please find out what I do. + // I do stuff within the GUI. + // this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler) + // this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + @Override + public int maxProgresstime() { + return 1000 + (250 * tier); + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public int getCapacity() { + return (16000 + (16000 * tier)); + } + + // This type of machine can have different water and steam capacities. + public int getSteamCapacity() { + return 2 * getCapacity(); + } + + @Override + protected int getProductionPerSecond() { + return steamPerSecond; + } + + @Override + protected int getMaxTemperature() { + return maxProgresstime(); + } + + @Override + protected int getEnergyConsumption() { + return 2; + } + + @Override + protected int getCooldownInterval() { + return 40; + } + + @Override + protected int getHeatUpRate() { + return 10; + } + + @Override + protected void updateFuel(IGregTechTileEntity tile, long ticks) { + ItemStack fuelStack = this.mInventory[2]; + if (fuelStack == null) return; + + int burnTime = getBurnTime(fuelStack); + if (burnTime > 0 && this.mTemperature <= 101) { + consumeFuel(tile, fuelStack, burnTime); + } + } + + @Override + protected void produceSteam(int aAmount) { + super.produceSteam(aAmount); + + if (mSteam.amount > getSteamCapacity()) { + sendSound(SOUND_EVENT_LET_OFF_EXCESS_STEAM); + + mSteam.amount = getSteamCapacity(); + } + } + + @Override + // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to + // support returning those different capacities. + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + return new FluidTankInfo[] { + new FluidTankInfo(this.mFluid, getCapacity()), new FluidTankInfo(this.mSteam, getSteamCapacity()) + }; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 1 || aIndex == 3; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 2; + } + + @Override + protected int getPollution() { + return (int) (CORE.ConfigSwitches.basePollutionPerSecondBoiler + * CORE.ConfigSwitches.pollutionReleasedByTierBoiler[this.tier]); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity, "AdvancedBoiler.png"); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Base(this.mName, tier, this.mDescription, this.mTextures); + } + + @Override + protected void onDangerousWaterLack(IGregTechTileEntity tile, long ticks) { + // Smart boilers don't explode! + } + + /** + * Returns burn time if the stack is a valid fuel, otherwise return 0. + */ + private static int getBurnTime(ItemStack stack) { + int burnTime = GameRegistry.getFuelValue(stack); + if (burnTime <= 0) { + burnTime = TileEntityFurnace.getItemBurnTime(stack); + } + + return burnTime; + } + + public void consumeFuel(IGregTechTileEntity tile, ItemStack fuel, int burnTime) { + this.mProcessingEnergy += burnTime / 10; + this.mTemperature += burnTime / 500; // will add bonus temperature points if the burn time is pretty high + + tile.decrStackSize(2, 1); + if (tile.getRandomNumber(3) == 0) { + if (fuel.getDisplayName().toLowerCase().contains("charcoal") + || fuel.getDisplayName().toLowerCase().contains("coke")) { + tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } else { + tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { + if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(aSide, aCover); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java index dfbd254897..867623f692 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java @@ -5,52 +5,55 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -public class GT_MetaTileEntity_Boiler_HV - extends GT_MetaTileEntity_Boiler_Base { - +public class GT_MetaTileEntity_Boiler_HV extends GT_MetaTileEntity_Boiler_Base { + public GT_MetaTileEntity_Boiler_HV(int aID, String aNameRegional, int aBoilerTier) { - super(aID, aNameRegional, aBoilerTier); + super(aID, aNameRegional, aBoilerTier); } - + public GT_MetaTileEntity_Boiler_HV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_Boiler_HV(this.mName, 3, this.mDescription, this.mTextures); } - - + + @Override + protected GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) + }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Talonite) + }; + } + @Override - protected GT_RenderedTexture getCasingTexture(){ - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); - } - - + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) + }; + } + @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT)}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Talonite)}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE)}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return getTop(aColor); - } - - - -} \ No newline at end of file + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java index e2b9046c68..6aeedaa6f3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java @@ -5,48 +5,55 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -public class GT_MetaTileEntity_Boiler_LV -extends GT_MetaTileEntity_Boiler_Base { - - public GT_MetaTileEntity_Boiler_LV(int aID, String aNameRegional, int aBoilerTier) { - super(aID, aNameRegional, aBoilerTier); - } - - public GT_MetaTileEntity_Boiler_LV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_LV(this.mName, 1, this.mDescription, this.mTextures); - } - - - @Override - protected GT_RenderedTexture getCasingTexture(){ - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT)}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Potin)}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE)}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return getTop(aColor); - } -} \ No newline at end of file +public class GT_MetaTileEntity_Boiler_LV extends GT_MetaTileEntity_Boiler_Base { + + public GT_MetaTileEntity_Boiler_LV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public GT_MetaTileEntity_Boiler_LV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_LV(this.mName, 1, this.mDescription, this.mTextures); + } + + @Override + protected GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) + }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Potin) + }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) + }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java index 7ef781da17..9f329f92da 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java @@ -5,48 +5,55 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -public class GT_MetaTileEntity_Boiler_MV -extends GT_MetaTileEntity_Boiler_Base { - - public GT_MetaTileEntity_Boiler_MV(int aID, String aNameRegional, int aBoilerTier) { - super(aID, aNameRegional, aBoilerTier); - } - - public GT_MetaTileEntity_Boiler_MV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_MV(this.mName, 2, this.mDescription, this.mTextures); - } - - @Override - protected GT_RenderedTexture getCasingTexture(){ - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT)}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Tumbaga)}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE)}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return getTop(aColor); - } - -} \ No newline at end of file +public class GT_MetaTileEntity_Boiler_MV extends GT_MetaTileEntity_Boiler_Base { + + public GT_MetaTileEntity_Boiler_MV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public GT_MetaTileEntity_Boiler_MV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_MV(this.mName, 2, this.mDescription, this.mTextures); + } + + @Override + protected GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) + }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Tumbaga) + }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) + }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java index f9cf904cc2..ba6b037d76 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java @@ -1,11 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_AdvancedBoiler; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_AdvancedBoiler; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.enums.Dyes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -13,182 +7,214 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; -import gregtech.common.gui.GT_Container_Boiler; -import gregtech.common.gui.GT_GUIContainer_Boiler; import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; - +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_AdvancedBoiler; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_AdvancedBoiler; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -public class GT_MetaTileEntity_Boiler_Solar -extends GT_MetaTileEntity_Boiler { - public GT_MetaTileEntity_Boiler_Solar(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, "Steam Power by the Sun"); - } - - public GT_MetaTileEntity_Boiler_Solar(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Produces "+(this.getPollution()*20)+" pollution/sec", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[4][17][]; - for (byte i = -1; i < 16; i = (byte) (i + 1)) { - final ITexture[] tmp0 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; - rTextures[0][(i + 1)] = tmp0; - final ITexture[] tmp1 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_SOLAR)}; - rTextures[1][(i + 1)] = tmp1; - final ITexture[] tmp2 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; - rTextures[2][(i + 1)] = tmp2; - final ITexture[] tmp3 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; - rTextures[3][(i + 1)] = tmp3; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[aSide >= 2 ? ((byte) (aSide != aFacing ? 2 : 3)) : aSide][aColorIndex + 1]; - } - - @Override - public int maxProgresstime() { - return 500; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png"); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_Solar(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - private int mRunTime = 0; - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mRunTime", this.mRunTime); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mRunTime = aNBT.getInteger("mRunTime"); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { - if (this.mTemperature <= 20) { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 45) { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - if (this.mSteam != null) { - final byte i = aBaseMetaTileEntity.getFrontFacing(); - final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) { - final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) { - final int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - if ((aTick % 25L) == 0L) { - if (this.mTemperature > 100) { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { - this.mHadNoWater = true; - } else { - if (this.mHadNoWater) { - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - this.mRunTime += 1; - int tOutput = 150; - if(this.mRunTime > 10000){ - tOutput = Math.max(50, 150 - ((this.mRunTime-10000)/100)); - } - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(tOutput); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += tOutput; - } else { - this.mSteam = GT_ModHandler.getSteam(tOutput); - } - } - } else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > 16000)) { - this.sendSound((byte) 1); - this.mSteam.amount = 12000; - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 256L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { - final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); - this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; - } - if ((this.mTemperature < 500) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) { - this.mProcessingEnergy -= 1; - this.mTemperature += 1; - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); - } - } - - @Override - protected int getPollution() { - return 0; - } - - @Override - protected int getProductionPerSecond() { - return 0; - } - - @Override - protected int getMaxTemperature() { - return 0; - } - - @Override - protected int getEnergyConsumption() { - return 0; - } - - @Override - protected int getCooldownInterval() { - return 0; - } - - @Override - protected void updateFuel(IGregTechTileEntity iGregTechTileEntity, long l) { - - } +public class GT_MetaTileEntity_Boiler_Solar extends GT_MetaTileEntity_Boiler { + public GT_MetaTileEntity_Boiler_Solar(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, "Steam Power by the Sun"); + } + + public GT_MetaTileEntity_Boiler_Solar( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, "Produces " + (this.getPollution() * 20) + " pollution/sec", CORE.GT_Tooltip + }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[4][17][]; + for (byte i = -1; i < 16; i = (byte) (i + 1)) { + final ITexture[] tmp0 = { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa)) + }; + rTextures[0][(i + 1)] = tmp0; + final ITexture[] tmp1 = { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP, Dyes.getModulation(i, Dyes._NULL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.BOILER_SOLAR) + }; + rTextures[1][(i + 1)] = tmp1; + final ITexture[] tmp2 = { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)) + }; + rTextures[2][(i + 1)] = tmp2; + final ITexture[] tmp3 = { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) + }; + rTextures[3][(i + 1)] = tmp3; + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[aSide >= 2 ? ((byte) (aSide != aFacing ? 2 : 3)) : aSide][aColorIndex + 1]; + } + + @Override + public int maxProgresstime() { + return 500; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png"); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Solar(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + private int mRunTime = 0; + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mRunTime", this.mRunTime); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mRunTime = aNBT.getInteger("mRunTime"); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { + if (this.mTemperature <= 20) { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + if (this.mSteam != null) { + final byte i = aBaseMetaTileEntity.getFrontFacing(); + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) { + final FluidStack tDrained = aBaseMetaTileEntity.drain( + ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) { + final int tFilledAmount = tTileEntity.fill( + ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill( + ForgeDirection.getOrientation(i).getOpposite(), + aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), + true); + } + } + } + } + if ((aTick % 25L) == 0L) { + if (this.mTemperature > 100) { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { + this.mHadNoWater = true; + } else { + if (this.mHadNoWater) { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + this.mRunTime += 1; + int tOutput = 150; + if (this.mRunTime > 10000) { + tOutput = Math.max(50, 150 - ((this.mRunTime - 10000) / 100)); + } + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(tOutput); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += tOutput; + } else { + this.mSteam = GT_ModHandler.getSteam(tOutput); + } + } + } else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && (this.mSteam.amount > 16000)) { + this.sendSound((byte) 1); + this.mSteam.amount = 12000; + } + if ((this.mProcessingEnergy <= 0) + && (aBaseMetaTileEntity.isAllowedToWork()) + && ((aTick % 256L) == 0L) + && (!aBaseMetaTileEntity.getWorld().isThundering())) { + final boolean bRain = + aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); + this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) + || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) + ? 0 + : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + if ((this.mTemperature < 500) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) { + this.mProcessingEnergy -= 1; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + + @Override + protected int getPollution() { + return 0; + } + + @Override + protected int getProductionPerSecond() { + return 0; + } + + @Override + protected int getMaxTemperature() { + return 0; + } + + @Override + protected int getEnergyConsumption() { + return 0; + } + + @Override + protected int getCooldownInterval() { + return 0; + } + + @Override + protected void updateFuel(IGregTechTileEntity iGregTechTileEntity, long l) {} } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_RfConvertor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_RfConvertor.java index c6f368f0c0..340a97fccf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_RfConvertor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_RfConvertor.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; import static gregtech.api.enums.GT_Values.V; -import cofh.api.energy.IEnergyConnection; -import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.IEnergyStorage; @@ -20,7 +18,6 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -41,308 +38,342 @@ import net.minecraftforge.common.util.ForgeDirection; */ public class GT_MetaTileEntity_RfConvertor extends GregtechMetaEnergyBuffer implements IEnergyReceiver { - - public GT_MetaTileEntity_RfConvertor(final String aName, final int aTier, - final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aDescription, aTextures, aSlotCount); - } - - public GT_MetaTileEntity_RfConvertor(final int aID, final String aName, - final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); - } - - @Override - public String[] getDescription() { - return new String[] { - "Use Screwdriver to change voltage", - "Hold Shift while using Screwdriver to change amperage", - EnumChatFormatting.DARK_AQUA+"Variable Output Voltage", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[12][17][]; - GT_RenderedTexture aTex = new GT_RenderedTexture(TexturesGtBlock.Casing_Material_ZirconiumCarbide); - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[1][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[2][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[3][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - rTextures[4][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - rTextures[5][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - rTextures[6][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; - rTextures[7][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; - rTextures[8][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; - rTextures[9][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - rTextures[10][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - rTextures[11][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aActive ? 0 : 6)][aColorIndex + 1]; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RfConvertor(this.mName, this.mTier, this.mDescription, - this.mTextures, this.mInventory.length); - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return Integer.MAX_VALUE; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return V[this.mTier]; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return !isOutputFacing(aSide); - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (!aBaseMetaTileEntity.isActive()) { - aBaseMetaTileEntity.setActive(true); - } - if (this.getEUVar() < this.maxEUStore()) { - for (byte i = 0; i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); i++) { - if (isInputFacing(i)) { - receiveEnergy(ForgeDirection.getOrientation(i), Integer.MAX_VALUE, false); - } - } - } - return; - } - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - String[] infoData = super.getInfoData(); - return new String[] { - infoData[0], - "Converts RF -> GTEU | Tier: "+this.mTier, - infoData[1], - infoData[2] - }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mTier", this.mTier); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mTier = aNBT.getByte("mTier"); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aPlayer.isSneaking()) { - byte aTest = (byte) (aCurrentOutputAmperage + 1); - if (aTest > 16 || aTest <= 0 ) { - aTest = 1; - } - aCurrentOutputAmperage = aTest; - PlayerUtils.messagePlayer(aPlayer, "Now handling "+maxAmperesOut()+" Amps."); - } - else { - if (this.mTier < (CORE.GTNH ? GT_Values.V.length : 9)) { - this.mTier++; - } - else { - this.mTier = 0; - } - PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+"."); - } - - } - - @Override - public boolean canConnectEnergy(ForgeDirection from) { - if (isOutputFacing((byte) from.ordinal())) { - return false; - } - return true; - } - - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - - // Cannot accept power on the output face. - if (!canConnectEnergy(from) || isOutputFacing((byte) from.ordinal())) { - return 0; - } - - TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide((byte) from.ordinal()); - if (tTileEntity == null) { - return 0; - } - - Logger.WARNING("Someone is trying to inject RF from "+from+". Type:"+tTileEntity.getClass().getName()); - - // Calculate maximum RF we need to consume - int aInputRF = MathUtils.safeInt(this.maxEUOutput() * GregTech_API.mEUtoRF / 100); - - // Make sure we only consume the correct amount of RF that is pushed into this Tile. - if (aInputRF > maxReceive) { - aInputRF = maxReceive; - } - - int aInjectedRF = 0; - boolean aVal = false; - - long aStoredEU = this.getEUVar(); - long aMaxEU = this.maxEUStore(); - Logger.WARNING("Stored: "+aStoredEU+", Capacity: "+aMaxEU+""); - if (aStoredEU < aMaxEU) { - Logger.WARNING("StoredEU < MaxEU"); - long aRemainingSpace = aMaxEU - aStoredEU; - if (aRemainingSpace > 0) { - long tEU = 0; - byte aSide = (byte) from.ordinal(); - Logger.WARNING("Free: "+aRemainingSpace+"EU"); - if (tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(aSide)), 1, true) == 1) { - tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(aSide)), (int) maxEUOutput() * 100 / GregTech_API.mRFtoEU, false); - Logger.WARNING("Drained from IEnergyProvider Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); - tEU = tEU * GregTech_API.mRFtoEU / 100; - } - else if (tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { - tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy((int) maxEUOutput() * 100 / GregTech_API.mRFtoEU, false); - Logger.WARNING("Drained from IEnergyStorage Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); - tEU = tEU * GregTech_API.mRFtoEU / 100; - } - else if (GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { - int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored(); - int extractRF = (int) maxEUOutput() * 100 / GregTech_API.mRFtoEU; - tEU = 0; - if (tTileEntity instanceof TileCapBank) { - ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork(); - if (network != null && network.getEnergyStoredL() > 0) { - tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * GregTech_API.mRFtoEU / 100, maxEUOutput()); - Logger.WARNING("Drained from EIO CapBank Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); - network.addEnergy((int) -(tEU * 100 / GregTech_API.mRFtoEU)); - } - } else { - if (storedRF > extractRF) { - ((IPowerContainer) tTileEntity).setEnergyStored(storedRF - extractRF); - tEU = maxEUOutput(); - Logger.WARNING("Drained from EIO Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); - } else { - ((IPowerContainer) tTileEntity).setEnergyStored(0); - tEU = storedRF * GregTech_API.mRFtoEU / 100; - Logger.WARNING("Drained from EIO Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); - } - } - } - Logger.WARNING("EU to inject: "+tEU+"EU"); - if (!simulate) { - aVal = this.getBaseMetaTileEntity().increaseStoredEnergyUnits(tEU, true); - } - if (tEU > 0) { - Logger.WARNING("Tried injecting "+tEU+" eu into self. Success? "+aVal); - } - } - } - return aInjectedRF; - } - - @Override - public int getEnergyStored(ForgeDirection from) { - long aStoredEU = this.getEUVar(); - long aMaxEU = this.maxEUStore(); - if (aStoredEU == 0) { - return 0; - } - if (aStoredEU < aMaxEU) { - long aRemainingSpace = aMaxEU - aStoredEU; - if (aRemainingSpace > 0) { - if (aRemainingSpace > (this.maxEUOutput() / (GregTech_API.mEUtoRF / 100))) { - int aCalculatedFreeSpace = 0; - int aRfPer10Eu = GregTech_API.mEUtoRF / 10; - // Calculate how many lots of '10 - aCalculatedFreeSpace = (int) Math.floor(aRemainingSpace / 10); - // Return value equal to how many lots of '10eu' packets we can fit in. - return Integer.MAX_VALUE - MathUtils.balance(aCalculatedFreeSpace * aRfPer10Eu, 0, Integer.MAX_VALUE); - } - } - } - return Integer.MAX_VALUE; - } - - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return Integer.MAX_VALUE; - } -} \ No newline at end of file + public GT_MetaTileEntity_RfConvertor( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + } + + public GT_MetaTileEntity_RfConvertor( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); + } + + @Override + public String[] getDescription() { + return new String[] { + "Use Screwdriver to change voltage", + "Hold Shift while using Screwdriver to change amperage", + EnumChatFormatting.DARK_AQUA + "Variable Output Voltage", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + GT_RenderedTexture aTex = new GT_RenderedTexture(TexturesGtBlock.Casing_Material_ZirconiumCarbide); + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[1][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[2][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[3][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + rTextures[4][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + rTextures[5][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + rTextures[6][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; + rTextures[7][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; + rTextures[8][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; + rTextures[9][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + rTextures[10][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + rTextures[11][i + 1] = new ITexture[] {aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aActive ? 0 : 6)][aColorIndex + 1]; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RfConvertor( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return Integer.MAX_VALUE; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (!aBaseMetaTileEntity.isActive()) { + aBaseMetaTileEntity.setActive(true); + } + if (this.getEUVar() < this.maxEUStore()) { + for (byte i = 0; + i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); + i++) { + if (isInputFacing(i)) { + receiveEnergy(ForgeDirection.getOrientation(i), Integer.MAX_VALUE, false); + } + } + } + return; + } + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String[] infoData = super.getInfoData(); + return new String[] {infoData[0], "Converts RF -> GTEU | Tier: " + this.mTier, infoData[1], infoData[2]}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mTier", this.mTier); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mTier = aNBT.getByte("mTier"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + byte aTest = (byte) (aCurrentOutputAmperage + 1); + if (aTest > 16 || aTest <= 0) { + aTest = 1; + } + aCurrentOutputAmperage = aTest; + PlayerUtils.messagePlayer(aPlayer, "Now handling " + maxAmperesOut() + " Amps."); + } else { + if (this.mTier < (CORE.GTNH ? GT_Values.V.length : 9)) { + this.mTier++; + } else { + this.mTier = 0; + } + PlayerUtils.messagePlayer(aPlayer, "Now running at " + GT_Values.VOLTAGE_NAMES[this.mTier] + "."); + } + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + if (isOutputFacing((byte) from.ordinal())) { + return false; + } + return true; + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + + // Cannot accept power on the output face. + if (!canConnectEnergy(from) || isOutputFacing((byte) from.ordinal())) { + return 0; + } + + TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide((byte) from.ordinal()); + if (tTileEntity == null) { + return 0; + } + + Logger.WARNING("Someone is trying to inject RF from " + from + ". Type:" + + tTileEntity.getClass().getName()); + + // Calculate maximum RF we need to consume + int aInputRF = MathUtils.safeInt(this.maxEUOutput() * GregTech_API.mEUtoRF / 100); + + // Make sure we only consume the correct amount of RF that is pushed into this Tile. + if (aInputRF > maxReceive) { + aInputRF = maxReceive; + } + + int aInjectedRF = 0; + boolean aVal = false; + + long aStoredEU = this.getEUVar(); + long aMaxEU = this.maxEUStore(); + Logger.WARNING("Stored: " + aStoredEU + ", Capacity: " + aMaxEU + ""); + if (aStoredEU < aMaxEU) { + Logger.WARNING("StoredEU < MaxEU"); + long aRemainingSpace = aMaxEU - aStoredEU; + if (aRemainingSpace > 0) { + long tEU = 0; + byte aSide = (byte) from.ordinal(); + Logger.WARNING("Free: " + aRemainingSpace + "EU"); + if (tTileEntity instanceof IEnergyProvider + && ((IEnergyProvider) tTileEntity) + .extractEnergy( + ForgeDirection.getOrientation(GT_Utility.getOppositeSide(aSide)), + 1, + true) + == 1) { + tEU = (long) ((IEnergyProvider) tTileEntity) + .extractEnergy( + ForgeDirection.getOrientation(GT_Utility.getOppositeSide(aSide)), + (int) maxEUOutput() * 100 / GregTech_API.mRFtoEU, + false); + Logger.WARNING("Drained from IEnergyProvider Tile: " + (tEU * 100 / GregTech_API.mRFtoEU) + ""); + tEU = tEU * GregTech_API.mRFtoEU / 100; + } else if (tTileEntity instanceof IEnergyStorage + && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { + tEU = (long) ((IEnergyStorage) tTileEntity) + .extractEnergy((int) maxEUOutput() * 100 / GregTech_API.mRFtoEU, false); + Logger.WARNING("Drained from IEnergyStorage Tile: " + (tEU * 100 / GregTech_API.mRFtoEU) + ""); + tEU = tEU * GregTech_API.mRFtoEU / 100; + } else if (GregTech_API.meIOLoaded + && tTileEntity instanceof IPowerContainer + && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { + int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored(); + int extractRF = (int) maxEUOutput() * 100 / GregTech_API.mRFtoEU; + tEU = 0; + if (tTileEntity instanceof TileCapBank) { + ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork(); + if (network != null && network.getEnergyStoredL() > 0) { + tEU = Math.min( + (Math.min( + Math.min(network.getEnergyStoredL(), storedRF - extractRF), + network.getMaxOutput())) + * GregTech_API.mRFtoEU + / 100, + maxEUOutput()); + Logger.WARNING("Drained from EIO CapBank Tile: " + (tEU * 100 / GregTech_API.mRFtoEU) + ""); + network.addEnergy((int) -(tEU * 100 / GregTech_API.mRFtoEU)); + } + } else { + if (storedRF > extractRF) { + ((IPowerContainer) tTileEntity).setEnergyStored(storedRF - extractRF); + tEU = maxEUOutput(); + Logger.WARNING("Drained from EIO Tile: " + (tEU * 100 / GregTech_API.mRFtoEU) + ""); + } else { + ((IPowerContainer) tTileEntity).setEnergyStored(0); + tEU = storedRF * GregTech_API.mRFtoEU / 100; + Logger.WARNING("Drained from EIO Tile: " + (tEU * 100 / GregTech_API.mRFtoEU) + ""); + } + } + } + Logger.WARNING("EU to inject: " + tEU + "EU"); + if (!simulate) { + aVal = this.getBaseMetaTileEntity().increaseStoredEnergyUnits(tEU, true); + } + if (tEU > 0) { + Logger.WARNING("Tried injecting " + tEU + " eu into self. Success? " + aVal); + } + } + } + return aInjectedRF; + } + + @Override + public int getEnergyStored(ForgeDirection from) { + long aStoredEU = this.getEUVar(); + long aMaxEU = this.maxEUStore(); + if (aStoredEU == 0) { + return 0; + } + if (aStoredEU < aMaxEU) { + long aRemainingSpace = aMaxEU - aStoredEU; + if (aRemainingSpace > 0) { + if (aRemainingSpace > (this.maxEUOutput() / (GregTech_API.mEUtoRF / 100))) { + int aCalculatedFreeSpace = 0; + int aRfPer10Eu = GregTech_API.mEUtoRF / 10; + // Calculate how many lots of '10 + aCalculatedFreeSpace = (int) Math.floor(aRemainingSpace / 10); + // Return value equal to how many lots of '10eu' packets we can fit in. + return Integer.MAX_VALUE + - MathUtils.balance(aCalculatedFreeSpace * aRfPer10Eu, 0, Integer.MAX_VALUE); + } + } + } + return Integer.MAX_VALUE; + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return Integer.MAX_VALUE; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java index d1628bdb59..7d9ecebf2c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java @@ -11,161 +11,175 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_SemiFluidGenerator extends GT_MetaTileEntity_BasicGenerator { - public int mEfficiency; - - /*public GT_MetaTileEntity_SemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier); - onConfigLoad(); - }*/ - - public GT_MetaTileEntity_SemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, - "Requires semi-fluid Fuel", - new ITexture[0]); - onConfigLoad(); - } - - public GT_MetaTileEntity_SemiFluidGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - public int getPollution() { - return (int) (CORE.ConfigSwitches.basePollutionPerSecondSemiFluidGenerator * CORE.ConfigSwitches.pollutionReleasedByTierSemiFluidGenerator[this.mTier]); - } - - @Override - public int getCapacity() { - return 4000 * this.mTier; - } - - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, - "SemiFluidGenerator.efficiency.tier." + this.mTier, 100 - (this.mTier * 5)); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SemiFluidGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - //Logger.WARNING("Fuel Count: "+Gregtech_Recipe_Map.sSemiFluidLiquidFuels.mRecipeList.size()); - return GTPP_Recipe_Map.sSemiFluidLiquidFuels; - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Produces "+(this.getPollution())+" pollution/sec", - "Fuel Efficiency: "+this.getEfficiency() + "%", - CORE.GT_Tooltip}; - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return (aSide == getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { - if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { - return true; - } - return super.allowCoverOnSide(aSide, aCover); - } - - @Override - public int getFuelValue(ItemStack aStack) { - if ((GT_Utility.isStackInvalid(aStack)) || (getRecipes() == null)) { - Logger.WARNING("Bad Fuel?"); - return 0; - } - int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack)); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); - } - Logger.WARNING("Good Fuel: "+rValue); - return rValue; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE) }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; - } - + public int mEfficiency; + + /*public GT_MetaTileEntity_SemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + onConfigLoad(); + }*/ + + public GT_MetaTileEntity_SemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires semi-fluid Fuel", new ITexture[0]); + onConfigLoad(); + } + + public GT_MetaTileEntity_SemiFluidGenerator( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + public int getPollution() { + return (int) (CORE.ConfigSwitches.basePollutionPerSecondSemiFluidGenerator + * CORE.ConfigSwitches.pollutionReleasedByTierSemiFluidGenerator[this.mTier]); + } + + @Override + public int getCapacity() { + return 4000 * this.mTier; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, + "SemiFluidGenerator.efficiency.tier." + this.mTier, + 100 - (this.mTier * 5)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SemiFluidGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + // Logger.WARNING("Fuel Count: "+Gregtech_Recipe_Map.sSemiFluidLiquidFuels.mRecipeList.size()); + return GTPP_Recipe_Map.sSemiFluidLiquidFuels; + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Produces " + (this.getPollution()) + " pollution/sec", + "Fuel Efficiency: " + this.getEfficiency() + "%", + CORE.GT_Tooltip + }; + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return (aSide == getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { + if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(aSide, aCover); + } + + @Override + public int getFuelValue(ItemStack aStack) { + if ((GT_Utility.isStackInvalid(aStack)) || (getRecipes() == null)) { + Logger.WARNING("Bad Fuel?"); + return 0; + } + int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + Logger.WARNING("Good Fuel: " + rValue); + return rValue; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] + }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { + super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) + }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) + }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE) + }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { + super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) + }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] + }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { + super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) + }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { + super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) + }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { + super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE) + }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { + super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java index 2a0133245e..2897f621d6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java @@ -1,9 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.item.ItemStack; - import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.ItemList; @@ -17,137 +14,177 @@ import gregtech.api.util.GT_Recipe; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntityDoubleFuelGeneratorBase -extends GregtechRocketFuelGeneratorBase { +public class GregtechMetaTileEntityDoubleFuelGeneratorBase extends GregtechRocketFuelGeneratorBase { - public int mEfficiency; + public int mEfficiency; - public GregtechMetaTileEntityDoubleFuelGeneratorBase(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", new ITexture[0]); - this.onConfigLoad(); - } + public GregtechMetaTileEntityDoubleFuelGeneratorBase( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", + new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntityDoubleFuelGeneratorBase( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } - public GregtechMetaTileEntityDoubleFuelGeneratorBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - @Override public String[] getDescription() { - return new String[]{this.mDescription, - "Generates power at " + this.getEfficiency() + "% Efficiency per tick", - "Output Voltage: "+this.getOutputTier()+" EU/t", - CORE.GT_Tooltip - }; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityDoubleFuelGeneratorBase(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } - - @Override - public int getCapacity() { - return 32000; - } - - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, (100 - (this.mTier * 8))); - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public int getFuelValue(final ItemStack aStack) { - int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); - } - return rValue; - } - - private GT_RenderedTexture getCasingTexture(){ - if (this.mTier <= 4){ - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - else if (this.mTier == 5){ - - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); - } - else { - - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); - } - //return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)}; - } - - @Override - public int getPollution() { - return 250; - } + return new String[] { + this.mDescription, + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + "Output Voltage: " + this.getOutputTier() + " EU/t", + CORE.GT_Tooltip + }; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityDoubleFuelGeneratorBase( + this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + + @Override + public int getCapacity() { + return 32000; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, (100 - (this.mTier * 8))); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + private GT_RenderedTexture getCasingTexture() { + if (this.mTier <= 4) { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } else if (this.mTier == 5) { + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } else { + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + // return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], + this.getCasingTexture(), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + super.getBack(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent) + }; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) + }; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + super.getSides(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal) + }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + this.getCasingTexture(), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + super.getBackActive(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast) + }; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) + }; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + super.getSidesActive(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active) + }; + } + + @Override + public int getPollution() { + return 250; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java index a392ae5a58..ba63952baf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -1,10 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.ItemList; @@ -16,136 +12,172 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenera import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntityGeothermalGenerator -extends GT_MetaTileEntity_BasicGenerator -{ - - public int mEfficiency; - - public GregtechMetaTileEntityGeothermalGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); - this.onConfigLoad(); - } - - public GregtechMetaTileEntityGeothermalGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - - @Override - public String[] getDescription() { - String aPollution = "Causes "+this.getPollution()+ " Pollution per second"; - return new String[]{ - this.mDescription, - "Generates power at " + this.getEfficiency() + "% Efficiency per tick", - aPollution, - CORE.GT_Tooltip}; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()){ - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public int getCapacity() { - //return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); - return 5000*this.mTier; - } - - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "ThermalGenerator.efficiency.tier." + this.mTier, (100 - (this.mTier * 7))); - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public int getFuelValue(final ItemStack aStack) { - int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); - } - return rValue; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical)}; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM)}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER)}; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT)}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active)}; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE)}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE)}; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE)}; - } - - @Override - public GT_Recipe_Map getRecipes() - { - return GT_Recipe_Map.sHotFuels; - } - - public int getPollution() { - return (int) (CORE.ConfigSwitches.basePollutionPerSecondGeothermalGenerator * CORE.ConfigSwitches.pollutionReleasedByTierGeothermalGenerator[mTier]); - } -} \ No newline at end of file +public class GregtechMetaTileEntityGeothermalGenerator extends GT_MetaTileEntity_BasicGenerator { + + public int mEfficiency; + + public GregtechMetaTileEntityGeothermalGenerator( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntityGeothermalGenerator( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } + + @Override + public String[] getDescription() { + String aPollution = "Causes " + this.getPollution() + " Pollution per second"; + return new String[] { + this.mDescription, + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + aPollution, + CORE.GT_Tooltip + }; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public int getCapacity() { + // return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); + return 5000 * this.mTier; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, + "ThermalGenerator.efficiency.tier." + this.mTier, + (100 - (this.mTier * 7))); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + super.getBack(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical) + }; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) + }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER) + }; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT) + }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + super.getBackActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active) + }; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) + }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + super.getTopActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE) + }; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE) + }; + } + + @Override + public GT_Recipe_Map getRecipes() { + return GT_Recipe_Map.sHotFuels; + } + + public int getPollution() { + return (int) (CORE.ConfigSwitches.basePollutionPerSecondGeothermalGenerator + * CORE.ConfigSwitches.pollutionReleasedByTierGeothermalGenerator[mTier]); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index c05c7ae3ff..b6c2f27ce6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -9,134 +9,164 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GTPP_Recipe; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntityRocketFuelGenerator -extends GregtechRocketFuelGeneratorBase { - - public int mEfficiency; - - public GregtechMetaTileEntityRocketFuelGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires GT++ Rocket Fuels", new ITexture[0]); - this.onConfigLoad(); - } - - public GregtechMetaTileEntityRocketFuelGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - //Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); - return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; - } - - @Override - public int getCapacity() { - return 32000; - } - - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, 80 - (10 * (this.mTier - 4))); - } - - @Override - public int getEfficiency() { - int eff = 80 - (10 * (this.mTier - 4)); - return eff; - - } - - @Override - public int getFuelValue(final ItemStack aStack) { - int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); - } - return rValue; - } - - private GT_RenderedTexture getCasingTexture(){ - if (this.mTier <= 4){ - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - else if (this.mTier == 5){ - - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); - } - else{ - - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); - } - //return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)}; - } +public class GregtechMetaTileEntityRocketFuelGenerator extends GregtechRocketFuelGeneratorBase { + + public int mEfficiency; + + public GregtechMetaTileEntityRocketFuelGenerator( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires GT++ Rocket Fuels", new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntityRocketFuelGenerator( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + // Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); + return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; + } + + @Override + public int getCapacity() { + return 32000; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, + "RocketEngine.efficiency.tier." + this.mTier, + 80 - (10 * (this.mTier - 4))); + } + + @Override + public int getEfficiency() { + int eff = 80 - (10 * (this.mTier - 4)); + return eff; + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + private GT_RenderedTexture getCasingTexture() { + if (this.mTier <= 4) { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } else if (this.mTier == 5) { + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } else { + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + // return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], + this.getCasingTexture(), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + super.getBack(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent) + }; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) + }; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + super.getSides(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal) + }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + this.getCasingTexture(), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + super.getBackActive(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast) + }; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) + }; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + super.getSidesActive(aColor)[0], + this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java index 68dbc4fb61..660fdb50b6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; import static gregtech.api.enums.GT_Values.V; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.Textures; @@ -11,177 +9,218 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SolarGenerator; import gtPlusPlus.xmod.gregtech.api.gui.GUI_SolarGenerator; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechMetaSolarGenerator; +import net.minecraft.entity.player.InventoryPlayer; public class GregtechMetaTileEntitySolarGenerator extends GregtechMetaSolarGenerator { - public GregtechMetaTileEntitySolarGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, "Feasts on the power of the Sun!", new ITexture[0]); - this.onConfigLoad(); - } + public GregtechMetaTileEntitySolarGenerator( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Feasts on the power of the Sun!", new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntitySolarGenerator( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } - public GregtechMetaTileEntitySolarGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - @Override public String[] getDescription() { - return new String[]{this.mDescription, - "Generates power at " + this.getEfficiency() + "% Efficiency per tick", - "Output Voltage: "+this.getOutputTier()+" EU/t", - CORE.GT_Tooltip - }; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png"); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "SunAbsorber.efficiency.tier." + this.mTier, 100 - (this.mTier * 10)); - - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() - && (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()))) { - - if (this.mSolarCharge <= 20) { - //Utils.LOG_WARNING("1."); - this.mSolarCharge = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 45) { - //Utils.LOG_WARNING("2."); - this.mSolarCharge -= 1; - this.mLossTimer = 0; - } - - if ((aTick % 10L) == 0L) { - - Logger.WARNING("getUniversalEnergyStored: "+aBaseMetaTileEntity.getUniversalEnergyStored() + " maxEUOutput * 20 + getMinimumStoredEU: " + ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())); - - if ((this.mSolarCharge > 100) && (aBaseMetaTileEntity.isAllowedToWork()) && - (!aBaseMetaTileEntity.getWorld().isThundering()) && - (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUStore() - this.getMinimumStoredEU()))) { - this.getBaseMetaTileEntity().increaseStoredEnergyUnits(sEnergyPerTick * this.getEfficiency(), true); - } - } - - if ((this.mSolarCharge < 500) && (this.mProcessingEnergy != 0) && ((aTick % 32L) == 0L)) { - Logger.WARNING("Adding Solar Charge. Currently "+this.mSolarCharge); - this.mProcessingEnergy -= 1; - this.mSolarCharge += 1; - } - - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 64L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { - Logger.WARNING("Adding Processing Energy. Currently "+this.mProcessingEnergy); - final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); - this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; - } - - if (aBaseMetaTileEntity.isServerSide()){ - //Utils.LOG_WARNING("6."); - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); - } - } - } - - @Override - public void inValidate() { - - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public long maxEUStore() { - return Math.max(this.getEUVar(), (V[this.mTier] * 16000) + this.getMinimumStoredEU()); - } - - - ITexture SolarArray[] = {new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_8V), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_MV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_HV), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_EV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_ZPM), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_UV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; - - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; - } - -} \ No newline at end of file + return new String[] { + this.mDescription, + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + "Output Voltage: " + this.getOutputTier() + " EU/t", + CORE.GT_Tooltip + }; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png"); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "SunAbsorber.efficiency.tier." + this.mTier, 100 - (this.mTier * 10)); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide() + && aBaseMetaTileEntity.isAllowedToWork() + && (aBaseMetaTileEntity.getUniversalEnergyStored() + < (this.maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()))) { + + if (this.mSolarCharge <= 20) { + // Utils.LOG_WARNING("1."); + this.mSolarCharge = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + // Utils.LOG_WARNING("2."); + this.mSolarCharge -= 1; + this.mLossTimer = 0; + } + + if ((aTick % 10L) == 0L) { + + Logger.WARNING("getUniversalEnergyStored: " + aBaseMetaTileEntity.getUniversalEnergyStored() + + " maxEUOutput * 20 + getMinimumStoredEU: " + + ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())); + + if ((this.mSolarCharge > 100) + && (aBaseMetaTileEntity.isAllowedToWork()) + && (!aBaseMetaTileEntity.getWorld().isThundering()) + && (aBaseMetaTileEntity.getUniversalEnergyStored() + < (this.maxEUStore() - this.getMinimumStoredEU()))) { + this.getBaseMetaTileEntity().increaseStoredEnergyUnits(sEnergyPerTick * this.getEfficiency(), true); + } + } + + if ((this.mSolarCharge < 500) && (this.mProcessingEnergy != 0) && ((aTick % 32L) == 0L)) { + Logger.WARNING("Adding Solar Charge. Currently " + this.mSolarCharge); + this.mProcessingEnergy -= 1; + this.mSolarCharge += 1; + } + + if ((this.mProcessingEnergy <= 0) + && (aBaseMetaTileEntity.isAllowedToWork()) + && ((aTick % 64L) == 0L) + && (!aBaseMetaTileEntity.getWorld().isThundering())) { + Logger.WARNING("Adding Processing Energy. Currently " + this.mProcessingEnergy); + final boolean bRain = + aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); + this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) + || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) + ? 0 + : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + + if (aBaseMetaTileEntity.isServerSide()) { + // Utils.LOG_WARNING("6."); + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() + && (aBaseMetaTileEntity.getUniversalEnergyStored() + >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + } + + @Override + public void inValidate() {} + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 16000) + this.getMinimumStoredEU()); + } + + ITexture SolarArray[] = { + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_8V), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_MV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_HV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_EV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_ZPM), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_UV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL) + }; + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) + }; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) + }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) + }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] + }; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) + }; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) + }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] {super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) + }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java index ab000b98d4..5e8907073f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java @@ -1,390 +1,399 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_RTG extends GT_MetaTileEntity_BasicGenerator { - public int mEfficiency; - private int mDays; - private long mTicksToBurnFor; - private int mVoltage = 0; - private GT_Recipe mCurrentRecipe; - private int mDaysRemaining = 0; - private int mDayTick = 0; - private byte mNewTier = 0; - - public int removeDayOfTime(){ - if (this.mDaysRemaining > 0){ - return this.mDaysRemaining--; - } - return this.mDaysRemaining; - } - - //Generates fuel value based on MC days - public static int convertDaysToTicks(float days){ - int value = 0; - value = MathUtils.roundToClosestInt(20*86400*days); - return value; - } - - public static long getTotalEUGenerated(int ticks, int voltage){ - return ticks*voltage; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setLong("mTicksToBurnFor", this.mTicksToBurnFor); - aNBT.setInteger("mVoltage", this.mVoltage); - aNBT.setInteger("mDaysRemaining", this.mDaysRemaining); - aNBT.setInteger("mDayTick", this.mDayTick); - aNBT.setByte("mNewTier", this.mNewTier); - - - if (this.mCurrentRecipe != null){ - final NBTTagList list = new NBTTagList(); - final ItemStack stack = this.mCurrentRecipe.mInputs[0]; - if(stack != null){ - final NBTTagCompound data = new NBTTagCompound(); - stack.writeToNBT(data); - data.setInteger("mSlot", 0); - list.appendTag(data); - } - aNBT.setTag("mRecipeItem", list); - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - //this.mMachineBlock = aNBT.getByte("mMachineBlock"); - this.mTicksToBurnFor = aNBT.getLong("mTicksToBurnFor"); - this.mVoltage = aNBT.getInteger("mVoltage"); - this.mDaysRemaining = aNBT.getInteger("mDaysRemaining"); - this.mDayTick = aNBT.getInteger("mDayTick"); - this.mNewTier = aNBT.getByte("mNewTier"); - - try { - ReflectionUtils.setByte(this, "mTier", this.mNewTier); - } - catch (Exception e) { - if (this.getBaseMetaTileEntity() != null){ - IGregTechTileEntity thisTile = this.getBaseMetaTileEntity(); - if (thisTile.isAllowedToWork() || thisTile.isActive()){ - thisTile.setActive(false); - } - } - } - - - final NBTTagList list = aNBT.getTagList("mRecipeItem", 10); - final NBTTagCompound data = list.getCompoundTagAt(0); - ItemStack lastUsedFuel = ItemStack.loadItemStackFromNBT(data); - if (lastUsedFuel != null){ - this.mCurrentRecipe = getRecipes().findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, new ItemStack[] { lastUsedFuel }); - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()){ - if (this.mDayTick < 24000){ - this.mDayTick++; - } - else if (this.mDayTick >= 24000){ - this.mDayTick = 0; - this.mDaysRemaining = this.removeDayOfTime(); - } - } - - - if ((aBaseMetaTileEntity.isServerSide()) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 10L == 0L)) { - long tProducedEU = 0L; - if (this.mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { - this.mInventory[getStackDisplaySlot()] = null; - } else { - if (this.mInventory[getStackDisplaySlot()] == null) - this.mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - this.mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " - + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); - } - } else { - int tFuelValue = getFuelValue(this.mFluid); - int tConsumed = consumedFluidPerOperation(this.mFluid); - if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { - long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, - (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if ((tFluidAmountToUse > 0L) - && (aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true))) { - tProducedEU = tFluidAmountToUse * tFuelValue; - FluidStack tmp260_257 = this.mFluid; - tmp260_257.amount = (int) (tmp260_257.amount - (tFluidAmountToUse * tConsumed)); - } - } - } - if ((this.mInventory[getInputSlot()] != null) - && (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() * 20L + getMinimumStoredEU()) - && (GT_Utility.getFluidForFilledItem(this.mInventory[getInputSlot()], true) == null)) { - int tFuelValue = getFuelValue(this.mInventory[getInputSlot()]); - if (tFuelValue > 0) { - ItemStack tEmptyContainer = getEmptyContainer(this.mInventory[getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - tProducedEU = tFuelValue; - } - } - } - if ((tProducedEU > 0L) && (getPollution() > 0)) { - PollutionUtils.addPollution(aBaseMetaTileEntity, (int) (tProducedEU * getPollution() / 500 * this.mTier + 1L)); - } - } - - if (aBaseMetaTileEntity.isServerSide()) - aBaseMetaTileEntity.setActive((aBaseMetaTileEntity.isAllowedToWork()) - && (aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU())); - } - - @Override - public String[] getDescription() { - return new String[]{this.mDescription, - "Fuel is measured in minecraft days (Check with Scanner)", - "RTG changes output voltage depending on fuel", - "Generates power at " + this.getEfficiency() + "% Efficiency per tick", - "Output Voltage: "+this.getOutputTier()+" EU/t", - CORE.GT_Tooltip - }; - } - - public GregtechMetaTileEntity_RTG(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires RTG Pellets", new ITexture[0]); - } - - private byte getTier(){ - int voltage = this.mVoltage; - if (voltage >= 512){ - return 4; - } - else if (voltage >= 128){ - return 3; - } - else if (voltage >= 32){ - return 2; - } - else if (voltage >= 8){ - return 1; - } - return 0; - } - - public GregtechMetaTileEntity_RTG(String aName, int aTier, String aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public boolean isOutputFacing(byte aSide) { - return ((aSide > 1) && (aSide != getBaseMetaTileEntity().getFrontFacing()) - && (aSide != getBaseMetaTileEntity().getBackFacing())); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_RTG(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - return GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public int getEfficiency() { - return this.mEfficiency = 100; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB) }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[]{ - gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()]}; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE) }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{ - gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()]}; - } - - - public int getPollution() { - return 0; - } - - @Override - public int getFuelValue(ItemStack aStack) { - if ((GT_Utility.isStackInvalid(aStack)) || (getRecipes() == null)) - return 0; - GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, - new ItemStack[] { aStack }); - if (tFuel != null){ - this.mCurrentRecipe = tFuel; - int voltage = tFuel.mEUt; - this.mVoltage = voltage; - int sfsf = this.mTier; - //this.mDaysRemaining = tFuel.mSpecialValue*365; - - //Do some voodoo. - byte mTier2; - //mTier2 = ReflectionUtils.getField(this.getClass(), "mTier"); - try { - if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_AM241.get(1))){ - mTier2 = 1; - } - else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PO210.get(1))){ - mTier2 = 3; - } - else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1))){ - mTier2 = 2; - } - else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_SR90.get(1))){ - mTier2 = 1; - } - else { - //Utils.LOG_INFO("test:"+tFuel.mInputs[0].getDisplayName() + " | " + (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1)))); - mTier2 = 0; - } - ReflectionUtils.setByte(this, "mTier", mTier2); - this.mNewTier = mTier2; - //ReflectionUtils.setFinalStatic(mTier2, GT_Values.V[0]); - } catch (Exception e) { - Logger.WARNING("Failed setting mTier."); - e.printStackTrace(); - } - - this.mTicksToBurnFor = getTotalEUGenerated(convertDaysToTicks(tFuel.mSpecialValue), voltage); - if (mTicksToBurnFor >= Integer.MAX_VALUE){ - mTicksToBurnFor = Integer.MAX_VALUE; - Logger.WARNING("Fuel went over Int limit, setting to MAX_VALUE."); - } - this.mDaysRemaining = MathUtils.roundToClosestInt(mTicksToBurnFor/20/60/3); - Logger.WARNING("step | "+(int) (mTicksToBurnFor * getEfficiency() / 100L)); - return (int) (mTicksToBurnFor * getEfficiency() / 100L); - //return (int) (tFuel.mSpecialValue * 365L * getEfficiency() / 100L); - //return tFuel.mEUt; - } - Logger.WARNING("Not sure"); - return 0; - } - - @Override - public long maxEUOutput() { - return ((getBaseMetaTileEntity().isAllowedToWork()) ? this.mVoltage : 0L); - } - - @Override - public long getOutputTier() { - if (this.mCurrentRecipe != null){ - return this.mVoltage = this.mCurrentRecipe.mEUt; - } - return 0; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public String[] getInfoData() { - return new String[] { "RTG - Running at tier "+this.mTier, - "Active: "+this.getBaseMetaTileEntity().isActive(), "Current Output: " + this.mVoltage + " EU/t", - "Days of Fuel remaining: "+(mTicksToBurnFor/20/60/20), - "Hours of Fuel remaining: "+(mTicksToBurnFor/20/60/60), - "Ticks of "+this.mVoltage+"v remaining: "+(mTicksToBurnFor), - "Current Recipe input: "+ this.mCurrentRecipe != null ? this.mCurrentRecipe.mInputs[0].getDisplayName() + " x1" : "NUll" - }; - } - -} \ No newline at end of file + public int mEfficiency; + private int mDays; + private long mTicksToBurnFor; + private int mVoltage = 0; + private GT_Recipe mCurrentRecipe; + private int mDaysRemaining = 0; + private int mDayTick = 0; + private byte mNewTier = 0; + + public int removeDayOfTime() { + if (this.mDaysRemaining > 0) { + return this.mDaysRemaining--; + } + return this.mDaysRemaining; + } + + // Generates fuel value based on MC days + public static int convertDaysToTicks(float days) { + int value = 0; + value = MathUtils.roundToClosestInt(20 * 86400 * days); + return value; + } + + public static long getTotalEUGenerated(int ticks, int voltage) { + return ticks * voltage; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("mTicksToBurnFor", this.mTicksToBurnFor); + aNBT.setInteger("mVoltage", this.mVoltage); + aNBT.setInteger("mDaysRemaining", this.mDaysRemaining); + aNBT.setInteger("mDayTick", this.mDayTick); + aNBT.setByte("mNewTier", this.mNewTier); + + if (this.mCurrentRecipe != null) { + final NBTTagList list = new NBTTagList(); + final ItemStack stack = this.mCurrentRecipe.mInputs[0]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("mSlot", 0); + list.appendTag(data); + } + aNBT.setTag("mRecipeItem", list); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + // this.mMachineBlock = aNBT.getByte("mMachineBlock"); + this.mTicksToBurnFor = aNBT.getLong("mTicksToBurnFor"); + this.mVoltage = aNBT.getInteger("mVoltage"); + this.mDaysRemaining = aNBT.getInteger("mDaysRemaining"); + this.mDayTick = aNBT.getInteger("mDayTick"); + this.mNewTier = aNBT.getByte("mNewTier"); + + try { + ReflectionUtils.setByte(this, "mTier", this.mNewTier); + } catch (Exception e) { + if (this.getBaseMetaTileEntity() != null) { + IGregTechTileEntity thisTile = this.getBaseMetaTileEntity(); + if (thisTile.isAllowedToWork() || thisTile.isActive()) { + thisTile.setActive(false); + } + } + } + + final NBTTagList list = aNBT.getTagList("mRecipeItem", 10); + final NBTTagCompound data = list.getCompoundTagAt(0); + ItemStack lastUsedFuel = ItemStack.loadItemStackFromNBT(data); + if (lastUsedFuel != null) { + this.mCurrentRecipe = getRecipes() + .findRecipe( + getBaseMetaTileEntity(), false, 9223372036854775807L, null, new ItemStack[] {lastUsedFuel}); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mDayTick < 24000) { + this.mDayTick++; + } else if (this.mDayTick >= 24000) { + this.mDayTick = 0; + this.mDaysRemaining = this.removeDayOfTime(); + } + } + + if ((aBaseMetaTileEntity.isServerSide()) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 10L == 0L)) { + long tProducedEU = 0L; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { + this.mInventory[getStackDisplaySlot()] = null; + } else { + if (this.mInventory[getStackDisplaySlot()] == null) + this.mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + this.mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + } + } else { + int tFuelValue = getFuelValue(this.mFluid); + int tConsumed = consumedFluidPerOperation(this.mFluid); + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { + long tFluidAmountToUse = Math.min( + this.mFluid.amount / tConsumed, + (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + if ((tFluidAmountToUse > 0L) + && (aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true))) { + tProducedEU = tFluidAmountToUse * tFuelValue; + FluidStack tmp260_257 = this.mFluid; + tmp260_257.amount = (int) (tmp260_257.amount - (tFluidAmountToUse * tConsumed)); + } + } + } + if ((this.mInventory[getInputSlot()] != null) + && (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() * 20L + getMinimumStoredEU()) + && (GT_Utility.getFluidForFilledItem(this.mInventory[getInputSlot()], true) == null)) { + int tFuelValue = getFuelValue(this.mInventory[getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = getEmptyContainer(this.mInventory[getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + tProducedEU = tFuelValue; + } + } + } + if ((tProducedEU > 0L) && (getPollution() > 0)) { + PollutionUtils.addPollution( + aBaseMetaTileEntity, (int) (tProducedEU * getPollution() / 500 * this.mTier + 1L)); + } + } + + if (aBaseMetaTileEntity.isServerSide()) + aBaseMetaTileEntity.setActive((aBaseMetaTileEntity.isAllowedToWork()) + && (aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU())); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Fuel is measured in minecraft days (Check with Scanner)", + "RTG changes output voltage depending on fuel", + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + "Output Voltage: " + this.getOutputTier() + " EU/t", + CORE.GT_Tooltip + }; + } + + public GregtechMetaTileEntity_RTG(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires RTG Pellets", new ITexture[0]); + } + + private byte getTier() { + int voltage = this.mVoltage; + if (voltage >= 512) { + return 4; + } else if (voltage >= 128) { + return 3; + } else if (voltage >= 32) { + return 2; + } else if (voltage >= 8) { + return 1; + } + return 0; + } + + public GregtechMetaTileEntity_RTG(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return ((aSide > 1) + && (aSide != getBaseMetaTileEntity().getFrontFacing()) + && (aSide != getBaseMetaTileEntity().getBackFacing())); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_RTG(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public int getEfficiency() { + return this.mEfficiency = 100; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { + super.getFront(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB) + }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { + super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) + }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) + }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) + }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { + gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()] + }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { + super.getFrontActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE) + }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { + super.getBackActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) + }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { + super.getBottomActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) + }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { + super.getTopActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) + }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { + gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()] + }; + } + + public int getPollution() { + return 0; + } + + @Override + public int getFuelValue(ItemStack aStack) { + if ((GT_Utility.isStackInvalid(aStack)) || (getRecipes() == null)) return 0; + GT_Recipe tFuel = getRecipes() + .findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, new ItemStack[] {aStack}); + if (tFuel != null) { + this.mCurrentRecipe = tFuel; + int voltage = tFuel.mEUt; + this.mVoltage = voltage; + int sfsf = this.mTier; + // this.mDaysRemaining = tFuel.mSpecialValue*365; + + // Do some voodoo. + byte mTier2; + // mTier2 = ReflectionUtils.getField(this.getClass(), "mTier"); + try { + if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_AM241.get(1))) { + mTier2 = 1; + } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PO210.get(1))) { + mTier2 = 3; + } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1))) { + mTier2 = 2; + } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_SR90.get(1))) { + mTier2 = 1; + } else { + // Utils.LOG_INFO("test:"+tFuel.mInputs[0].getDisplayName() + " | " + + // (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1)))); + mTier2 = 0; + } + ReflectionUtils.setByte(this, "mTier", mTier2); + this.mNewTier = mTier2; + // ReflectionUtils.setFinalStatic(mTier2, GT_Values.V[0]); + } catch (Exception e) { + Logger.WARNING("Failed setting mTier."); + e.printStackTrace(); + } + + this.mTicksToBurnFor = getTotalEUGenerated(convertDaysToTicks(tFuel.mSpecialValue), voltage); + if (mTicksToBurnFor >= Integer.MAX_VALUE) { + mTicksToBurnFor = Integer.MAX_VALUE; + Logger.WARNING("Fuel went over Int limit, setting to MAX_VALUE."); + } + this.mDaysRemaining = MathUtils.roundToClosestInt(mTicksToBurnFor / 20 / 60 / 3); + Logger.WARNING("step | " + (int) (mTicksToBurnFor * getEfficiency() / 100L)); + return (int) (mTicksToBurnFor * getEfficiency() / 100L); + // return (int) (tFuel.mSpecialValue * 365L * getEfficiency() / 100L); + // return tFuel.mEUt; + } + Logger.WARNING("Not sure"); + return 0; + } + + @Override + public long maxEUOutput() { + return ((getBaseMetaTileEntity().isAllowedToWork()) ? this.mVoltage : 0L); + } + + @Override + public long getOutputTier() { + if (this.mCurrentRecipe != null) { + return this.mVoltage = this.mCurrentRecipe.mEUt; + } + return 0; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + "RTG - Running at tier " + this.mTier, + "Active: " + this.getBaseMetaTileEntity().isActive(), + "Current Output: " + this.mVoltage + " EU/t", + "Days of Fuel remaining: " + (mTicksToBurnFor / 20 / 60 / 20), + "Hours of Fuel remaining: " + (mTicksToBurnFor / 20 / 60 / 60), + "Ticks of " + this.mVoltage + "v remaining: " + (mTicksToBurnFor), + "Current Recipe input: " + this.mCurrentRecipe != null + ? this.mCurrentRecipe.mInputs[0].getDisplayName() + " x1" + : "NUll" + }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_CombustionGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_CombustionGenerator.java index 58919f0954..3398ad0fc6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_CombustionGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_CombustionGenerator.java @@ -15,25 +15,27 @@ public class GT_MetaTileEntity_ULV_CombustionGenerator extends GT_MetaTileEntity super(aID, aName, aNameRegional, aTier); } - public GT_MetaTileEntity_ULV_CombustionGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_ULV_CombustionGenerator( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Produces "+(this.getPollution()*20)+" pollution/sec", - "Fuel Efficiency: "+this.getEfficiency() + "%", - CORE.GT_Tooltip}; - } @Override - public long maxEUStore() { + public String[] getDescription() { + return new String[] { + this.mDescription, + "Produces " + (this.getPollution() * 20) + " pollution/sec", + "Fuel Efficiency: " + this.getEfficiency() + "%", + CORE.GT_Tooltip + }; + } + + @Override + public long maxEUStore() { return Math.max(getEUVar(), V[1] * 80L + getMinimumStoredEU()); - } + } - @Override + @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_ULV_CombustionGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } @@ -45,6 +47,7 @@ public class GT_MetaTileEntity_ULV_CombustionGenerator extends GT_MetaTileEntity @Override public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "DieselGenerator.efficiency.tier." + this.mTier, 95); + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "DieselGenerator.efficiency.tier." + this.mTier, 95); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_GasTurbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_GasTurbine.java index 17bb4463c4..b8f8004dad 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_GasTurbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_GasTurbine.java @@ -21,20 +21,21 @@ public class GT_MetaTileEntity_ULV_GasTurbine extends GT_MetaTileEntity_GasTurbi public GT_MetaTileEntity_ULV_GasTurbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Produces "+(this.getPollution()*20)+" pollution/sec", - "Fuel Efficiency: "+this.getEfficiency() + "%", - CORE.GT_Tooltip}; - } @Override - public long maxEUStore() { + public String[] getDescription() { + return new String[] { + this.mDescription, + "Produces " + (this.getPollution() * 20) + " pollution/sec", + "Fuel Efficiency: " + this.getEfficiency() + "%", + CORE.GT_Tooltip + }; + } + + @Override + public long maxEUStore() { return Math.max(getEUVar(), V[1] * 80L + getMinimumStoredEU()); - } + } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_ULV_GasTurbine(this.mName, this.mTier, this.mDescription, this.mTextures); @@ -47,13 +48,15 @@ public class GT_MetaTileEntity_ULV_GasTurbine extends GT_MetaTileEntity_GasTurbi @Override public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "GasTurbine.efficiency.tier." + this.mTier, 95); + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "GasTurbine.efficiency.tier." + this.mTier, 95); } @Override public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], - new GT_RenderedTexture((IIconContainer) TexturesGtBlock.Overlay_Machine_Turbine_Active)}; - } - -} \ No newline at end of file + return new ITexture[] { + super.getSidesActive(aColor)[0], + new GT_RenderedTexture((IIconContainer) TexturesGtBlock.Overlay_Machine_Turbine_Active) + }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_SteamTurbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_SteamTurbine.java index ef3310c6fc..09e3e3201c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_SteamTurbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_SteamTurbine.java @@ -21,20 +21,21 @@ public class GT_MetaTileEntity_ULV_SteamTurbine extends GT_MetaTileEntity_SteamT public GT_MetaTileEntity_ULV_SteamTurbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Produces "+(this.getPollution()*20)+" pollution/sec", - "Fuel Efficiency: "+this.getEfficiency() + "%", - CORE.GT_Tooltip}; - } @Override - public long maxEUStore() { + public String[] getDescription() { + return new String[] { + this.mDescription, + "Produces " + (this.getPollution() * 20) + " pollution/sec", + "Fuel Efficiency: " + this.getEfficiency() + "%", + CORE.GT_Tooltip + }; + } + + @Override + public long maxEUStore() { return Math.max(getEUVar(), V[1] * 80L + getMinimumStoredEU()); - } + } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_ULV_SteamTurbine(this.mName, this.mTier, this.mDescription, this.mTextures); @@ -44,15 +45,18 @@ public class GT_MetaTileEntity_ULV_SteamTurbine extends GT_MetaTileEntity_SteamT public int getCapacity() { return 16000; } - + @Override public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "SteamTurbine.efficiency.tier." + this.mTier, 6 + 1); + this.mEfficiency = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "SteamTurbine.efficiency.tier." + this.mTier, 6 + 1); } @Override public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], - new GT_RenderedTexture((IIconContainer) TexturesGtBlock.Overlay_Machine_Turbine_Active)}; - } + return new ITexture[] { + super.getSidesActive(aColor)[0], + new GT_RenderedTexture((IIconContainer) TexturesGtBlock.Overlay_Machine_Turbine_Active) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java index 087da7465d..fb2af1cd44 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java @@ -2,9 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators.creative; import static gregtech.api.enums.GT_Values.V; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -21,6 +18,8 @@ import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -36,198 +35,229 @@ import net.minecraft.world.World; */ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { - private int mVoltageTier = 3; - - public GregtechMetaCreativeEnergyBuffer(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aDescription, aTextures, aSlotCount); - // TODO Auto-generated constructor stub - } - - public GregtechMetaCreativeEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); - } - - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "Use Screwdriver to change voltage", "Hold Shift while using Screwdriver to change amperage", EnumChatFormatting.GREEN - + "CREATIVE MACHINE", CORE.GT_Tooltip}; - } - - /* - * MACHINE_STEEL_SIDE - */ - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - CustomIcon h = TexturesGtBlock.Casing_Material_RedSteel; - CustomIcon g = TexturesGtBlock.Casing_Material_Grisium; - CustomIcon k; - boolean j = MathUtils.isNumberEven(this.mVoltageTier); - final ITexture[][][] rTextures = new ITexture[2][17][]; - k = j ? g : h; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{new GT_RenderedTexture(k)}; - rTextures[1][i - + 1] = new ITexture[]{new GT_RenderedTexture(k), this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mVoltageTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mVoltageTier]}; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; - } - - @Override - protected void showEnergy(final World worldIn, final EntityPlayer playerIn){ - final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); - final double c = ((double) tempStorage / this.maxEUStore()) * 100; - final double roundOff = Math.round(c * 100.00) / 100.00; - PlayerUtils.messagePlayer(playerIn, "Energy: " + GT_Utility.formatNumbers(tempStorage) + " EU at "+V[this.mVoltageTier]+"v ("+roundOff+"%)"); - PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut())+"A"); - - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaCreativeEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return Long.MAX_VALUE; - } - - @Override - public long maxEUInput() { - return V[mVoltageTier]; - } - - @Override - public long maxEUOutput() { - return V[mVoltageTier]; - } - - @Override - public long maxAmperesIn() { - return aCurrentOutputAmperage; - } - - @Override - public long maxAmperesOut() { - return aCurrentOutputAmperage; - } - - @Override - public int getProgresstime() { - return Integer.MAX_VALUE; - } - @Override - public int maxProgresstime() { - return Integer.MAX_VALUE; - } - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(Integer.MAX_VALUE, true); - } - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - String[] infoData = super.getInfoData(); - return new String[]{infoData[0], "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: " + this.mVoltageTier, infoData[1], infoData[2]}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mVoltageTier", this.mVoltageTier); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mVoltageTier = aNBT.getInteger("mVoltageTier"); - super.loadNBTData(aNBT); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (KeyboardUtils.isShiftKeyDown()) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - else { - if (this.mVoltageTier < (GT_Values.VN[9].equals("UHV") ? GT_Values.V.length - 1 : 9)) { - this.mVoltageTier++; - } - else { - this.mVoltageTier = 0; - } - this.markDirty(); - try { - Field field = ReflectionUtils.getField(this.getClass(), "mTextures"); - field.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - ITexture[][][] V = getTextureSet(null); - if (V != null) { - Logger.REFLECTION("Got Valid Textures."); - if (this.getBaseMetaTileEntity().isClientSide()) { - Logger.REFLECTION("Clientside Call."); - Logger.REFLECTION("Refreshing Textures on buffer."); - field.set(this, V); - Logger.REFLECTION("Refreshed Textures on buffer."); - } - else { - Logger.REFLECTION("Serverside Call."); - } - } - else { - Logger.REFLECTION("Bad mTextures setter."); - } - } - catch (Throwable t) { - // Bad refresh. - t.printStackTrace(); - Logger.REFLECTION("Bad mTextures setter."); - } - PlayerUtils.messagePlayer(aPlayer, "Now running at " + GT_Values.VOLTAGE_NAMES[this.mVoltageTier] + "."); - } - - } + private int mVoltageTier = 3; + + public GregtechMetaCreativeEnergyBuffer( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + // TODO Auto-generated constructor stub + } + + public GregtechMetaCreativeEnergyBuffer( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Use Screwdriver to change voltage", + "Hold Shift while using Screwdriver to change amperage", + EnumChatFormatting.GREEN + "CREATIVE MACHINE", + CORE.GT_Tooltip + }; + } + + /* + * MACHINE_STEEL_SIDE + */ + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + CustomIcon h = TexturesGtBlock.Casing_Material_RedSteel; + CustomIcon g = TexturesGtBlock.Casing_Material_Grisium; + CustomIcon k; + boolean j = MathUtils.isNumberEven(this.mVoltageTier); + final ITexture[][][] rTextures = new ITexture[2][17][]; + k = j ? g : h; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] {new GT_RenderedTexture(k)}; + rTextures[1][i + 1] = new ITexture[] { + new GT_RenderedTexture(k), + this.mInventory.length > 4 + ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mVoltageTier] + : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mVoltageTier] + }; + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; + } + + @Override + protected void showEnergy(final World worldIn, final EntityPlayer playerIn) { + final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); + final double c = ((double) tempStorage / this.maxEUStore()) * 100; + final double roundOff = Math.round(c * 100.00) / 100.00; + PlayerUtils.messagePlayer( + playerIn, + "Energy: " + GT_Utility.formatNumbers(tempStorage) + " EU at " + V[this.mVoltageTier] + "v (" + roundOff + + "%)"); + PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut()) + "A"); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaCreativeEnergyBuffer( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public long maxEUInput() { + return V[mVoltageTier]; + } + + @Override + public long maxEUOutput() { + return V[mVoltageTier]; + } + + @Override + public long maxAmperesIn() { + return aCurrentOutputAmperage; + } + + @Override + public long maxAmperesOut() { + return aCurrentOutputAmperage; + } + + @Override + public int getProgresstime() { + return Integer.MAX_VALUE; + } + + @Override + public int maxProgresstime() { + return Integer.MAX_VALUE; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(Integer.MAX_VALUE, true); + } + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String[] infoData = super.getInfoData(); + return new String[] { + infoData[0], "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: " + this.mVoltageTier, infoData[1], infoData[2] + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mVoltageTier", this.mVoltageTier); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mVoltageTier = aNBT.getInteger("mVoltageTier"); + super.loadNBTData(aNBT); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (KeyboardUtils.isShiftKeyDown()) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } else { + if (this.mVoltageTier < (GT_Values.VN[9].equals("UHV") ? GT_Values.V.length - 1 : 9)) { + this.mVoltageTier++; + } else { + this.mVoltageTier = 0; + } + this.markDirty(); + try { + Field field = ReflectionUtils.getField(this.getClass(), "mTextures"); + field.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + ITexture[][][] V = getTextureSet(null); + if (V != null) { + Logger.REFLECTION("Got Valid Textures."); + if (this.getBaseMetaTileEntity().isClientSide()) { + Logger.REFLECTION("Clientside Call."); + Logger.REFLECTION("Refreshing Textures on buffer."); + field.set(this, V); + Logger.REFLECTION("Refreshed Textures on buffer."); + } else { + Logger.REFLECTION("Serverside Call."); + } + } else { + Logger.REFLECTION("Bad mTextures setter."); + } + } catch (Throwable t) { + // Bad refresh. + t.printStackTrace(); + Logger.REFLECTION("Bad mTextures setter."); + } + PlayerUtils.messagePlayer(aPlayer, "Now running at " + GT_Values.VOLTAGE_NAMES[this.mVoltageTier] + "."); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java index 4651121500..2847a15539 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import java.util.*; - import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -18,6 +16,7 @@ import gtPlusPlus.xmod.gregtech.api.gui.basic.*; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import ic2.api.crops.*; import ic2.core.item.DamageHandler; +import java.util.*; import net.minecraft.entity.player.*; import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; @@ -25,668 +24,709 @@ import net.minecraft.tileentity.TileEntity; public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank { - protected String mLocalName; - - private static final int SLOT_WEEDEX_1 = 1; - private static final int SLOT_WEEDEX_2 = 2; - private static final int SLOT_FERT_1 = 3; - private static final int SLOT_FERT_4 = 6; - private static final int SLOT_OUTPUT_START = 7; - - public boolean mModeAlternative = false; - - public GT_MetaTileEntity_CropHarvestor(final int aID, final int aTier, final String aDescription) { - super(aID, "basicmachine.cropharvester.0"+aTier, "Crop Manager ("+GT_Values.VN[aTier]+")", aTier, 21, aDescription); - this.mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; - } - - public GT_MetaTileEntity_CropHarvestor(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 21, aDescription, aTextures); - this.mLocalName = "Crop Manager ("+GT_Values.VN[aTier]+")"; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity, this.mLocalName); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - - @Override - public boolean isOverclockerUpgradable() { - return true; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public long maxAmperesIn() { - return 8; - } - - @Override - public long getMinimumStoredEU() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUStore() { - return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); - } - - @Override - public long maxEUInput() { - return GT_Values.V[this.mTier]; - } - - @Override - public int getCapacity() { - return 32000 * this.mTier; - } - - @Override - public int getTankPressure() { - return -100; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_CropHarvestor(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public int getSizeInventory() { - return 21; - } - - private static final int getRange(int aTier) { - switch(aTier) { - case 1: - return 1; - case 2: - return 5; - case 3: - return 9; - case 4: - return 13; - case 5: - return 17; - case 6: - return 21; - case 7: - return 25; - case 8: - return 29; - case 9: - return 33; - default: - return 0; - } - } - - private HashSet mCropCache = new HashSet(); - private boolean mInvalidCache = false; - - public boolean doesInventoryHaveSpace() { - for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { - if (this.mInventory[i] == null || this.mInventory[i].stackSize < 64) { - return true; - } - } - return false; - } - - public long powerUsage() { - return this.maxEUInput() / 8; - } - - public long powerUsageSecondary() { - return this.maxEUInput() / 32; - } - - - public static AutoMap splitOutputStacks(ItemStack aOutput) { - return splitOutputStacks(new ItemStack[] {aOutput}); - } - - public static AutoMap splitOutputStacks(ItemStack[] aOutputs) { - AutoMap aOutputMap = new AutoMap(); - for (ItemStack aStack : aOutputs) { - if (aStack != null) { - if (aStack.stackSize <= 64) { - aOutputMap.add(aStack); - } else { - int aStacks = 0; - int aExcess = 0; - int aOriginalSize = aStack.stackSize; - while (aOriginalSize >= 64) { - aStacks += 1; - aOriginalSize -= 64; - } - aExcess = aOriginalSize; - for (int i = 0; i < aStacks; i++) { - aOutputMap.add(ItemUtils.getSimpleStack(aStack, 64)); - } - aOutputMap.add(ItemUtils.getSimpleStack(aStack, aExcess)); - } - } - } - return aOutputMap; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().isAllowedToWork() && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || aTick % 100 == 0)) { - if (this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { - - int aTileX = this.getBaseMetaTileEntity().getXCoord(); - int aTileY = this.getBaseMetaTileEntity().getXCoord(); - int aTileZ = this.getBaseMetaTileEntity().getXCoord(); - - int aRadius = 10 + getRange(this.mTier); - int aSide = (aRadius-1)/2; - ArrayList aAllDrops = new ArrayList(); - - if (this.mCropCache.isEmpty() || aTick % 1200 == 0 || this.mInvalidCache) { - if (!this.mCropCache.isEmpty()) { - this.mCropCache.clear(); - } - //Logger.INFO("Looking for crops."); - for (int y = 0; y <= 2; y++) { - for (int x = (-aSide); x <= aSide; x++) { - for (int z = (-aSide); z <= aSide; z++) { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, y, z); - if (tTileEntity != null && tTileEntity instanceof ICropTile) { - ICropTile tCrop = (ICropTile) tTileEntity; - this.mCropCache.add(tCrop); - } - } - } - } - } - - //Process Cache - if (doesInventoryHaveSpace()) { - for (ICropTile tCrop : this.mCropCache) { - if (tCrop == null) { - this.mInvalidCache = true; - break; - } - CropCard aCrop = tCrop.getCrop(); - if (aCrop != null) { - //Logger.INFO("Found "+aCrop.displayName()+" at offset "+x+", "+y+", "+z); - if (!aCrop.canGrow(tCrop) && aCrop.canBeHarvested(tCrop)) { - if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsage(), true)) { - ItemStack[] aHarvest = tCrop.harvest_automated(true); - if (aHarvest != null && aHarvest.length > 0) { - for (ItemStack aStack : aHarvest) { - if (aStack.stackSize > 0) { - if (this.mTier * 5 > MathUtils.randInt(1, 100)) { - aStack.stackSize += Math.floor(tCrop.getGain()/10); - Logger.INFO("Bonus output given for "+aCrop.displayName()); - } - Logger.INFO("Harvested "+aCrop.displayName()); - aAllDrops.addAll(splitOutputStacks(aStack)); - } - } - } - } - } - if (this.mModeAlternative) { - processSecondaryFunctions(tCrop); - } - } - } - - if (!aAllDrops.isEmpty()) { - Logger.INFO("Handling "+aAllDrops.size()+" Harvests"); - Iterator iter = aAllDrops.iterator(); - while (iter.hasNext()) { - ItemStack aDrop = iter.next(); - if (ItemUtils.checkForInvalidItems(aDrop)) { - - for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { - if (this.mInventory[i] != null) { - //Logger.INFO("Slot "+i+" contains "+this.mInventory[i].getDisplayName()); - if (GT_Utility.areStacksEqual(aDrop, this.mInventory[i], false)) { - //Same - if (this.mInventory[i].stackSize < 64 && (this.mInventory[i].stackSize + aDrop.stackSize <= 64)) { - //can merge - //Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + aDrop.stackSize)); - this.mInventory[i].stackSize += aDrop.stackSize; - break; - } - else if (this.mInventory[i].stackSize < 64 && (this.mInventory[i].stackSize + aDrop.stackSize > 64)) { - //can merge - //Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + aDrop.stackSize)); - int aRemainder = this.mInventory[i].stackSize + aDrop.stackSize - 64; - Logger.INFO("Remainder: "+aRemainder+", Continuing."); - this.mInventory[i].stackSize = 64; - aDrop.stackSize = aRemainder; - continue; - } - else { - //Logger.INFO("Slot "+i+" size: 64, Continuing."); - continue; - } - } - } - else { - //Logger.INFO("Slot "+i+" is empty, setting to "+aDrop.getDisplayName()+" x"+aDrop.stackSize); - this.mInventory[i] = aDrop; - break; - } - } - } - - } - } - } - } - } - } - - public boolean hasFertilizer() { - for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { - if (this.mInventory[i] != null) { - return true; - } - } - return false; - } - - public boolean consumeFertilizer(boolean aSimulate) { - if (hasFertilizer()) { - for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { - if (this.mInventory[i] != null) { - consume(i, 1, aSimulate); - return true; - } - } - } - return false; - } - - public boolean hasWeedEX() { - for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { - if (this.mInventory[i] != null) { - return true; - } - } - return false; - } - - public boolean consumeWeedEX(boolean aSimulate) { - if (hasWeedEX()) { - for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { - if (this.mInventory[i] != null) { - damage(i, 1, aSimulate); - return true; - } - } - } - return false; - } - - public void processSecondaryFunctions(ICropTile aCrop) { - if (!this.mModeAlternative) { - return; - } - if (hasFertilizer() && consumeFertilizer(true) && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) && applyFertilizer(aCrop)) { - if (consumeFertilizer(false)) { - //Logger.INFO("Consumed Fert."); - } - } - if (this.getFluidAmount() > 0 && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) && applyHydration(aCrop)) { - //Logger.INFO("Consumed Water."); - } - if (hasWeedEX() && consumeWeedEX(true) && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) && applyWeedEx(aCrop)) { - if (consumeWeedEX(false)) { - //Logger.INFO("Consumed Weed-EX."); - } - } - } - - - public boolean applyWeedEx(ICropTile aCrop) { - if (aCrop.getWeedExStorage() < 150) { - aCrop.setWeedExStorage(aCrop.getWeedExStorage() + 50); - boolean triggerDecline; - triggerDecline = aCrop.getWorld().rand.nextInt(3) == 0; - if (aCrop.getCrop() != null && aCrop.getCrop().isWeed(aCrop) && aCrop.getWeedExStorage() >= 75 && triggerDecline) { - switch (aCrop.getWorld().rand.nextInt(5)) { - case 0 : - if (aCrop.getGrowth() > 0) { - aCrop.setGrowth((byte) (aCrop.getGrowth() - 1)); - } - case 1 : - if (aCrop.getGain() > 0) { - aCrop.setGain((byte) (aCrop.getGain() - 1)); - } - default : - if (aCrop.getResistance() > 0) { - aCrop.setResistance((byte) (aCrop.getResistance() - 1)); - } - } - } - return true; - } else { - return false; - } - } - - public boolean applyFertilizer(ICropTile aCrop) { - if (aCrop.getNutrientStorage() >= 100) { - return false; - } else { - //Logger.INFO("Current Nutrient: "+aCrop.getNutrientStorage()+" for "+aCrop.getCrop().displayName()); - aCrop.setNutrientStorage(aCrop.getNutrientStorage() + 100); - return true; - } - } - - public boolean applyHydration(ICropTile aCrop) { - if (aCrop.getHydrationStorage() >= 200 || this.getFluidAmount() == 0) { - //Logger.INFO("Hydration Max"); - return false; - } else { - int apply = 200 - aCrop.getHydrationStorage(); - if (this.getFluidAmount() >= 0) { - int drain = 0; - if (this.getFluidAmount() >= apply) { - drain = apply; - } - else { - drain = this.getFluidAmount(); - } - this.mFluid.amount -= drain; - if (this.mFluid.amount <= 0) { - this.mFluid = null; - } - //Logger.INFO("Did Hydrate"); - aCrop.setHydrationStorage(aCrop.getHydrationStorage() + drain); - return true; - } - else { - //Logger.INFO("No water?"); - return false; - } - } - } - - public boolean consume(int aSlot, int amount, boolean simulate) { - ItemStack stack = this.mInventory[aSlot]; - if (stack != null && stack.stackSize >= amount) { - int currentAmount = Math.min(amount, stack.stackSize); - amount -= currentAmount; - if (!simulate) { - if (stack.stackSize == currentAmount) { - this.mInventory[aSlot] = null; - } else { - stack.stackSize -= currentAmount; - } - } - else { - return amount >= 0; - } - return true; - } - return false; - } - - public ItemStack damage(int aSlot, int amount, boolean simulate) { - ItemStack ret = null; - int damageApplied = 0; - ItemStack stack = this.mInventory[aSlot]; - Item item = stack.getItem(); - if (stack != null && item.isDamageable() && (ret == null - || stack.getItem() == ret.getItem() && ItemStack.areItemStackTagsEqual(stack, ret))) { - if (simulate) { - stack = stack.copy(); - } - int maxDamage = DamageHandler.getMaxDamage(stack); - while (amount > 0 && stack.stackSize > 0) { - int currentAmount = Math.min(amount, maxDamage - DamageHandler.getDamage(stack)); - DamageHandler.damage(stack, currentAmount, null); - damageApplied += currentAmount; - amount -= currentAmount; - if (DamageHandler.getDamage(stack) >= maxDamage) { - --stack.stackSize; - DamageHandler.setDamage(stack, 0); - } - - if (ret == null) { - ret = stack.copy(); - } - } - if (stack.stackSize == 0 && !simulate) { - this.mInventory[aSlot] = null; - } - } - - if (ret != null) { - int i = DamageHandler.getMaxDamage(ret); - ret.stackSize = damageApplied / i; - DamageHandler.setDamage(ret, damageApplied % i); - } - return ret; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aStack != null && aIndex >= SLOT_OUTPUT_START && aIndex < this.getSizeInventory(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aStack != null) { - if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) { - return aIndex >= SLOT_FERT_1 && aIndex <= SLOT_FERT_4; - } - else if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) { - return aIndex >= SLOT_WEEDEX_1 && aIndex <= SLOT_WEEDEX_2; - } - } - return false; - } - - @Override - public String[] getDescription() { - int aRadius = 10 + getRange(this.mTier); - int aSide = (aRadius-1)/2; - return new String[] { - this.mDescription, - "Secondary mode can Hydrate/Fertilize/Weed-EX", - "Consumes "+powerUsage()+"eu per harvest", - "Consumes "+powerUsageSecondary()+"eu per secondary operation", - "Can harvest 2 blocks above", - "Radius: "+aSide+" each side ("+aRadius+"x3x"+aRadius+")", - "Has "+(this.mTier * 5)+"% chance for extra drops", - "Holds "+this.getCapacity()+"L of Water", - CORE.GT_Tooltip - }; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return true; - } - - /*@Override - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) - return 118+(aRedstone?8:0); - if (GT_Utility.getOppositeSide(aSide) == aFacing) - return 113+(aRedstone?8:0); - - int tIndex = 128+(aRedstone?8:0); - - switch (aFacing) { - case 0: - return tIndex+64; - case 1: - return tIndex+32; - case 2: switch (aSide) { - case 0: return tIndex+32; - case 1: return tIndex+32; - case 4: return tIndex+16; - case 5: return tIndex+48; - } - case 3: switch (aSide) { - case 0: return tIndex+64; - case 1: return tIndex+64; - case 4: return tIndex+48; - case 5: return tIndex+16; - } - case 4: switch (aSide) { - case 0: return tIndex+16; - case 1: return tIndex+16; - case 2: return tIndex+48; - case 3: return tIndex+16; - } - case 5: switch (aSide) { - case 0: return tIndex+48; - case 1: return tIndex+48; - case 2: return tIndex+16; - case 3: return tIndex+48; - } - } - return tIndex; - } */ - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getBack(i); - rTextures[7][i + 1] = this.getBottom(i); - rTextures[8][i + 1] = this.getTop(i); - rTextures[9][i + 1] = this.getSides(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == 0 || aSide == 1) { - return this.mTextures[3][aColorIndex + 1]; - } - else { - return this.mTextures[4][aColorIndex + 1]; - } - /*return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex - + 1];*/ - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter)}; - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mModeAlternative", this.mModeAlternative); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mModeAlternative = aNBT.getBoolean("mModeAlternative"); - } - + protected String mLocalName; + + private static final int SLOT_WEEDEX_1 = 1; + private static final int SLOT_WEEDEX_2 = 2; + private static final int SLOT_FERT_1 = 3; + private static final int SLOT_FERT_4 = 6; + private static final int SLOT_OUTPUT_START = 7; + + public boolean mModeAlternative = false; + + public GT_MetaTileEntity_CropHarvestor(final int aID, final int aTier, final String aDescription) { + super( + aID, + "basicmachine.cropharvester.0" + aTier, + "Crop Manager (" + GT_Values.VN[aTier] + ")", + aTier, + 21, + aDescription); + this.mLocalName = "Crop Manager (" + GT_Values.VN[aTier] + ")"; + } + + public GT_MetaTileEntity_CropHarvestor( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 21, aDescription, aTextures); + this.mLocalName = "Crop Manager (" + GT_Values.VN[aTier] + ")"; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_CropHarvestor(aPlayerInventory, aBaseMetaTileEntity, this.mLocalName); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public long maxAmperesIn() { + return 8; + } + + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public int getCapacity() { + return 32000 * this.mTier; + } + + @Override + public int getTankPressure() { + return -100; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_CropHarvestor(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getSizeInventory() { + return 21; + } + + private static final int getRange(int aTier) { + switch (aTier) { + case 1: + return 1; + case 2: + return 5; + case 3: + return 9; + case 4: + return 13; + case 5: + return 17; + case 6: + return 21; + case 7: + return 25; + case 8: + return 29; + case 9: + return 33; + default: + return 0; + } + } + + private HashSet mCropCache = new HashSet(); + private boolean mInvalidCache = false; + + public boolean doesInventoryHaveSpace() { + for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { + if (this.mInventory[i] == null || this.mInventory[i].stackSize < 64) { + return true; + } + } + return false; + } + + public long powerUsage() { + return this.maxEUInput() / 8; + } + + public long powerUsageSecondary() { + return this.maxEUInput() / 32; + } + + public static AutoMap splitOutputStacks(ItemStack aOutput) { + return splitOutputStacks(new ItemStack[] {aOutput}); + } + + public static AutoMap splitOutputStacks(ItemStack[] aOutputs) { + AutoMap aOutputMap = new AutoMap(); + for (ItemStack aStack : aOutputs) { + if (aStack != null) { + if (aStack.stackSize <= 64) { + aOutputMap.add(aStack); + } else { + int aStacks = 0; + int aExcess = 0; + int aOriginalSize = aStack.stackSize; + while (aOriginalSize >= 64) { + aStacks += 1; + aOriginalSize -= 64; + } + aExcess = aOriginalSize; + for (int i = 0; i < aStacks; i++) { + aOutputMap.add(ItemUtils.getSimpleStack(aStack, 64)); + } + aOutputMap.add(ItemUtils.getSimpleStack(aStack, aExcess)); + } + } + } + return aOutputMap; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isServerSide() + && getBaseMetaTileEntity().isAllowedToWork() + && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || aTick % 100 == 0)) { + if (this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { + + int aTileX = this.getBaseMetaTileEntity().getXCoord(); + int aTileY = this.getBaseMetaTileEntity().getXCoord(); + int aTileZ = this.getBaseMetaTileEntity().getXCoord(); + + int aRadius = 10 + getRange(this.mTier); + int aSide = (aRadius - 1) / 2; + ArrayList aAllDrops = new ArrayList(); + + if (this.mCropCache.isEmpty() || aTick % 1200 == 0 || this.mInvalidCache) { + if (!this.mCropCache.isEmpty()) { + this.mCropCache.clear(); + } + // Logger.INFO("Looking for crops."); + for (int y = 0; y <= 2; y++) { + for (int x = (-aSide); x <= aSide; x++) { + for (int z = (-aSide); z <= aSide; z++) { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, y, z); + if (tTileEntity != null && tTileEntity instanceof ICropTile) { + ICropTile tCrop = (ICropTile) tTileEntity; + this.mCropCache.add(tCrop); + } + } + } + } + } + + // Process Cache + if (doesInventoryHaveSpace()) { + for (ICropTile tCrop : this.mCropCache) { + if (tCrop == null) { + this.mInvalidCache = true; + break; + } + CropCard aCrop = tCrop.getCrop(); + if (aCrop != null) { + // Logger.INFO("Found "+aCrop.displayName()+" at offset "+x+", "+y+", "+z); + if (!aCrop.canGrow(tCrop) && aCrop.canBeHarvested(tCrop)) { + if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsage(), true)) { + ItemStack[] aHarvest = tCrop.harvest_automated(true); + if (aHarvest != null && aHarvest.length > 0) { + for (ItemStack aStack : aHarvest) { + if (aStack.stackSize > 0) { + if (this.mTier * 5 > MathUtils.randInt(1, 100)) { + aStack.stackSize += Math.floor(tCrop.getGain() / 10); + Logger.INFO("Bonus output given for " + aCrop.displayName()); + } + Logger.INFO("Harvested " + aCrop.displayName()); + aAllDrops.addAll(splitOutputStacks(aStack)); + } + } + } + } + } + if (this.mModeAlternative) { + processSecondaryFunctions(tCrop); + } + } + } + + if (!aAllDrops.isEmpty()) { + Logger.INFO("Handling " + aAllDrops.size() + " Harvests"); + Iterator iter = aAllDrops.iterator(); + while (iter.hasNext()) { + ItemStack aDrop = iter.next(); + if (ItemUtils.checkForInvalidItems(aDrop)) { + + for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { + if (this.mInventory[i] != null) { + // Logger.INFO("Slot "+i+" contains "+this.mInventory[i].getDisplayName()); + if (GT_Utility.areStacksEqual(aDrop, this.mInventory[i], false)) { + // Same + if (this.mInventory[i].stackSize < 64 + && (this.mInventory[i].stackSize + aDrop.stackSize <= 64)) { + // can merge + // Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop + // Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + + // aDrop.stackSize)); + this.mInventory[i].stackSize += aDrop.stackSize; + break; + } else if (this.mInventory[i].stackSize < 64 + && (this.mInventory[i].stackSize + aDrop.stackSize > 64)) { + // can merge + // Logger.INFO("Slot "+i+" size: "+mInventory[i].stackSize+" + Drop + // Size: "+aDrop.stackSize+" = "+(mInventory[i].stackSize + + // aDrop.stackSize)); + int aRemainder = this.mInventory[i].stackSize + aDrop.stackSize - 64; + Logger.INFO("Remainder: " + aRemainder + ", Continuing."); + this.mInventory[i].stackSize = 64; + aDrop.stackSize = aRemainder; + continue; + } else { + // Logger.INFO("Slot "+i+" size: 64, Continuing."); + continue; + } + } + } else { + // Logger.INFO("Slot "+i+" is empty, setting to "+aDrop.getDisplayName()+" + // x"+aDrop.stackSize); + this.mInventory[i] = aDrop; + break; + } + } + } + } + } + } + } + } + } + + public boolean hasFertilizer() { + for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { + if (this.mInventory[i] != null) { + return true; + } + } + return false; + } + + public boolean consumeFertilizer(boolean aSimulate) { + if (hasFertilizer()) { + for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { + if (this.mInventory[i] != null) { + consume(i, 1, aSimulate); + return true; + } + } + } + return false; + } + + public boolean hasWeedEX() { + for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { + if (this.mInventory[i] != null) { + return true; + } + } + return false; + } + + public boolean consumeWeedEX(boolean aSimulate) { + if (hasWeedEX()) { + for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { + if (this.mInventory[i] != null) { + damage(i, 1, aSimulate); + return true; + } + } + } + return false; + } + + public void processSecondaryFunctions(ICropTile aCrop) { + if (!this.mModeAlternative) { + return; + } + if (hasFertilizer() + && consumeFertilizer(true) + && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() + && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) + && applyFertilizer(aCrop)) { + if (consumeFertilizer(false)) { + // Logger.INFO("Consumed Fert."); + } + } + if (this.getFluidAmount() > 0 + && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() + && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) + && applyHydration(aCrop)) { + // Logger.INFO("Consumed Water."); + } + if (hasWeedEX() + && consumeWeedEX(true) + && this.getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU() + && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) + && applyWeedEx(aCrop)) { + if (consumeWeedEX(false)) { + // Logger.INFO("Consumed Weed-EX."); + } + } + } + + public boolean applyWeedEx(ICropTile aCrop) { + if (aCrop.getWeedExStorage() < 150) { + aCrop.setWeedExStorage(aCrop.getWeedExStorage() + 50); + boolean triggerDecline; + triggerDecline = aCrop.getWorld().rand.nextInt(3) == 0; + if (aCrop.getCrop() != null + && aCrop.getCrop().isWeed(aCrop) + && aCrop.getWeedExStorage() >= 75 + && triggerDecline) { + switch (aCrop.getWorld().rand.nextInt(5)) { + case 0: + if (aCrop.getGrowth() > 0) { + aCrop.setGrowth((byte) (aCrop.getGrowth() - 1)); + } + case 1: + if (aCrop.getGain() > 0) { + aCrop.setGain((byte) (aCrop.getGain() - 1)); + } + default: + if (aCrop.getResistance() > 0) { + aCrop.setResistance((byte) (aCrop.getResistance() - 1)); + } + } + } + return true; + } else { + return false; + } + } + + public boolean applyFertilizer(ICropTile aCrop) { + if (aCrop.getNutrientStorage() >= 100) { + return false; + } else { + // Logger.INFO("Current Nutrient: "+aCrop.getNutrientStorage()+" for "+aCrop.getCrop().displayName()); + aCrop.setNutrientStorage(aCrop.getNutrientStorage() + 100); + return true; + } + } + + public boolean applyHydration(ICropTile aCrop) { + if (aCrop.getHydrationStorage() >= 200 || this.getFluidAmount() == 0) { + // Logger.INFO("Hydration Max"); + return false; + } else { + int apply = 200 - aCrop.getHydrationStorage(); + if (this.getFluidAmount() >= 0) { + int drain = 0; + if (this.getFluidAmount() >= apply) { + drain = apply; + } else { + drain = this.getFluidAmount(); + } + this.mFluid.amount -= drain; + if (this.mFluid.amount <= 0) { + this.mFluid = null; + } + // Logger.INFO("Did Hydrate"); + aCrop.setHydrationStorage(aCrop.getHydrationStorage() + drain); + return true; + } else { + // Logger.INFO("No water?"); + return false; + } + } + } + + public boolean consume(int aSlot, int amount, boolean simulate) { + ItemStack stack = this.mInventory[aSlot]; + if (stack != null && stack.stackSize >= amount) { + int currentAmount = Math.min(amount, stack.stackSize); + amount -= currentAmount; + if (!simulate) { + if (stack.stackSize == currentAmount) { + this.mInventory[aSlot] = null; + } else { + stack.stackSize -= currentAmount; + } + } else { + return amount >= 0; + } + return true; + } + return false; + } + + public ItemStack damage(int aSlot, int amount, boolean simulate) { + ItemStack ret = null; + int damageApplied = 0; + ItemStack stack = this.mInventory[aSlot]; + Item item = stack.getItem(); + if (stack != null + && item.isDamageable() + && (ret == null || stack.getItem() == ret.getItem() && ItemStack.areItemStackTagsEqual(stack, ret))) { + if (simulate) { + stack = stack.copy(); + } + int maxDamage = DamageHandler.getMaxDamage(stack); + while (amount > 0 && stack.stackSize > 0) { + int currentAmount = Math.min(amount, maxDamage - DamageHandler.getDamage(stack)); + DamageHandler.damage(stack, currentAmount, null); + damageApplied += currentAmount; + amount -= currentAmount; + if (DamageHandler.getDamage(stack) >= maxDamage) { + --stack.stackSize; + DamageHandler.setDamage(stack, 0); + } + + if (ret == null) { + ret = stack.copy(); + } + } + if (stack.stackSize == 0 && !simulate) { + this.mInventory[aSlot] = null; + } + } + + if (ret != null) { + int i = DamageHandler.getMaxDamage(ret); + ret.stackSize = damageApplied / i; + DamageHandler.setDamage(ret, damageApplied % i); + } + return ret; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aStack != null && aIndex >= SLOT_OUTPUT_START && aIndex < this.getSizeInventory(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aStack != null) { + if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) { + return aIndex >= SLOT_FERT_1 && aIndex <= SLOT_FERT_4; + } else if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) { + return aIndex >= SLOT_WEEDEX_1 && aIndex <= SLOT_WEEDEX_2; + } + } + return false; + } + + @Override + public String[] getDescription() { + int aRadius = 10 + getRange(this.mTier); + int aSide = (aRadius - 1) / 2; + return new String[] { + this.mDescription, + "Secondary mode can Hydrate/Fertilize/Weed-EX", + "Consumes " + powerUsage() + "eu per harvest", + "Consumes " + powerUsageSecondary() + "eu per secondary operation", + "Can harvest 2 blocks above", + "Radius: " + aSide + " each side (" + aRadius + "x3x" + aRadius + ")", + "Has " + (this.mTier * 5) + "% chance for extra drops", + "Holds " + this.getCapacity() + "L of Water", + CORE.GT_Tooltip + }; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return true; + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) + return 118+(aRedstone?8:0); + if (GT_Utility.getOppositeSide(aSide) == aFacing) + return 113+(aRedstone?8:0); + + int tIndex = 128+(aRedstone?8:0); + + switch (aFacing) { + case 0: + return tIndex+64; + case 1: + return tIndex+32; + case 2: switch (aSide) { + case 0: return tIndex+32; + case 1: return tIndex+32; + case 4: return tIndex+16; + case 5: return tIndex+48; + } + case 3: switch (aSide) { + case 0: return tIndex+64; + case 1: return tIndex+64; + case 4: return tIndex+48; + case 5: return tIndex+16; + } + case 4: switch (aSide) { + case 0: return tIndex+16; + case 1: return tIndex+16; + case 2: return tIndex+48; + case 3: return tIndex+16; + } + case 5: switch (aSide) { + case 0: return tIndex+48; + case 1: return tIndex+48; + case 2: return tIndex+16; + case 3: return tIndex+48; + } + } + return tIndex; + } */ + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getBack(i); + rTextures[7][i + 1] = this.getBottom(i); + rTextures[8][i + 1] = this.getTop(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == 0 || aSide == 1) { + return this.mTextures[3][aColorIndex + 1]; + } else { + return this.mTextures[4][aColorIndex + 1]; + } + /*return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1];*/ + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) + }; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mModeAlternative", this.mModeAlternative); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mModeAlternative = aNBT.getBoolean("mModeAlternative"); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_WorldAccelerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_WorldAccelerator.java index 129446c40d..6ba1e373eb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_WorldAccelerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_WorldAccelerator.java @@ -2,21 +2,8 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; import static gregtech.api.enums.GT_Values.V; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - 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.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons.CustomIcon; import gregtech.api.interfaces.ITexture; @@ -24,305 +11,313 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class GT_MetaTileEntity_WorldAccelerator extends GT_MetaTileEntity_TieredMachineBlock { - public static String[] BlacklistedTileEntiyClassNames; - - private byte mMode = 0; // 0: RandomTicks around 1: TileEntities with range - // 1 - private static CustomIcon _mGTIco_Norm_Idle; - private static CustomIcon _mGTIco_Norm_Active; - private static CustomIcon _mGTIco_TE_Idle; - private static CustomIcon _mGTIco_TE_Active; - private static int[] mAccelerateStatic = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, 512, 512, 512, 512, 512 }; - - @Override - public void registerIcons(IIconRegister aBlockIconRegister) { - super.registerIcons(aBlockIconRegister); - _mGTIco_Norm_Idle = new CustomIcon("iconsets/OVERLAY_ACCELERATOR"); - _mGTIco_Norm_Active = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_ACTIVE"); - _mGTIco_TE_Idle = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_TE"); - _mGTIco_TE_Active = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_TE_ACTIVE"); - } - - @SideOnly(Side.CLIENT) - @Override - public void onValueUpdate(byte aValue) { - mMode = aValue; - } - - @Override - public byte getUpdateData() { - return mMode; - } - - public GT_MetaTileEntity_WorldAccelerator(int pID, String pName, String pNameRegional, int pTier) { - super(pID, pName, pNameRegional, pTier, 0, ""); - } - - @Override - public String[] getDescription() { - return new String[] { - String.format("Accelerating things (Radius: %d EU/t: %d Speed Bonus: x%d)", mTier, - getEnergyDemand(mTier, false), mAccelerateStatic[mTier]), - "Use a screwdriver to change mode", "To accelerate TileEntities, this machine has to be adjacent to it", - "This machine accepts up to 8 Amps", "Accelerating TileEntities doubles Energy-Demand"}; - - } - - public GT_MetaTileEntity_WorldAccelerator(String pName, int pTier, int pInvSlotCount, String pDescription, - ITexture[][][] pTextures) { - super(pName, pTier, pInvSlotCount, pDescription, pTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity pTileEntity) { - return new GT_MetaTileEntity_WorldAccelerator(mName, mTier, mInventory.length, mDescription, mTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] pTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity pBaseMetaTileEntity, byte pSide, byte pFacing, byte pColorIndex, - boolean pActive, boolean pRedstone) { - if (mMode == 0) - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][pColorIndex + 1], - (pSide < 2) ? null - : pActive ? new GT_RenderedTexture(_mGTIco_Norm_Active) - : new GT_RenderedTexture(_mGTIco_Norm_Idle) }; - else - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][pColorIndex + 1], (pSide < 2) ? null - : pActive ? new GT_RenderedTexture(_mGTIco_TE_Active) : new GT_RenderedTexture(_mGTIco_TE_Idle) }; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity pBaseMetaTileEntity, int pIndex, byte pSide, ItemStack pStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity pBaseMetaTileEntity, int pIndex, byte pSide, ItemStack pStack) { - return false; - } - - @Override - public void saveNBTData(NBTTagCompound pNBT) { - pNBT.setByte("mAccelMode", mMode); - } - - public static long getEnergyDemand(int pTier, boolean pIsAcceleratingTEs) { - return V[pTier] * (pIsAcceleratingTEs ? 6 : 3); - } - - @Override - public void loadNBTData(NBTTagCompound pNBT) { - mMode = pNBT.getByte("mAccelMode"); - } - - @Override - public boolean isAccessAllowed(EntityPlayer pPlayer) { - return true; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return true; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public long maxEUStore() { - return 512 + V[mTier] * 50; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public long maxAmperesIn() { - return 8; - } - - private static String[] mModeStr = { "Blocks", "TileEntities" }; - - @Override - public void onScrewdriverRightClick(byte pSide, EntityPlayer pPlayer, float pX, float pY, float pZ) { - mMode = (byte) (mMode == 0x00 ? 0x01 : 0x00); - markDirty(); - PlayerUtils.messagePlayer(pPlayer, String.format("Switched mode to: %s", mModeStr[mMode])); - } - - @Override - public void onPostTick(IGregTechTileEntity pBaseMetaTileEntity, long pTick) { - try { - if (!pBaseMetaTileEntity.isServerSide()) - return; - - long tEnergyDemand = getEnergyDemand(mTier, (mMode == 1)); - - // Do we have enough energy to run? Or are we not allowed to run? - if (pBaseMetaTileEntity.getStoredEU() < tEnergyDemand || !pBaseMetaTileEntity.isAllowedToWork()) { - // Check if machine was active before - if (pBaseMetaTileEntity.isActive()) - pBaseMetaTileEntity.setActive(false); // Then disable it now - } else { - // Continue to drain power - if (pBaseMetaTileEntity.decreaseStoredEnergyUnits(tEnergyDemand, false)) { - World tWorld = pBaseMetaTileEntity.getWorld(); - // Limit the random ticks to once per second - if (mMode == 0) { - if (pTick % 20 == 0) - doAccelerateNormalBlocks(pBaseMetaTileEntity, tWorld); - } else - doAccelerateTileEntities(pBaseMetaTileEntity, tWorld); - - } else { - // Energy drain failed. Disable machine - if (pBaseMetaTileEntity.isActive()) - pBaseMetaTileEntity.setActive(false); - } - } - } catch (Exception e) { - Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.onPostTick.crash"); - Logger.ERROR(e.getMessage()); - } - } - - private void doAccelerateTileEntities(IGregTechTileEntity pBaseMetaTileEntity, World pWorld) { - try { - if (!pBaseMetaTileEntity.isActive()) - getBaseMetaTileEntity().setActive(true); - - for (ForgeDirection tDir : ForgeDirection.VALID_DIRECTIONS) { - TileEntity tTile = pBaseMetaTileEntity.getTileEntityAtSide((byte) tDir.ordinal()); - if (isTEBlackListed(tTile)) - continue; - - long tMaxTime = System.nanoTime() + 1000000; - for (int j = 0; j < mAccelerateStatic[mTier]; j++) { - tTile.updateEntity(); - if (System.nanoTime() > tMaxTime) - break; - } - } - } catch (Exception e) { - Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.doAccelerateTileEntities.crash"); - Logger.ERROR(e.getMessage()); - } - } - - private static List _mBlacklistedTileEntities = new ArrayList(); - - // Inspired by ChromatiCraft's TileAccelerator - private boolean isTEBlackListed(TileEntity pTile) { - if (pTile == null) - return true; // Obvious - if (!pTile.canUpdate()) - return true; // Skip if TE can't update at all - if (pTile.isInvalid()) - return true; // Obvious - - String tSimpleClassName = pTile.getClass().getSimpleName().toLowerCase(); - String tCanonicalName = pTile.getClass().getCanonicalName().toLowerCase(); - if (tSimpleClassName.contains("conduit") || tSimpleClassName.contains("wire") - || tSimpleClassName.contains("cable")) - return true; - if (tCanonicalName.contains("appeng") || tCanonicalName.contains("gregtech")) - // Don't accelerate ANY Gregtech machines! - return true; - for (String tS : BlacklistedTileEntiyClassNames) { - if (tCanonicalName.equalsIgnoreCase(tS)) - return true; - } - - return false; - } - - /** - * Accelerate normal blocks. Eats some power and adds randomTicks to every - * block within its working area (Tier-Number = radius) This does only - * affect blocks that implement the "RandomTick" method; Which is mostly - * used for grass growth and plants. - * - * @param pBaseMetaTileEntity - */ - private void doAccelerateNormalBlocks(IGregTechTileEntity pBaseMetaTileEntity, World pWorld) { - if (!pBaseMetaTileEntity.isActive()) - getBaseMetaTileEntity().setActive(true); - - Random rnd = new Random(); - int tX = pBaseMetaTileEntity.getXCoord(); - int tY = pBaseMetaTileEntity.getYCoord(); - int tZ = pBaseMetaTileEntity.getZCoord(); - - int tX1 = tX - mTier; - int tX2 = tX + mTier; - int tY1 = Math.max(tY - mTier, 0); // Limit to bedrock - int tY2 = Math.min(tY + mTier, 255); // Limit to build height - int tZ1 = tZ - mTier; - int tZ2 = tZ + mTier; - - for (int xi = tX1; xi <= tX2; xi++) - for (int yi = tY1; yi <= tY2; yi++) - for (int zi = tZ1; zi <= tZ2; zi++) - tryTickBlock(pWorld, xi, yi, zi, rnd); - - } - - /** - * Send a tick to the target block - * - * @param pWorld - * @param pX - * @param pY - * @param pZ - * @param pRnd - */ - private void tryTickBlock(World pWorld, int pX, int pY, int pZ, Random pRnd) { - try { - for (int j = 0; j < mTier; j++) { - Block tBlock = pWorld.getBlock(pX, pY, pZ); - if (tBlock.getTickRandomly()) - tBlock.updateTick(pWorld, pX, pY, pZ, pRnd); - } - } catch (Exception e) { - Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.tryTickBlock.crash"); - Logger.ERROR(e.getMessage()); - } - } -} \ No newline at end of file + public static String[] BlacklistedTileEntiyClassNames; + + private byte mMode = 0; // 0: RandomTicks around 1: TileEntities with range + // 1 + private static CustomIcon _mGTIco_Norm_Idle; + private static CustomIcon _mGTIco_Norm_Active; + private static CustomIcon _mGTIco_TE_Idle; + private static CustomIcon _mGTIco_TE_Active; + private static int[] mAccelerateStatic = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, 512, 512, 512, 512, 512}; + + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + _mGTIco_Norm_Idle = new CustomIcon("iconsets/OVERLAY_ACCELERATOR"); + _mGTIco_Norm_Active = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_ACTIVE"); + _mGTIco_TE_Idle = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_TE"); + _mGTIco_TE_Active = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_TE_ACTIVE"); + } + + @SideOnly(Side.CLIENT) + @Override + public void onValueUpdate(byte aValue) { + mMode = aValue; + } + + @Override + public byte getUpdateData() { + return mMode; + } + + public GT_MetaTileEntity_WorldAccelerator(int pID, String pName, String pNameRegional, int pTier) { + super(pID, pName, pNameRegional, pTier, 0, ""); + } + + @Override + public String[] getDescription() { + return new String[] { + String.format( + "Accelerating things (Radius: %d EU/t: %d Speed Bonus: x%d)", + mTier, getEnergyDemand(mTier, false), mAccelerateStatic[mTier]), + "Use a screwdriver to change mode", + "To accelerate TileEntities, this machine has to be adjacent to it", + "This machine accepts up to 8 Amps", + "Accelerating TileEntities doubles Energy-Demand" + }; + } + + public GT_MetaTileEntity_WorldAccelerator( + String pName, int pTier, int pInvSlotCount, String pDescription, ITexture[][][] pTextures) { + super(pName, pTier, pInvSlotCount, pDescription, pTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity pTileEntity) { + return new GT_MetaTileEntity_WorldAccelerator(mName, mTier, mInventory.length, mDescription, mTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] pTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture( + IGregTechTileEntity pBaseMetaTileEntity, + byte pSide, + byte pFacing, + byte pColorIndex, + boolean pActive, + boolean pRedstone) { + if (mMode == 0) + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][pColorIndex + 1], + (pSide < 2) + ? null + : pActive + ? new GT_RenderedTexture(_mGTIco_Norm_Active) + : new GT_RenderedTexture(_mGTIco_Norm_Idle) + }; + else + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][pColorIndex + 1], + (pSide < 2) + ? null + : pActive ? new GT_RenderedTexture(_mGTIco_TE_Active) : new GT_RenderedTexture(_mGTIco_TE_Idle) + }; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity pBaseMetaTileEntity, int pIndex, byte pSide, ItemStack pStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity pBaseMetaTileEntity, int pIndex, byte pSide, ItemStack pStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound pNBT) { + pNBT.setByte("mAccelMode", mMode); + } + + public static long getEnergyDemand(int pTier, boolean pIsAcceleratingTEs) { + return V[pTier] * (pIsAcceleratingTEs ? 6 : 3); + } + + @Override + public void loadNBTData(NBTTagCompound pNBT) { + mMode = pNBT.getByte("mAccelMode"); + } + + @Override + public boolean isAccessAllowed(EntityPlayer pPlayer) { + return true; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return true; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUStore() { + return 512 + V[mTier] * 50; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxAmperesIn() { + return 8; + } + + private static String[] mModeStr = {"Blocks", "TileEntities"}; + + @Override + public void onScrewdriverRightClick(byte pSide, EntityPlayer pPlayer, float pX, float pY, float pZ) { + mMode = (byte) (mMode == 0x00 ? 0x01 : 0x00); + markDirty(); + PlayerUtils.messagePlayer(pPlayer, String.format("Switched mode to: %s", mModeStr[mMode])); + } + + @Override + public void onPostTick(IGregTechTileEntity pBaseMetaTileEntity, long pTick) { + try { + if (!pBaseMetaTileEntity.isServerSide()) return; + + long tEnergyDemand = getEnergyDemand(mTier, (mMode == 1)); + + // Do we have enough energy to run? Or are we not allowed to run? + if (pBaseMetaTileEntity.getStoredEU() < tEnergyDemand || !pBaseMetaTileEntity.isAllowedToWork()) { + // Check if machine was active before + if (pBaseMetaTileEntity.isActive()) pBaseMetaTileEntity.setActive(false); // Then disable it now + } else { + // Continue to drain power + if (pBaseMetaTileEntity.decreaseStoredEnergyUnits(tEnergyDemand, false)) { + World tWorld = pBaseMetaTileEntity.getWorld(); + // Limit the random ticks to once per second + if (mMode == 0) { + if (pTick % 20 == 0) doAccelerateNormalBlocks(pBaseMetaTileEntity, tWorld); + } else doAccelerateTileEntities(pBaseMetaTileEntity, tWorld); + + } else { + // Energy drain failed. Disable machine + if (pBaseMetaTileEntity.isActive()) pBaseMetaTileEntity.setActive(false); + } + } + } catch (Exception e) { + Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.onPostTick.crash"); + Logger.ERROR(e.getMessage()); + } + } + + private void doAccelerateTileEntities(IGregTechTileEntity pBaseMetaTileEntity, World pWorld) { + try { + if (!pBaseMetaTileEntity.isActive()) getBaseMetaTileEntity().setActive(true); + + for (ForgeDirection tDir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tTile = pBaseMetaTileEntity.getTileEntityAtSide((byte) tDir.ordinal()); + if (isTEBlackListed(tTile)) continue; + + long tMaxTime = System.nanoTime() + 1000000; + for (int j = 0; j < mAccelerateStatic[mTier]; j++) { + tTile.updateEntity(); + if (System.nanoTime() > tMaxTime) break; + } + } + } catch (Exception e) { + Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.doAccelerateTileEntities.crash"); + Logger.ERROR(e.getMessage()); + } + } + + private static List _mBlacklistedTileEntities = new ArrayList(); + + // Inspired by ChromatiCraft's TileAccelerator + private boolean isTEBlackListed(TileEntity pTile) { + if (pTile == null) return true; // Obvious + if (!pTile.canUpdate()) return true; // Skip if TE can't update at all + if (pTile.isInvalid()) return true; // Obvious + + String tSimpleClassName = pTile.getClass().getSimpleName().toLowerCase(); + String tCanonicalName = pTile.getClass().getCanonicalName().toLowerCase(); + if (tSimpleClassName.contains("conduit") + || tSimpleClassName.contains("wire") + || tSimpleClassName.contains("cable")) return true; + if (tCanonicalName.contains("appeng") || tCanonicalName.contains("gregtech")) + // Don't accelerate ANY Gregtech machines! + return true; + for (String tS : BlacklistedTileEntiyClassNames) { + if (tCanonicalName.equalsIgnoreCase(tS)) return true; + } + + return false; + } + + /** + * Accelerate normal blocks. Eats some power and adds randomTicks to every + * block within its working area (Tier-Number = radius) This does only + * affect blocks that implement the "RandomTick" method; Which is mostly + * used for grass growth and plants. + * + * @param pBaseMetaTileEntity + */ + private void doAccelerateNormalBlocks(IGregTechTileEntity pBaseMetaTileEntity, World pWorld) { + if (!pBaseMetaTileEntity.isActive()) getBaseMetaTileEntity().setActive(true); + + Random rnd = new Random(); + int tX = pBaseMetaTileEntity.getXCoord(); + int tY = pBaseMetaTileEntity.getYCoord(); + int tZ = pBaseMetaTileEntity.getZCoord(); + + int tX1 = tX - mTier; + int tX2 = tX + mTier; + int tY1 = Math.max(tY - mTier, 0); // Limit to bedrock + int tY2 = Math.min(tY + mTier, 255); // Limit to build height + int tZ1 = tZ - mTier; + int tZ2 = tZ + mTier; + + for (int xi = tX1; xi <= tX2; xi++) + for (int yi = tY1; yi <= tY2; yi++) + for (int zi = tZ1; zi <= tZ2; zi++) tryTickBlock(pWorld, xi, yi, zi, rnd); + } + + /** + * Send a tick to the target block + * + * @param pWorld + * @param pX + * @param pY + * @param pZ + * @param pRnd + */ + private void tryTickBlock(World pWorld, int pX, int pY, int pZ, Random pRnd) { + try { + for (int j = 0; j < mTier; j++) { + Block tBlock = pWorld.getBlock(pX, pY, pZ); + if (tBlock.getTickRandomly()) tBlock.updateTick(pWorld, pX, pY, pZ, pRnd); + } + } catch (Exception e) { + Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.tryTickBlock.crash"); + Logger.ERROR(e.getMessage()); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index 33ffd1f118..23263bd9fd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; import static gregtech.api.enums.GT_Values.V; -import org.apache.commons.lang3.ArrayUtils; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; @@ -34,834 +32,865 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import org.apache.commons.lang3.ArrayUtils; public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_BasicMachine { - public int mPollutionReduction = 0; - protected int mBaseEff = 2500; - protected int mOptimalAirFlow = 0; - protected boolean mHasPollution = false; - protected int SLOT_ROTOR = 5; - protected int SLOT_FILTER = 6; - protected static boolean mPollutionEnabled = true; - - protected boolean mSaveRotor = false; - - public GregtechMetaAtmosphericReconditioner(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 2, "Making sure you don't live in Gwalior - Uses 2A", 3, 0, "Recycler.png", "", - new ITexture[]{ - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) - }); - mPollutionEnabled = PollutionUtils.isPollutionEnabled(); - } - - public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); - mPollutionEnabled = PollutionUtils.isPollutionEnabled(); - } - - /*public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); - }*/ - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaAtmosphericReconditioner(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); - } - - @Override - public String[] getDescription() { - - boolean highTier = this.mTier >= 7; - - String[] A = new String[]{ - this.mDescription, - highTier ? "Will attempt to remove 1/4 pollution from 8 surrounding chunks" : "", - highTier ? "If these chunks are not loaded, they will be ignored" : "", - "Requires a turbine rotor and an Air Filter [T1/T2] to run.", - "The turbine rotor must be manually inserted/replaced", - "Can be configured with a soldering iron to change modes", - "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", - "High Efficiency: Removes full pollution, Turbine takes 100% dmg", - "Turbine Rotor will not break in LE mode", - "Insert an equal tier Conveyor Module to enable automation" - }; - if (!mPollutionEnabled) { - String[] B = new String[] { - "===============================================", - "Pollution is disabled, scrubbers will now have a bonus use", - "They are now able to remove ALL lingering pollution as GT ignores it", - "and it will linger forever!", - "===============================================", - }; - A = ArrayUtils.addAll(A, B); - } - return A; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); - aNBT.setBoolean("mSaveRotor", mSaveRotor); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mOptimalAirFlow = aNBT.getInteger("mOptimalAirFlow"); - this.mSaveRotor = aNBT.getBoolean("mSaveRotor"); - } - - @Override - public long maxAmperesIn() { - return 2; - } - - @Override - public long getMinimumStoredEU() { - return V[mTier] * 2; - } - - @Override - public long maxEUStore() { - return V[mTier] * 256; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - - //Get Current Pollution Amount. - int mCurrentPollution = getCurrentChunkPollution(); - boolean isIdle = true; - - //Get Inventory Item - ItemStack stackRotor = this.mInventory[SLOT_ROTOR]; - ItemStack stackFilter = this.mInventory[SLOT_FILTER]; - - //Power Drain - long drainEU = maxEUInput() * maxAmperesIn(); - if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU){ - if(aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)){ - isIdle = false; - } - else { - aBaseMetaTileEntity.setActive(false); - this.sendSound((byte) -122); - } - } - else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU/4){ - if(aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU/4), false)){ - isIdle = false; - } - else { - aBaseMetaTileEntity.setActive(false); - this.sendSound((byte) -122); - } - } - else { - aBaseMetaTileEntity.setActive(false); - this.sendSound((byte) -122); - } - - //Only try once/sec. - if (!isIdle && aTick % 20L == 0L){ - - - - for (int i=0;i 0){ - Logger.INFO("Has Pollution? "+mHasPollution+", Current Pollution: "+mCurrentPollution); - - //Only check every 30s. - if (!isIdle && aTick % (20L * 30) == 0L){ - mPollutionEnabled = PollutionUtils.isPollutionEnabled(); - //Clear out pollution if it's disabled, because I am a nice gal. - if (!PollutionUtils.isPollutionEnabled()) { - PollutionUtils.nullifyPollution(this.getBaseMetaTileEntity()); - } - } - - - - - //Use a Turbine - if(hasRotor(stackRotor) && hasAirFilter(stackFilter)){ - Logger.INFO("Found Turbine."); - - mBaseEff = getBaseEfficiency(stackRotor); - mOptimalAirFlow = getOptimalAirFlow(stackRotor); - - //Make sure we have a valid Turbine and Eff/Airflow - if (this.mBaseEff > 0 && this.mOptimalAirFlow > 0){ - //Utils.LOG_WARNING("Pollution Cleaner [5]"); - - //Log Debug information. - Logger.INFO("mBaseEff[1]:"+mBaseEff); - Logger.INFO("mOptimalAirFlow[1]:"+mOptimalAirFlow); - - //Calculate The Voltage we are running - long tVoltage = drainEU; - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - //Check Sides for Air, - //More air means more pollution processing. - int mAirSides = getFreeSpaces(); - - int reduction = 0; - - //If no sides are free, how will you process the atmosphere? - if (mAirSides > 0){ - reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); //Was originally *100 - Logger.INFO("mPollutionReduction[1]:"+reduction); - - //I stole this code - reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); - Logger.INFO("reduction[2]:"+reduction); - reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); - Logger.INFO("reduction[3]:"+reduction); - - mPollutionReduction = reduction; - - //Set a temp to remove variable to aleviate duplicate code. - int toRemove = 0; - - Logger.INFO("mCurrentPollution[4]:"+mCurrentPollution); - Logger.INFO("mCurrentPollution[5]:"+reduction); - if (reduction <= mCurrentPollution){ - //Clean some Air. - toRemove = reduction; - } - else { - //Makes sure we don't get negative pollution. - toRemove = mCurrentPollution; - } - - toRemove = toRemove/2; - Logger.INFO("mCurrentPollution[6]:"+toRemove); - - //We are good to clean - if (toRemove > 0){ - if (damageTurbineRotor() && damageAirFilter()){ - Logger.INFO("Removing "+toRemove+" pollution"); - removePollution(mSaveRotor ? (toRemove/2) : toRemove); - Logger.INFO("mNewPollution[4]:"+getCurrentChunkPollution()); - } - else { - Logger.INFO("Could not damage turbine rotor or Air Filter."); - aBaseMetaTileEntity.setActive(false); - } - } //End of pollution removal block. - } //End of valid air sides block. - } //End of valid toolstats block. - } //End of correct inventory item block. - else { - //Utils.LOG_WARNING("Wrong Tool metaitem Found."); - } - } - } - else if (!aBaseMetaTileEntity.isActive()) { - return; - } - } //End of can work block. - else { //Disable Machine. - //aBaseMetaTileEntity.setActive(false); - } - } //End of 1/sec action block. - else { - - if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution && !isIdle && aBaseMetaTileEntity.isAllowedToWork()){ - aBaseMetaTileEntity.setActive(true); - } - else if (isIdle || !this.mHasPollution || mCurrentPollution <= 0 || stackRotor == null || stackFilter == null || !hasRotor(stackRotor) || !hasAirFilter(stackFilter)){ - aBaseMetaTileEntity.setActive(false); - } - - } - if (this.getBaseMetaTileEntity().isActive()) { - if (MathUtils.randInt(0, 5) <= 2) { - this.sendSound((byte) -120); - } - } - - } //End of is serverside block. - } - - - public int getCurrentChunkPollution(){ - int mCurrentChunkPollution = 0; - if (this.mTier < 7) { - mCurrentChunkPollution = PollutionUtils.getPollution(getBaseMetaTileEntity()); - } - else { - AutoMap aSurrounding = new AutoMap(); - World aWorld = this.getBaseMetaTileEntity().getWorld(); - int xPos = this.getBaseMetaTileEntity().getXCoord(); - int zPos = this.getBaseMetaTileEntity().getZCoord(); - Chunk a1 = aWorld.getChunkFromBlockCoords(xPos-32, zPos-32); - Chunk a2 = aWorld.getChunkFromBlockCoords(xPos-32, zPos); - Chunk a3 = aWorld.getChunkFromBlockCoords(xPos-32, zPos+32); - Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos-32); - Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); - Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos+32); - Chunk c1 = aWorld.getChunkFromBlockCoords(xPos+32, zPos-32); - Chunk c2 = aWorld.getChunkFromBlockCoords(xPos+32, zPos); - Chunk c3 = aWorld.getChunkFromBlockCoords(xPos+32, zPos+32); - aSurrounding.put(a1); - aSurrounding.put(a2); - aSurrounding.put(a3); - aSurrounding.put(b1); - aSurrounding.put(b2); - aSurrounding.put(b3); - aSurrounding.put(c1); - aSurrounding.put(c2); - aSurrounding.put(c3); - for (Chunk r : aSurrounding) { - mCurrentChunkPollution += getPollutionInChunk(r); - } - } - if (mCurrentChunkPollution > 0){ - mHasPollution = true; - } - else { - mHasPollution = false; - } - return mCurrentChunkPollution; - } - - public int getPollutionInChunk(Chunk aChunk){ - int mCurrentChunkPollution = PollutionUtils.getPollution(aChunk); - if (mCurrentChunkPollution > 0){ - mHasPollution = true; - } - else { - mHasPollution = false; - } - return mCurrentChunkPollution; - } - - public boolean hasRotor(ItemStack rotorStack){ - if(rotorStack != null){ - if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { - //Logger.INFO("Found Basic Turbine Rotor."); - return true; - } - else if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool && rotorStack.getItemDamage() >= 170 && rotorStack.getItemDamage() <= 179){ - //Logger.INFO("Found Turbine Rotor."); - return true; - } - else { - //Logger.INFO("Found: "+rotorStack.getDisplayName()+":"+rotorStack.getItemDamage()); - } - } - //Logger.INFO("Found No Turbine Rotor."); - return false; - } - - public boolean damageTurbineRotor(){ - try{ - - boolean creativeRotor = false; - ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; - if (rotorStack == null) { - return false; - } - else if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { - long currentUse = ItemBasicScrubberTurbine.getFilterDamage(rotorStack); - //Remove broken Filter - if (rotorStack.getItemDamage() == 0 && currentUse >= 2000-10){ - Logger.INFO("Depleting ItemBasicScrubberTurbine T1"); - this.mInventory[this.SLOT_FILTER] = null; - return false; - } - else if (rotorStack.getItemDamage() == 1 && currentUse >= 4000-10){ - Logger.INFO("Depleting ItemBasicScrubberTurbine T2"); - this.mInventory[this.SLOT_FILTER] = null; - return false; - } - else if (rotorStack.getItemDamage() == 2 && currentUse >= 6000-10){ - Logger.INFO("Depleting ItemBasicScrubberTurbine T3"); - this.mInventory[this.SLOT_FILTER] = null; - return false; - } - else { - //Do Damage - Logger.INFO("Damaging ItemBasicScrubberTurbine"); - ItemBasicScrubberTurbine.setFilterDamage(rotorStack, currentUse+10); - Logger.INFO("Rotor Damage: "+currentUse); - return true; - } - } - else if(rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) { - Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack); - Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack); - if (t1 == Materials._NULL && t2 == Materials._NULL){ - Logger.INFO("Found creative rotor."); - creativeRotor = true; - } - } - else { - Logger.INFO("Bad item in rotor slot."); - return false; - } - - if(mInventory[SLOT_ROTOR].getItem() instanceof GT_MetaGenerated_Tool_01 && - ((GT_MetaGenerated_Tool) mInventory[SLOT_ROTOR].getItem()).getToolStats(mInventory[SLOT_ROTOR]).getSpeedMultiplier()>0 && - GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed>0 ) { - - long damageValue = (long) Math.floor(Math.abs(MathUtils.randFloat(1, 2) - MathUtils.randFloat(1, 3)) * (1 + 3 - 1) + 1); - double fDam = Math.floor(Math.abs(MathUtils.randFloat(1f, 2f) - MathUtils.randFloat(1f, 2f)) * (1f + 2f - 1f) + 1f); - damageValue -= fDam; - - //Logger.INFO("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]"); - /*Materials M1 = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[this.SLOT_ROTOR]); - Materials M2 = GT_MetaGenerated_Tool.getSecondaryMaterial(this.mInventory[this.SLOT_ROTOR]); - - Logger.INFO("Trying to do "+damageValue+" damage to the rotor. [2]");*/ - - //Damage Rotor - //int rotorDurability = this.mInventory[this.SLOT_ROTOR].getItemDamage(); - long rotorDamage = creativeRotor ? 0 : GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); - long rotorDurabilityMax = creativeRotor ? Integer.MAX_VALUE : GT_MetaGenerated_Tool.getToolMaxDamage(this.mInventory[this.SLOT_ROTOR]); - long rotorDurability = (rotorDurabilityMax - rotorDamage); - Logger.INFO("Rotor Damage: "+rotorDamage + " | Max Durability: "+rotorDurabilityMax+" | "+" Remaining Durability: "+rotorDurability); - if (rotorDurability >= damageValue){ - - - if (!mSaveRotor){ - Logger.INFO("Damaging Rotor."); - - if (!creativeRotor) - GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null); - - long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); - if (tempDur < rotorDurabilityMax){ - return true; - } - else { - rotorDurability = 0; - } - } - else { - Logger.INFO("Damaging Rotor."); - if (rotorDurability > 1000){ - if (!creativeRotor) - GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue/2, 0, null); - long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); - if (tempDur < rotorDurabilityMax){ - return true; - } - else { - rotorDurability = 0; - } - } - } - - - } - - if (rotorDurability <= 0 && !mSaveRotor && !creativeRotor) { - Logger.INFO("Destroying Rotor."); - this.mInventory[this.SLOT_ROTOR] = null; - return false; - } - else if (rotorDurability <= 0 && mSaveRotor) { - Logger.INFO("Saving Rotor."); - return false; - } - - - }else { - Logger.INFO("Bad Rotor."); - return false; - } - } - catch (Throwable t){ - t.printStackTrace(); - } - return false; - } - - public int getFreeSpaces(){ - int mAir = 0; - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - if(aBaseMetaTileEntity.getAirOffset(1, 0, 0)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(-1, 0, 0)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(0, 0, 1)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(0, 0, -1)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(0, 1, 0)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(0, -1, 0)){ - mAir++; - } - return mAir; - } - - public boolean removePollution(int toRemove){ - - if (this == null || this.getBaseMetaTileEntity() == null || this.getBaseMetaTileEntity().getWorld() == null) { - return false; - } - - if (this.mTier < 7) { - int startPollution = getCurrentChunkPollution(); - Logger.INFO("Current Chunk Pollution: "+startPollution); - PollutionUtils.removePollution(this.getBaseMetaTileEntity(), toRemove); - int after = getCurrentChunkPollution(); - Logger.INFO("Current Chunk Pollution: "+after); - return (after aSurrounding = new AutoMap(); - Chunk aThisChunk = this.getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord()); - int mainChunkX = aThisChunk.xPosition; - int mainChunkZ = aThisChunk.zPosition; - - World aWorld = this.getBaseMetaTileEntity().getWorld(); - int xPos = this.getBaseMetaTileEntity().getXCoord(); - int zPos = this.getBaseMetaTileEntity().getZCoord(); - - Chunk a1 = aWorld.getChunkFromBlockCoords(xPos-32, zPos-32); - Chunk a2 = aWorld.getChunkFromBlockCoords(xPos-32, zPos); - Chunk a3 = aWorld.getChunkFromBlockCoords(xPos-32, zPos+32); - Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos-32); - Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); - Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos+32); - Chunk c1 = aWorld.getChunkFromBlockCoords(xPos+32, zPos-32); - Chunk c2 = aWorld.getChunkFromBlockCoords(xPos+32, zPos); - Chunk c3 = aWorld.getChunkFromBlockCoords(xPos+32, zPos+32); - - aSurrounding.put(a1); - aSurrounding.put(a2); - aSurrounding.put(a3); - aSurrounding.put(b1); - aSurrounding.put(b2); - aSurrounding.put(b3); - aSurrounding.put(c1); - aSurrounding.put(c2); - aSurrounding.put(c3); - - for (Chunk r : aSurrounding) { - if (!r.isChunkLoaded) { - continue; - } - - int startPollution = getPollutionInChunk(r); - if (startPollution == 0) { - continue; - } - - Logger.INFO("Trying to remove pollution from chunk "+r.xPosition+", "+r.zPosition+" | "+startPollution); - int after = 0; - boolean isMainChunk = r.isAtLocation(mainChunkX, mainChunkZ); - - int removal = Math.max(0, !isMainChunk ? (toRemove/4) : toRemove); - if (removePollution(r, removal)) { - chunksWithRemoval++; - after = getPollutionInChunk(r); - } - else { - after = 0; - } - if (startPollution - after > 0) { - totalRemoved += (startPollution - after); - } - Logger.INFO("Removed "+(startPollution - after)+" pollution from chunk "+r.xPosition+", "+r.zPosition+" | "+after); - } - return totalRemoved > 0 && chunksWithRemoval > 0; - } - } - - public boolean removePollution(Chunk aChunk, int toRemove){ - int before = getCurrentChunkPollution(); - PollutionUtils.removePollution(aChunk, toRemove); - int after = getCurrentChunkPollution(); - return (after= 50-1){ - this.mInventory[this.SLOT_FILTER] = null; - return false; - } - else if (filter.getItemDamage() == 1 && currentUse >= 2500-1){ - this.mInventory[this.SLOT_FILTER] = null; - return false; - } - else { - //Do Damage - ItemAirFilter.setFilterDamage(filter, currentUse+1); - Logger.INFO("Filter Damage: "+currentUse); - return true; - } - } - return false; - } - - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName); - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - if (aIndex == SLOT_FILTER) { - if (aStack.getItem() instanceof ItemAirFilter) { - Logger.INFO("Inserting Air Filter into "+aIndex); - return true; - } - } - if (aIndex == SLOT_ROTOR) { - if (this.mInventory[7] != null) { - Logger.INFO("Found conveyor, can automate turbines. Inserting into "+aIndex); - if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { - return true; - } - if (aStack.getItem() instanceof GT_MetaGenerated_Tool && aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 179){ - return true; - } - } - } - //return super.canInsertItem(aIndex, aStack, aSide); - return false; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - this.mSaveRotor = Utils.invertBoolean(mSaveRotor); - if (mSaveRotor){ - PlayerUtils.messagePlayer(aPlayer, "Running in low efficiency mode, rotors will not break."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Running in high efficiency mode, rotors will break."); - } - return true; - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - if (aIndex == -120) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(103)), MathUtils.randInt(5, 50), 0.05F, aX, aY, aZ); - } else if (aIndex == -121 || aIndex == -122) { - //GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(108)), 0, 0.5F, aX, aY, aZ); - } /*else if (aIndex == -122) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(6)), 100, 1.0F, aX, aY, aZ); - }*/ else { - super.doSound((byte) 0, aX, aY, aZ); - } - } - - @Override - public boolean canHaveInsufficientEnergy() { - // TODO Auto-generated method stub - return super.canHaveInsufficientEnergy(); - } - - @Override - public String[] getInfoData() { - AutoMap aTooltipSuper = new AutoMap(); - for (String s : super.getInfoData()) { - aTooltipSuper.put(s); - } - int mAirSides = getFreeSpaces(); - int reduction = 0; - - try { - long tVoltage = maxEUInput(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); - reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); - reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); - - aTooltipSuper.put("Maximum pollution removed per second: "+reduction); - } - catch (Throwable t) { - aTooltipSuper.put("Maximum pollution removed per second: "+mPollutionReduction); - } - aTooltipSuper.put("Air Sides: "+mAirSides); - - String[] mBuiltOutput = new String[aTooltipSuper.size()]; - int aIndex = 0; - for (String i : aTooltipSuper) { - mBuiltOutput[aIndex++] = i; - } - - - - return mBuiltOutput; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - if (aSide <= 1) { - return false; - } - return super.allowCoverOnSide(aSide, aCoverID); - } - - @Override - public ITexture[] getTopFacingInactive(byte aColor) { - return super.getTopFacingInactive(aColor); - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); - aNBT.setBoolean("mSaveRotor", mSaveRotor); - super.setItemNBT(aNBT); - } - - private static ItemStack[] sGregTurbines; - - public static ItemStack getTieredTurbine(int aTier) { - if (sGregTurbines == null) { - sGregTurbines = new ItemStack[3]; - sGregTurbines[0] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Iron, Materials.Iron, null); - sGregTurbines[1] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Bronze, Materials.Bronze, null); - sGregTurbines[2] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Steel, Materials.Steel, null); - } - else { - return sGregTurbines[aTier]; - } - - return null; - } - - public int getBaseEfficiency(ItemStack aStackRotor) { - if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { - return getBaseEfficiency(getTieredTurbine(aStackRotor.getItemDamage())); - } - return (int) ((50.0F + (10.0F * ((GT_MetaGenerated_Tool) aStackRotor.getItem()).getToolCombatDamage(aStackRotor))) * 100); - } - - public int getOptimalAirFlow(ItemStack aStackRotor) { - if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { - return getOptimalAirFlow(getTieredTurbine(aStackRotor.getItemDamage())); - } - return (int) Math.max(Float.MIN_NORMAL, ((GT_MetaGenerated_Tool) aStackRotor.getItem()).getToolStats(aStackRotor).getSpeedMultiplier() - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStackRotor).mToolSpeed * 50); - } - -} \ No newline at end of file + public int mPollutionReduction = 0; + protected int mBaseEff = 2500; + protected int mOptimalAirFlow = 0; + protected boolean mHasPollution = false; + protected int SLOT_ROTOR = 5; + protected int SLOT_FILTER = 6; + protected static boolean mPollutionEnabled = true; + + protected boolean mSaveRotor = false; + + public GregtechMetaAtmosphericReconditioner(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 2, + "Making sure you don't live in Gwalior - Uses 2A", + 3, + 0, + "Recycler.png", + "", + new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) + }); + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + } + + public GregtechMetaAtmosphericReconditioner( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + } + + /*public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); + }*/ + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaAtmosphericReconditioner( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public String[] getDescription() { + + boolean highTier = this.mTier >= 7; + + String[] A = new String[] { + this.mDescription, + highTier ? "Will attempt to remove 1/4 pollution from 8 surrounding chunks" : "", + highTier ? "If these chunks are not loaded, they will be ignored" : "", + "Requires a turbine rotor and an Air Filter [T1/T2] to run.", + "The turbine rotor must be manually inserted/replaced", + "Can be configured with a soldering iron to change modes", + "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", + "High Efficiency: Removes full pollution, Turbine takes 100% dmg", + "Turbine Rotor will not break in LE mode", + "Insert an equal tier Conveyor Module to enable automation" + }; + if (!mPollutionEnabled) { + String[] B = new String[] { + "===============================================", + "Pollution is disabled, scrubbers will now have a bonus use", + "They are now able to remove ALL lingering pollution as GT ignores it", + "and it will linger forever!", + "===============================================", + }; + A = ArrayUtils.addAll(A, B); + } + return A; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); + aNBT.setBoolean("mSaveRotor", mSaveRotor); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mOptimalAirFlow = aNBT.getInteger("mOptimalAirFlow"); + this.mSaveRotor = aNBT.getBoolean("mSaveRotor"); + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 2; + } + + @Override + public long maxEUStore() { + return V[mTier] * 256; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + + // Get Current Pollution Amount. + int mCurrentPollution = getCurrentChunkPollution(); + boolean isIdle = true; + + // Get Inventory Item + ItemStack stackRotor = this.mInventory[SLOT_ROTOR]; + ItemStack stackFilter = this.mInventory[SLOT_FILTER]; + + // Power Drain + long drainEU = maxEUInput() * maxAmperesIn(); + if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU) { + if (aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)) { + isIdle = false; + } else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU / 4) { + if (aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU / 4), false)) { + isIdle = false; + } else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + + // Only try once/sec. + if (!isIdle && aTick % 20L == 0L) { + + for (int i = 0; i < this.mInventory.length; i++) { + ItemStack aSlotContent = this.mInventory[i]; + if (aSlotContent != null) { + Logger.INFO("Found " + aSlotContent.getDisplayName() + " in slot " + i); + } + } + + for (int i = 0; i < this.mInventory.length; i++) { + if (hasRotor(this.mInventory[i])) { + Logger.INFO("Found Rotor in slot " + i); + break; + } + } + for (int i = 0; i < this.mInventory.length; i++) { + if (hasAirFilter(this.mInventory[i])) { + Logger.INFO("Found Filter in slot " + i); + break; + } + } + + // Check if machine can work. + if ((aBaseMetaTileEntity.isAllowedToWork())) { + Logger.INFO("Can work."); + + // Enable machine animation/graphic + if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution) { + if (!this.getBaseMetaTileEntity().isActive()) { + Logger.INFO("Set Active."); + aBaseMetaTileEntity.setActive(true); + } + } else if (!this.mHasPollution + || mCurrentPollution <= 0 + || stackRotor == null + || stackFilter == null + || !hasRotor(stackRotor) + || !hasAirFilter(stackFilter)) { + if (!this.getBaseMetaTileEntity().isActive()) { + Logger.INFO("Set Inactive."); + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } + + // If Active. + if (aBaseMetaTileEntity.isActive()) { + Logger.INFO("Doing something."); + + // Do nothing if there is no pollution. + if (this.mHasPollution && mCurrentPollution > 0) { + Logger.INFO( + "Has Pollution? " + mHasPollution + ", Current Pollution: " + mCurrentPollution); + + // Only check every 30s. + if (!isIdle && aTick % (20L * 30) == 0L) { + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + // Clear out pollution if it's disabled, because I am a nice gal. + if (!PollutionUtils.isPollutionEnabled()) { + PollutionUtils.nullifyPollution(this.getBaseMetaTileEntity()); + } + } + + // Use a Turbine + if (hasRotor(stackRotor) && hasAirFilter(stackFilter)) { + Logger.INFO("Found Turbine."); + + mBaseEff = getBaseEfficiency(stackRotor); + mOptimalAirFlow = getOptimalAirFlow(stackRotor); + + // Make sure we have a valid Turbine and Eff/Airflow + if (this.mBaseEff > 0 && this.mOptimalAirFlow > 0) { + // Utils.LOG_WARNING("Pollution Cleaner [5]"); + + // Log Debug information. + Logger.INFO("mBaseEff[1]:" + mBaseEff); + Logger.INFO("mOptimalAirFlow[1]:" + mOptimalAirFlow); + + // Calculate The Voltage we are running + long tVoltage = drainEU; + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + // Check Sides for Air, + // More air means more pollution processing. + int mAirSides = getFreeSpaces(); + + int reduction = 0; + + // If no sides are free, how will you process the atmosphere? + if (mAirSides > 0) { + reduction += (((Math.max((tTier - 2), 1) * 2) * 50) + * mAirSides); // Was originally *100 + Logger.INFO("mPollutionReduction[1]:" + reduction); + + // I stole this code + reduction = (MathUtils.safeInt((long) reduction * this.mBaseEff) / 100000) + * mAirSides + * Math.max((tTier - 2), 1); + Logger.INFO("reduction[2]:" + reduction); + reduction = MathUtils.safeInt(((long) reduction / 100) * this.mOptimalAirFlow); + Logger.INFO("reduction[3]:" + reduction); + + mPollutionReduction = reduction; + + // Set a temp to remove variable to aleviate duplicate code. + int toRemove = 0; + + Logger.INFO("mCurrentPollution[4]:" + mCurrentPollution); + Logger.INFO("mCurrentPollution[5]:" + reduction); + if (reduction <= mCurrentPollution) { + // Clean some Air. + toRemove = reduction; + } else { + // Makes sure we don't get negative pollution. + toRemove = mCurrentPollution; + } + + toRemove = toRemove / 2; + Logger.INFO("mCurrentPollution[6]:" + toRemove); + + // We are good to clean + if (toRemove > 0) { + if (damageTurbineRotor() && damageAirFilter()) { + Logger.INFO("Removing " + toRemove + " pollution"); + removePollution(mSaveRotor ? (toRemove / 2) : toRemove); + Logger.INFO("mNewPollution[4]:" + getCurrentChunkPollution()); + } else { + Logger.INFO("Could not damage turbine rotor or Air Filter."); + aBaseMetaTileEntity.setActive(false); + } + } // End of pollution removal block. + } // End of valid air sides block. + } // End of valid toolstats block. + } // End of correct inventory item block. + else { + // Utils.LOG_WARNING("Wrong Tool metaitem Found."); + } + } + } else if (!aBaseMetaTileEntity.isActive()) { + return; + } + } // End of can work block. + else { // Disable Machine. + // aBaseMetaTileEntity.setActive(false); + } + } // End of 1/sec action block. + else { + + if (hasRotor(stackRotor) + && hasAirFilter(stackFilter) + && this.mHasPollution + && !isIdle + && aBaseMetaTileEntity.isAllowedToWork()) { + aBaseMetaTileEntity.setActive(true); + } else if (isIdle + || !this.mHasPollution + || mCurrentPollution <= 0 + || stackRotor == null + || stackFilter == null + || !hasRotor(stackRotor) + || !hasAirFilter(stackFilter)) { + aBaseMetaTileEntity.setActive(false); + } + } + if (this.getBaseMetaTileEntity().isActive()) { + if (MathUtils.randInt(0, 5) <= 2) { + this.sendSound((byte) -120); + } + } + } // End of is serverside block. + } + + public int getCurrentChunkPollution() { + int mCurrentChunkPollution = 0; + if (this.mTier < 7) { + mCurrentChunkPollution = PollutionUtils.getPollution(getBaseMetaTileEntity()); + } else { + AutoMap aSurrounding = new AutoMap(); + World aWorld = this.getBaseMetaTileEntity().getWorld(); + int xPos = this.getBaseMetaTileEntity().getXCoord(); + int zPos = this.getBaseMetaTileEntity().getZCoord(); + Chunk a1 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos - 32); + Chunk a2 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos); + Chunk a3 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos + 32); + Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos - 32); + Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); + Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos + 32); + Chunk c1 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos - 32); + Chunk c2 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos); + Chunk c3 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos + 32); + aSurrounding.put(a1); + aSurrounding.put(a2); + aSurrounding.put(a3); + aSurrounding.put(b1); + aSurrounding.put(b2); + aSurrounding.put(b3); + aSurrounding.put(c1); + aSurrounding.put(c2); + aSurrounding.put(c3); + for (Chunk r : aSurrounding) { + mCurrentChunkPollution += getPollutionInChunk(r); + } + } + if (mCurrentChunkPollution > 0) { + mHasPollution = true; + } else { + mHasPollution = false; + } + return mCurrentChunkPollution; + } + + public int getPollutionInChunk(Chunk aChunk) { + int mCurrentChunkPollution = PollutionUtils.getPollution(aChunk); + if (mCurrentChunkPollution > 0) { + mHasPollution = true; + } else { + mHasPollution = false; + } + return mCurrentChunkPollution; + } + + public boolean hasRotor(ItemStack rotorStack) { + if (rotorStack != null) { + if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + // Logger.INFO("Found Basic Turbine Rotor."); + return true; + } else if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool + && rotorStack.getItemDamage() >= 170 + && rotorStack.getItemDamage() <= 179) { + // Logger.INFO("Found Turbine Rotor."); + return true; + } else { + // Logger.INFO("Found: "+rotorStack.getDisplayName()+":"+rotorStack.getItemDamage()); + } + } + // Logger.INFO("Found No Turbine Rotor."); + return false; + } + + public boolean damageTurbineRotor() { + try { + + boolean creativeRotor = false; + ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; + if (rotorStack == null) { + return false; + } else if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + long currentUse = ItemBasicScrubberTurbine.getFilterDamage(rotorStack); + // Remove broken Filter + if (rotorStack.getItemDamage() == 0 && currentUse >= 2000 - 10) { + Logger.INFO("Depleting ItemBasicScrubberTurbine T1"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else if (rotorStack.getItemDamage() == 1 && currentUse >= 4000 - 10) { + Logger.INFO("Depleting ItemBasicScrubberTurbine T2"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else if (rotorStack.getItemDamage() == 2 && currentUse >= 6000 - 10) { + Logger.INFO("Depleting ItemBasicScrubberTurbine T3"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else { + // Do Damage + Logger.INFO("Damaging ItemBasicScrubberTurbine"); + ItemBasicScrubberTurbine.setFilterDamage(rotorStack, currentUse + 10); + Logger.INFO("Rotor Damage: " + currentUse); + return true; + } + } else if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) { + Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack); + Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack); + if (t1 == Materials._NULL && t2 == Materials._NULL) { + Logger.INFO("Found creative rotor."); + creativeRotor = true; + } + } else { + Logger.INFO("Bad item in rotor slot."); + return false; + } + + if (mInventory[SLOT_ROTOR].getItem() instanceof GT_MetaGenerated_Tool_01 + && ((GT_MetaGenerated_Tool) mInventory[SLOT_ROTOR].getItem()) + .getToolStats(mInventory[SLOT_ROTOR]) + .getSpeedMultiplier() + > 0 + && GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed > 0) { + + long damageValue = (long) + Math.floor(Math.abs(MathUtils.randFloat(1, 2) - MathUtils.randFloat(1, 3)) * (1 + 3 - 1) + 1); + double fDam = Math.floor( + Math.abs(MathUtils.randFloat(1f, 2f) - MathUtils.randFloat(1f, 2f)) * (1f + 2f - 1f) + 1f); + damageValue -= fDam; + + // Logger.INFO("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]"); + /*Materials M1 = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[this.SLOT_ROTOR]); + Materials M2 = GT_MetaGenerated_Tool.getSecondaryMaterial(this.mInventory[this.SLOT_ROTOR]); + + Logger.INFO("Trying to do "+damageValue+" damage to the rotor. [2]");*/ + + // Damage Rotor + // int rotorDurability = this.mInventory[this.SLOT_ROTOR].getItemDamage(); + long rotorDamage = + creativeRotor ? 0 : GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurabilityMax = creativeRotor + ? Integer.MAX_VALUE + : GT_MetaGenerated_Tool.getToolMaxDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurability = (rotorDurabilityMax - rotorDamage); + Logger.INFO("Rotor Damage: " + rotorDamage + " | Max Durability: " + rotorDurabilityMax + " | " + + " Remaining Durability: " + rotorDurability); + if (rotorDurability >= damageValue) { + + if (!mSaveRotor) { + Logger.INFO("Damaging Rotor."); + + if (!creativeRotor) + GT_ModHandler.damageOrDechargeItem( + this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null); + + long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax) { + return true; + } else { + rotorDurability = 0; + } + } else { + Logger.INFO("Damaging Rotor."); + if (rotorDurability > 1000) { + if (!creativeRotor) + GT_ModHandler.damageOrDechargeItem( + this.mInventory[this.SLOT_ROTOR], (int) damageValue / 2, 0, null); + long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax) { + return true; + } else { + rotorDurability = 0; + } + } + } + } + + if (rotorDurability <= 0 && !mSaveRotor && !creativeRotor) { + Logger.INFO("Destroying Rotor."); + this.mInventory[this.SLOT_ROTOR] = null; + return false; + } else if (rotorDurability <= 0 && mSaveRotor) { + Logger.INFO("Saving Rotor."); + return false; + } + + } else { + Logger.INFO("Bad Rotor."); + return false; + } + } catch (Throwable t) { + t.printStackTrace(); + } + return false; + } + + public int getFreeSpaces() { + int mAir = 0; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (aBaseMetaTileEntity.getAirOffset(1, 0, 0)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(-1, 0, 0)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, 0, 1)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, 0, -1)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, 1, 0)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, -1, 0)) { + mAir++; + } + return mAir; + } + + public boolean removePollution(int toRemove) { + + if (this == null + || this.getBaseMetaTileEntity() == null + || this.getBaseMetaTileEntity().getWorld() == null) { + return false; + } + + if (this.mTier < 7) { + int startPollution = getCurrentChunkPollution(); + Logger.INFO("Current Chunk Pollution: " + startPollution); + PollutionUtils.removePollution(this.getBaseMetaTileEntity(), toRemove); + int after = getCurrentChunkPollution(); + Logger.INFO("Current Chunk Pollution: " + after); + return (after < startPollution); + } else { + int chunksWithRemoval = 0; + int totalRemoved = 0; + AutoMap aSurrounding = new AutoMap(); + Chunk aThisChunk = this.getBaseMetaTileEntity() + .getWorld() + .getChunkFromBlockCoords( + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getZCoord()); + int mainChunkX = aThisChunk.xPosition; + int mainChunkZ = aThisChunk.zPosition; + + World aWorld = this.getBaseMetaTileEntity().getWorld(); + int xPos = this.getBaseMetaTileEntity().getXCoord(); + int zPos = this.getBaseMetaTileEntity().getZCoord(); + + Chunk a1 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos - 32); + Chunk a2 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos); + Chunk a3 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos + 32); + Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos - 32); + Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); + Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos + 32); + Chunk c1 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos - 32); + Chunk c2 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos); + Chunk c3 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos + 32); + + aSurrounding.put(a1); + aSurrounding.put(a2); + aSurrounding.put(a3); + aSurrounding.put(b1); + aSurrounding.put(b2); + aSurrounding.put(b3); + aSurrounding.put(c1); + aSurrounding.put(c2); + aSurrounding.put(c3); + + for (Chunk r : aSurrounding) { + if (!r.isChunkLoaded) { + continue; + } + + int startPollution = getPollutionInChunk(r); + if (startPollution == 0) { + continue; + } + + Logger.INFO("Trying to remove pollution from chunk " + r.xPosition + ", " + r.zPosition + " | " + + startPollution); + int after = 0; + boolean isMainChunk = r.isAtLocation(mainChunkX, mainChunkZ); + + int removal = Math.max(0, !isMainChunk ? (toRemove / 4) : toRemove); + if (removePollution(r, removal)) { + chunksWithRemoval++; + after = getPollutionInChunk(r); + } else { + after = 0; + } + if (startPollution - after > 0) { + totalRemoved += (startPollution - after); + } + Logger.INFO("Removed " + (startPollution - after) + " pollution from chunk " + r.xPosition + ", " + + r.zPosition + " | " + after); + } + return totalRemoved > 0 && chunksWithRemoval > 0; + } + } + + public boolean removePollution(Chunk aChunk, int toRemove) { + int before = getCurrentChunkPollution(); + PollutionUtils.removePollution(aChunk, toRemove); + int after = getCurrentChunkPollution(); + return (after < before); + } + + public boolean hasAirFilter(ItemStack filter) { + if (filter == null) { + return false; + } + if (filter.getItem() instanceof ItemAirFilter) { + return true; + } + return false; + } + + public boolean damageAirFilter() { + ItemStack filter = this.mInventory[this.SLOT_FILTER]; + if (filter == null) { + return false; + } + + boolean creativeRotor = false; + ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; + if (rotorStack != null) { + if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) { + Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack); + Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack); + if (t1 == Materials._NULL && t2 == Materials._NULL) { + creativeRotor = true; + } + } + } + + if (creativeRotor) { + return true; + } + + if (filter.getItem() instanceof ItemAirFilter) { + + long currentUse = ItemAirFilter.getFilterDamage(filter); + + // Remove broken Filter + if (filter.getItemDamage() == 0 && currentUse >= 50 - 1) { + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else if (filter.getItemDamage() == 1 && currentUse >= 2500 - 1) { + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else { + // Do Damage + ItemAirFilter.setFilterDamage(filter, currentUse + 1); + Logger.INFO("Filter Damage: " + currentUse); + return true; + } + } + return false; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex == SLOT_FILTER) { + if (aStack.getItem() instanceof ItemAirFilter) { + Logger.INFO("Inserting Air Filter into " + aIndex); + return true; + } + } + if (aIndex == SLOT_ROTOR) { + if (this.mInventory[7] != null) { + Logger.INFO("Found conveyor, can automate turbines. Inserting into " + aIndex); + if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (aStack.getItem() instanceof GT_MetaGenerated_Tool + && aStack.getItemDamage() >= 170 + && aStack.getItemDamage() <= 179) { + return true; + } + } + } + // return super.canInsertItem(aIndex, aStack, aSide); + return false; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mSaveRotor = Utils.invertBoolean(mSaveRotor); + if (mSaveRotor) { + PlayerUtils.messagePlayer(aPlayer, "Running in low efficiency mode, rotors will not break."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Running in high efficiency mode, rotors will break."); + } + return true; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + if (aIndex == -120) { + GT_Utility.doSoundAtClient( + (String) GregTech_API.sSoundList.get(Integer.valueOf(103)), + MathUtils.randInt(5, 50), + 0.05F, + aX, + aY, + aZ); + } else if (aIndex == -121 || aIndex == -122) { + // GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(108)), 0, 0.5F, aX, aY, + // aZ); + } /*else if (aIndex == -122) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(6)), 100, 1.0F, aX, aY, aZ); + }*/ else { + super.doSound((byte) 0, aX, aY, aZ); + } + } + + @Override + public boolean canHaveInsufficientEnergy() { + // TODO Auto-generated method stub + return super.canHaveInsufficientEnergy(); + } + + @Override + public String[] getInfoData() { + AutoMap aTooltipSuper = new AutoMap(); + for (String s : super.getInfoData()) { + aTooltipSuper.put(s); + } + int mAirSides = getFreeSpaces(); + int reduction = 0; + + try { + long tVoltage = maxEUInput(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + reduction += (((Math.max((tTier - 2), 1) * 2) * 50) * mAirSides); + reduction = (MathUtils.safeInt((long) reduction * this.mBaseEff) / 100000) + * mAirSides + * Math.max((tTier - 2), 1); + reduction = MathUtils.safeInt(((long) reduction / 100) * this.mOptimalAirFlow); + + aTooltipSuper.put("Maximum pollution removed per second: " + reduction); + } catch (Throwable t) { + aTooltipSuper.put("Maximum pollution removed per second: " + mPollutionReduction); + } + aTooltipSuper.put("Air Sides: " + mAirSides); + + String[] mBuiltOutput = new String[aTooltipSuper.size()]; + int aIndex = 0; + for (String i : aTooltipSuper) { + mBuiltOutput[aIndex++] = i; + } + + return mBuiltOutput; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + if (aSide <= 1) { + return false; + } + return super.allowCoverOnSide(aSide, aCoverID); + } + + @Override + public ITexture[] getTopFacingInactive(byte aColor) { + return super.getTopFacingInactive(aColor); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); + aNBT.setBoolean("mSaveRotor", mSaveRotor); + super.setItemNBT(aNBT); + } + + private static ItemStack[] sGregTurbines; + + public static ItemStack getTieredTurbine(int aTier) { + if (sGregTurbines == null) { + sGregTurbines = new ItemStack[3]; + sGregTurbines[0] = GT_MetaGenerated_Tool.sInstances + .get("gt.metatool.01") + .getToolWithStats(GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Iron, Materials.Iron, null); + sGregTurbines[1] = GT_MetaGenerated_Tool.sInstances + .get("gt.metatool.01") + .getToolWithStats( + GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Bronze, Materials.Bronze, null); + sGregTurbines[2] = GT_MetaGenerated_Tool.sInstances + .get("gt.metatool.01") + .getToolWithStats( + GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Steel, Materials.Steel, null); + } else { + return sGregTurbines[aTier]; + } + + return null; + } + + public int getBaseEfficiency(ItemStack aStackRotor) { + if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { + return getBaseEfficiency(getTieredTurbine(aStackRotor.getItemDamage())); + } + return (int) + ((50.0F + (10.0F * ((GT_MetaGenerated_Tool) aStackRotor.getItem()).getToolCombatDamage(aStackRotor))) + * 100); + } + + public int getOptimalAirFlow(ItemStack aStackRotor) { + if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { + return getOptimalAirFlow(getTieredTurbine(aStackRotor.getItemDamage())); + } + return (int) Math.max( + Float.MIN_NORMAL, + ((GT_MetaGenerated_Tool) aStackRotor.getItem()) + .getToolStats(aStackRotor) + .getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStackRotor).mToolSpeed + * 50); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaCondensor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaCondensor.java index 0f7edd062d..531c7c5694 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaCondensor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaCondensor.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.enums.Dyes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -9,166 +7,174 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SteamCondenser; import gtPlusPlus.xmod.gregtech.api.gui.GUI_SteamCondenser; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechMetaBoilerBase; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -public class GregtechMetaCondensor extends GregtechMetaBoilerBase{ +public class GregtechMetaCondensor extends GregtechMetaBoilerBase { - public GregtechMetaCondensor(final int aID, final String aName, final String aNameRegional) - { - super(aID, aName, aNameRegional, "A Steam condenser - [IC2->Steam]", new ITexture[0]); - } + public GregtechMetaCondensor(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, "A Steam condenser - [IC2->Steam]", new ITexture[0]); + } - public GregtechMetaCondensor(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) - { - super(aName, aTier, aDescription, aTextures); - } + public GregtechMetaCondensor( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "IC2 Steam + Water = Normal Steam.", "Requires no power to run, although it's not very fast.", CORE.GT_Tooltip}; - } + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "IC2 Steam + Water = Normal Steam.", + "Requires no power to run, although it's not very fast.", + CORE.GT_Tooltip + }; + } - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) - { - final ITexture[][][] rTextures = new ITexture[5][17][]; - for (byte i = -1; i < 16; i++){ - rTextures[0][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa))}; - rTextures[1][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; - rTextures[2][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; - rTextures[3][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER) }; - rTextures[4][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE) }; - } - return rTextures; - } + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[5][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][(i + 1)] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)) + }; + rTextures[1][(i + 1)] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) + }; + rTextures[2][(i + 1)] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) + }; + rTextures[3][(i + 1)] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER) + }; + rTextures[4][(i + 1)] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE) + }; + } + return rTextures; + } - @Override - public int maxProgresstime() - { - return 1000; - } + @Override + public int maxProgresstime() { + return 1000; + } - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) - { - return new CONTAINER_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity); - } + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity); + } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) - { - return new GUI_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png"); - } + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png"); + } - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) - { - return new GregtechMetaCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); - } + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); + } - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) - { - this.RI = MathUtils.randLong(5L, 30L); - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) - { - if (this.mTemperature <= 5) - { - this.mTemperature = 5; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 10) - { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) - { - final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) - { - final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) - { - final int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if ((aTick % 10L) == 0L) { - if (this.mTemperature > 5) - { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) - { - this.mHadNoWater = true; - } - else - { - if (this.mHadNoWater) - { - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(30L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 30; - } else { - this.mSteam = GT_ModHandler.getSteam(30L); - } - } - } - else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > getSteamCapacity())) - { - this.sendSound((byte)1); - this.mSteam.amount = getSteamCapacity() * 3 / 4; - } - /*if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(IC2.getItemFromBlock(p_150898_0_))))) - { - this.mProcessingEnergy += 1000; - aBaseMetaTileEntity.decrStackSize(2, 1); - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); - }*/ - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && ((aTick % this.RI) == 0L)) - { - this.mProcessingEnergy -= 40; - this.mTemperature += 2; - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); - } - } + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + this.RI = MathUtils.randLong(5L, 30L); + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { + if (this.mTemperature <= 5) { + this.mTemperature = 5; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 10) { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte) (i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) { + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) { + final FluidStack tDrained = aBaseMetaTileEntity.drain( + ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) { + final int tFilledAmount = tTileEntity.fill( + ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill( + ForgeDirection.getOrientation(i).getOpposite(), + aBaseMetaTileEntity.drain( + ForgeDirection.getOrientation(i), tFilledAmount, true), + true); + } + } + } + } + } + if ((aTick % 10L) == 0L) { + if (this.mTemperature > 5) { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { + this.mHadNoWater = true; + } else { + if (this.mHadNoWater) { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(30L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 30; + } else { + this.mSteam = GT_ModHandler.getSteam(30L); + } + } + } else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && (this.mSteam.amount > getSteamCapacity())) { + this.sendSound((byte) 1); + this.mSteam.amount = getSteamCapacity() * 3 / 4; + } + /*if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && + (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(IC2.getItemFromBlock(p_150898_0_))))) + { + this.mProcessingEnergy += 1000; + aBaseMetaTileEntity.decrStackSize(2, 1); + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); + }*/ + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && ((aTick % this.RI) == 0L)) { + this.mProcessingEnergy -= 40; + this.mTemperature += 2; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } - @Override - public final int fill(final FluidStack aFluid, final boolean doFill) - { - if ((Utils.isIC2Steam(aFluid)) && (this.mProcessingEnergy < 50)) - { - final int tFilledAmount = Math.min(50, aFluid.amount); - if (doFill) { - this.mProcessingEnergy += tFilledAmount; - } - return tFilledAmount; - } - return super.fill(aFluid, doFill); - } + @Override + public final int fill(final FluidStack aFluid, final boolean doFill) { + if ((Utils.isIC2Steam(aFluid)) && (this.mProcessingEnergy < 50)) { + final int tFilledAmount = Math.min(50, aFluid.amount); + if (doFill) { + this.mProcessingEnergy += tFilledAmount; + } + return tFilledAmount; + } + return super.fill(aFluid, doFill); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java index 88658c399d..f1e0cc7161 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java @@ -18,306 +18,402 @@ import net.minecraft.world.World; public class GregtechMetaGarbageCollector extends GregtechMetaTileEntity { - long mLastCleanup = 0; - long mLocalTickVar = 0; - int mFrequency = 5; - - public GregtechMetaGarbageCollector(final String aName, final String aNameRegional, final String aDescription) { - super(991, aName, aNameRegional, 5, 0, aDescription); - } - - public GregtechMetaGarbageCollector(final String aName, final String aDescription, final ITexture[][][] aTextures) { - super(aName, 5, 0, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {this.mDescription, - "Can request the JVM to perform garbage collection", - "Configurable to run once every 5 minute interval (5-180)", - "This Machine has no recipe", - "Admin Tool, Limit one per world if possible", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; - } - - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; - } - - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; - } - - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; - } - - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)}; - } - - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; - } - - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; - } - - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; - } - - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; - } - - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)}; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (mFrequency < 180){ - mFrequency += 5; - } - else { - mFrequency = 5; - } - PlayerUtils.messagePlayer(aPlayer, "Running every "+mFrequency+" minutes."); - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaGarbageCollector(this.mName, this.mDescription, this.mTextures); - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isElectric() {return false;} - @Override public boolean isValidSlot(final int aIndex) {return false;} - @Override public boolean isFacingValid(final byte aFacing) {return true;} - @Override public boolean isEnetInput() {return false;} - @Override public boolean isEnetOutput() {return false;} - @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return 0;} - @Override public long maxEUStore() {return 0;} - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return 0;} - @Override public int dechargerSlotCount() {return 0;} - @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} - @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - { - return true; - } - this.showPollution(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - private void showPollution(final World worldIn, final EntityPlayer playerIn){ - PlayerUtils.messagePlayer(playerIn, "Running every "+mFrequency+" minutes. Owner: "+this.getBaseMetaTileEntity().getOwnerName()); - long aDiff = mLocalTickVar - this.mLastCleanup; - PlayerUtils.messagePlayer(playerIn, "Last run: "+Utils.getSecondsFromMillis(aDiff)+" seconds ago."); - - - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - - @Override - public String[] getInfoData() { - return new String[] { - this.getLocalName() - }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { - } - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return true; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.getBaseMetaTileEntity().isServerSide()) { - mLocalTickVar = System.currentTimeMillis(); - long aDiff = mLocalTickVar - this.mLastCleanup; - if (Utils.getSecondsFromMillis(aDiff) >= (this.mFrequency * 60)) { - CORE.gc(); - this.mLastCleanup = mLocalTickVar; - } - } - } - -} \ No newline at end of file + long mLastCleanup = 0; + long mLocalTickVar = 0; + int mFrequency = 5; + + public GregtechMetaGarbageCollector(final String aName, final String aNameRegional, final String aDescription) { + super(991, aName, aNameRegional, 5, 0, aDescription); + } + + public GregtechMetaGarbageCollector(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Can request the JVM to perform garbage collection", + "Configurable to run once every 5 minute interval (5-180)", + "This Machine has no recipe", + "Admin Tool, Limit one per world if possible", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3) + }; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (mFrequency < 180) { + mFrequency += 5; + } else { + mFrequency = 5; + } + PlayerUtils.messagePlayer(aPlayer, "Running every " + mFrequency + " minutes."); + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaGarbageCollector(this.mName, this.mDescription, this.mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showPollution(final World worldIn, final EntityPlayer playerIn) { + PlayerUtils.messagePlayer( + playerIn, + "Running every " + mFrequency + " minutes. Owner: " + + this.getBaseMetaTileEntity().getOwnerName()); + long aDiff = mLocalTickVar - this.mLastCleanup; + PlayerUtils.messagePlayer(playerIn, "Last run: " + Utils.getSecondsFromMillis(aDiff) + " seconds ago."); + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return new String[] {this.getLocalName()}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) {} + + @Override + public void loadNBTData(final NBTTagCompound aNBT) {} + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + mLocalTickVar = System.currentTimeMillis(); + long aDiff = mLocalTickVar - this.mLastCleanup; + if (Utils.getSecondsFromMillis(aDiff) >= (this.mFrequency * 60)) { + CORE.gc(); + this.mLastCleanup = mLocalTickVar; + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java index 65217f9e53..ce04d50fab 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java @@ -18,365 +18,476 @@ import net.minecraft.world.World; public class GregtechMetaPollutionCreator extends GregtechMetaTileEntity { - int mCurrentPollution; - int mAveragePollution; - int mAveragePollutionArray[] = new int[10]; - private int mArrayPos = 0; - private int mTickTimer = 0; - private int mSecondTimer = 0; - - public GregtechMetaPollutionCreator(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaPollutionCreator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {this.mDescription, "A useful debug machine to create pollution.", CORE.GT_Tooltip}; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; - } - - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; - } - - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (pollutionMultiplier > 99){ - pollutionMultiplier = 1; - } - else { - pollutionMultiplier++; - } - PlayerUtils.messagePlayer(aPlayer, "Pollution Mutliplier is now "+pollutionMultiplier+"."); - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPollutionCreator(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(final int aIndex) {return true;} - @Override public boolean isFacingValid(final byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return false;} - @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return 0;} - @Override public long maxEUStore() {return 0;} - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return 0;} - @Override public int dechargerSlotCount() {return 0;} - @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} - @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - { - return true; - } - this.showPollution(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - public int pollutionMultiplier = 1; - - private void showPollution(final World worldIn, final EntityPlayer playerIn){ - if(!PollutionUtils.isPollutionEnabled()){ - PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); - } - else { - addPollution(); - PlayerUtils.messagePlayer(playerIn, "This chunk now contains "+getCurrentChunkPollution()+" pollution."); - //PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" pollution."); - } - } - - private boolean addPollution(){ - PollutionUtils.addPollution(getBaseMetaTileEntity(), 100000*pollutionMultiplier); - return true; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - public int getCurrentChunkPollution(){ - return getCurrentChunkPollution(this.getBaseMetaTileEntity()); - } - - public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){ - return PollutionUtils.getPollution(aBaseMetaTileEntity); - } - - - @Override - public String[] getInfoData() { - return new String[] { - this.getLocalName(), - "Current Pollution: "+this.mCurrentPollution, - "Average/10 minutes:"+getAveragePollutionOverLastTen()}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { - } - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - //int mCurrentPollution; - //int mAveragePollution; - //int mAveragePollutionArray[] = new int[10]; - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); - aNBT.setInteger("mAveragePollution", this.mAveragePollution); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); - this.mAveragePollution = aNBT.getInteger("mAveragePollution"); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - if (this.getBaseMetaTileEntity().isServerSide()) { - if (this.mCurrentPollution == 0) { - this.mCurrentPollution = getCurrentChunkPollution(); - } - if (this.mArrayPos < 0 || this.mArrayPos > 9) { - this.mArrayPos = 0; - } - this.mTickTimer = 0; - } - } - - - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.getBaseMetaTileEntity().isServerSide()) { - //TickTimer - 20 times a second - this.mTickTimer++; - if (mTickTimer % 20 == 0){ - this.mCurrentPollution = getCurrentChunkPollution(); - } - } - } - - public int getAveragePollutionOverLastTen(){ - int counter = 0; - int total = 0; - - for (int i=0;i 0 && counter > 0){ - returnValue = (total/counter); - this.mAveragePollution = returnValue; - } - else { - returnValue = getCurrentChunkPollution(); - } - //Logger.INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" |"); - return returnValue; - } - -} \ No newline at end of file + int mCurrentPollution; + int mAveragePollution; + int mAveragePollutionArray[] = new int[10]; + private int mArrayPos = 0; + private int mTickTimer = 0; + private int mSecondTimer = 0; + + public GregtechMetaPollutionCreator( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaPollutionCreator( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "A useful debug machine to create pollution.", CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (pollutionMultiplier > 99) { + pollutionMultiplier = 1; + } else { + pollutionMultiplier++; + } + PlayerUtils.messagePlayer(aPlayer, "Pollution Mutliplier is now " + pollutionMultiplier + "."); + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPollutionCreator( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + public int pollutionMultiplier = 1; + + private void showPollution(final World worldIn, final EntityPlayer playerIn) { + if (!PollutionUtils.isPollutionEnabled()) { + PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); + } else { + addPollution(); + PlayerUtils.messagePlayer( + playerIn, "This chunk now contains " + getCurrentChunkPollution() + " pollution."); + // PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" + // pollution."); + } + } + + private boolean addPollution() { + PollutionUtils.addPollution(getBaseMetaTileEntity(), 100000 * pollutionMultiplier); + return true; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public int getCurrentChunkPollution() { + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } + + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity) { + return PollutionUtils.getPollution(aBaseMetaTileEntity); + } + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + "Current Pollution: " + this.mCurrentPollution, + "Average/10 minutes:" + getAveragePollutionOverLastTen() + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + // int mCurrentPollution; + // int mAveragePollution; + // int mAveragePollutionArray[] = new int[10]; + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + aNBT.setInteger("mAveragePollution", this.mAveragePollution); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mCurrentPollution == 0) { + this.mCurrentPollution = getCurrentChunkPollution(); + } + if (this.mArrayPos < 0 || this.mArrayPos > 9) { + this.mArrayPos = 0; + } + this.mTickTimer = 0; + } + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + // TickTimer - 20 times a second + this.mTickTimer++; + if (mTickTimer % 20 == 0) { + this.mCurrentPollution = getCurrentChunkPollution(); + } + } + } + + public int getAveragePollutionOverLastTen() { + int counter = 0; + int total = 0; + + for (int i = 0; i < this.mAveragePollutionArray.length; i++) { + if (this.mAveragePollutionArray[i] != 0) { + total += this.mAveragePollutionArray[i]; + counter++; + } + } + int returnValue = 0; + if (total > 0 && counter > 0) { + returnValue = (total / counter); + this.mAveragePollution = returnValue; + } else { + returnValue = getCurrentChunkPollution(); + } + // Logger.INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" + // |"); + return returnValue; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java index 69a4f96708..9ba3db911a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java @@ -19,417 +19,524 @@ import net.minecraft.world.World; public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { - int mCurrentPollution; - int mAveragePollution; - int mAveragePollutionArray[] = new int[10]; - private int mArrayPos = 0; - private int mTickTimer = 0; - private int mSecondTimer = 0; - private long mRedstoneLevel = 0; - - public GregtechMetaPollutionDetector(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaPollutionDetector(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {this.mDescription, "Right click to check pollution levels.", - "Configure with screwdriver to set redstone output amount.", - "Does not use power.", - CORE.GT_Tooltip}; - } - - @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[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } - : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - /*@Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - }*/ - - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; - } - - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; - } - - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPollutionDetector(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(final int aIndex) {return true;} - @Override public boolean isFacingValid(final byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return false;} - @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return 0;} - @Override public long maxEUStore() {return 0;} - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return 0;} - @Override public int dechargerSlotCount() {return 0;} - @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} - @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - { - return true; - } - this.showPollution(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - private void showPollution(final World worldIn, final EntityPlayer playerIn){ - if(!PollutionUtils.isPollutionEnabled()){ - PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); - } - else { - PlayerUtils.messagePlayer(playerIn, "This chunk contains "+getCurrentChunkPollution()+" pollution."); - PlayerUtils.messagePlayer(playerIn, "Emit Redstone at pollution level: "+this.mRedstoneLevel); - } - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - public int getCurrentChunkPollution(){ - return getCurrentChunkPollution(this.getBaseMetaTileEntity()); - } - - public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){ - return PollutionUtils.getPollution(aBaseMetaTileEntity); - } - - - @Override - public String[] getInfoData() { - return new String[] { - this.getLocalName(), - "Current Pollution: "+this.mCurrentPollution, - "Average/10 Sec: "+this.mAveragePollution, - "Emit Redstone at pollution level: "+this.mRedstoneLevel}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { - } - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - //int mCurrentPollution; - //int mAveragePollution; - //int mAveragePollutionArray[] = new int[10]; - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); - aNBT.setInteger("mAveragePollution", this.mAveragePollution); - aNBT.setLong("mRedstoneLevel", this.mRedstoneLevel); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); - this.mAveragePollution = aNBT.getInteger("mAveragePollution"); - this.mRedstoneLevel = aNBT.getLong("mRedstoneLevel"); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - } - - public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - //Only Calc server-side - if (!this.getBaseMetaTileEntity().isServerSide()) { - return; - } - //Emit Redstone - if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ - for (int i=0;i<6;i++){ - this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 16); - } - this.markDirty(); - } - else { - for (int i=0;i<6;i++){ - this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 0); - } - this.markDirty(); - } - - //Do Math for stats - if (this.mTickTimer % 20 == 0) { - mCurrentPollution = this.getCurrentChunkPollution(); - if (mArrayPos > mAveragePollutionArray.length-1) { - mArrayPos = 0; - } - mAveragePollutionArray[mArrayPos] = mCurrentPollution; - mAveragePollution = getAveragePollutionOverLastTen(); - mArrayPos++; - } - this.mTickTimer++; - - } - - public int getAveragePollutionOverLastTen(){ - return MathUtils.getIntAverage(mAveragePollutionArray); - - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { - - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0: - this.mRedstoneLevel -= 5000; - break; - case 1: - this.mRedstoneLevel += 5000; - break; - case 2: - this.mRedstoneLevel -= 50000; - break; - case 3: - this.mRedstoneLevel += 50000; - } - this.markDirty(); - GT_Utility.sendChatToPlayer(aPlayer, "Emit Redstone at Pollution Level: " + this.mRedstoneLevel); - } - - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - public boolean allowGeneralRedstoneOutput() { - if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ - this.markDirty(); - return true; - } - return false; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, - EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - } - - @Override - public void onMachineBlockUpdate() { - super.onMachineBlockUpdate(); - } - - @Override - public boolean hasSidedRedstoneOutputBehavior() { - if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ - this.markDirty(); - return true; - } - return false; - } - -} \ No newline at end of file + int mCurrentPollution; + int mAveragePollution; + int mAveragePollutionArray[] = new int[10]; + private int mArrayPos = 0; + private int mTickTimer = 0; + private int mSecondTimer = 0; + private long mRedstoneLevel = 0; + + public GregtechMetaPollutionDetector( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaPollutionDetector( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Right click to check pollution levels.", + "Configure with screwdriver to set redstone output amount.", + "Does not use power.", + CORE.GT_Tooltip + }; + } + + @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[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) + } + : new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(Textures.BlockIcons.VOID) + }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + /*@Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + }*/ + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPollutionDetector( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showPollution(final World worldIn, final EntityPlayer playerIn) { + if (!PollutionUtils.isPollutionEnabled()) { + PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); + } else { + PlayerUtils.messagePlayer(playerIn, "This chunk contains " + getCurrentChunkPollution() + " pollution."); + PlayerUtils.messagePlayer(playerIn, "Emit Redstone at pollution level: " + this.mRedstoneLevel); + } + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public int getCurrentChunkPollution() { + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } + + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity) { + return PollutionUtils.getPollution(aBaseMetaTileEntity); + } + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + "Current Pollution: " + this.mCurrentPollution, + "Average/10 Sec: " + this.mAveragePollution, + "Emit Redstone at pollution level: " + this.mRedstoneLevel + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + // int mCurrentPollution; + // int mAveragePollution; + // int mAveragePollutionArray[] = new int[10]; + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + aNBT.setInteger("mAveragePollution", this.mAveragePollution); + aNBT.setLong("mRedstoneLevel", this.mRedstoneLevel); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + this.mRedstoneLevel = aNBT.getLong("mRedstoneLevel"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + // Only Calc server-side + if (!this.getBaseMetaTileEntity().isServerSide()) { + return; + } + // Emit Redstone + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { + for (int i = 0; i < 6; i++) { + this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 16); + } + this.markDirty(); + } else { + for (int i = 0; i < 6; i++) { + this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 0); + } + this.markDirty(); + } + + // Do Math for stats + if (this.mTickTimer % 20 == 0) { + mCurrentPollution = this.getCurrentChunkPollution(); + if (mArrayPos > mAveragePollutionArray.length - 1) { + mArrayPos = 0; + } + mAveragePollutionArray[mArrayPos] = mCurrentPollution; + mAveragePollution = getAveragePollutionOverLastTen(); + mArrayPos++; + } + this.mTickTimer++; + } + + public int getAveragePollutionOverLastTen() { + return MathUtils.getIntAverage(mAveragePollutionArray); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + this.mRedstoneLevel -= 5000; + break; + case 1: + this.mRedstoneLevel += 5000; + break; + case 2: + this.mRedstoneLevel -= 50000; + break; + case 3: + this.mRedstoneLevel += 50000; + } + this.markDirty(); + GT_Utility.sendChatToPlayer(aPlayer, "Emit Redstone at Pollution Level: " + this.mRedstoneLevel); + } + + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + public boolean allowGeneralRedstoneOutput() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { + this.markDirty(); + return true; + } + return false; + } + + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { + this.markDirty(); + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java index 58bddefc19..9b60732f62 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java @@ -3,11 +3,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; import static gregtech.api.enums.GT_Values.V; import static net.minecraftforge.common.ForgeChunkManager.getMaxChunkDepthFor; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - import com.google.common.collect.MapMaker; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -20,6 +15,10 @@ import gtPlusPlus.GTplusplus; import gtPlusPlus.core.chunkloading.GTPP_ChunkManager; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -29,378 +28,451 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket; public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_BasicMachine { - public GregtechMetaTileEntityChunkLoader(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 4, "Loads " + getMaxChunksToLoadForTier(aTier) + " chunks when powered", 0, 0, "Recycler.png", "", new ITexture[]{}); - } - - public GregtechMetaTileEntityChunkLoader(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 4, aDescription, aTextures, 0, 0, aGUIName, aNEIName); - } - - public static int getMaxChunksToLoadForTier(int aTier) { - if (aTier < 4) { - return Math.min(3 * 3, getMaxChunkDepthFor(CORE.MODID)); - } - if (aTier < 6) { - return Math.min(7 * 7, getMaxChunkDepthFor(CORE.MODID)); - } - if (aTier < 8) { - return Math.min(15 * 15, getMaxChunkDepthFor(CORE.MODID)); - } - else { - return 0; - } - } - - public static int getChunkRadiusForTier(int aTier) { - if (aTier < 4) { - return Math.min(1, (int)Math.floor(Math.sqrt(getMaxChunkDepthFor(CORE.MODID)))); - } - if (aTier < 6) { - return Math.min(3, (int)Math.floor(Math.sqrt(getMaxChunkDepthFor(CORE.MODID)))); - } - if (aTier < 8) { - return Math.min(7, (int)Math.floor(Math.sqrt(getMaxChunkDepthFor(CORE.MODID)))); - } - else { - return 0; - } - } - - @Override - public String[] getDescription() { - return new String[] { - "Loads " + getMaxChunksToLoadForTier(this.mTier) + " chunks when powered", - "Consumes 2A", - "Behaves Identically to a Railcraft World Anchor", - CORE.GT_Tooltip - }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; - } - - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; - } - - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; - } - - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; - } - - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; - } - - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; - } - - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; - } - - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; - } - - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; - } - - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - - @Override - public String[] getInfoData() { - return super.getInfoData(); - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return true; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (aBaseMetaTileEntity.isServerSide()) { - if (aBaseMetaTileEntity.getXCoord() != prevX || aBaseMetaTileEntity.getYCoord() != prevY || aBaseMetaTileEntity.getZCoord() != prevZ) { - releaseTicket(); - prevX = aBaseMetaTileEntity.getXCoord(); - prevY = aBaseMetaTileEntity.getYCoord(); - prevZ = aBaseMetaTileEntity.getZCoord(); - } - - if (hasActiveTicket() && (getTicket().world != aBaseMetaTileEntity.getWorld() || refreshTicket || !aBaseMetaTileEntity.isAllowedToWork())) { - releaseTicket(); - } - - if (++updateCycle % updateCycleLength == 0) { - updateCycle = 0; - if (canChunkload()) { - setEUVar(getEUVar() - getEnergyConsumption()); - } - } - - if (!hasActiveTicket()) { - requestTicket(); - } - } - } - - @Override - public long maxAmperesIn() { - return 4; - } - - @Override - public long getMinimumStoredEU() { - return V[mTier] * 2; - } - - @Override - public long maxEUStore() { - return V[mTier] * 256; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public void onRemoval() { - super.onRemoval(); - releaseTicket(); - } - - public long getEnergyConsumption() { - return V[mTier] * 2 * updateCycleLength; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - - prevX = aNBT.getInteger("prevX"); - prevY = aNBT.getInteger("prevY"); - prevZ = aNBT.getInteger("prevZ"); - - NBTTagCompound uuidNBT = aNBT.getCompoundTag("uuid"); - uuid = new UUID(uuidNBT.getLong("most"), uuidNBT.getLong("least")); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - - aNBT.setInteger("prevX", prevX); - aNBT.setInteger("prevY", prevY); - aNBT.setInteger("prevZ", prevZ); - - if (uuid != null) { - NBTTagCompound uuidNBT = new NBTTagCompound(); - uuidNBT.setLong("most", uuid.getMostSignificantBits()); - uuidNBT.setLong("least", uuid.getLeastSignificantBits()); - aNBT.setTag("uuid", uuidNBT); - } - } - - public boolean canChunkload() { - return getBaseMetaTileEntity().isAllowedToWork() && getEUVar() >= getEnergyConsumption(); - } - - /* - * Chunkloading Vars - */ - - private Set mLoadedChunks = new HashSet<>(); - private static final Map tickets = new MapMaker().makeMap(); - private boolean refreshTicket; - private int updateCycle = 0; - private static final int updateCycleLength = 20; - private UUID uuid; - private int prevX, prevY, prevZ; - private boolean hasTicket; - - public boolean addChunkToLoadedList(ChunkCoordIntPair aActiveChunk) { - return mLoadedChunks.add(aActiveChunk); - } - - public boolean removeChunkFromLoadedList(ChunkCoordIntPair aActiveChunk) { - return mLoadedChunks.remove(aActiveChunk); - } - - public Set getManagedChunks() { - return mLoadedChunks; - } - - public int getChunkloaderTier() { - return mTier; - } - - public void forceChunkLoading(Ticket ticket) { - setTicket(ticket); - setupChunks(); - - if (mLoadedChunks != null) { - for (ChunkCoordIntPair chunk : mLoadedChunks) { - ForgeChunkManager.forceChunk(ticket, chunk); - } - } - } - - public void setupChunks() { - if (!hasTicket) { - mLoadedChunks = null; - } else { - mLoadedChunks = GTPP_ChunkManager.getChunksAround(getBaseMetaTileEntity().getXCoord() >> 4, getBaseMetaTileEntity().getZCoord() >> 4, getChunkRadiusForTier(mTier)); - } - } - - protected Ticket getTicketFromForge() { - return ForgeChunkManager.requestTicket(GTplusplus.instance, getBaseMetaTileEntity().getWorld(), ForgeChunkManager.Type.NORMAL); - } - - public boolean hasActiveTicket() { - return getTicket() != null; - } - - protected void releaseTicket() { - refreshTicket = false; - setTicket(null); - } - - protected void requestTicket() { - if (canChunkload()) { - Ticket chunkTicket = getTicketFromForge(); - if (chunkTicket != null) { - setTicketData(chunkTicket); - forceChunkLoading(chunkTicket); - } - } - } - - protected void setTicketData(Ticket chunkTicket) { - if (chunkTicket != null) { - chunkTicket.getModData().setInteger("xCoord", getBaseMetaTileEntity().getXCoord()); - chunkTicket.getModData().setInteger("yCoord", getBaseMetaTileEntity().getYCoord()); - chunkTicket.getModData().setInteger("zCoord", getBaseMetaTileEntity().getZCoord()); - chunkTicket.setChunkListDepth(getMaxChunksToLoadForTier(mTier)); - } - } - - public void setTicket(Ticket t) { - Ticket ticket = getTicket(); - if (ticket != t) { - if (ticket != null) { - if (ticket.world == getBaseMetaTileEntity().getWorld()) { - for (ChunkCoordIntPair chunk : ticket.getChunkList()) { - if (ForgeChunkManager.getPersistentChunksFor(getBaseMetaTileEntity().getWorld()).keys().contains(chunk)) { - ForgeChunkManager.unforceChunk(ticket, chunk); - } - } - ForgeChunkManager.releaseTicket(ticket); - } - tickets.remove(getUUID()); - } - } - hasTicket = t != null; - if (hasTicket) { - tickets.put(getUUID(), t); - } - } - - public Ticket getTicket() { - return tickets.get(getUUID()); - } - - public UUID getUUID() { - if (uuid == null) { - uuid = UUID.randomUUID(); - } - return uuid; - } -} \ No newline at end of file + public GregtechMetaTileEntityChunkLoader(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 4, + "Loads " + getMaxChunksToLoadForTier(aTier) + " chunks when powered", + 0, + 0, + "Recycler.png", + "", + new ITexture[] {}); + } + + public GregtechMetaTileEntityChunkLoader( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 4, aDescription, aTextures, 0, 0, aGUIName, aNEIName); + } + + public static int getMaxChunksToLoadForTier(int aTier) { + if (aTier < 4) { + return Math.min(3 * 3, getMaxChunkDepthFor(CORE.MODID)); + } + if (aTier < 6) { + return Math.min(7 * 7, getMaxChunkDepthFor(CORE.MODID)); + } + if (aTier < 8) { + return Math.min(15 * 15, getMaxChunkDepthFor(CORE.MODID)); + } else { + return 0; + } + } + + public static int getChunkRadiusForTier(int aTier) { + if (aTier < 4) { + return Math.min(1, (int) Math.floor(Math.sqrt(getMaxChunkDepthFor(CORE.MODID)))); + } + if (aTier < 6) { + return Math.min(3, (int) Math.floor(Math.sqrt(getMaxChunkDepthFor(CORE.MODID)))); + } + if (aTier < 8) { + return Math.min(7, (int) Math.floor(Math.sqrt(getMaxChunkDepthFor(CORE.MODID)))); + } else { + return 0; + } + } + + @Override + public String[] getDescription() { + return new String[] { + "Loads " + getMaxChunksToLoadForTier(this.mTier) + " chunks when powered", + "Consumes 2A", + "Behaves Identically to a Railcraft World Anchor", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier]) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier]) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier]) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier]) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier]) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier + 1]) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier + 1]) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier + 1]) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier + 1]) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), + new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier + 1]) + }; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityChunkLoader( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return super.getInfoData(); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + if (aBaseMetaTileEntity.getXCoord() != prevX + || aBaseMetaTileEntity.getYCoord() != prevY + || aBaseMetaTileEntity.getZCoord() != prevZ) { + releaseTicket(); + prevX = aBaseMetaTileEntity.getXCoord(); + prevY = aBaseMetaTileEntity.getYCoord(); + prevZ = aBaseMetaTileEntity.getZCoord(); + } + + if (hasActiveTicket() + && (getTicket().world != aBaseMetaTileEntity.getWorld() + || refreshTicket + || !aBaseMetaTileEntity.isAllowedToWork())) { + releaseTicket(); + } + + if (++updateCycle % updateCycleLength == 0) { + updateCycle = 0; + if (canChunkload()) { + setEUVar(getEUVar() - getEnergyConsumption()); + } + } + + if (!hasActiveTicket()) { + requestTicket(); + } + } + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 2; + } + + @Override + public long maxEUStore() { + return V[mTier] * 256; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public void onRemoval() { + super.onRemoval(); + releaseTicket(); + } + + public long getEnergyConsumption() { + return V[mTier] * 2 * updateCycleLength; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + + prevX = aNBT.getInteger("prevX"); + prevY = aNBT.getInteger("prevY"); + prevZ = aNBT.getInteger("prevZ"); + + NBTTagCompound uuidNBT = aNBT.getCompoundTag("uuid"); + uuid = new UUID(uuidNBT.getLong("most"), uuidNBT.getLong("least")); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + + aNBT.setInteger("prevX", prevX); + aNBT.setInteger("prevY", prevY); + aNBT.setInteger("prevZ", prevZ); + + if (uuid != null) { + NBTTagCompound uuidNBT = new NBTTagCompound(); + uuidNBT.setLong("most", uuid.getMostSignificantBits()); + uuidNBT.setLong("least", uuid.getLeastSignificantBits()); + aNBT.setTag("uuid", uuidNBT); + } + } + + public boolean canChunkload() { + return getBaseMetaTileEntity().isAllowedToWork() && getEUVar() >= getEnergyConsumption(); + } + + /* + * Chunkloading Vars + */ + + private Set mLoadedChunks = new HashSet<>(); + private static final Map tickets = new MapMaker().makeMap(); + private boolean refreshTicket; + private int updateCycle = 0; + private static final int updateCycleLength = 20; + private UUID uuid; + private int prevX, prevY, prevZ; + private boolean hasTicket; + + public boolean addChunkToLoadedList(ChunkCoordIntPair aActiveChunk) { + return mLoadedChunks.add(aActiveChunk); + } + + public boolean removeChunkFromLoadedList(ChunkCoordIntPair aActiveChunk) { + return mLoadedChunks.remove(aActiveChunk); + } + + public Set getManagedChunks() { + return mLoadedChunks; + } + + public int getChunkloaderTier() { + return mTier; + } + + public void forceChunkLoading(Ticket ticket) { + setTicket(ticket); + setupChunks(); + + if (mLoadedChunks != null) { + for (ChunkCoordIntPair chunk : mLoadedChunks) { + ForgeChunkManager.forceChunk(ticket, chunk); + } + } + } + + public void setupChunks() { + if (!hasTicket) { + mLoadedChunks = null; + } else { + mLoadedChunks = GTPP_ChunkManager.getChunksAround( + getBaseMetaTileEntity().getXCoord() >> 4, + getBaseMetaTileEntity().getZCoord() >> 4, + getChunkRadiusForTier(mTier)); + } + } + + protected Ticket getTicketFromForge() { + return ForgeChunkManager.requestTicket( + GTplusplus.instance, getBaseMetaTileEntity().getWorld(), ForgeChunkManager.Type.NORMAL); + } + + public boolean hasActiveTicket() { + return getTicket() != null; + } + + protected void releaseTicket() { + refreshTicket = false; + setTicket(null); + } + + protected void requestTicket() { + if (canChunkload()) { + Ticket chunkTicket = getTicketFromForge(); + if (chunkTicket != null) { + setTicketData(chunkTicket); + forceChunkLoading(chunkTicket); + } + } + } + + protected void setTicketData(Ticket chunkTicket) { + if (chunkTicket != null) { + chunkTicket + .getModData() + .setInteger("xCoord", getBaseMetaTileEntity().getXCoord()); + chunkTicket + .getModData() + .setInteger("yCoord", getBaseMetaTileEntity().getYCoord()); + chunkTicket + .getModData() + .setInteger("zCoord", getBaseMetaTileEntity().getZCoord()); + chunkTicket.setChunkListDepth(getMaxChunksToLoadForTier(mTier)); + } + } + + public void setTicket(Ticket t) { + Ticket ticket = getTicket(); + if (ticket != t) { + if (ticket != null) { + if (ticket.world == getBaseMetaTileEntity().getWorld()) { + for (ChunkCoordIntPair chunk : ticket.getChunkList()) { + if (ForgeChunkManager.getPersistentChunksFor( + getBaseMetaTileEntity().getWorld()) + .keys() + .contains(chunk)) { + ForgeChunkManager.unforceChunk(ticket, chunk); + } + } + ForgeChunkManager.releaseTicket(ticket); + } + tickets.remove(getUUID()); + } + } + hasTicket = t != null; + if (hasTicket) { + tickets.put(getUUID(), t); + } + } + + public Ticket getTicket() { + return tickets.get(getUUID()); + } + + public UUID getUUID() { + if (uuid == null) { + uuid = UUID.randomUUID(); + } + return uuid; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java index 8456f40797..ea2f47ab8e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java @@ -1,204 +1,286 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; - -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaTileEntityThaumcraftResearcher extends GregtechMetaTileEntity { - public GregtechMetaTileEntityThaumcraftResearcher(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaTileEntityThaumcraftResearcher(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {this.mDescription, "Generates Thaumcraft research notes, because it's magic."}; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Metal_Grate_A)}; - } - - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Metal_Grate_B)}; - } - - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{getSides(aColor)[0]}; - } - - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; - } - - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; - } - - - public ITexture[] getFrontActive(final byte aColor) { - return getFront(aColor); - } - - - public ITexture[] getBackActive(final byte aColor) { - return getBack(aColor); - } - - - public ITexture[] getBottomActive(final byte aColor) { - return getBottom(aColor); - } - - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getSidesActive(final byte aColor) { - return getSides(aColor); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityThaumcraftResearcher(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(final int aIndex) {return true;} - @Override public boolean isFacingValid(final byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return false;} - @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getBackFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return 0;} - @Override public long maxEUStore() {return 512000;} - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return 0;} - @Override public int dechargerSlotCount() {return 0;} - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} - - @Override - public int getCapacity() { - return 128000; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - { - return true; - } - return true; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return aSide==this.getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return true; - } - - @Override - public String[] getInfoData() { - return new String[] { - this.getLocalName(), - }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int getSizeInventory() { - return 2; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - //aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); - //aNBT.setInteger("mAveragePollution", this.mAveragePollution); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - //this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); - //this.mAveragePollution = aNBT.getInteger("mAveragePollution"); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - -} \ No newline at end of file + public GregtechMetaTileEntityThaumcraftResearcher( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaTileEntityThaumcraftResearcher( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Generates Thaumcraft research notes, because it's magic."}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Metal_Grate_A) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Metal_Grate_B) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {getSides(aColor)[0]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return getSides(aColor); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityThaumcraftResearcher( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 512000; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public int getCapacity() { + return 128000; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + return true; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int getSizeInventory() { + return 2; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + // aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + // aNBT.setInteger("mAveragePollution", this.mAveragePollution); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + // this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + // this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java index f2fc0cce7a..ae8be6a161 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import java.util.List; - import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -12,58 +10,72 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.List; import net.minecraft.item.ItemStack; import team.chisel.carving.Carving; public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMachine { - private ItemStack mInputCache; - private ItemStack mOutputCache; - - public GregtechMetaTileEntity_AutoChisel(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Chisels things, Gregtech style", 1, 1, "Compressor.png", "", - new ITexture[]{ - new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), - new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB), - new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), - new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), - new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), - new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB) - }); - } - - public GregtechMetaTileEntity_AutoChisel(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_AutoChisel(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); - } - - @Override - public String[] getDescription() { - String[] A = new String[]{ - this.mDescription, - "What you want to chisel goes in slot 1", - "What you want to get goes in the special slot (bottom right)", - "If special slot is empty, first chisel result is used" - }; - return A; - } - + private ItemStack mInputCache; + private ItemStack mOutputCache; + + public GregtechMetaTileEntity_AutoChisel(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "Chisels things, Gregtech style", + 1, + 1, + "Compressor.png", + "", + new ITexture[] { + new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB), + new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), + new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB) + }); + } + + public GregtechMetaTileEntity_AutoChisel( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AutoChisel( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public String[] getDescription() { + String[] A = new String[] { + this.mDescription, + "What you want to chisel goes in slot 1", + "What you want to get goes in the special slot (bottom right)", + "If special slot is empty, first chisel result is used" + }; + return A; + } + @Override public GT_Recipe.GT_Recipe_Map getRecipeList() { return null; } - + private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { - if (mInputCache != null && mOutputCache != null) { - if (GT_Utility.areStacksEqual(aStack, mInputCache) && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { - return true; - } + if (mInputCache != null && mOutputCache != null) { + if (GT_Utility.areStacksEqual(aStack, mInputCache) + && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { + return true; + } } // clear cache if it was invalid if (aClearOnFailure) { @@ -72,84 +84,83 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa } return false; } - + private void cacheItem(ItemStack mInputItem, ItemStack mOutputItem) { mOutputCache = mOutputItem.copy(); mInputCache = mInputItem.copy(); } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return hasValidCache(aStack, this.getSpecialSlot(), false) ? true : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && hasChiselResults(aStack); + protected boolean allowPutStackValidated( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return hasValidCache(aStack, this.getSpecialSlot(), false) + ? true + : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && hasChiselResults(aStack); + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { + List results = getItemsForChiseling(from); + for (ItemStack s : results) { + if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { + return true; + } + } + return false; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean hasChiselResults(ItemStack from) { + List results = getItemsForChiseling(from); + return results.size() > 0; } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { - List results = getItemsForChiseling(from); - for (ItemStack s : results) { - if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { - return true; - } - } - return false; - } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean hasChiselResults(ItemStack from) { - List results = getItemsForChiseling(from); - return results.size() > 0; - } - - private static List getItemsForChiseling(ItemStack aStack){ - return Carving.chisel.getItemsForChiseling(aStack); - } - - private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { - ItemStack tOutput = null; - if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { - tOutput = aTarget; - } - else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { - tOutput = null; - } - else { - tOutput = getItemsForChiseling(aInput).get(0); - } - return tOutput; - } - + + private static List getItemsForChiseling(ItemStack aStack) { + return Carving.chisel.getItemsForChiseling(aStack); + } + + private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { + ItemStack tOutput = null; + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + } else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { + tOutput = null; + } else { + tOutput = getItemsForChiseling(aInput).get(0); + } + return tOutput; + } + @Override public int checkRecipe() { - ItemStack tOutput = null; - ItemStack aInput = getInputAt(0); - ItemStack aTarget = getSpecialSlot(); + ItemStack tOutput = null; + ItemStack aInput = getInputAt(0); + ItemStack aTarget = getSpecialSlot(); boolean tIsCached = hasValidCache(aInput, aTarget, true); - if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { - tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); - if (tOutput != null) { - tOutput = tOutput.copy(); - tOutput.stackSize = 1; - // We can chisel this - if (canOutput(tOutput)) { - getInputAt(0).stackSize -= 1; - calculateOverclockedNess(16, 20); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - } - if (!tIsCached) { - cacheItem(ItemUtils.getSimpleStack(aInput, 1), ItemUtils.getSimpleStack(tOutput, 1)); - } - this.mOutputItems[0] = tOutput.copy(); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; - } - else { - mOutputBlocked++; - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - } - } - } - return DID_NOT_FIND_RECIPE; + if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { + tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); + if (tOutput != null) { + tOutput = tOutput.copy(); + tOutput.stackSize = 1; + // We can chisel this + if (canOutput(tOutput)) { + getInputAt(0).stackSize -= 1; + calculateOverclockedNess(16, 20); + // In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + if (!tIsCached) { + cacheItem(ItemUtils.getSimpleStack(aInput, 1), ItemUtils.getSimpleStack(tOutput, 1)); + } + this.mOutputItems[0] = tOutput.copy(); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } else { + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + } + } + return DID_NOT_FIND_RECIPE; } - -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_BasicWasher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_BasicWasher.java index 99b3faa7d4..268863ffd2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_BasicWasher.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_BasicWasher.java @@ -6,66 +6,76 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Recipe; import gtPlusPlus.core.lib.CORE; -import gregtech.api.util.GTPP_Recipe; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_BasicWasher extends GT_MetaTileEntity_BasicMachine { - public GregtechMetaTileEntity_BasicWasher(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, - "It's like an automatic Cauldron for washing dusts.", 1, 1, "PotionBrewer.png", "", - new ITexture[]{ - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER) - } - ); - } - - public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - } + public GregtechMetaTileEntity_BasicWasher(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "It's like an automatic Cauldron for washing dusts.", + 1, + 1, + "PotionBrewer.png", + "", + new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER) + }); + } - /*public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - }*/ + public GregtechMetaTileEntity_BasicWasher( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "Grants no byproducts, but it is fast.", CORE.GT_Tooltip}; - } + /*public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + }*/ - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_BasicWasher(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); - } + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Grants no byproducts, but it is fast.", CORE.GT_Tooltip}; + } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes; - } + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_BasicWasher( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); - } + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes; + } - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return (aFluid.getFluid().getName().equals("water")) || (super.isFluidInputAllowed(aFluid)); - } + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && (getRecipeList().containsInput(aStack)); + } - @Override - public int getCapacity() { - return 8000 * Math.max(1, this.mTier); - } + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().equals("water")) || (super.isFluidInputAllowed(aFluid)); + } + @Override + public int getCapacity() { + return 8000 * Math.max(1, this.mTier); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java index c872e5c912..2ae5e1e54a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java @@ -1,13 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import static gregtech.api.enums.GT_Values.E; - -import java.util.HashSet; -import java.util.List; - -import cpw.mods.fml.common.registry.LanguageRegistry; -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -15,16 +7,13 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; -import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.slots.SlotChemicalPlantInput; import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.Container_FluidReactor; import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.GUI_FluidReactor; -import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.List; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -37,630 +26,648 @@ import net.minecraftforge.fluids.IFluidHandler; public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_BasicMachine { - public boolean mFluidTransfer_1 = false; - public boolean mFluidTransfer_2 = false; - - public FluidStack[] mInputFluids = new FluidStack[4]; - public FluidStack[] mOutputFluids = new FluidStack[2]; - - public GregtechMetaTileEntity_ChemicalReactor(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, - "For mixing fluids", 4, 4, "ChemicalReactor.png", "", - new ITexture[]{ - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side), - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front), - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top), - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top) - } - ); - } - - public GregtechMetaTileEntity_ChemicalReactor(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - } - - /*public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - }*/ - - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "Because why not?", CORE.GT_Tooltip}; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - try { - GregtechMetaTileEntity_ChemicalReactor y = new GregtechMetaTileEntity_ChemicalReactor(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); - return y; - } - catch(Throwable t) { - t.printStackTrace(); - } - return null; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - try { - Container_FluidReactor y = new Container_FluidReactor(aPlayerInventory, aBaseMetaTileEntity); - return y; - } - catch(Throwable t) { - t.printStackTrace(); - } - return null; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_FluidReactor(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - this.mGUIName, - GT_Utility.isStringValid(this.mNEIName) - ? this.mNEIName - : (this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "")); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return null; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return (super.isFluidInputAllowed(aFluid)); - } - - @Override - public int getCapacity() { - return 32000 * Math.max(1, this.mTier) / 4; - } - - @Override - public int getInputSlot() { - return 3; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return aSide > 1; - } - - @Override - public boolean isLiquidOutput(byte aSide) { - return aSide < 2; - } - - @Override - public int getOutputSlot() { - return super.getOutputSlot(); - } - - @Override - public int getStackDisplaySlot() { - return super.getStackDisplaySlot(); - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean canTankBeFilled() { - return super.canTankBeFilled(); - } - - @Override - public boolean canTankBeEmptied() { - return super.canTankBeEmptied(); - } - - @Override - public FluidStack getDisplayedFluid() { - return super.getDisplayedFluid(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mFluidTransfer_1", mFluidTransfer_1); - aNBT.setBoolean("mFluidTransfer_2", mFluidTransfer_2); - for (int i=0;i<4;i++) { - if (this.mInputFluids[i] != null) { - aNBT.setTag("mInputFluid"+i, this.mInputFluids[i].writeToNBT(new NBTTagCompound())); - } - } - for (int i=0;i<2;i++) { - if (this.mOutputFluids[i] != null) { - aNBT.setTag("mOutputFluid"+i, this.mOutputFluids[i].writeToNBT(new NBTTagCompound())); - } - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mFluidTransfer_1 = aNBT.getBoolean("mFluidTransfer_1"); - mFluidTransfer_2 = aNBT.getBoolean("mFluidTransfer_2"); - for (int i=0;i<4;i++) { - if (this.mInputFluids[i] == null) { - this.mInputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mInputFluid"+i)); - } - } - for (int i=0;i<2;i++) { - if (this.mOutputFluids[i] == null) { - this.mOutputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid"+i)); - } - } - } - - /* - * Custom Fluid Handling - TODO - */ - - public FluidStack getFillableStack() { - return this.mFluid; - } - - public FluidStack setFillableStack(FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; - } - - public FluidStack getDrainableStack() { - return this.mFluid; - } - - public FluidStack setDrainableStack(FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; - } - - - - - - - - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - // Re-implement basic machine logic from the ground up.= - - if (aBaseMetaTileEntity.isServerSide()) { - this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; - this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; - this.doDisplayThings(); - boolean tSucceeded = false; - int i; - if (this.mMaxProgresstime > 0 && (this.mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { - aBaseMetaTileEntity.setActive(true); - if (this.mProgresstime >= 0 && !this.drainEnergyForProcess((long) this.mEUt)) { - if (!this.mStuttering) { - this.stutterProcess(); - if (this.canHaveInsufficientEnergy()) { - this.mProgresstime = -100; - } - - this.mStuttering = true; - } - } else { - if (++this.mProgresstime >= this.mMaxProgresstime) { - for (i = 0; i < this.mOutputItems.length; ++i) { - for (i = 0; i < this.mOutputItems.length && !aBaseMetaTileEntity.addStackToSlot( - this.getOutputSlot() + (i + i) % this.mOutputItems.length, - this.mOutputItems[i]); ++i) { - ; - } - } - - if (this.mOutputFluid != null) { - if (this.getDrainableStack() == null) { - this.setDrainableStack(this.mOutputFluid.copy()); - } else if (this.mOutputFluid.isFluidEqual(this.getDrainableStack())) { - FluidStack var10000 = this.getDrainableStack(); - var10000.amount += this.mOutputFluid.amount; - } - } - - for (i = 0; i < this.mOutputItems.length; ++i) { - this.mOutputItems[i] = null; - } - - this.mOutputFluid = null; - this.mEUt = 0; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - this.mStuttering = false; - tSucceeded = true; - this.endProcess(); - } - - if (this.mProgresstime > 5) { - this.mStuttering = false; - } - } - } else { - aBaseMetaTileEntity.setActive(false); - } - - boolean tRemovedOutputFluid = false; - if (this.doesAutoOutputFluids() && this.getDrainableStack() != null - && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing && (tSucceeded || aTick % 20L == 0L)) { - IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); - if (tTank != null) { - FluidStack tDrained = this.drain(1000, false); - if (tDrained != null) { - int tFilledAmount = tTank.fill( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) { - tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), - this.drain(tFilledAmount, true), true); - } - } - } - - if (this.getDrainableStack() == null) { - tRemovedOutputFluid = true; - } - } - - int j; - if (this.doesAutoOutput() && !this.isOutputEmpty() - && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing - && (tSucceeded || this.mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() - || aTick % 600L == 0L)) { - TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - j = 0; - - for (byte tCosts = 1; j < this.mOutputItems.length && tCosts > 0 - && aBaseMetaTileEntity.isUniversalEnergyStored(128L); ++j) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, - aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), (List) null, - false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - if (tCosts > 0) { - aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) tCosts, true); - } - } - } - - if (this.mOutputBlocked != 0) { - if (this.isOutputEmpty()) { - this.mOutputBlocked = 0; - } else { - ++this.mOutputBlocked; - } - } - - if (this.allowToCheckRecipe()) { - if (this.mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() - && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() - || aTick % 600L == 0L || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) - && this.hasEnoughEnergyToCheckRecipe()) { - if (this.checkRecipe() == 2) { - if (this.mInventory[3] != null && this.mInventory[3].stackSize <= 0) { - this.mInventory[3] = null; - } - - i = this.getInputSlot(); - - for (j = i + this.mInputSlotCount; i < j; ++i) { - if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { - this.mInventory[i] = null; - } - } - - for (i = 0; i < this.mOutputItems.length; ++i) { - this.mOutputItems[i] = GT_Utility.copy(new Object[]{this.mOutputItems[i]}); - if (this.mOutputItems[i] != null && this.mOutputItems[i].stackSize > 64) { - this.mOutputItems[i].stackSize = 64; - } - - this.mOutputItems[i] = GT_OreDictUnificator.get(true, this.mOutputItems[i]); - } - - if (this.mFluid != null && this.mFluid.amount <= 0) { - this.mFluid = null; - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - if (GT_Utility.isDebugItem(this.mInventory[this.dechargerSlotStartIndex()])) { - this.mEUt = this.mMaxProgresstime = 1; - } - - this.startProcess(); - } else { - this.mMaxProgresstime = 0; - - for (i = 0; i < this.mOutputItems.length; ++i) { - this.mOutputItems[i] = null; - } - - this.mOutputFluid = null; - } - } - } else if (!this.mStuttering) { - this.stutterProcess(); - this.mStuttering = true; - } - } - - - - } - - @Override - protected void doDisplayThings() { - // TODO Auto-generated method stub - super.doDisplayThings(); - } - - @Override - protected ItemStack getSpecialSlot() { - // TODO Auto-generated method stub - return super.getSpecialSlot(); - } - - @Override - protected ItemStack getOutputAt(int aIndex) { - // TODO Auto-generated method stub - return super.getOutputAt(aIndex); - } - - @Override - protected ItemStack[] getAllOutputs() { - // TODO Auto-generated method stub - return super.getAllOutputs(); - } - - @Override - protected ItemStack getInputAt(int aIndex) { - // TODO Auto-generated method stub - return super.getInputAt(aIndex); - } - - @Override - protected ItemStack[] getAllInputs() { - // TODO Auto-generated method stub - return super.getAllInputs(); - } - - @Override - protected boolean displaysInputFluid() { - return true; - } - - @Override - protected boolean displaysOutputFluid() { - return true; - } - - @Override - public boolean doesAutoOutput() { - return super.doesAutoOutput(); - } - - @Override - public boolean doesAutoOutputFluids() { - return this.mFluidTransfer_1 && this.mFluidTransfer_2; - } - - @Override - public void startProcess() { - super.startProcess(); - } - - @Override - public void endProcess() { - super.endProcess(); - } - - @Override - public String[] getInfoData() { - return super.getInfoData(); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPullStack(aBaseMetaTileEntity, aIndex, aSide, aStack); - } - - @Override - public int checkRecipe() { - return super.checkRecipe(); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - - /* if (aBaseMetaTileEntity != null) { - if (!aBaseMetaTileEntity.getWorld().isRemote) { - itemslots : for (int i=3;i<7;i++) { - ItemStack aStack = aBaseMetaTileEntity.getStackInSlot(i); - if (aStack != null) { - if (FluidContainerRegistry.isContainer(aStack)) { - if (this.isItemValidForSlot(i, aStack)) { - // Add Fluid - FluidStack aContainerFluid = FluidContainerRegistry.getFluidForFilledItem(aStack); - if (aContainerFluid != null) { - fluidslots : for (FluidStack u : mInputFluids) { - if (u != null && u.isFluidEqual(aContainerFluid)) { - if (u.amount <= (this.getCapacity() - aContainerFluid.amount)) { - - // Matching, not full, let's fill, then continue - u.amount += aContainerFluid.amount; - - // Update stack size - if (aStack.stackSize > 1) { - aStack.stackSize--; - } - else { - aStack = null; - } - - // Add Output container - // TODO - - continue itemslots; - } - else { - // Too full - break fluidslots; - } - } - else { - if (u == null ) { - - // Empty, let's fill, then continue - u = aContainerFluid.copy(); - - // Update stack size - if (aStack.stackSize > 1) { - aStack.stackSize--; - } - else { - aStack = null; - } - - // Add Output container - // TODO - - continue itemslots; - - } - else { - // Not empty, doesn't match, check next slot. - continue fluidslots; - } - } - } - - - - } - // Eat Input - - // Add Container to Output - } - } - } - } - } - }*/ - - } - - @Override - public FluidStack getFluid() { - return super.getFluid(); - } - - @Override - public int getFluidAmount() { - return super.getFluidAmount(); - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - return super.fill(aFluid, doFill); - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return super.drain(maxDrain, doDrain); - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - super.setItemNBT(aNBT); - } - - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - if (aIndex >= 3 && aIndex <= 6) { - return SlotChemicalPlantInput.isItemValidForChemicalPlantSlot(aStack); - } - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - return super.getAccessibleSlotsFromSide(aSide); - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - if (aIndex >= 3 && aIndex <= 6) { - return super.canInsertItem(aIndex, aStack, aSide); - } - return false; - } - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - if (aIndex >= 7 && aIndex <= 11) { - return super.canExtractItem(aIndex, aStack, aSide); - } - return false; - } - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - // TODO Auto-generated method stub - return super.canFill(aSide, aFluid); - } - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - // TODO Auto-generated method stub - return super.canDrain(aSide, aFluid); - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - // TODO Auto-generated method stub - return super.getTankInfo(aSide); - } - - @Override - public int fill_default( - ForgeDirection aSide, FluidStack aFluid, boolean doFill - ) { - // TODO Auto-generated method stub - return super.fill_default(aSide, aFluid, doFill); - } - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - // TODO Auto-generated method stub - return super.fill(aSide, aFluid, doFill); - } - - @Override - public FluidStack drain( - ForgeDirection aSide, FluidStack aFluid, boolean doDrain - ) { - // TODO Auto-generated method stub - return super.drain(aSide, aFluid, doDrain); - } - - @Override - public FluidStack drain( - ForgeDirection aSide, int maxDrain, boolean doDrain - ) { - // TODO Auto-generated method stub - return super.drain(aSide, maxDrain, doDrain); - } - + public boolean mFluidTransfer_1 = false; + public boolean mFluidTransfer_2 = false; + + public FluidStack[] mInputFluids = new FluidStack[4]; + public FluidStack[] mOutputFluids = new FluidStack[2]; + + public GregtechMetaTileEntity_ChemicalReactor(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "For mixing fluids", + 4, + 4, + "ChemicalReactor.png", + "", + new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top) + }); + } + + public GregtechMetaTileEntity_ChemicalReactor( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + /*public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + }*/ + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Because why not?", CORE.GT_Tooltip}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + try { + GregtechMetaTileEntity_ChemicalReactor y = new GregtechMetaTileEntity_ChemicalReactor( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + return y; + } catch (Throwable t) { + t.printStackTrace(); + } + return null; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + try { + Container_FluidReactor y = new Container_FluidReactor(aPlayerInventory, aBaseMetaTileEntity); + return y; + } catch (Throwable t) { + t.printStackTrace(); + } + return null; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_FluidReactor( + aPlayerInventory, + aBaseMetaTileEntity, + this.getLocalName(), + this.mGUIName, + GT_Utility.isStringValid(this.mNEIName) + ? this.mNEIName + : (this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "")); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000 * Math.max(1, this.mTier) / 4; + } + + @Override + public int getInputSlot() { + return 3; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide < 2; + } + + @Override + public int getOutputSlot() { + return super.getOutputSlot(); + } + + @Override + public int getStackDisplaySlot() { + return super.getStackDisplaySlot(); + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return super.canTankBeFilled(); + } + + @Override + public boolean canTankBeEmptied() { + return super.canTankBeEmptied(); + } + + @Override + public FluidStack getDisplayedFluid() { + return super.getDisplayedFluid(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer_1", mFluidTransfer_1); + aNBT.setBoolean("mFluidTransfer_2", mFluidTransfer_2); + for (int i = 0; i < 4; i++) { + if (this.mInputFluids[i] != null) { + aNBT.setTag("mInputFluid" + i, this.mInputFluids[i].writeToNBT(new NBTTagCompound())); + } + } + for (int i = 0; i < 2; i++) { + if (this.mOutputFluids[i] != null) { + aNBT.setTag("mOutputFluid" + i, this.mOutputFluids[i].writeToNBT(new NBTTagCompound())); + } + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer_1 = aNBT.getBoolean("mFluidTransfer_1"); + mFluidTransfer_2 = aNBT.getBoolean("mFluidTransfer_2"); + for (int i = 0; i < 4; i++) { + if (this.mInputFluids[i] == null) { + this.mInputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mInputFluid" + i)); + } + } + for (int i = 0; i < 2; i++) { + if (this.mOutputFluids[i] == null) { + this.mOutputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid" + i)); + } + } + } + + /* + * Custom Fluid Handling - TODO + */ + + public FluidStack getFillableStack() { + return this.mFluid; + } + + public FluidStack setFillableStack(FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + public FluidStack getDrainableStack() { + return this.mFluid; + } + + public FluidStack setDrainableStack(FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // Re-implement basic machine logic from the ground up.= + + if (aBaseMetaTileEntity.isServerSide()) { + this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; + this.doDisplayThings(); + boolean tSucceeded = false; + int i; + if (this.mMaxProgresstime > 0 && (this.mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (this.mProgresstime >= 0 && !this.drainEnergyForProcess((long) this.mEUt)) { + if (!this.mStuttering) { + this.stutterProcess(); + if (this.canHaveInsufficientEnergy()) { + this.mProgresstime = -100; + } + + this.mStuttering = true; + } + } else { + if (++this.mProgresstime >= this.mMaxProgresstime) { + for (i = 0; i < this.mOutputItems.length; ++i) { + for (i = 0; + i < this.mOutputItems.length + && !aBaseMetaTileEntity.addStackToSlot( + this.getOutputSlot() + (i + i) % this.mOutputItems.length, + this.mOutputItems[i]); + ++i) { + ; + } + } + + if (this.mOutputFluid != null) { + if (this.getDrainableStack() == null) { + this.setDrainableStack(this.mOutputFluid.copy()); + } else if (this.mOutputFluid.isFluidEqual(this.getDrainableStack())) { + FluidStack var10000 = this.getDrainableStack(); + var10000.amount += this.mOutputFluid.amount; + } + } + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = null; + } + + this.mOutputFluid = null; + this.mEUt = 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + this.mStuttering = false; + tSucceeded = true; + this.endProcess(); + } + + if (this.mProgresstime > 5) { + this.mStuttering = false; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + if (this.doesAutoOutputFluids() + && this.getDrainableStack() != null + && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing + && (tSucceeded || aTick % 20L == 0L)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = this.drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) { + tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), + this.drain(tFilledAmount, true), + true); + } + } + } + + if (this.getDrainableStack() == null) { + tRemovedOutputFluid = true; + } + } + + int j; + if (this.doesAutoOutput() + && !this.isOutputEmpty() + && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing + && (tSucceeded + || this.mOutputBlocked % 300 == 1 + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600L == 0L)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + j = 0; + + for (byte tCosts = 1; + j < this.mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128L); + ++j) { + tCosts = GT_Utility.moveOneItemStack( + aBaseMetaTileEntity, + tTileEntity2, + aBaseMetaTileEntity.getFrontFacing(), + aBaseMetaTileEntity.getBackFacing(), + (List) null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + if (tCosts > 0) { + aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) tCosts, true); + } + } + } + + if (this.mOutputBlocked != 0) { + if (this.isOutputEmpty()) { + this.mOutputBlocked = 0; + } else { + ++this.mOutputBlocked; + } + } + + if (this.allowToCheckRecipe()) { + if (this.mMaxProgresstime <= 0 + && aBaseMetaTileEntity.isAllowedToWork() + && (tRemovedOutputFluid + || tSucceeded + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600L == 0L + || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) + && this.hasEnoughEnergyToCheckRecipe()) { + if (this.checkRecipe() == 2) { + if (this.mInventory[3] != null && this.mInventory[3].stackSize <= 0) { + this.mInventory[3] = null; + } + + i = this.getInputSlot(); + + for (j = i + this.mInputSlotCount; i < j; ++i) { + if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { + this.mInventory[i] = null; + } + } + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = GT_Utility.copy(new Object[] {this.mOutputItems[i]}); + if (this.mOutputItems[i] != null && this.mOutputItems[i].stackSize > 64) { + this.mOutputItems[i].stackSize = 64; + } + + this.mOutputItems[i] = GT_OreDictUnificator.get(true, this.mOutputItems[i]); + } + + if (this.mFluid != null && this.mFluid.amount <= 0) { + this.mFluid = null; + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + if (GT_Utility.isDebugItem(this.mInventory[this.dechargerSlotStartIndex()])) { + this.mEUt = this.mMaxProgresstime = 1; + } + + this.startProcess(); + } else { + this.mMaxProgresstime = 0; + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = null; + } + + this.mOutputFluid = null; + } + } + } else if (!this.mStuttering) { + this.stutterProcess(); + this.mStuttering = true; + } + } + } + + @Override + protected void doDisplayThings() { + // TODO Auto-generated method stub + super.doDisplayThings(); + } + + @Override + protected ItemStack getSpecialSlot() { + // TODO Auto-generated method stub + return super.getSpecialSlot(); + } + + @Override + protected ItemStack getOutputAt(int aIndex) { + // TODO Auto-generated method stub + return super.getOutputAt(aIndex); + } + + @Override + protected ItemStack[] getAllOutputs() { + // TODO Auto-generated method stub + return super.getAllOutputs(); + } + + @Override + protected ItemStack getInputAt(int aIndex) { + // TODO Auto-generated method stub + return super.getInputAt(aIndex); + } + + @Override + protected ItemStack[] getAllInputs() { + // TODO Auto-generated method stub + return super.getAllInputs(); + } + + @Override + protected boolean displaysInputFluid() { + return true; + } + + @Override + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public boolean doesAutoOutput() { + return super.doesAutoOutput(); + } + + @Override + public boolean doesAutoOutputFluids() { + return this.mFluidTransfer_1 && this.mFluidTransfer_2; + } + + @Override + public void startProcess() { + super.startProcess(); + } + + @Override + public void endProcess() { + super.endProcess(); + } + + @Override + public String[] getInfoData() { + return super.getInfoData(); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPullStack(aBaseMetaTileEntity, aIndex, aSide, aStack); + } + + @Override + public int checkRecipe() { + return super.checkRecipe(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + + /* if (aBaseMetaTileEntity != null) { + if (!aBaseMetaTileEntity.getWorld().isRemote) { + itemslots : for (int i=3;i<7;i++) { + ItemStack aStack = aBaseMetaTileEntity.getStackInSlot(i); + if (aStack != null) { + if (FluidContainerRegistry.isContainer(aStack)) { + if (this.isItemValidForSlot(i, aStack)) { + // Add Fluid + FluidStack aContainerFluid = FluidContainerRegistry.getFluidForFilledItem(aStack); + if (aContainerFluid != null) { + fluidslots : for (FluidStack u : mInputFluids) { + if (u != null && u.isFluidEqual(aContainerFluid)) { + if (u.amount <= (this.getCapacity() - aContainerFluid.amount)) { + + // Matching, not full, let's fill, then continue + u.amount += aContainerFluid.amount; + + // Update stack size + if (aStack.stackSize > 1) { + aStack.stackSize--; + } + else { + aStack = null; + } + + // Add Output container + // TODO + + continue itemslots; + } + else { + // Too full + break fluidslots; + } + } + else { + if (u == null ) { + + // Empty, let's fill, then continue + u = aContainerFluid.copy(); + + // Update stack size + if (aStack.stackSize > 1) { + aStack.stackSize--; + } + else { + aStack = null; + } + + // Add Output container + // TODO + + continue itemslots; + + } + else { + // Not empty, doesn't match, check next slot. + continue fluidslots; + } + } + } + + + + } + // Eat Input + + // Add Container to Output + } + } + } + } + } + }*/ + + } + + @Override + public FluidStack getFluid() { + return super.getFluid(); + } + + @Override + public int getFluidAmount() { + return super.getFluidAmount(); + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + if (aIndex >= 3 && aIndex <= 6) { + return SlotChemicalPlantInput.isItemValidForChemicalPlantSlot(aStack); + } + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) { + return super.getAccessibleSlotsFromSide(aSide); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex >= 3 && aIndex <= 6) { + return super.canInsertItem(aIndex, aStack, aSide); + } + return false; + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex >= 7 && aIndex <= 11) { + return super.canExtractItem(aIndex, aStack, aSide); + } + return false; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + // TODO Auto-generated method stub + return super.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + // TODO Auto-generated method stub + return super.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + // TODO Auto-generated method stub + return super.getTankInfo(aSide); + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + // TODO Auto-generated method stub + return super.fill_default(aSide, aFluid, doFill); + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + // TODO Auto-generated method stub + return super.fill(aSide, aFluid, doFill); + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + // TODO Auto-generated method stub + return super.drain(aSide, aFluid, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + // TODO Auto-generated method stub + return super.drain(aSide, maxDrain, doDrain); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java index 2197ce193d..eb52042b9b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java @@ -1,13 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import java.util.ArrayList; -import java.util.Random; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; @@ -15,688 +7,718 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeMachine; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_CompactFusionReactor extends GT_MetaTileEntity_DeluxeMachine { - private boolean mCanProcessRecipe = false; - private boolean mCharging = false; - private long mChargeConsumed = 0; - - private GT_Recipe mLastRecipe; - private long mEUStore; - private boolean mRunningOnLoad = false; - private boolean mMachine = false; - private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; - private int mStartUpCheck = 100, mUpdate = 0; - private FluidStack[] mOutputFluids = null; - - public GregtechMetaTileEntity_CompactFusionReactor(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, 1, "PotionBrewer.png", ""); - } - - public GregtechMetaTileEntity_CompactFusionReactor(String aName, int aTier, String aDescription, - ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "Not Very Fast, but not very big either.", - "Each side pair in/out puts to different slots.", "Top & Bottom Sides are Outputs.", - "Front & Back are Input Plasma 1.", "Sides are Input Plasma 2." }; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_CompactFusionReactor(this.mName, this.mTier, this.mDescription, - this.mTextures, this.mGUIName, this.mNEIName); - } - - public int tier() { - return this.mTier; - } - - public int tierOverclock() { - return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; - } - - private GT_RenderedTexture getCasingTexture() { - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex - + 1]; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return (aFluid.getFluid().getName().contains("plasma")) || (super.isFluidInputAllowed(aFluid)); - } - - @Override - public int getCapacity() { - return 32000; - } - - @Override - public void abortProcess() { - super.abortProcess(); - } - - long mFusionPoint = 20000000L; - - @Override - public int checkRecipe() { - Logger.MACHINE_INFO("Recipe Tick 1."); - if (!this.mCanProcessRecipe) { - Logger.MACHINE_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); - if (this.mChargeConsumed < mFusionPoint) { - Logger.MACHINE_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); - this.mCharging = true; - this.mCanProcessRecipe = false; - if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits((mFusionPoint / 100), false)) { - Logger.MACHINE_INFO("Recipe Tick 1.3 - Charging Internal storage. " + (mFusionPoint / 100) + "/" - + mFusionPoint); - mChargeConsumed += (mFusionPoint / 100); - } - } - else { - mChargeConsumed = 0; - this.mCharging = false; - this.mCanProcessRecipe = true; - - } - } - else { - Logger.MACHINE_INFO("Recipe Tick 1.1 - Try to Process Recipe."); - if (checkRecipeMulti()) { - Logger.MACHINE_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); - return 2; - } - } - Logger.MACHINE_INFO("Recipe Tick 2. - Process Recipe failed."); - return 0; - } - - public ArrayList getStoredFluids() { - ArrayList mList = new ArrayList(); - mList.add(this.mFluid); - mList.add(this.mFluid2); - return mList; - } - - public boolean checkRecipeMulti() { - ArrayList tFluidList = getStoredFluids(); - int tFluidList_sS = tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - tFluidList_sS = tFluidList.size(); - } - else { - tFluidList.remove(i--); - tFluidList_sS = tFluidList.size(); - break; - } - } - } - } - if (tFluidList.size() > 1) { - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); - GT_Recipe tRecipe = getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, - GT_Values.V[8], tFluids, new ItemStack[] {}); - if (tRecipe == null) { - return false; - } - if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && maxEUStore() < tRecipe.mSpecialValue)) { - this.mLastRecipe = null; - Logger.MACHINE_INFO("Just plain bad."); - return false; - } - if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { - this.mLastRecipe = tRecipe; - this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); - this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); - - this.mEfficiencyIncrease = 10000; - - this.mOutputFluids = this.mLastRecipe.mFluidOutputs; - mRunningOnLoad = false; - return true; - } - } - return false; - } - - public int overclock(int mStartEnergy) { - if (tierOverclock() == 1) { - return 1; - } - if (tierOverclock() == 2) { - return mStartEnergy < 160000000 ? 2 : 1; - } - return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean doesAutoOutputFluids() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public long maxAmperesIn() { - return 16L; - } - - @Override - public long maxEUStore() { - return Long.MAX_VALUE; - } - - @Override - public void doExplosion(long aExplosionPower) { - super.doExplosion(aExplosionPower * 2); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - onRunningTickMulti(); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) - && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) - && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - if (MathUtils.randInt(0, 4) == 4) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", - (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), - aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), - (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); - aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", - (aBaseMetaTileEntity.getXCoord() + 0.4F) - (tRandom.nextFloat() * 0.3F), - aBaseMetaTileEntity.getYCoord() + 0.2f + (tRandom.nextFloat() * 0.1F), - (aBaseMetaTileEntity.getZCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), 0.0D, 0.0D, 0.0D); - aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", - (aBaseMetaTileEntity.getXCoord() + 0.6F) - (tRandom.nextFloat() * 0.9F), - aBaseMetaTileEntity.getYCoord() + 0.4f + (tRandom.nextFloat() * 0.3F), - (aBaseMetaTileEntity.getZCoord() + 1.8F) - (tRandom.nextFloat() * 2.6F), 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); - aNBT.setBoolean("mCharging", this.mCharging); - aNBT.setLong("mChargeConsumed", this.mChargeConsumed); - aNBT.setInteger("mEfficiency", this.mEfficiency); - aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); - aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); - aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); - aNBT.setInteger("mUpdate", mUpdate); - aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); - aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); - aNBT.setBoolean("mMachine", this.mMachine); - aNBT.setLong("mEUStore", this.mEUStore); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (mMaxProgresstime > 0) - mRunningOnLoad = true; - this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); - this.mCharging = aNBT.getBoolean("mCharging"); - this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); - this.mEfficiency = aNBT.getInteger("mEfficiency"); - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); - this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); - this.mUpdate = aNBT.getInteger("mUpdate"); - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); - this.mMachine = aNBT.getBoolean("mMachine"); - this.mEUStore = aNBT.getLong("mEUStore"); - super.loadNBTData(aNBT); - } - - @Override - public String[] getInfoData() { - String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; - float plasmaOut = 0; - String fusionName = ""; - int powerRequired = 0; - if (this.mLastRecipe != null) { - fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName() + " Fusion."; - powerRequired = this.mLastRecipe.mEUt; - if (this.mLastRecipe.getFluidOutput(0) != null) { - plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; - } - } - - return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", - "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t", - "Current Recipe: " + fusionName }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) }; - } - - @Override - public void onMachineBlockUpdate() { - this.mUpdate = 50; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - // super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - // Logger.MACHINE_INFO("1"); - if (mEfficiency < 0) - mEfficiency = 0; - if (mRunningOnLoad) { - Logger.MACHINE_INFO("2"); - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - checkRecipeMulti(); - } - if (--mUpdate == 0 || --mStartUpCheck == 0) { - Logger.MACHINE_INFO("3"); - mMachine = true; - } - if (mStartUpCheck < 0) { - //Logger.MACHINE_INFO("4"); - if (mMachine) { - //Logger.MACHINE_INFO("5"); - - if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { - if (aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true)) { - //Logger.MACHINE_INFO("5.5 A"); - } - else { - //Logger.MACHINE_INFO("5.5 B"); - } - } - if (this.mEUStore <= 0 && mMaxProgresstime > 0) { - Logger.MACHINE_INFO("6"); - stopMachine(); - this.mLastRecipe = null; - } - if (mMaxProgresstime > 0) { - Logger.MACHINE_INFO("7"); - this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); - if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { - if (mOutputFluids != null) - for (FluidStack tStack : mOutputFluids) - if (tStack != null) - addOutput(tStack); - mEfficiency = Math.max(0, (mEfficiency + mEfficiencyIncrease)); - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - if (mOutputFluids != null && mOutputFluids.length > 0) { - - } - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - if (aBaseMetaTileEntity.isAllowedToWork()) - checkRecipeMulti(); - } - } - else { - //Logger.MACHINE_INFO("8"); - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() - || aBaseMetaTileEntity.hasInventoryBeenModified()) { - Logger.MACHINE_INFO("9"); - // turnCasingActive(mMaxProgresstime > 0); - if (aBaseMetaTileEntity.isAllowedToWork()) { - Logger.MACHINE_INFO("10"); - if (checkRecipeMulti()) { - Logger.MACHINE_INFO("11"); - if (this.mEUStore < this.mLastRecipe.mSpecialValue) { - Logger.MACHINE_INFO("12"); - mMaxProgresstime = 0; - // turnCasingActive(false); - } - aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); - } - } - if (mMaxProgresstime <= 0) - mEfficiency = Math.max(0, mEfficiency - 1000); - } - } - } - else { - // turnCasingActive(false); - Logger.MACHINE_INFO("Bad"); - this.mLastRecipe = null; - stopMachine(); - } - } - Logger.MACHINE_INFO("Good | "+mMaxProgresstime); - aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); - } - } - - public boolean onRunningTickMulti() { - if (this.getBaseMetaTileEntity().isServerSide()) { - if (mEUt < 0) { - if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { - this.mLastRecipe = null; - stopMachine(); - Logger.MACHINE_INFO("a1"); - return false; - } - } - if (this.mEUStore <= 0) { - this.mLastRecipe = null; - stopMachine(); - Logger.MACHINE_INFO("a2"); - return false; - } - } - return true; - } - - public boolean drainEnergyInput(long aEU) { - return false; - } - - public boolean addOutput(FluidStack aLiquid) { - if (aLiquid == null) - return false; - FluidStack copiedFluidStack = aLiquid.copy(); - this.mOutputFluid = copiedFluidStack; - return false; - } - - public void stopMachine() { - mEUt = 0; - mEfficiency = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - getBaseMetaTileEntity().disableWorking(); - } - - @Override - public boolean isLiquidInput(byte aSide) { - switch (aSide) { - case 0: - return true; - case 1: - return true; - case 2: - return true; - case 3: - return false; - case 4: - return false; - case 5: - return false; - default: - return false; - } - } - - @Override - public boolean isLiquidOutput(byte aSide) { - switch (aSide) { - case 0: - return false; - case 1: - return false; - case 2: - return false; - case 3: - return true; - case 4: - return true; - case 5: - return true; - default: - return true; - } - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - return super.fill(aFluid, doFill); - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return super.drain(maxDrain, doDrain); - } - - @Override - public int getTankPressure() { - return 500; - } - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return false; - } - else { - return super.canFill(aSide, aFluid); - } - } - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.canDrain(aSide, aFluid); - } - else { - return false; - } - } - - @Override - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return 0; - } - else { - return super.fill_default(aSide, aFluid, doFill); - } - } - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.fill(aSide, aFluid, doFill); - } - else { - return 0; - } - } - - @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.drain(aSide, aFluid, doDrain); - } - else { - return null; - } - } - - @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.drain(aSide, maxDrain, doDrain); - } - else { - return null; - } - } - - @Override - public boolean isOverclockerUpgradable() { - return true; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - // TODO Auto-generated method stub - return super.onRightclick(aBaseMetaTileEntity, aPlayer); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - // TODO Auto-generated method stub - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - // TODO Auto-generated method stub - return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - // TODO Auto-generated method stub - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return false; - } - - @Override - public void onExplosion() { - // TODO Auto-generated method stub - super.onExplosion(); - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, - aZ); - } - } - + private boolean mCanProcessRecipe = false; + private boolean mCharging = false; + private long mChargeConsumed = 0; + + private GT_Recipe mLastRecipe; + private long mEUStore; + private boolean mRunningOnLoad = false; + private boolean mMachine = false; + private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; + private int mStartUpCheck = 100, mUpdate = 0; + private FluidStack[] mOutputFluids = null; + + public GregtechMetaTileEntity_CompactFusionReactor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, 1, "PotionBrewer.png", ""); + } + + public GregtechMetaTileEntity_CompactFusionReactor( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Not Very Fast, but not very big either.", + "Each side pair in/out puts to different slots.", + "Top & Bottom Sides are Outputs.", + "Front & Back are Input Plasma 1.", + "Sides are Input Plasma 2." + }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_CompactFusionReactor( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public int tier() { + return this.mTier; + } + + public int tierOverclock() { + return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; + } + + private GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().contains("plasma")) || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public void abortProcess() { + super.abortProcess(); + } + + long mFusionPoint = 20000000L; + + @Override + public int checkRecipe() { + Logger.MACHINE_INFO("Recipe Tick 1."); + if (!this.mCanProcessRecipe) { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + if (this.mChargeConsumed < mFusionPoint) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + this.mCharging = true; + this.mCanProcessRecipe = false; + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits((mFusionPoint / 100), false)) { + Logger.MACHINE_INFO("Recipe Tick 1.3 - Charging Internal storage. " + (mFusionPoint / 100) + "/" + + mFusionPoint); + mChargeConsumed += (mFusionPoint / 100); + } + } else { + mChargeConsumed = 0; + this.mCharging = false; + this.mCanProcessRecipe = true; + } + } else { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Try to Process Recipe."); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + return 2; + } + } + Logger.MACHINE_INFO("Recipe Tick 2. - Process Recipe failed."); + return 0; + } + + public ArrayList getStoredFluids() { + ArrayList mList = new ArrayList(); + mList.add(this.mFluid); + mList.add(this.mFluid2); + return mList; + } + + public boolean checkRecipeMulti() { + ArrayList tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = getRecipeList() + .findRecipe( + this.getBaseMetaTileEntity(), + this.mLastRecipe, + false, + GT_Values.V[8], + tFluids, + new ItemStack[] {}); + if (tRecipe == null) { + return false; + } + if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && maxEUStore() < tRecipe.mSpecialValue)) { + this.mLastRecipe = null; + Logger.MACHINE_INFO("Just plain bad."); + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); + + this.mEfficiencyIncrease = 10000; + + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean doesAutoOutputFluids() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public long maxAmperesIn() { + return 16L; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower * 2); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + onRunningTickMulti(); + if ((aBaseMetaTileEntity.isClientSide()) + && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) + && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + if (MathUtils.randInt(0, 4) == 4) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), + 0.0D, + 0.0D, + 0.0D); + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.4F) - (tRandom.nextFloat() * 0.3F), + aBaseMetaTileEntity.getYCoord() + 0.2f + (tRandom.nextFloat() * 0.1F), + (aBaseMetaTileEntity.getZCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + 0.0D, + 0.0D, + 0.0D); + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.6F) - (tRandom.nextFloat() * 0.9F), + aBaseMetaTileEntity.getYCoord() + 0.4f + (tRandom.nextFloat() * 0.3F), + (aBaseMetaTileEntity.getZCoord() + 1.8F) - (tRandom.nextFloat() * 2.6F), + 0.0D, + 0.0D, + 0.0D); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); + aNBT.setBoolean("mCharging", this.mCharging); + aNBT.setLong("mChargeConsumed", this.mChargeConsumed); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); + aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); + aNBT.setInteger("mUpdate", mUpdate); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); + aNBT.setBoolean("mMachine", this.mMachine); + aNBT.setLong("mEUStore", this.mEUStore); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (mMaxProgresstime > 0) mRunningOnLoad = true; + this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); + this.mCharging = aNBT.getBoolean("mCharging"); + this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); + this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); + this.mUpdate = aNBT.getInteger("mUpdate"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); + this.mMachine = aNBT.getBoolean("mMachine"); + this.mEUStore = aNBT.getLong("mEUStore"); + super.loadNBTData(aNBT); + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + String fusionName = ""; + int powerRequired = 0; + if (this.mLastRecipe != null) { + fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName() + " Fusion."; + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { + "Fusion Reactor MK " + tier, + "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), + "Plasma Output: " + plasmaOut + "L/t", + "Current Recipe: " + fusionName + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW)}; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW)}; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) + }; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + // Logger.MACHINE_INFO("1"); + if (mEfficiency < 0) mEfficiency = 0; + if (mRunningOnLoad) { + Logger.MACHINE_INFO("2"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipeMulti(); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + Logger.MACHINE_INFO("3"); + mMachine = true; + } + if (mStartUpCheck < 0) { + // Logger.MACHINE_INFO("4"); + if (mMachine) { + // Logger.MACHINE_INFO("5"); + + if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { + if (aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true)) { + // Logger.MACHINE_INFO("5.5 A"); + } else { + // Logger.MACHINE_INFO("5.5 B"); + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + Logger.MACHINE_INFO("6"); + stopMachine(); + this.mLastRecipe = null; + } + if (mMaxProgresstime > 0) { + Logger.MACHINE_INFO("7"); + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); + mEfficiency = Math.max(0, (mEfficiency + mEfficiencyIncrease)); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) {} + + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipeMulti(); + } + } else { + // Logger.MACHINE_INFO("8"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aTick % 100 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified()) { + Logger.MACHINE_INFO("9"); + // turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + Logger.MACHINE_INFO("10"); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("11"); + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + Logger.MACHINE_INFO("12"); + mMaxProgresstime = 0; + // turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + // turnCasingActive(false); + Logger.MACHINE_INFO("Bad"); + this.mLastRecipe = null; + stopMachine(); + } + } + Logger.MACHINE_INFO("Good | " + mMaxProgresstime); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean onRunningTickMulti() { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a1"); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a2"); + return false; + } + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack copiedFluidStack = aLiquid.copy(); + this.mOutputFluid = copiedFluidStack; + return false; + } + + public void stopMachine() { + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + @Override + public boolean isLiquidInput(byte aSide) { + switch (aSide) { + case 0: + return true; + case 1: + return true; + case 2: + return true; + case 3: + return false; + case 4: + return false; + case 5: + return false; + default: + return false; + } + } + + @Override + public boolean isLiquidOutput(byte aSide) { + switch (aSide) { + case 0: + return false; + case 1: + return false; + case 2: + return false; + case 3: + return true; + case 4: + return true; + case 5: + return true; + default: + return true; + } + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public int getTankPressure() { + return 500; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return false; + } else { + return super.canFill(aSide, aFluid); + } + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.canDrain(aSide, aFluid); + } else { + return false; + } + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return 0; + } else { + return super.fill_default(aSide, aFluid, doFill); + } + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.fill(aSide, aFluid, doFill); + } else { + return 0; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, aFluid, doDrain); + } else { + return null; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, maxDrain, doDrain); + } else { + return null; + } + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + // TODO Auto-generated method stub + return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return false; + } + + @Override + public void onExplosion() { + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient( + (String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, aZ); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java index 6cae58ced2..08c9934db8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java @@ -1,13 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import java.util.ArrayList; -import java.util.Random; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; @@ -15,690 +7,722 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeMachine; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_PocketFusion extends GT_MetaTileEntity_DeluxeMachine { - private boolean mCanProcessRecipe = false; - private boolean mCharging = false; - private long mChargeConsumed = 0; - - private GT_Recipe mLastRecipe; - private long mEUStore; - private boolean mRunningOnLoad = false; - private boolean mMachine = false; - private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; - private int mStartUpCheck = 100, mUpdate = 0; - private FluidStack[] mOutputFluids = null; - - public GregtechMetaTileEntity_PocketFusion(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, 1, "PotionBrewer.png", ""); - } - - public GregtechMetaTileEntity_PocketFusion(String aName, int aTier, String aDescription, - ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "Not Very Fast, but not very big either.", - "Each side pair in/out puts to different slots.", "Top & Bottom Sides are Outputs.", - "Front & Back are Input Plasma 1.", "Sides are Input Plasma 2.", CORE.GT_Tooltip }; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_PocketFusion(this.mName, this.mTier, this.mDescription, - this.mTextures, this.mGUIName, this.mNEIName); - } - - public int tier() { - return this.mTier; - } - - public int tierOverclock() { - return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; - } - - private GT_RenderedTexture getCasingTexture() { - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex - + 1]; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return (aFluid.getFluid().getName().contains("plasma")) || (super.isFluidInputAllowed(aFluid)); - } - - @Override - public int getCapacity() { - return 32000; - } - - @Override - public void abortProcess() { - super.abortProcess(); - } - - long mFusionPoint = 20000000L; - - @Override - public int checkRecipe() { - Logger.MACHINE_INFO("Recipe Tick 1."); - if (!this.mCanProcessRecipe) { - Logger.MACHINE_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); - if (this.mChargeConsumed < mFusionPoint) { - Logger.MACHINE_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); - this.mCharging = true; - this.mCanProcessRecipe = false; - if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits((mFusionPoint / 100), false)) { - Logger.MACHINE_INFO("Recipe Tick 1.3 - Charging Internal storage. " + (mFusionPoint / 100) + "/" - + mFusionPoint); - mChargeConsumed += (mFusionPoint / 100); - } - } - else { - mChargeConsumed = 0; - this.mCharging = false; - this.mCanProcessRecipe = true; - - } - } - else { - Logger.MACHINE_INFO("Recipe Tick 1.1 - Try to Process Recipe."); - if (checkRecipeMulti()) { - Logger.MACHINE_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); - return 2; - } - } - Logger.MACHINE_INFO("Recipe Tick 2. - Process Recipe failed."); - return 0; - } - - public ArrayList getStoredFluids() { - ArrayList mList = new ArrayList(); - mList.add(this.mFluid); - mList.add(this.mFluid2); - return mList; - } - - public boolean checkRecipeMulti() { - ArrayList tFluidList = getStoredFluids(); - int tFluidList_sS = tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - tFluidList_sS = tFluidList.size(); - } - else { - tFluidList.remove(i--); - tFluidList_sS = tFluidList.size(); - break; - } - } - } - } - if (tFluidList.size() > 1) { - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); - GT_Recipe tRecipe = getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, - GT_Values.V[8], tFluids, new ItemStack[] {}); - - if (tRecipe == null) { - return false; - } - - if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && maxEUStore() < tRecipe.mSpecialValue)) { - this.mLastRecipe = null; - Logger.MACHINE_INFO("Just plain bad."); - return false; - } - if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { - this.mLastRecipe = tRecipe; - this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); - this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); - - this.mEfficiencyIncrease = 10000; - - this.mOutputFluids = this.mLastRecipe.mFluidOutputs; - mRunningOnLoad = false; - return true; - } - } - return false; - } - - public int overclock(int mStartEnergy) { - if (tierOverclock() == 1) { - return 1; - } - if (tierOverclock() == 2) { - return mStartEnergy < 160000000 ? 2 : 1; - } - return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean doesAutoOutputFluids() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public long maxAmperesIn() { - return 16L; - } - - @Override - public long maxEUStore() { - return Long.MAX_VALUE; - } - - @Override - public void doExplosion(long aExplosionPower) { - super.doExplosion(aExplosionPower * 2); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - onRunningTickMulti(); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) - && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) - && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - if (MathUtils.randInt(0, 4) == 4) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", - (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), - aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), - (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); - aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", - (aBaseMetaTileEntity.getXCoord() + 0.4F) - (tRandom.nextFloat() * 0.3F), - aBaseMetaTileEntity.getYCoord() + 0.2f + (tRandom.nextFloat() * 0.1F), - (aBaseMetaTileEntity.getZCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), 0.0D, 0.0D, 0.0D); - aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", - (aBaseMetaTileEntity.getXCoord() + 0.6F) - (tRandom.nextFloat() * 0.9F), - aBaseMetaTileEntity.getYCoord() + 0.4f + (tRandom.nextFloat() * 0.3F), - (aBaseMetaTileEntity.getZCoord() + 1.8F) - (tRandom.nextFloat() * 2.6F), 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); - aNBT.setBoolean("mCharging", this.mCharging); - aNBT.setLong("mChargeConsumed", this.mChargeConsumed); - aNBT.setInteger("mEfficiency", this.mEfficiency); - aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); - aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); - aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); - aNBT.setInteger("mUpdate", mUpdate); - aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); - aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); - aNBT.setBoolean("mMachine", this.mMachine); - aNBT.setLong("mEUStore", this.mEUStore); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (mMaxProgresstime > 0) - mRunningOnLoad = true; - this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); - this.mCharging = aNBT.getBoolean("mCharging"); - this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); - this.mEfficiency = aNBT.getInteger("mEfficiency"); - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); - this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); - this.mUpdate = aNBT.getInteger("mUpdate"); - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); - this.mMachine = aNBT.getBoolean("mMachine"); - this.mEUStore = aNBT.getLong("mEUStore"); - super.loadNBTData(aNBT); - } - - @Override - public String[] getInfoData() { - String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; - float plasmaOut = 0; - String fusionName = ""; - int powerRequired = 0; - if (this.mLastRecipe != null) { - fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName() + " Fusion."; - powerRequired = this.mLastRecipe.mEUt; - if (this.mLastRecipe.getFluidOutput(0) != null) { - plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; - } - } - - return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", - "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t", - "Current Recipe: " + fusionName }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) }; - } - - @Override - public void onMachineBlockUpdate() { - this.mUpdate = 50; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - // super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - // Logger.MACHINE_INFO("1"); - if (mEfficiency < 0) - mEfficiency = 0; - if (mRunningOnLoad) { - Logger.MACHINE_INFO("2"); - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - checkRecipeMulti(); - } - if (--mUpdate == 0 || --mStartUpCheck == 0) { - Logger.MACHINE_INFO("3"); - mMachine = true; - } - if (mStartUpCheck < 0) { - //Logger.MACHINE_INFO("4"); - if (mMachine) { - //Logger.MACHINE_INFO("5"); - - if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { - if (aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true)) { - //Logger.MACHINE_INFO("5.5 A"); - } - else { - //Logger.MACHINE_INFO("5.5 B"); - } - } - if (this.mEUStore <= 0 && mMaxProgresstime > 0) { - Logger.MACHINE_INFO("6"); - stopMachine(); - this.mLastRecipe = null; - } - if (mMaxProgresstime > 0) { - Logger.MACHINE_INFO("7"); - this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); - if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { - if (mOutputFluids != null) - for (FluidStack tStack : mOutputFluids) - if (tStack != null) - addOutput(tStack); - mEfficiency = Math.max(0, (mEfficiency + mEfficiencyIncrease)); - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - if (mOutputFluids != null && mOutputFluids.length > 0) { - - } - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - if (aBaseMetaTileEntity.isAllowedToWork()) - checkRecipeMulti(); - } - } - else { - //Logger.MACHINE_INFO("8"); - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() - || aBaseMetaTileEntity.hasInventoryBeenModified()) { - Logger.MACHINE_INFO("9"); - // turnCasingActive(mMaxProgresstime > 0); - if (aBaseMetaTileEntity.isAllowedToWork()) { - Logger.MACHINE_INFO("10"); - if (checkRecipeMulti()) { - Logger.MACHINE_INFO("11"); - if (this.mEUStore < this.mLastRecipe.mSpecialValue) { - Logger.MACHINE_INFO("12"); - mMaxProgresstime = 0; - // turnCasingActive(false); - } - aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); - } - } - if (mMaxProgresstime <= 0) - mEfficiency = Math.max(0, mEfficiency - 1000); - } - } - } - else { - // turnCasingActive(false); - Logger.MACHINE_INFO("Bad"); - this.mLastRecipe = null; - stopMachine(); - } - } - Logger.MACHINE_INFO("Good | "+mMaxProgresstime); - aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); - } - } - - public boolean onRunningTickMulti() { - if (this.getBaseMetaTileEntity().isServerSide()) { - if (mEUt < 0) { - if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { - this.mLastRecipe = null; - stopMachine(); - Logger.MACHINE_INFO("a1"); - return false; - } - } - if (this.mEUStore <= 0) { - this.mLastRecipe = null; - stopMachine(); - Logger.MACHINE_INFO("a2"); - return false; - } - } - return true; - } - - public boolean drainEnergyInput(long aEU) { - return false; - } - - public boolean addOutput(FluidStack aLiquid) { - if (aLiquid == null) - return false; - FluidStack copiedFluidStack = aLiquid.copy(); - this.mOutputFluid = copiedFluidStack; - return false; - } - - public void stopMachine() { - mEUt = 0; - mEfficiency = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - getBaseMetaTileEntity().disableWorking(); - } - - @Override - public boolean isLiquidInput(byte aSide) { - switch (aSide) { - case 0: - return true; - case 1: - return true; - case 2: - return true; - case 3: - return false; - case 4: - return false; - case 5: - return false; - default: - return false; - } - } - - @Override - public boolean isLiquidOutput(byte aSide) { - switch (aSide) { - case 0: - return false; - case 1: - return false; - case 2: - return false; - case 3: - return true; - case 4: - return true; - case 5: - return true; - default: - return true; - } - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - return super.fill(aFluid, doFill); - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return super.drain(maxDrain, doDrain); - } - - @Override - public int getTankPressure() { - return 500; - } - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return false; - } - else { - return super.canFill(aSide, aFluid); - } - } - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.canDrain(aSide, aFluid); - } - else { - return false; - } - } - - @Override - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return 0; - } - else { - return super.fill_default(aSide, aFluid, doFill); - } - } - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.fill(aSide, aFluid, doFill); - } - else { - return 0; - } - } - - @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.drain(aSide, aFluid, doDrain); - } - else { - return null; - } - } - - @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { - return super.drain(aSide, maxDrain, doDrain); - } - else { - return null; - } - } - - @Override - public boolean isOverclockerUpgradable() { - return true; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - // TODO Auto-generated method stub - return super.onRightclick(aBaseMetaTileEntity, aPlayer); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - // TODO Auto-generated method stub - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - // TODO Auto-generated method stub - return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - // TODO Auto-generated method stub - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return false; - } - - @Override - public void onExplosion() { - // TODO Auto-generated method stub - super.onExplosion(); - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, - aZ); - } - } - + private boolean mCanProcessRecipe = false; + private boolean mCharging = false; + private long mChargeConsumed = 0; + + private GT_Recipe mLastRecipe; + private long mEUStore; + private boolean mRunningOnLoad = false; + private boolean mMachine = false; + private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; + private int mStartUpCheck = 100, mUpdate = 0; + private FluidStack[] mOutputFluids = null; + + public GregtechMetaTileEntity_PocketFusion(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, 1, "PotionBrewer.png", ""); + } + + public GregtechMetaTileEntity_PocketFusion( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Not Very Fast, but not very big either.", + "Each side pair in/out puts to different slots.", + "Top & Bottom Sides are Outputs.", + "Front & Back are Input Plasma 1.", + "Sides are Input Plasma 2.", + CORE.GT_Tooltip + }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_PocketFusion( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public int tier() { + return this.mTier; + } + + public int tierOverclock() { + return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; + } + + private GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().contains("plasma")) || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public void abortProcess() { + super.abortProcess(); + } + + long mFusionPoint = 20000000L; + + @Override + public int checkRecipe() { + Logger.MACHINE_INFO("Recipe Tick 1."); + if (!this.mCanProcessRecipe) { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + if (this.mChargeConsumed < mFusionPoint) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + this.mCharging = true; + this.mCanProcessRecipe = false; + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits((mFusionPoint / 100), false)) { + Logger.MACHINE_INFO("Recipe Tick 1.3 - Charging Internal storage. " + (mFusionPoint / 100) + "/" + + mFusionPoint); + mChargeConsumed += (mFusionPoint / 100); + } + } else { + mChargeConsumed = 0; + this.mCharging = false; + this.mCanProcessRecipe = true; + } + } else { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Try to Process Recipe."); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + return 2; + } + } + Logger.MACHINE_INFO("Recipe Tick 2. - Process Recipe failed."); + return 0; + } + + public ArrayList getStoredFluids() { + ArrayList mList = new ArrayList(); + mList.add(this.mFluid); + mList.add(this.mFluid2); + return mList; + } + + public boolean checkRecipeMulti() { + ArrayList tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = getRecipeList() + .findRecipe( + this.getBaseMetaTileEntity(), + this.mLastRecipe, + false, + GT_Values.V[8], + tFluids, + new ItemStack[] {}); + + if (tRecipe == null) { + return false; + } + + if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && maxEUStore() < tRecipe.mSpecialValue)) { + this.mLastRecipe = null; + Logger.MACHINE_INFO("Just plain bad."); + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); + + this.mEfficiencyIncrease = 10000; + + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean doesAutoOutputFluids() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public long maxAmperesIn() { + return 16L; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower * 2); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + onRunningTickMulti(); + if ((aBaseMetaTileEntity.isClientSide()) + && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) + && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + if (MathUtils.randInt(0, 4) == 4) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), + 0.0D, + 0.0D, + 0.0D); + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.4F) - (tRandom.nextFloat() * 0.3F), + aBaseMetaTileEntity.getYCoord() + 0.2f + (tRandom.nextFloat() * 0.1F), + (aBaseMetaTileEntity.getZCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + 0.0D, + 0.0D, + 0.0D); + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.6F) - (tRandom.nextFloat() * 0.9F), + aBaseMetaTileEntity.getYCoord() + 0.4f + (tRandom.nextFloat() * 0.3F), + (aBaseMetaTileEntity.getZCoord() + 1.8F) - (tRandom.nextFloat() * 2.6F), + 0.0D, + 0.0D, + 0.0D); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); + aNBT.setBoolean("mCharging", this.mCharging); + aNBT.setLong("mChargeConsumed", this.mChargeConsumed); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); + aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); + aNBT.setInteger("mUpdate", mUpdate); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); + aNBT.setBoolean("mMachine", this.mMachine); + aNBT.setLong("mEUStore", this.mEUStore); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (mMaxProgresstime > 0) mRunningOnLoad = true; + this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); + this.mCharging = aNBT.getBoolean("mCharging"); + this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); + this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); + this.mUpdate = aNBT.getInteger("mUpdate"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); + this.mMachine = aNBT.getBoolean("mMachine"); + this.mEUStore = aNBT.getLong("mEUStore"); + super.loadNBTData(aNBT); + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + String fusionName = ""; + int powerRequired = 0; + if (this.mLastRecipe != null) { + fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName() + " Fusion."; + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { + "Fusion Reactor MK " + tier, + "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), + "Plasma Output: " + plasmaOut + "L/t", + "Current Recipe: " + fusionName + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] {this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW)}; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW)}; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) + }; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + // Logger.MACHINE_INFO("1"); + if (mEfficiency < 0) mEfficiency = 0; + if (mRunningOnLoad) { + Logger.MACHINE_INFO("2"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipeMulti(); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + Logger.MACHINE_INFO("3"); + mMachine = true; + } + if (mStartUpCheck < 0) { + // Logger.MACHINE_INFO("4"); + if (mMachine) { + // Logger.MACHINE_INFO("5"); + + if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { + if (aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true)) { + // Logger.MACHINE_INFO("5.5 A"); + } else { + // Logger.MACHINE_INFO("5.5 B"); + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + Logger.MACHINE_INFO("6"); + stopMachine(); + this.mLastRecipe = null; + } + if (mMaxProgresstime > 0) { + Logger.MACHINE_INFO("7"); + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); + mEfficiency = Math.max(0, (mEfficiency + mEfficiencyIncrease)); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) {} + + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipeMulti(); + } + } else { + // Logger.MACHINE_INFO("8"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aTick % 100 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified()) { + Logger.MACHINE_INFO("9"); + // turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + Logger.MACHINE_INFO("10"); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("11"); + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + Logger.MACHINE_INFO("12"); + mMaxProgresstime = 0; + // turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + // turnCasingActive(false); + Logger.MACHINE_INFO("Bad"); + this.mLastRecipe = null; + stopMachine(); + } + } + Logger.MACHINE_INFO("Good | " + mMaxProgresstime); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean onRunningTickMulti() { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a1"); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a2"); + return false; + } + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack copiedFluidStack = aLiquid.copy(); + this.mOutputFluid = copiedFluidStack; + return false; + } + + public void stopMachine() { + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + @Override + public boolean isLiquidInput(byte aSide) { + switch (aSide) { + case 0: + return true; + case 1: + return true; + case 2: + return true; + case 3: + return false; + case 4: + return false; + case 5: + return false; + default: + return false; + } + } + + @Override + public boolean isLiquidOutput(byte aSide) { + switch (aSide) { + case 0: + return false; + case 1: + return false; + case 2: + return false; + case 3: + return true; + case 4: + return true; + case 5: + return true; + default: + return true; + } + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public int getTankPressure() { + return 500; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return false; + } else { + return super.canFill(aSide, aFluid); + } + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.canDrain(aSide, aFluid); + } else { + return false; + } + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return 0; + } else { + return super.fill_default(aSide, aFluid, doFill); + } + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.fill(aSide, aFluid, doFill); + } else { + return 0; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, aFluid, doDrain); + } else { + return null; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, maxDrain, doDrain); + } else { + return null; + } + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + // TODO Auto-generated method stub + return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return false; + } + + @Override + public void onExplosion() { + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient( + (String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, aZ); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorColdTrap.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorColdTrap.java index f7acc3390d..f9ecc4be18 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorColdTrap.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorColdTrap.java @@ -14,59 +14,58 @@ import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_ReactorColdTrap extends GT_MetaTileEntity_BasicMachine { - public GregtechMetaTileEntity_ReactorColdTrap(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, - "Just like the Arctic", 2, 9, "Dehydrator.png", "", - new ITexture[]{ - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_SIDE_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_SIDE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_FRONT_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_FRONT), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP) - } - ); - } + public GregtechMetaTileEntity_ReactorColdTrap(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "Just like the Arctic", 2, 9, "Dehydrator.png", "", new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_SIDE_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_SIDE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_FRONT_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_FRONT), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP) + }); + } - public GregtechMetaTileEntity_ReactorColdTrap(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 2, 9, aGUIName, aNEIName); - } + public GregtechMetaTileEntity_ReactorColdTrap( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 2, 9, aGUIName, aNEIName); + } - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "Does not require ice cubes", CORE.GT_Tooltip}; - } + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Does not require ice cubes", CORE.GT_Tooltip}; + } - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_ReactorColdTrap(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); - } + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_ReactorColdTrap( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } - @Override - public boolean allowSelectCircuit() { - return true; - } + @Override + public boolean allowSelectCircuit() { + return true; + } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GTPP_Recipe.GTPP_Recipe_Map.sColdTrapRecipes; - } + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sColdTrapRecipes; + } - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); - } + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && (getRecipeList().containsInput(aStack)); + } - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return super.isFluidInputAllowed(aFluid); - } - - @Override - public int getCapacity() { - return 16000 * Math.max(1, this.mTier); - } + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return super.isFluidInputAllowed(aFluid); + } + @Override + public int getCapacity() { + return 16000 * Math.max(1, this.mTier); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorProcessingUnit.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorProcessingUnit.java index cfe86f37f5..8f8711a7fe 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorProcessingUnit.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorProcessingUnit.java @@ -14,59 +14,69 @@ import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_ReactorProcessingUnit extends GT_MetaTileEntity_BasicMachine { - public GregtechMetaTileEntity_ReactorProcessingUnit(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, - "Processes Nuclear things", 2, 9, "Dehydrator.png", "", - new ITexture[]{ - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_SIDE_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_SIDE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_FRONT_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_FRONT), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP) - } - ); - } + public GregtechMetaTileEntity_ReactorProcessingUnit(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "Processes Nuclear things", + 2, + 9, + "Dehydrator.png", + "", + new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_SIDE_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_SIDE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_FRONT_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_FRONT), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP) + }); + } - public GregtechMetaTileEntity_ReactorProcessingUnit(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 2, 9, aGUIName, aNEIName); - } + public GregtechMetaTileEntity_ReactorProcessingUnit( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 2, 9, aGUIName, aNEIName); + } - @Override - public String[] getDescription() { - return new String[]{this.mDescription, CORE.GT_Tooltip}; - } + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_ReactorProcessingUnit(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); - } + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_ReactorProcessingUnit( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } - @Override - public boolean allowSelectCircuit() { - return true; - } + @Override + public boolean allowSelectCircuit() { + return true; + } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GTPP_Recipe.GTPP_Recipe_Map.sReactorProcessingUnitRecipes; - } + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sReactorProcessingUnitRecipes; + } - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); - } + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && (getRecipeList().containsInput(aStack)); + } - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return super.isFluidInputAllowed(aFluid); - } - - @Override - public int getCapacity() { - return 8000 * Math.max(1, this.mTier); - } + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return super.isFluidInputAllowed(aFluid); + } + @Override + public int getCapacity() { + return 8000 * Math.max(1, this.mTier); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 13da9cd868..db74a46f1b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import java.util.*; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -17,6 +15,7 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; +import java.util.*; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -25,569 +24,683 @@ import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { - private boolean mHasBeenMapped = false; - private int mCurrentDimension = 0; - public int mMode = 0; - public boolean mLocked = true; - - public GregtechMetaWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaWirelessCharger(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {this.mDescription, - "Can be locked to the owner by sneaking with a screwdriver", - "Can also be locked with a lock upgrade", - "", - "3 Modes, Long-Range, Local and Mixed.", - "Long-Range: Can supply 2A of power to a single player up to "+(GT_Values.V[this.mTier]*4)+"m away.", - "Local: Can supply several Amps to each player within "+this.mTier*20+"m.", - "Mixed: Provides both 2A of long range and 1A per player locally.", - "Mixed mode is more conservative of power and as a result only", - "Gets half the distances each singular mode gets.", - CORE.GT_Tooltip - }; - } - - public int getTier(){ - return this.mTier; - } - - public int getMode(){ - return this.mMode; - } - - public int getDimensionID(){ - return this.mCurrentDimension; - } - - public Map getLocalMap(){ - return this.mLocalChargingMap; - } - - public Map getLongRangeMap(){ - return this.mWirelessChargingMap; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; - } - - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; - } - - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - - if (aPlayer.isSneaking()) { - mLocked = !mLocked; - PlayerUtils.messagePlayer(aPlayer, mLocked ? "Locked to owner." : "Unlocked."); - return; - } - - mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){ - for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities){ - if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ - EntityPlayer mTemp = (EntityPlayer) mTempPlayer; - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - - if (this.mMode >= 2){ - this.mMode = 0; - } - else { - this.mMode++; - } - if (this.mMode == 0){ - PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Charge Mode."); - } - else if (this.mMode == 1){ - PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Now in Mixed Charge Mode."); - } - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaWirelessCharger(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(final int aIndex) {return true;} - @Override public boolean isFacingValid(final byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return false;} - @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return 0;} - @Override public long maxEUStore() {return GT_Values.V[this.mTier]*128;} - - @Override - public int getCapacity() { - return (int) (GT_Values.V[this.mTier]*32); - } - - @Override - public long maxEUInput() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - if (this.mMode == 0){ - return 2; - } - else if (this.mMode == 1){ - return this.mLocalChargingMap.size()*8; - } - else { - return ((this.mLocalChargingMap.size()*4)+this.mWirelessChargingMap.size()); - } - } - - @Override - public long maxAmperesOut() { - return 0; - } - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return 0;} - @Override public int dechargerSlotCount() {return 0;} - @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} - @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - { - return true; - } - return true; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - return new String[] { - this.getLocalName()}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { - } - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setBoolean("mLocked", this.mLocked); - aNBT.setInteger("mMode", this.mMode); - aNBT.setInteger("mCurrentDimension", this.mCurrentDimension); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mLocked = aNBT.getBoolean("mLocked"); - this.mMode = aNBT.getInteger("mMode"); - this.mCurrentDimension = aNBT.getInteger("mCurrentDimension"); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - } - - private Map mWirelessChargingMap = new HashMap(); - private Map mLocalChargingMap = new HashMap(); - - private boolean isValidPlayer(EntityPlayer aPlayer) { - BaseMetaTileEntity aTile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); - if (mLocked || ( aTile != null && aTile.privateAccess())) { - if (aPlayer.getUniqueID().equals(getBaseMetaTileEntity().getOwnerUuid())){ - return true; - } - else { - return false; - } - } - return true; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.getBaseMetaTileEntity().isServerSide()) { - - if (this.mCurrentDimension != aBaseMetaTileEntity.getWorld().provider.dimensionId){ - this.mCurrentDimension = aBaseMetaTileEntity.getWorld().provider.dimensionId; - } - - if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ - mHasBeenMapped = true; - } - - if (aTick % 20 == 0 && mHasBeenMapped){ - if (!aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()){ - for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities){ - if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ - EntityPlayer mTemp = (EntityPlayer) mTempPlayer; - - if (this.mMode == 1 || this.mMode == 2){ - int tempRange = (this.mMode == 1 ? this.mTier*20 : this.mTier*10); - if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ - if (isValidPlayer(mTemp) && !mLocalChargingMap.containsKey(mTemp.getDisplayName())){ - mLocalChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); - ChargingHelper.addValidPlayer(mTemp, this); - //PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m - Local]."); - } - } - else { - if (mLocalChargingMap.containsKey(mTemp.getDisplayName())){ - if (mLocalChargingMap.remove(mTemp.getDisplayName()) != null){ - //PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m - Local]."); - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - } - if (this.mMode == 0 || this.mMode == 2){ - int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); - if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) <= tempRange){ - if (!mWirelessChargingMap.containsKey(mTemp.getDisplayName())){ - if (isValidPlayer(mTemp)) { - mWirelessChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); - ChargingHelper.addValidPlayer(mTemp, this); - PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m - Long-Range]."); - } - } - } - else { - if (mWirelessChargingMap.containsKey(mTemp.getDisplayName())){ - if (mWirelessChargingMap.remove(mTemp.getDisplayName()) != null){ - PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m - Long Range]."); - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - } - /*if (this.mMode == 0 || this.mMode == 2){ - int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); - if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ - if (!mWirelessChargingMap.containsKey(mTemp)){ - mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); - PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); - ChargingHelper.addValidPlayer(mTemp, this); - } - } - else { - if (mWirelessChargingMap.containsKey(mTemp)){ - if (mWirelessChargingMap.remove(mTemp) != null){ - PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - } */ - - } - } - } - } - - - } - } - - public BlockPos getTileEntityPosition(){ - return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld()); - } - - public BlockPos getPositionOfEntity(Entity mEntity){ - if (mEntity == null){ - return null; - } - return EntityUtils.findBlockPosUnderEntity(mEntity); - } - - public double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB){ - if (objectA == null || objectB == null){ - return 0f; - } - int[] objectArray1 = new int[]{objectA.xPos, objectA.yPos, objectA.zPos}; - int[] objectArray2 = new int[]{objectB.xPos, objectB.yPos, objectB.zPos}; - - final double distance = Math.sqrt( - (objectArray2[0]-objectArray1[0])*(objectArray2[0]-objectArray1[0]) - +(objectArray2[1]-objectArray1[1])*(objectArray2[1]-objectArray1[1]) - +(objectArray2[2]-objectArray1[2])*(objectArray2[2]-objectArray1[2])); - return distance; - } - - @Override - public void onRemoval() { - - ChargingHelper.removeEntry(getTileEntityPosition(), this); - - mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){ - for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities){ - if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ - EntityPlayer mTemp = (EntityPlayer) mTempPlayer; - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - - - super.onRemoval(); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, - EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - - int tempRange; - - if (this.mMode == 0 || this.mMode == 2){ - tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); - } - else { - tempRange = this.mMode == 1 ? this.mTier*20 : this.mTier*10; - } - - if (this.mMode == 2){ - PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: "+this.mTier*10+"m | Long: "+tempRange+"m"); - PlayerUtils.messagePlayer(aPlayer, "Players with access:"); - for (String name : this.getLocalMap().keySet()) { - PlayerUtils.messagePlayer(aPlayer, "Local: "+name); - } - for (String name : this.getLongRangeMap().keySet()) { - PlayerUtils.messagePlayer(aPlayer, "Long: "+name); - } - } - else if (this.mMode == 1){ - PlayerUtils.messagePlayer(aPlayer, "Local Mode: "+this.mTier*20+"m"); - PlayerUtils.messagePlayer(aPlayer, "Players with access:"); - for (String name : this.getLocalMap().keySet()) { - PlayerUtils.messagePlayer(aPlayer, ""+name); - } - - } - else { - PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); - PlayerUtils.messagePlayer(aPlayer, "Players with access:"); - for (String name : this.getLongRangeMap().keySet()) { - PlayerUtils.messagePlayer(aPlayer, ""+name); - } - } - - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - } - - @Override - public void onServerStart() { - mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - super.onServerStart(); - } - - @Override - public void onExplosion() { - ChargingHelper.removeEntry(getTileEntityPosition(), this); - super.onExplosion(); - } - - @Override - public void doExplosion(long aExplosionPower) { - ChargingHelper.removeEntry(getTileEntityPosition(), this); - super.doExplosion(aExplosionPower); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ - mHasBeenMapped = true; - } - } - super.onPreTick(aBaseMetaTileEntity, aTick); - } - -} \ No newline at end of file + private boolean mHasBeenMapped = false; + private int mCurrentDimension = 0; + public int mMode = 0; + public boolean mLocked = true; + + public GregtechMetaWirelessCharger( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaWirelessCharger( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Can be locked to the owner by sneaking with a screwdriver", + "Can also be locked with a lock upgrade", + "", + "3 Modes, Long-Range, Local and Mixed.", + "Long-Range: Can supply 2A of power to a single player up to " + (GT_Values.V[this.mTier] * 4) + "m away.", + "Local: Can supply several Amps to each player within " + this.mTier * 20 + "m.", + "Mixed: Provides both 2A of long range and 1A per player locally.", + "Mixed mode is more conservative of power and as a result only", + "Gets half the distances each singular mode gets.", + CORE.GT_Tooltip + }; + } + + public int getTier() { + return this.mTier; + } + + public int getMode() { + return this.mMode; + } + + public int getDimensionID() { + return this.mCurrentDimension; + } + + public Map getLocalMap() { + return this.mLocalChargingMap; + } + + public Map getLongRangeMap() { + return this.mWirelessChargingMap; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) + }; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + + if (aPlayer.isSneaking()) { + mLocked = !mLocked; + PlayerUtils.messagePlayer(aPlayer, mLocked ? "Locked to owner." : "Unlocked."); + return; + } + + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()) { + for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities) { + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + + if (this.mMode >= 2) { + this.mMode = 0; + } else { + this.mMode++; + } + if (this.mMode == 0) { + PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Charge Mode."); + } else if (this.mMode == 1) { + PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Now in Mixed Charge Mode."); + } + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaWirelessCharger( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return GT_Values.V[this.mTier] * 128; + } + + @Override + public int getCapacity() { + return (int) (GT_Values.V[this.mTier] * 32); + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + if (this.mMode == 0) { + return 2; + } else if (this.mMode == 1) { + return this.mLocalChargingMap.size() * 8; + } else { + return ((this.mLocalChargingMap.size() * 4) + this.mWirelessChargingMap.size()); + } + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + return true; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return new String[] {this.getLocalName()}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("mLocked", this.mLocked); + aNBT.setInteger("mMode", this.mMode); + aNBT.setInteger("mCurrentDimension", this.mCurrentDimension); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mLocked = aNBT.getBoolean("mLocked"); + this.mMode = aNBT.getInteger("mMode"); + this.mCurrentDimension = aNBT.getInteger("mCurrentDimension"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + private Map mWirelessChargingMap = new HashMap(); + private Map mLocalChargingMap = new HashMap(); + + private boolean isValidPlayer(EntityPlayer aPlayer) { + BaseMetaTileEntity aTile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); + if (mLocked || (aTile != null && aTile.privateAccess())) { + if (aPlayer.getUniqueID().equals(getBaseMetaTileEntity().getOwnerUuid())) { + return true; + } else { + return false; + } + } + return true; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + + if (this.mCurrentDimension != aBaseMetaTileEntity.getWorld().provider.dimensionId) { + this.mCurrentDimension = aBaseMetaTileEntity.getWorld().provider.dimensionId; + } + + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)) { + mHasBeenMapped = true; + } + + if (aTick % 20 == 0 && mHasBeenMapped) { + if (!aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()) { + for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities) { + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + + if (this.mMode == 1 || this.mMode == 2) { + int tempRange = (this.mMode == 1 ? this.mTier * 20 : this.mTier * 10); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) + < tempRange) { + if (isValidPlayer(mTemp) + && !mLocalChargingMap.containsKey(mTemp.getDisplayName())) { + mLocalChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); + ChargingHelper.addValidPlayer(mTemp, this); + // PlayerUtils.messagePlayer(mTemp, "You have entered charging range. + // ["+tempRange+"m - Local]."); + } + } else { + if (mLocalChargingMap.containsKey(mTemp.getDisplayName())) { + if (mLocalChargingMap.remove(mTemp.getDisplayName()) != null) { + // PlayerUtils.messagePlayer(mTemp, "You have left charging range. + // ["+tempRange+"m - Local]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + } + if (this.mMode == 0 || this.mMode == 2) { + int tempRange = (int) + (this.mMode == 0 ? 4 * GT_Values.V[this.mTier] : 2 * GT_Values.V[this.mTier]); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) + <= tempRange) { + if (!mWirelessChargingMap.containsKey(mTemp.getDisplayName())) { + if (isValidPlayer(mTemp)) { + mWirelessChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); + ChargingHelper.addValidPlayer(mTemp, this); + PlayerUtils.messagePlayer( + mTemp, + "You have entered charging range. [" + tempRange + + "m - Long-Range]."); + } + } + } else { + if (mWirelessChargingMap.containsKey(mTemp.getDisplayName())) { + if (mWirelessChargingMap.remove(mTemp.getDisplayName()) != null) { + PlayerUtils.messagePlayer( + mTemp, + "You have left charging range. [" + tempRange + "m - Long Range]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + } + /*if (this.mMode == 0 || this.mMode == 2){ + int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ + if (!mWirelessChargingMap.containsKey(mTemp)){ + mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + ChargingHelper.addValidPlayer(mTemp, this); + } + } + else { + if (mWirelessChargingMap.containsKey(mTemp)){ + if (mWirelessChargingMap.remove(mTemp) != null){ + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + } */ + + } + } + } + } + } + } + + public BlockPos getTileEntityPosition() { + return new BlockPos( + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getYCoord(), + this.getBaseMetaTileEntity().getZCoord(), + this.getBaseMetaTileEntity().getWorld()); + } + + public BlockPos getPositionOfEntity(Entity mEntity) { + if (mEntity == null) { + return null; + } + return EntityUtils.findBlockPosUnderEntity(mEntity); + } + + public double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB) { + if (objectA == null || objectB == null) { + return 0f; + } + int[] objectArray1 = new int[] {objectA.xPos, objectA.yPos, objectA.zPos}; + int[] objectArray2 = new int[] {objectB.xPos, objectB.yPos, objectB.zPos}; + + final double distance = Math.sqrt((objectArray2[0] - objectArray1[0]) * (objectArray2[0] - objectArray1[0]) + + (objectArray2[1] - objectArray1[1]) * (objectArray2[1] - objectArray1[1]) + + (objectArray2[2] - objectArray1[2]) * (objectArray2[2] - objectArray1[2])); + return distance; + } + + @Override + public void onRemoval() { + + ChargingHelper.removeEntry(getTileEntityPosition(), this); + + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()) { + for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities) { + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + + super.onRemoval(); + } + + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + + int tempRange; + + if (this.mMode == 0 || this.mMode == 2) { + tempRange = (int) (this.mMode == 0 ? 4 * GT_Values.V[this.mTier] : 2 * GT_Values.V[this.mTier]); + } else { + tempRange = this.mMode == 1 ? this.mTier * 20 : this.mTier * 10; + } + + if (this.mMode == 2) { + PlayerUtils.messagePlayer( + aPlayer, "Mixed Mode | Local: " + this.mTier * 10 + "m | Long: " + tempRange + "m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLocalMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, "Local: " + name); + } + for (String name : this.getLongRangeMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, "Long: " + name); + } + } else if (this.mMode == 1) { + PlayerUtils.messagePlayer(aPlayer, "Local Mode: " + this.mTier * 20 + "m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLocalMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, "" + name); + } + + } else { + PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: " + tempRange + "m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLongRangeMap().keySet()) { + PlayerUtils.messagePlayer(aPlayer, "" + name); + } + } + + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public void onServerStart() { + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + super.onServerStart(); + } + + @Override + public void onExplosion() { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.onExplosion(); + } + + @Override + public void doExplosion(long aExplosionPower) { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.doExplosion(aExplosionPower); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)) { + mHasBeenMapped = true; + } + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index 89b26eddc7..01cc1ab213 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -1,7 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -25,568 +29,594 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private long mVoltage; - private byte mTier; - private int mCasing; - - private ItemStack mSchematicCache;; - private ItemStack mInputCache; - private ItemStack mOutputCache; - private GT_Recipe mCachedRecipe; - - private IStructureDefinition STRUCTURE_DEFINITION = null; - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GMTE_AmazonPackager(mName); - } - - public GMTE_AmazonPackager(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GMTE_AmazonPackager(String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Packager"; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "Generic3By3"; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GMTE_AmazonPackager.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(TAE.getIndexFromPage(2, 9)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 9))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Amazon Warehouse") - .addInfo("This Multiblock is used for EXTREME packaging requirements") - .addInfo("Dust Schematics are inserted into the input busses") - .addInfo("If inserted into the controller, it is shared across all busses") - .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot") - .addInfo("500% faster than using single block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes 16 items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo("Supply Depot Casings", 10) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher("GT++"); - return tt; - } - - private final void initFields() { - mVoltage = getMaxInputVoltage(); - mTier = (byte) Math.max(1, GT_Utility.getTier(mVoltage)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(2, 9); - } - - - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; - } - - private static final FluidStack[] sNoFluids = new FluidStack[] {}; - - @Override - public boolean checkRecipe(ItemStack aStack) { - - //Just the best place to check this~ - initFields(); - - ArrayList tItems = getStoredInputs(); - if (this.getGUIItemStack() != null) { - tItems.add(this.getGUIItemStack()); - } - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - boolean state = checkRecipeGeneric(tItemInputs, sNoFluids, getMaxParallelRecipes(), 75, 500, 10000); - - - if (state) { - return true; - } - else { - tItems = getStoredInputs(); - AutoMap mCompleted = new AutoMap(); - AutoMap mSchematics = new AutoMap(); - for (ItemStack tInputItem : tItems) { - if (tInputItem != null) { - if (ItemList.Schematic_1by1.isStackEqual((Object) tInputItem) || ItemList.Schematic_2by2.isStackEqual((Object) tInputItem) || ItemList.Schematic_3by3.isStackEqual((Object) tInputItem)) { - mSchematics.put(new ItemStackData(tInputItem)); - } - } - } - if (mSchematics.size() > 0) { - for (ItemStackData g : mSchematics) { - for (ItemStack tInputItem : tItems) { - if (tInputItem != null) { - mCompleted.put(new ItemStackData(tInputItem)); - checkRecipe(tInputItem, g.getStack()); - } - } - } - } - - return mCompleted != null && mCompleted.size() > 0; - } - } - - public boolean checkRecipe(ItemStack inputStack, ItemStack schematicStack) { - if (GT_Utility.isStackValid((Object) inputStack) && GT_Utility.isStackValid((Object) schematicStack) - && GT_Utility.getContainerItem(inputStack, true) == null) { - ItemStack tOutputStack; - if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack)&& inputStack.stackSize >= 1) { - tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[]{inputStack}); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input = inputStack; - --input.stackSize; - this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); - //this.mMaxProgresstime = 16 / (1 << this.mTier - 1); - this.mMaxProgresstime = 2; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } else if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) - && inputStack.stackSize >= 4) { - tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[]{inputStack, - inputStack, null, inputStack, inputStack}); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input2 = inputStack; - input2.stackSize -= 4; - this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); - //this.mMaxProgresstime = 32 / (1 << this.mTier - 1); - this.mMaxProgresstime = 4; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } else if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) - && inputStack.stackSize >= 9) { - tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[]{inputStack, - inputStack, inputStack, inputStack, inputStack, - inputStack, inputStack, inputStack, inputStack}); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input3 = inputStack; - input3.stackSize -= 9; - this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); - //this.mMaxProgresstime = 64 / (1 << this.mTier - 1); - this.mMaxProgresstime = 6; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } - } - return false; - } - - private ItemStack getSchematic(ItemStack[] aInputs) { - for (ItemStack aStack : aInputs) { - if (ItemList.Schematic_Dust.isStackEqual(aStack) || ItemList.Schematic_1by1.isStackEqual(aStack) || ItemList.Schematic_2by2.isStackEqual(aStack) || ItemList.Schematic_3by3.isStackEqual(aStack)) { - return aStack; - } - } - return null; - } - - private ItemStack getRecipeInput(ItemStack[] aInputs) { - for (ItemStack aStack : aInputs) { - if (!ItemList.Schematic_Dust.isStackEqual(aStack) && !ItemList.Schematic_1by1.isStackEqual(aStack) && !ItemList.Schematic_2by2.isStackEqual(aStack) && !ItemList.Schematic_3by3.isStackEqual(aStack)) { - return aStack; - } - } - return null; - } - - private boolean hasValidCache(ItemStack aStack, ItemStack aSchematic, boolean aClearOnFailure) { - if (mSchematicCache != null && mInputCache != null && mOutputCache != null && mCachedRecipe != null) { - if (GT_Utility.areStacksEqual(aStack, mInputCache) && GT_Utility.areStacksEqual(aSchematic, mSchematicCache)) { - return true; - } - } - // clear cache if it was invalid - if (aClearOnFailure) { - mSchematicCache = null; - mInputCache = null; - mOutputCache = null; - mCachedRecipe = null; - } - return false; - } - - private void cacheItem(ItemStack aSchematic, ItemStack aInputItem, ItemStack aOutputItem, GT_Recipe aRecipe) { - mSchematicCache = aSchematic.copy(); - mInputCache = aInputItem.copy(); - mOutputCache = aOutputItem.copy(); - mCachedRecipe = aRecipe; - } - - private GT_Recipe generatePackageRecipe(ItemStack aSchematic, ItemStack aInput) { - boolean tIsCached = hasValidCache(aInput, aSchematic, true); - if (tIsCached) { - ItemStack tOutput = mOutputCache.copy(); - if (tOutput != null) { - if (mCachedRecipe != null && GT_Utility.areStacksEqual(aInput, mInputCache) && GT_Utility.areStacksEqual(tOutput, mOutputCache)) { - int aRequiredInputSize = 0; - if (ItemList.Schematic_Dust.isStackEqual(aSchematic)) { - if (OrePrefixes.dustTiny.contains(aInput)) { - aRequiredInputSize = 9; - } - if (OrePrefixes.dustSmall.contains(aInput)) { - aRequiredInputSize = 4; - } - if (OrePrefixes.dust.contains(aInput)) { - aRequiredInputSize = 1; - } - } - if (ItemList.Schematic_1by1.isStackEqual(aSchematic)) { - aRequiredInputSize = 1; - } - if (ItemList.Schematic_2by2.isStackEqual(aSchematic)) { - aRequiredInputSize = 4; - } - if (ItemList.Schematic_3by3.isStackEqual(aSchematic)) { - aRequiredInputSize = 9; - } - if (aInput.stackSize >= aRequiredInputSize) { - log("Using Cached Recipe. Require: "+aRequiredInputSize+", Found: "+aInput.stackSize); - return mCachedRecipe; - } - else { - log("Not enough input"); - } - } - } - } - // We can package this - GT_Recipe aRecipe = lookupRecipe(); - log("Looking up new recipe"); - if (aRecipe != null) { - // Cache it - aInput = aInput != null ? aInput : getRecipeInput(aRecipe.mInputs); - cacheItem(aSchematic, aInput, aRecipe.mOutputs[0], aRecipe); - if (hasValidCache(aInput, aSchematic, false)) { - log("Caching Recipe"); - return aRecipe; - } - } - return null; - } - - private GT_Recipe lookupRecipe() { - ArrayList aItems = getStoredInputs(); - if (this.getGUIItemStack() != null) { - aItems.add(this.getGUIItemStack()); - } - ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, false, - gregtech.api.enums.GT_Values.V[mTier], sNoFluids, aItemInputs); - - if (tRecipe != null) { - return tRecipe; - } - return null; - } - - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - ItemStack aInput = getRecipeInput(aItemInputs); - ItemStack aSchematic = getSchematic(aItemInputs); - GT_Recipe tRecipe = generatePackageRecipe(aSchematic, aInput); - - ItemStack[] aRealInputs = new ItemStack[] {aSchematic, aInput}; - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, sNoFluids, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - mCachedRecipe = null; - log("BAD RETURN - 3 - Reset Cached Recipe"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - if (this.hasPerfectOverclock()) this.mMaxProgresstime /= 4; - else this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } - - public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) { - //If Schematic Static is not 1x1, 2x2, 3x3 - if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) && !ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) && !ItemList.Schematic_3by3.isStackEqual((Object) schematicStack)) { - return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); - } - //Something - if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe((IHasWorldObjectAndCoords) this.getBaseMetaTileEntity(), true, GT_Values.V[this.mTier], - (FluidStack[]) null, new ItemStack[]{GT_Utility.copyAmount(64L, new Object[]{aStack}), schematicStack}) != null) { - return true; - } - //1x1 - if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) - && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack}) != null) { - return true; - } - //2x2 - if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) - && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack, aStack, null, aStack, aStack}) != null) { - return true; - } - //3x3 - if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) && GT_ModHandler.getRecipeOutput( - new ItemStack[]{aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack}) != null) { - return true; - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - public int getMaxEfficiency(ItemStack p0) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack arg0){ - return CORE.ConfigSwitches.pollutionPerSecondMultiPackager; - } - - @Override - public int getMaxParallelRecipes() { - return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } +public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private long mVoltage; + private byte mTier; + private int mCasing; + + private ItemStack mSchematicCache; + ; + private ItemStack mInputCache; + private ItemStack mOutputCache; + private GT_Recipe mCachedRecipe; + + private IStructureDefinition STRUCTURE_DEFINITION = null; + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GMTE_AmazonPackager(mName); + } + + public GMTE_AmazonPackager(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GMTE_AmazonPackager(String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Packager"; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GMTE_AmazonPackager.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(TAE.getIndexFromPage(2, 9)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 9)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Amazon Warehouse") + .addInfo("This Multiblock is used for EXTREME packaging requirements") + .addInfo("Dust Schematics are inserted into the input busses") + .addInfo("If inserted into the controller, it is shared across all busses") + .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot") + .addInfo("500% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes 16 items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Supply Depot Casings", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher("GT++"); + return tt; + } + + private final void initFields() { + mVoltage = getMaxInputVoltage(); + mTier = (byte) Math.max(1, GT_Utility.getTier(mVoltage)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(2, 9); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; + } + + private static final FluidStack[] sNoFluids = new FluidStack[] {}; + + @Override + public boolean checkRecipe(ItemStack aStack) { + + // Just the best place to check this~ + initFields(); + + ArrayList tItems = getStoredInputs(); + if (this.getGUIItemStack() != null) { + tItems.add(this.getGUIItemStack()); + } + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + boolean state = checkRecipeGeneric(tItemInputs, sNoFluids, getMaxParallelRecipes(), 75, 500, 10000); + + if (state) { + return true; + } else { + tItems = getStoredInputs(); + AutoMap mCompleted = new AutoMap(); + AutoMap mSchematics = new AutoMap(); + for (ItemStack tInputItem : tItems) { + if (tInputItem != null) { + if (ItemList.Schematic_1by1.isStackEqual((Object) tInputItem) + || ItemList.Schematic_2by2.isStackEqual((Object) tInputItem) + || ItemList.Schematic_3by3.isStackEqual((Object) tInputItem)) { + mSchematics.put(new ItemStackData(tInputItem)); + } + } + } + if (mSchematics.size() > 0) { + for (ItemStackData g : mSchematics) { + for (ItemStack tInputItem : tItems) { + if (tInputItem != null) { + mCompleted.put(new ItemStackData(tInputItem)); + checkRecipe(tInputItem, g.getStack()); + } + } + } + } + + return mCompleted != null && mCompleted.size() > 0; + } + } + + public boolean checkRecipe(ItemStack inputStack, ItemStack schematicStack) { + if (GT_Utility.isStackValid((Object) inputStack) + && GT_Utility.isStackValid((Object) schematicStack) + && GT_Utility.getContainerItem(inputStack, true) == null) { + ItemStack tOutputStack; + if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 1) { + tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[] {inputStack}); + if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { + final ItemStack input = inputStack; + --input.stackSize; + this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + // this.mMaxProgresstime = 16 / (1 << this.mTier - 1); + this.mMaxProgresstime = 2; + this.addOutput(tOutputStack); + updateSlots(); + return true; + } + return false; + } else if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 4) { + tOutputStack = GT_ModHandler.getRecipeOutput( + new ItemStack[] {inputStack, inputStack, null, inputStack, inputStack}); + if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { + final ItemStack input2 = inputStack; + input2.stackSize -= 4; + this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + // this.mMaxProgresstime = 32 / (1 << this.mTier - 1); + this.mMaxProgresstime = 4; + this.addOutput(tOutputStack); + updateSlots(); + return true; + } + return false; + } else if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 9) { + tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[] { + inputStack, + inputStack, + inputStack, + inputStack, + inputStack, + inputStack, + inputStack, + inputStack, + inputStack + }); + if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { + final ItemStack input3 = inputStack; + input3.stackSize -= 9; + this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + // this.mMaxProgresstime = 64 / (1 << this.mTier - 1); + this.mMaxProgresstime = 6; + this.addOutput(tOutputStack); + updateSlots(); + return true; + } + return false; + } + } + return false; + } + + private ItemStack getSchematic(ItemStack[] aInputs) { + for (ItemStack aStack : aInputs) { + if (ItemList.Schematic_Dust.isStackEqual(aStack) + || ItemList.Schematic_1by1.isStackEqual(aStack) + || ItemList.Schematic_2by2.isStackEqual(aStack) + || ItemList.Schematic_3by3.isStackEqual(aStack)) { + return aStack; + } + } + return null; + } + + private ItemStack getRecipeInput(ItemStack[] aInputs) { + for (ItemStack aStack : aInputs) { + if (!ItemList.Schematic_Dust.isStackEqual(aStack) + && !ItemList.Schematic_1by1.isStackEqual(aStack) + && !ItemList.Schematic_2by2.isStackEqual(aStack) + && !ItemList.Schematic_3by3.isStackEqual(aStack)) { + return aStack; + } + } + return null; + } + + private boolean hasValidCache(ItemStack aStack, ItemStack aSchematic, boolean aClearOnFailure) { + if (mSchematicCache != null && mInputCache != null && mOutputCache != null && mCachedRecipe != null) { + if (GT_Utility.areStacksEqual(aStack, mInputCache) + && GT_Utility.areStacksEqual(aSchematic, mSchematicCache)) { + return true; + } + } + // clear cache if it was invalid + if (aClearOnFailure) { + mSchematicCache = null; + mInputCache = null; + mOutputCache = null; + mCachedRecipe = null; + } + return false; + } + + private void cacheItem(ItemStack aSchematic, ItemStack aInputItem, ItemStack aOutputItem, GT_Recipe aRecipe) { + mSchematicCache = aSchematic.copy(); + mInputCache = aInputItem.copy(); + mOutputCache = aOutputItem.copy(); + mCachedRecipe = aRecipe; + } + + private GT_Recipe generatePackageRecipe(ItemStack aSchematic, ItemStack aInput) { + boolean tIsCached = hasValidCache(aInput, aSchematic, true); + if (tIsCached) { + ItemStack tOutput = mOutputCache.copy(); + if (tOutput != null) { + if (mCachedRecipe != null + && GT_Utility.areStacksEqual(aInput, mInputCache) + && GT_Utility.areStacksEqual(tOutput, mOutputCache)) { + int aRequiredInputSize = 0; + if (ItemList.Schematic_Dust.isStackEqual(aSchematic)) { + if (OrePrefixes.dustTiny.contains(aInput)) { + aRequiredInputSize = 9; + } + if (OrePrefixes.dustSmall.contains(aInput)) { + aRequiredInputSize = 4; + } + if (OrePrefixes.dust.contains(aInput)) { + aRequiredInputSize = 1; + } + } + if (ItemList.Schematic_1by1.isStackEqual(aSchematic)) { + aRequiredInputSize = 1; + } + if (ItemList.Schematic_2by2.isStackEqual(aSchematic)) { + aRequiredInputSize = 4; + } + if (ItemList.Schematic_3by3.isStackEqual(aSchematic)) { + aRequiredInputSize = 9; + } + if (aInput.stackSize >= aRequiredInputSize) { + log("Using Cached Recipe. Require: " + aRequiredInputSize + ", Found: " + aInput.stackSize); + return mCachedRecipe; + } else { + log("Not enough input"); + } + } + } + } + // We can package this + GT_Recipe aRecipe = lookupRecipe(); + log("Looking up new recipe"); + if (aRecipe != null) { + // Cache it + aInput = aInput != null ? aInput : getRecipeInput(aRecipe.mInputs); + cacheItem(aSchematic, aInput, aRecipe.mOutputs[0], aRecipe); + if (hasValidCache(aInput, aSchematic, false)) { + log("Caching Recipe"); + return aRecipe; + } + } + return null; + } + + private GT_Recipe lookupRecipe() { + ArrayList aItems = getStoredInputs(); + if (this.getGUIItemStack() != null) { + aItems.add(this.getGUIItemStack()); + } + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + false, + gregtech.api.enums.GT_Values.V[mTier], + sNoFluids, + aItemInputs); + + if (tRecipe != null) { + return tRecipe; + } + return null; + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + ItemStack aInput = getRecipeInput(aItemInputs); + ItemStack aSchematic = getSchematic(aItemInputs); + GT_Recipe tRecipe = generatePackageRecipe(aSchematic, aInput); + + ItemStack[] aRealInputs = new ItemStack[] {aSchematic, aInput}; + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, sNoFluids, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + mCachedRecipe = null; + log("BAD RETURN - 3 - Reset Cached Recipe"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + if (this.hasPerfectOverclock()) this.mMaxProgresstime /= 4; + else this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) { + // If Schematic Static is not 1x1, 2x2, 3x3 + if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) + && !ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) + && !ItemList.Schematic_3by3.isStackEqual((Object) schematicStack)) { + return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); + } + // Something + if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe( + (IHasWorldObjectAndCoords) this.getBaseMetaTileEntity(), + true, + GT_Values.V[this.mTier], + (FluidStack[]) null, + new ItemStack[] {GT_Utility.copyAmount(64L, new Object[] {aStack}), schematicStack}) + != null) { + return true; + } + // 1x1 + if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) + && GT_ModHandler.getRecipeOutput(new ItemStack[] {aStack}) != null) { + return true; + } + // 2x2 + if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) + && GT_ModHandler.getRecipeOutput(new ItemStack[] {aStack, aStack, null, aStack, aStack}) != null) { + return true; + } + // 3x3 + if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) + && GT_ModHandler.getRecipeOutput( + new ItemStack[] {aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack + }) + != null) { + return true; + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + public int getMaxEfficiency(ItemStack p0) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack arg0) { + return CORE.ConfigSwitches.pollutionPerSecondMultiPackager; + } + + @Override + public int getMaxParallelRecipes() { + return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java index 769499476c..8b8d12dbd5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java @@ -2,13 +2,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; import static gregtech.api.enums.GT_Values.W; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - import com.gtnewhorizon.structurelib.structure.IStructureDefinition; - import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; @@ -27,6 +21,10 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; @@ -39,467 +37,480 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMTE_TeslaTower extends GregtechMeta_MultiBlockBase { - private Block casingBlock; - private int casingMeta; - private int frameMeta; - private int casingTextureIndex; - - private ForgeDirection back; - - private int xLoc, yLoc, zLoc; - - protected int mRange; - - /** - * Machine Mode, - * {@value false} Attacks all entities, - * {@value true} Only attacks players. - */ - - protected volatile boolean mMode = false; - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMTE_TeslaTower(mName); - } - - public GregtechMTE_TeslaTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - initFields(); - } - - public GregtechMTE_TeslaTower(String aName) { - super(aName); - initFields(); - } - - @Override - public String getMachineType() { - return "Weaponized Lighting Rod"; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - /*@Override - public String[] getTooltip() { - String casings = getCasingBlockItem().get(0).getDisplayName(); - return new String[]{ - "Controller Block for the Tesla Defence Tower Mk3200", - "Enemies within "+this.mRange+"m are blasted with a high energy plasma.", - "This uses 5,000,000EU per blast.", - "Can screwdriver to toggle mode between Players and all Entities.", - "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", - "3x1x3 Base of " + casings, - "1x3x1 " + casings + " pillar (Center of base)", - "1x3x1 " + MaterialUtils.getMaterialName(getFrameMaterial()) + " Frame Boxes (Each pillar side and on top)", - "1x Maintenance Hatch (One of base casings)", - "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"}; - }*/ - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Tesla Defence Tower Mk3200") - .addInfo("Enemies within "+this.mRange+"m are blasted with a high energy plasma.") - .addInfo("This uses 5,000,000EU per blast.") - .addInfo("Can screwdriver to toggle mode between Players and all Entities.") - .addSeparator() - .beginStructureBlock(1, 7, 1, false) - .addController("Top Middle") - .addCasingInfo("Casing", 360) - .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) - .addInputBus("Any 4 dot hint (min 1)", 4) - .addInputHatch("Any 4 dot hint(min 1)", 4) - .addOutputHatch("Any 4 dot hint(min 1)", 4) - .addEnergyHatch("Any 4 dot hint(min 1)", 4) - .addMaintenanceHatch("Any 4 dot hint(min 1)", 4) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - private final void initFields() { - casingBlock = ModBlocks.blockCasings2Misc; - casingMeta = getCasingBlockItem().get(0).getItemDamage(); - casingTextureIndex = getCasingTextureIndex(); - mRange = 50; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mMode", this.mMode); - aNBT.setInteger("mRange", this.mRange); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mMode = aNBT.getBoolean("mMode"); - this.mRange = aNBT.getInteger("mRange"); - super.loadNBTData(aNBT); - } - - private boolean isEnergyEnough() { - if (this.getEUVar() >= 5000000){ - return true; - } - return false; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - - if (!isEnergyEnough()) { - this.mProgresstime = 0; - this.mMaxProgresstime = 20; - this.getBaseMetaTileEntity().setActive(false); - stopMachine(); - } - else { - this.mProgresstime = 1; - this.mMaxProgresstime = 100; - this.getBaseMetaTileEntity().setActive(true); - - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - updateCoordinates(); - //check base layer - for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { - for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { - if (xOff == 0 && zOff == 0) continue; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); - if (!checkCasingBlock(xOff, 0, zOff) - && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) - && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)){ - Logger.INFO("bad block"); - return false; - } - } - } - if(!checkHatches()){ - Logger.INFO("bad Hatches"); - return false; - } - if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()){ - Logger.INFO("bad Voltage"); - return false; - } - //check tower - for (int yOff = 1; yOff < 4; yOff++) { - if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) - || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)){ - Logger.INFO("bad frame?"); - return false; - } - } - Logger.INFO("good"); - return true; - } - - private void updateCoordinates() { - casingTextureIndex = getCasingTextureIndex(); - mRange = 50; - xLoc = getBaseMetaTileEntity().getXCoord(); - yLoc = getBaseMetaTileEntity().getYCoord(); - zLoc = getBaseMetaTileEntity().getZCoord(); - back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()); - } - - protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { - Logger.INFO("Looking For Casing."); - return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); - } - //meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation) - protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { - Logger.INFO("Looking For Frame."); - return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); - } - - protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { - return checkBlockAndMeta(xLoc + xOff, yLoc + yOff, zLoc + zOff, block, meta); - } - - private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) { - Logger.INFO("Found: "+getBaseMetaTileEntity().getBlock(x, y, z).getLocalizedName()+" | Meta: "+getBaseMetaTileEntity().getMetaID(x, y, z)); - Logger.INFO("Expected: "+block.getLocalizedName()+" | Meta: "+meta); - return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) - && getBaseMetaTileEntity().getBlock(x, y, z) == block; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - protected int getMinTier() { - return 7; - } - - protected boolean checkHatches() { - return !mMaintenanceHatches.isEmpty() && !mEnergyHatches.isEmpty(); - } - - private Map, Entity> mInRange = new HashMap, Entity>(); - - @SuppressWarnings("unchecked") - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - try { - if (this.getBaseMetaTileEntity().isServerSide()){ - if (this.mEnergyHatches.size() > 0) { - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches){ - if (isValidMetaTileEntity(tHatch)) { - long mHT = tHatch.getBaseMetaTileEntity().getInputVoltage(); - if (tHatch.getEUVar() >= mHT) { - for (int o=0;o<(tHatch.getEUVar()/mHT);o++){ - //1A - if (this.getEUVar()<(this.maxEUStore()-mHT)){ - tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); - this.setEUVar(this.getEUVar()+mHT); - } - //2A - if (this.getEUVar()<(this.maxEUStore()-mHT)){ - tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); - this.setEUVar(this.getEUVar()+mHT); - } - } - } - } - } - } - - if (aTick % 10 == 0){ - if (this.getEUVar() >= 5000000){ - //Logger.INFO("Can Zap."); - this.getBaseMetaTileEntity().enableWorking(); - this.getBaseMetaTileEntity().setActive(true); - if (this.mProgresstime <= 0){ - this.mProgresstime++; - } - else if (this.mProgresstime >= 100){ - this.mProgresstime = 0; - } - this.mMaxProgresstime = 10000; - } - //Logger.INFO("Allowed to be Working? "+this.getBaseMetaTileEntity().isAllowedToWork()); - //Logger.INFO("Working? "+this.getBaseMetaTileEntity().isActive()); - //Logger.INFO("Has Working just been enabled? "+this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()); - } - - - if (aTick % 20 == 0){ - List o = aBaseMetaTileEntity.getWorld().loadedEntityList; - //Clean up old entities first - if (this.mInRange.size() > 0){ - for (Entity j : this.mInRange.values()){ - if (((Entity) j).getDistance(this.xLoc, this.yLoc, this.zLoc) > this.mRange){ - mInRange.remove(new Pair(((Entity) j).getUniqueID().getMostSignificantBits(), ((Entity) j).getUniqueID().getLeastSignificantBits()), (Entity) j); - } - } - } - //Add new entities - if (o.size() > 0){ - for (Object r : o){ - if (r instanceof Entity){ - if (!((Entity) r).getUniqueID().equals(getOwner())){ - if (((Entity) r).isEntityAlive() || r instanceof EntityLiving){ - if (((Entity) r).getDistance(this.xLoc, this.yLoc, this.zLoc) <= this.mRange){ - if (r instanceof EntityItem){ - //Do nothing - } - else { - if (!this.mMode){ - mInRange.put(new Pair(((Entity) r).getUniqueID().getMostSignificantBits(), ((Entity) r).getUniqueID().getLeastSignificantBits()), (Entity) r); - } - else { - if (r instanceof EntityPlayer){ - mInRange.put(new Pair(((Entity) r).getUniqueID().getMostSignificantBits(), ((Entity) r).getUniqueID().getLeastSignificantBits()), (Entity) r); - } - } - } - } - } - } - } - } - } - } - } - } - catch (Throwable r){ - - } - super.onPreTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - try { - if (this.getBaseMetaTileEntity().isServerSide()){ - //Handle Progress Time - if (this.getEUVar() >= 0 && !this.getBaseMetaTileEntity().isAllowedToWork()){ - this.mProgresstime = 20; - this.mMaxProgresstime = 40; - } - else if (this.getEUVar() >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()){ - this.mProgresstime = 20; - this.mMaxProgresstime = 40; - } - - if (aTick % 10 == 0){ - if (this.mInRange.size() > 0){ - if (this.getEUVar() >= 5000000){ - - for (Entity f : mInRange.values()){ - if (f instanceof EntityLiving){ - int j1 = (int) f.posX; - int l1 = (int) f.posY; - int k1 = (int) f.posZ; - World world = aBaseMetaTileEntity.getWorld(); - - if (f.isEntityAlive() && !f.getUniqueID().equals(getOwner())){ - //if (world.canLightningStrikeAt(j1, l1+1, k1)){ - //if (isEnergyEnough() && world.addWeatherEffect(new EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1))){ - if (isEnergyEnough() && world.addWeatherEffect(new EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1, f, getOwner()))){ - if (f == null || f.isDead || !f.isEntityAlive()){ - this.mInRange.remove(new Pair(f.getUniqueID().getMostSignificantBits(), f.getUniqueID().getLeastSignificantBits())); - } - this.setEUVar(this.getEUVar()-5000000); - } - //} - } - - } - } - } - } - } - } - } - catch (Throwable r){ - - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - - protected GregtechItemList getCasingBlockItem() { - return GregtechItemList.Casing_TeslaTower; - } - - protected int getCasingTextureIndex() { - return TAE.GTPP_INDEX(30); - } - - public UUID getOwner(){ - return PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public long maxAmperesIn() { - return 32; - } - - @Override - public long maxEUInput() { - return 131072; - } - - @Override - public long maxEUStore() { - return Integer.MAX_VALUE; - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mMode = Utils.invertBoolean(mMode); - this.mInRange.clear(); - if (mMode){ - PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Now only targetting players."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Targetting all types of entities."); - } - } - - @Override - public int getMaxParallelRecipes() { - return 0; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - // TODO Auto-generated method stub - - } - - @Override - public IStructureDefinition getStructureDefinition() { - // TODO Auto-generated method stub - return null; - } - - + private Block casingBlock; + private int casingMeta; + private int frameMeta; + private int casingTextureIndex; + + private ForgeDirection back; + + private int xLoc, yLoc, zLoc; + + protected int mRange; + + /** + * Machine Mode, + * {@value false} Attacks all entities, + * {@value true} Only attacks players. + */ + protected volatile boolean mMode = false; + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTE_TeslaTower(mName); + } + + public GregtechMTE_TeslaTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + initFields(); + } + + public GregtechMTE_TeslaTower(String aName) { + super(aName); + initFields(); + } + + @Override + public String getMachineType() { + return "Weaponized Lighting Rod"; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + /*@Override + public String[] getTooltip() { + String casings = getCasingBlockItem().get(0).getDisplayName(); + return new String[]{ + "Controller Block for the Tesla Defence Tower Mk3200", + "Enemies within "+this.mRange+"m are blasted with a high energy plasma.", + "This uses 5,000,000EU per blast.", + "Can screwdriver to toggle mode between Players and all Entities.", + "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", + "3x1x3 Base of " + casings, + "1x3x1 " + casings + " pillar (Center of base)", + "1x3x1 " + MaterialUtils.getMaterialName(getFrameMaterial()) + " Frame Boxes (Each pillar side and on top)", + "1x Maintenance Hatch (One of base casings)", + "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"}; + }*/ + + @Override + protected final GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Tesla Defence Tower Mk3200") + .addInfo("Enemies within " + this.mRange + "m are blasted with a high energy plasma.") + .addInfo("This uses 5,000,000EU per blast.") + .addInfo("Can screwdriver to toggle mode between Players and all Entities.") + .addSeparator() + .beginStructureBlock(1, 7, 1, false) + .addController("Top Middle") + .addCasingInfo("Casing", 360) + .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) + .addInputBus("Any 4 dot hint (min 1)", 4) + .addInputHatch("Any 4 dot hint(min 1)", 4) + .addOutputHatch("Any 4 dot hint(min 1)", 4) + .addEnergyHatch("Any 4 dot hint(min 1)", 4) + .addMaintenanceHatch("Any 4 dot hint(min 1)", 4) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + private final void initFields() { + casingBlock = ModBlocks.blockCasings2Misc; + casingMeta = getCasingBlockItem().get(0).getItemDamage(); + casingTextureIndex = getCasingTextureIndex(); + mRange = 50; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureIndex(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mMode", this.mMode); + aNBT.setInteger("mRange", this.mRange); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mMode = aNBT.getBoolean("mMode"); + this.mRange = aNBT.getInteger("mRange"); + super.loadNBTData(aNBT); + } + + private boolean isEnergyEnough() { + if (this.getEUVar() >= 5000000) { + return true; + } + return false; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + + if (!isEnergyEnough()) { + this.mProgresstime = 0; + this.mMaxProgresstime = 20; + this.getBaseMetaTileEntity().setActive(false); + stopMachine(); + } else { + this.mProgresstime = 1; + this.mMaxProgresstime = 100; + this.getBaseMetaTileEntity().setActive(true); + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + updateCoordinates(); + // check base layer + for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { + for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { + if (xOff == 0 && zOff == 0) continue; + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); + if (!checkCasingBlock(xOff, 0, zOff) + && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) + && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)) { + Logger.INFO("bad block"); + return false; + } + } + } + if (!checkHatches()) { + Logger.INFO("bad Hatches"); + return false; + } + if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) { + Logger.INFO("bad Voltage"); + return false; + } + // check tower + for (int yOff = 1; yOff < 4; yOff++) { + if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) + || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) + || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)) { + Logger.INFO("bad frame?"); + return false; + } + } + Logger.INFO("good"); + return true; + } + + private void updateCoordinates() { + casingTextureIndex = getCasingTextureIndex(); + mRange = 50; + xLoc = getBaseMetaTileEntity().getXCoord(); + yLoc = getBaseMetaTileEntity().getYCoord(); + zLoc = getBaseMetaTileEntity().getZCoord(); + back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()); + } + + protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { + Logger.INFO("Looking For Casing."); + return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); + } + // meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight + // operation) + protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { + Logger.INFO("Looking For Frame."); + return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); + } + + protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { + return checkBlockAndMeta(xLoc + xOff, yLoc + yOff, zLoc + zOff, block, meta); + } + + private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) { + Logger.INFO("Found: " + getBaseMetaTileEntity().getBlock(x, y, z).getLocalizedName() + " | Meta: " + + getBaseMetaTileEntity().getMetaID(x, y, z)); + Logger.INFO("Expected: " + block.getLocalizedName() + " | Meta: " + meta); + return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) + && getBaseMetaTileEntity().getBlock(x, y, z) == block; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + protected int getMinTier() { + return 7; + } + + protected boolean checkHatches() { + return !mMaintenanceHatches.isEmpty() && !mEnergyHatches.isEmpty(); + } + + private Map, Entity> mInRange = new HashMap, Entity>(); + + @SuppressWarnings("unchecked") + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + try { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mEnergyHatches.size() > 0) { + for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + long mHT = tHatch.getBaseMetaTileEntity().getInputVoltage(); + if (tHatch.getEUVar() >= mHT) { + for (int o = 0; o < (tHatch.getEUVar() / mHT); o++) { + // 1A + if (this.getEUVar() < (this.maxEUStore() - mHT)) { + tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); + this.setEUVar(this.getEUVar() + mHT); + } + // 2A + if (this.getEUVar() < (this.maxEUStore() - mHT)) { + tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); + this.setEUVar(this.getEUVar() + mHT); + } + } + } + } + } + } + + if (aTick % 10 == 0) { + if (this.getEUVar() >= 5000000) { + // Logger.INFO("Can Zap."); + this.getBaseMetaTileEntity().enableWorking(); + this.getBaseMetaTileEntity().setActive(true); + if (this.mProgresstime <= 0) { + this.mProgresstime++; + } else if (this.mProgresstime >= 100) { + this.mProgresstime = 0; + } + this.mMaxProgresstime = 10000; + } + // Logger.INFO("Allowed to be Working? "+this.getBaseMetaTileEntity().isAllowedToWork()); + // Logger.INFO("Working? "+this.getBaseMetaTileEntity().isActive()); + // Logger.INFO("Has Working just been enabled? + // "+this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()); + } + + if (aTick % 20 == 0) { + List o = aBaseMetaTileEntity.getWorld().loadedEntityList; + // Clean up old entities first + if (this.mInRange.size() > 0) { + for (Entity j : this.mInRange.values()) { + if (((Entity) j).getDistance(this.xLoc, this.yLoc, this.zLoc) > this.mRange) { + mInRange.remove( + new Pair( + ((Entity) j).getUniqueID().getMostSignificantBits(), + ((Entity) j).getUniqueID().getLeastSignificantBits()), + (Entity) j); + } + } + } + // Add new entities + if (o.size() > 0) { + for (Object r : o) { + if (r instanceof Entity) { + if (!((Entity) r).getUniqueID().equals(getOwner())) { + if (((Entity) r).isEntityAlive() || r instanceof EntityLiving) { + if (((Entity) r).getDistance(this.xLoc, this.yLoc, this.zLoc) <= this.mRange) { + if (r instanceof EntityItem) { + // Do nothing + } else { + if (!this.mMode) { + mInRange.put( + new Pair( + ((Entity) r) + .getUniqueID() + .getMostSignificantBits(), + ((Entity) r) + .getUniqueID() + .getLeastSignificantBits()), + (Entity) r); + } else { + if (r instanceof EntityPlayer) { + mInRange.put( + new Pair( + ((Entity) r) + .getUniqueID() + .getMostSignificantBits(), + ((Entity) r) + .getUniqueID() + .getLeastSignificantBits()), + (Entity) r); + } + } + } + } + } + } + } + } + } + } + } + } catch (Throwable r) { + + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + try { + if (this.getBaseMetaTileEntity().isServerSide()) { + // Handle Progress Time + if (this.getEUVar() >= 0 && !this.getBaseMetaTileEntity().isAllowedToWork()) { + this.mProgresstime = 20; + this.mMaxProgresstime = 40; + } else if (this.getEUVar() >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()) { + this.mProgresstime = 20; + this.mMaxProgresstime = 40; + } + + if (aTick % 10 == 0) { + if (this.mInRange.size() > 0) { + if (this.getEUVar() >= 5000000) { + + for (Entity f : mInRange.values()) { + if (f instanceof EntityLiving) { + int j1 = (int) f.posX; + int l1 = (int) f.posY; + int k1 = (int) f.posZ; + World world = aBaseMetaTileEntity.getWorld(); + + if (f.isEntityAlive() && !f.getUniqueID().equals(getOwner())) { + // if (world.canLightningStrikeAt(j1, l1+1, k1)){ + // if (isEnergyEnough() && world.addWeatherEffect(new + // EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1))){ + if (isEnergyEnough() + && world.addWeatherEffect(new EntityTeslaTowerLightning( + world, (double) j1, (double) l1, (double) k1, f, getOwner()))) { + if (f == null || f.isDead || !f.isEntityAlive()) { + this.mInRange.remove(new Pair( + f.getUniqueID().getMostSignificantBits(), + f.getUniqueID().getLeastSignificantBits())); + } + this.setEUVar(this.getEUVar() - 5000000); + } + // } + } + } + } + } + } + } + } + } catch (Throwable r) { + + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + protected GregtechItemList getCasingBlockItem() { + return GregtechItemList.Casing_TeslaTower; + } + + protected int getCasingTextureIndex() { + return TAE.GTPP_INDEX(30); + } + + public UUID getOwner() { + return PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public long maxAmperesIn() { + return 32; + } + + @Override + public long maxEUInput() { + return 131072; + } + + @Override + public long maxEUStore() { + return Integer.MAX_VALUE; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mMode = Utils.invertBoolean(mMode); + this.mInRange.clear(); + if (mMode) { + PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Now only targetting players."); + } else { + PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Targetting all types of entities."); + } + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + // TODO Auto-generated method stub + + } + + @Override + public IStructureDefinition getStructureDefinition() { + // TODO Auto-generated method stub + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java index 7013986b81..337bf1fd3c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java @@ -1,7 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -22,373 +27,375 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofCoil; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_IndustrialAlloySmelter extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - private HeatingCoilLevel mHeatingCapacity; - private int mLevel = 0; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialAlloySmelter(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); - } - - public GregtechMetaTileEntity_IndustrialAlloySmelter(String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialAlloySmelter(this.mName); - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiFurnace.png"); - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sAlloySmelterRecipes; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialAlloySmelter; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Alloy Smelter"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Alloy Smelter") - .addInfo("Gains one parallel per voltage tier") - .addInfo("Gains one multiplier per coil tier") - .addInfo("Parallel = Tier * Coil Tier") - .addInfo("Gains 5% speed bonus per coil tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 5, 3, true) - .addController("Bottom center") - .addCasingInfo("Inconel Reinforced Casings", 10) - .addCasingInfo("Integral Encasement V", 8) - .addCasingInfo("Heating Coils", 16) - .addInputBus("Any Inconel Reinforced Casing", 1) - .addOutputBus("Any Inconel Reinforced Casing", 1) - .addEnergyHatch("Any Inconel Reinforced Casing", 1) - .addMaintenanceHatch("Any Inconel Reinforced Casing", 1) - .addMufflerHatch("Any Inconel Reinforced Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"HHH", "H-H", "HHH"}, - {"VVV", "V-V", "VVV"}, - {"HHH", "H-H", "HHH"}, - {"C~C", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialAlloySmelter.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1))) - ) - .addElement( - 'H', - ofCoil( - GregtechMetaTileEntity_IndustrialAlloySmelter::setCoilLevel, GregtechMetaTileEntity_IndustrialAlloySmelter::getCoilLevel - ) - ) - .addElement( - 'V', - ofBlock( - ModBlocks.blockCasingsTieredGTPP, 4 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mLevel = 0; - setCoilLevel(HeatingCoilLevel.None); - return checkPiece(mName, 1, 4, 0) && mCasing >= 10 && getCoilLevel() != HeatingCoilLevel.None && (mLevel = getCoilLevel().getTier() + 1) > 0 && checkHatch(); - } - - @Override - public int getMaxParallelRecipes() { - return (this.mLevel * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - - @Override - public boolean checkRecipe(ItemStack aStack) { - FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tInputs = new ArrayList<>(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - if (tInputs.size() > 1) { - ItemStack[] tItems = tInputs.toArray(new ItemStack[0]); - if (checkRecipeGeneric(tItems, tFluids, getMaxParallelRecipes(), 100, 5 * this.mLevel, 10000)) { - return true; - } - } - } - return false; - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - Logger.WARNING("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = this.getRecipeMap().findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - Logger.WARNING("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - Logger.WARNING("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - int tHeatCapacityDivTiers = (int) mHeatingCapacity.getHeat() / 900; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - // Count recipes to do in parallel, consuming input items and fluids and - // considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - Logger.WARNING("Broke at " + parallelRecipes + "."); - break; - } - Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = mLevel * 5; - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); - int rInt = 2; - - this.mEUt = (int) Math.max(Math.ceil(tTotalEUt), 1); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= (tHeatCapacityDivTiers >= rInt ? 4 : 2); - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) - tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - Logger.WARNING("GOOD RETURN - 1"); - return true; - - } - - public HeatingCoilLevel getCoilLevel() { - return mHeatingCapacity; - } - - public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - mHeatingCapacity = aCoilLevel; - } +public class GregtechMetaTileEntity_IndustrialAlloySmelter + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + private HeatingCoilLevel mHeatingCapacity; + private int mLevel = 0; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialAlloySmelter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); + } + + public GregtechMetaTileEntity_IndustrialAlloySmelter(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialAlloySmelter(this.mName); + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiFurnace.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sAlloySmelterRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialAlloySmelter; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Alloy Smelter"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Alloy Smelter") + .addInfo("Gains one parallel per voltage tier") + .addInfo("Gains one multiplier per coil tier") + .addInfo("Parallel = Tier * Coil Tier") + .addInfo("Gains 5% speed bonus per coil tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 5, 3, true) + .addController("Bottom center") + .addCasingInfo("Inconel Reinforced Casings", 10) + .addCasingInfo("Integral Encasement V", 8) + .addCasingInfo("Heating Coils", 16) + .addInputBus("Any Inconel Reinforced Casing", 1) + .addOutputBus("Any Inconel Reinforced Casing", 1) + .addEnergyHatch("Any Inconel Reinforced Casing", 1) + .addMaintenanceHatch("Any Inconel Reinforced Casing", 1) + .addMufflerHatch("Any Inconel Reinforced Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"VVV", "V-V", "VVV"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialAlloySmelter.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1)))) + .addElement( + 'H', + ofCoil( + GregtechMetaTileEntity_IndustrialAlloySmelter::setCoilLevel, + GregtechMetaTileEntity_IndustrialAlloySmelter::getCoilLevel)) + .addElement('V', ofBlock(ModBlocks.blockCasingsTieredGTPP, 4)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mLevel = 0; + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 4, 0) + && mCasing >= 10 + && getCoilLevel() != HeatingCoilLevel.None + && (mLevel = getCoilLevel().getTier() + 1) > 0 + && checkHatch(); + } + + @Override + public int getMaxParallelRecipes() { + return (this.mLevel * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tInputs = new ArrayList<>(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { + tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + if (tInputs.size() > 1) { + ItemStack[] tItems = tInputs.toArray(new ItemStack[0]); + if (checkRecipeGeneric(tItems, tFluids, getMaxParallelRecipes(), 100, 5 * this.mLevel, 10000)) { + return true; + } + } + } + return false; + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + Logger.WARNING("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = this.getRecipeMap() + .findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + Logger.WARNING("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + Logger.WARNING("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + int tHeatCapacityDivTiers = (int) mHeatingCapacity.getHeat() / 900; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // Count recipes to do in parallel, consuming input items and fluids and + // considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + Logger.WARNING("Broke at " + parallelRecipes + "."); + break; + } + Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = mLevel * 5; + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + int rInt = 2; + + this.mEUt = (int) Math.max(Math.ceil(tTotalEUt), 1); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= (tHeatCapacityDivTiers >= rInt ? 4 : 2); + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.WARNING("GOOD RETURN - 1"); + return true; + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java index 79025840ed..9cc6b7fedd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java @@ -1,5 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -25,280 +30,287 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialArcFurnace extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - //862 - private static final int mCasingTextureID = TAE.getIndexFromPage(3, 3); - public static String mCasingName = "Tempered Arc Furnace Casing"; - private boolean mPlasmaMode = false; - private int mSize = 0; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialArcFurnace(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialArcFurnace(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialArcFurnace(this.mName); - } - - @Override - public String getMachineType() { - return "(Plasma/Electric) Arc Furnace"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for Industrial Arc Furnace") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Processes 8 items per voltage tier * W/L") - .addInfo("Max Size required to process Plasma recipes") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addController("Top center") - .addStructureInfo("Size: nx3xn [WxHxL] (Hollow)") - .addStructureInfo("n can be 3, 5 or 7") - .addCasingInfo(mCasingName, 10) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName + "3", new String[][]{ - {"CCC", "C~C", "CCC"}, - {"CCC", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - }) - .addShape(mName + "5", new String[][]{ - {"CCCCC", "CCCCC", "CC~CC", "CCCCC", "CCCCC"}, - {"CCCCC", "C---C", "C---C", "C---C", "CCCCC"}, - {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, - }) - .addShape(mName + "7", new String[][]{ - {"CCCCCCC", "CCCCCCC", "CCCCCCC", "CCC~CCC", "CCCCCCC", "CCCCCCC", "CCCCCCC"}, - {"CCCCCCC", "C-----C", "C-----C", "C-----C", "C-----C", "C-----C", "CCCCCCC"}, - {"CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC"}, - }) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialArcFurnace.class) - .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 3))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - public void clearHatches() { - mOutputHatches.clear(); - mInputHatches.clear(); - mOutputBusses.clear(); - mInputBusses.clear(); - mEnergyHatches.clear(); - mMaintenanceHatches.clear(); - mMufflerHatches.clear(); - } - - private int getSizeFromHint(ItemStack stackSize) { - switch (stackSize.stackSize) { - case 1: return 3; - case 2: return 5; - default: return 7; - } - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - int size = getSizeFromHint(stackSize); - buildPiece(mName + size, stackSize, hintsOnly, (size - 1) / 2, (size - 1) / 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - int size = getSizeFromHint(stackSize); - return survivialBuildPiece(mName + size, stackSize, (size - 1) / 2, (size - 1) / 2, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mSize = 0; - if (checkPiece(mName + "3", 1, 1, 0)) { - mSize = 3; - return mCasing >= 10 && checkHatch(); - } - mCasing = 0; - clearHatches(); - if (checkPiece(mName + "5", 2, 2, 0)) { - mSize = 5; - return mCasing >= 10 && checkHatch(); - } - mCasing = 0; - clearHatches(); - if (checkPiece(mName + "7", 3, 3, 0)) { - mSize = 7; - return mCasing >= 10 && checkHatch(); - } - return false; - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(207)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return mCasingTextureID; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialExtruder"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return mPlasmaMode ? GT_Recipe.GT_Recipe_Map.sPlasmaArcFurnaceRecipes : GT_Recipe.GT_Recipe_Map.sArcFurnaceRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return this.checkRecipeGeneric(getMaxParallelRecipes(), 100, 250); - } - - @Override - public int getMaxParallelRecipes() { - return (this.mSize * 8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialArcFurnace; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings4Misc; - } - - - public byte getCasingMeta() { - return 3; - } - - public Block getCasingBlock2() { - return ModBlocks.blockCasings3Misc; - } - - - public byte getCasingMeta2() { - return 15; - } - - public byte getCasingTextureIndex() { - return (byte) mCasingTextureID; - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (this.mSize > 5) { - this.mPlasmaMode = Utils.invertBoolean(mPlasmaMode); - if (mPlasmaMode) { - PlayerUtils.messagePlayer(aPlayer, "["+EnumChatFormatting.RED+"MODE"+EnumChatFormatting.RESET+"] "+EnumChatFormatting.LIGHT_PURPLE+"Plasma"+EnumChatFormatting.RESET); - } - else { - PlayerUtils.messagePlayer(aPlayer, "["+EnumChatFormatting.RED+"MODE"+EnumChatFormatting.RESET+"] "+EnumChatFormatting.YELLOW+"Electric"+EnumChatFormatting.RESET); - } - } - else { - PlayerUtils.messagePlayer(aPlayer, "["+EnumChatFormatting.RED+"MODE"+EnumChatFormatting.RESET+"] "+EnumChatFormatting.GRAY+"Cannot change mode, structure not large enough."+EnumChatFormatting.RESET); - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mPlasmaMode", mPlasmaMode); - aNBT.setInteger("mSize", mSize); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mPlasmaMode = aNBT.getBoolean("mPlasmaMode"); - mSize = aNBT.getInteger("mSize"); - } - - @Override - public void onMachineBlockUpdate() { - mUpdate = 100; - } +public class GregtechMetaTileEntity_IndustrialArcFurnace + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + // 862 + private static final int mCasingTextureID = TAE.getIndexFromPage(3, 3); + public static String mCasingName = "Tempered Arc Furnace Casing"; + private boolean mPlasmaMode = false; + private int mSize = 0; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialArcFurnace(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialArcFurnace(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialArcFurnace(this.mName); + } + + @Override + public String getMachineType() { + return "(Plasma/Electric) Arc Furnace"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for Industrial Arc Furnace") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes 8 items per voltage tier * W/L") + .addInfo("Max Size required to process Plasma recipes") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addController("Top center") + .addStructureInfo("Size: nx3xn [WxHxL] (Hollow)") + .addStructureInfo("n can be 3, 5 or 7") + .addCasingInfo(mCasingName, 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName + "3", new String[][] { + {"CCC", "C~C", "CCC"}, + {"CCC", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + }) + .addShape(mName + "5", new String[][] { + {"CCCCC", "CCCCC", "CC~CC", "CCCCC", "CCCCC"}, + {"CCCCC", "C---C", "C---C", "C---C", "CCCCC"}, + {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + }) + .addShape(mName + "7", new String[][] { + {"CCCCCCC", "CCCCCCC", "CCCCCCC", "CCC~CCC", "CCCCCCC", "CCCCCCC", "CCCCCCC"}, + {"CCCCCCC", "C-----C", "C-----C", "C-----C", "C-----C", "C-----C", "CCCCCCC"}, + {"CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC"}, + }) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialArcFurnace.class) + .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 3)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public void clearHatches() { + mOutputHatches.clear(); + mInputHatches.clear(); + mOutputBusses.clear(); + mInputBusses.clear(); + mEnergyHatches.clear(); + mMaintenanceHatches.clear(); + mMufflerHatches.clear(); + } + + private int getSizeFromHint(ItemStack stackSize) { + switch (stackSize.stackSize) { + case 1: + return 3; + case 2: + return 5; + default: + return 7; + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + int size = getSizeFromHint(stackSize); + buildPiece(mName + size, stackSize, hintsOnly, (size - 1) / 2, (size - 1) / 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + int size = getSizeFromHint(stackSize); + return survivialBuildPiece( + mName + size, stackSize, (size - 1) / 2, (size - 1) / 2, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mSize = 0; + if (checkPiece(mName + "3", 1, 1, 0)) { + mSize = 3; + return mCasing >= 10 && checkHatch(); + } + mCasing = 0; + clearHatches(); + if (checkPiece(mName + "5", 2, 2, 0)) { + mSize = 5; + return mCasing >= 10 && checkHatch(); + } + mCasing = 0; + clearHatches(); + if (checkPiece(mName + "7", 3, 3, 0)) { + mSize = 7; + return mCasing >= 10 && checkHatch(); + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return mCasingTextureID; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialExtruder"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mPlasmaMode + ? GT_Recipe.GT_Recipe_Map.sPlasmaArcFurnaceRecipes + : GT_Recipe.GT_Recipe_Map.sArcFurnaceRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return this.checkRecipeGeneric(getMaxParallelRecipes(), 100, 250); + } + + @Override + public int getMaxParallelRecipes() { + return (this.mSize * 8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialArcFurnace; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + public byte getCasingMeta() { + return 3; + } + + public Block getCasingBlock2() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta2() { + return 15; + } + + public byte getCasingTextureIndex() { + return (byte) mCasingTextureID; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mSize > 5) { + this.mPlasmaMode = Utils.invertBoolean(mPlasmaMode); + if (mPlasmaMode) { + PlayerUtils.messagePlayer( + aPlayer, + "[" + EnumChatFormatting.RED + "MODE" + EnumChatFormatting.RESET + "] " + + EnumChatFormatting.LIGHT_PURPLE + "Plasma" + EnumChatFormatting.RESET); + } else { + PlayerUtils.messagePlayer( + aPlayer, + "[" + EnumChatFormatting.RED + "MODE" + EnumChatFormatting.RESET + "] " + + EnumChatFormatting.YELLOW + "Electric" + EnumChatFormatting.RESET); + } + } else { + PlayerUtils.messagePlayer( + aPlayer, + "[" + EnumChatFormatting.RED + "MODE" + EnumChatFormatting.RESET + "] " + EnumChatFormatting.GRAY + + "Cannot change mode, structure not large enough." + EnumChatFormatting.RESET); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mPlasmaMode", mPlasmaMode); + aNBT.setInteger("mSize", mSize); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mPlasmaMode = aNBT.getBoolean("mPlasmaMode"); + mSize = aNBT.getInteger("mSize"); + } + + @Override + public void onMachineBlockUpdate() { + mUpdate = 100; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java index fd8d895990..346c8804ab 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -1,5 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -24,219 +30,211 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private boolean mIsAnimated; - private static final CustomIcon frontFaceActive = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); - private static final CustomIcon frontFace = new CustomIcon("iconsets/LARGECENTRIFUGE5"); - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - //public static double recipesComplete = 0; - - public GregtechMetaTileEntity_IndustrialCentrifuge(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - mIsAnimated = true; - } - - public GregtechMetaTileEntity_IndustrialCentrifuge(final String aName) { - super(aName); - mIsAnimated = true; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); - } - - @Override - public String getMachineType() { - return "Centrifuge"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Centrifuge") - .addInfo("125% faster than using single block machines of the same voltage") - .addInfo("Disable animations with a screwdriver") - .addInfo("Only uses 90% of the EU/t normally required") - .addInfo("Processes six items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo("Centrifuge Casings", 10) - .addInputBus("Any Casing except front", 1) - .addOutputBus("Any Casing except front", 1) - .addInputHatch("Any Casing except front", 1) - .addOutputHatch("Any Casing except front", 1) - .addEnergyHatch("Any Casing except front", 1) - .addMaintenanceHatch("Any Casing except front", 1) - .addMufflerHatch("Any Casing except front", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialCentrifuge.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 0))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - if (usingAnimations()) { - return frontFaceActive; - } else { - return frontFace; - } - } - - @Override - protected IIconContainer getInactiveOverlay() { - return frontFace; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(0); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialCentrifuge"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(6* GT_Utility.getTier(this.getMaxInputVoltage()), 90, 125); - } - - @Override - public int getMaxParallelRecipes() { - return (6 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 90; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasingsMisc; - } - - public byte getCasingMeta() { - return 0; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(0); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCentrifuge; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - this.mIsAnimated = !mIsAnimated; - Logger.INFO("Is Centrifuge animated "+this.mIsAnimated); - if (this.mIsAnimated) { - PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture. "); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture. "); - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mIsAnimated", mIsAnimated); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (aNBT.hasKey("mIsAnimated")) { - mIsAnimated = aNBT.getBoolean("mIsAnimated"); - } - else { - mIsAnimated = true; - } - } - - public boolean usingAnimations() { - //Logger.INFO("Is animated? "+this.mIsAnimated); - return this.mIsAnimated; - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialCentrifuge + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private boolean mIsAnimated; + private static final CustomIcon frontFaceActive = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static final CustomIcon frontFace = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + // public static double recipesComplete = 0; + + public GregtechMetaTileEntity_IndustrialCentrifuge(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mIsAnimated = true; + } + + public GregtechMetaTileEntity_IndustrialCentrifuge(final String aName) { + super(aName); + mIsAnimated = true; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); + } + + @Override + public String getMachineType() { + return "Centrifuge"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Centrifuge") + .addInfo("125% faster than using single block machines of the same voltage") + .addInfo("Disable animations with a screwdriver") + .addInfo("Only uses 90% of the EU/t normally required") + .addInfo("Processes six items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Centrifuge Casings", 10) + .addInputBus("Any Casing except front", 1) + .addOutputBus("Any Casing except front", 1) + .addInputHatch("Any Casing except front", 1) + .addOutputHatch("Any Casing except front", 1) + .addEnergyHatch("Any Casing except front", 1) + .addMaintenanceHatch("Any Casing except front", 1) + .addMufflerHatch("Any Casing except front", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialCentrifuge.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 0)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + if (usingAnimations()) { + return frontFaceActive; + } else { + return frontFace; + } + } + + @Override + protected IIconContainer getInactiveOverlay() { + return frontFace; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(0); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialCentrifuge"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(6 * GT_Utility.getTier(this.getMaxInputVoltage()), 90, 125); + } + + @Override + public int getMaxParallelRecipes() { + return (6 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 90; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(0); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCentrifuge; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mIsAnimated = !mIsAnimated; + Logger.INFO("Is Centrifuge animated " + this.mIsAnimated); + if (this.mIsAnimated) { + PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture. "); + } else { + PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture. "); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mIsAnimated", mIsAnimated); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("mIsAnimated")) { + mIsAnimated = aNBT.getBoolean("mIsAnimated"); + } else { + mIsAnimated = true; + } + } + + public boolean usingAnimations() { + // Logger.INFO("Is animated? "+this.mIsAnimated); + return this.mIsAnimated; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index 8233437748..92fc3cb1c8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -1,7 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -19,6 +23,8 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -26,143 +32,137 @@ import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; import team.chisel.carving.Carving; +public class GregtechMetaTileEntity_IndustrialChisel + extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; private ItemStack mInputCache; private ItemStack mOutputCache; private GTPP_Recipe mCachedRecipe; - public GregtechMetaTileEntity_IndustrialChisel(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialChisel(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialChisel(this.mName); - } - - @Override - public String getMachineType() { - return "Chisel"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Auto Chisel") - .addInfo("Target block goes in GUI slot") - .addInfo("If no target provided, firdt chisel result is used") - .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 16") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo("Sturdy Printer Casing", 10) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialChisel.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(90) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 5))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return 90; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "ImplosionCompressor"; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - + public GregtechMetaTileEntity_IndustrialChisel(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialChisel(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialChisel(this.mName); + } + + @Override + public String getMachineType() { + return "Chisel"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Auto Chisel") + .addInfo("Target block goes in GUI slot") + .addInfo("If no target provided, firdt chisel result is used") + .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 16") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Sturdy Printer Casing", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialChisel.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(90) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 5)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return 90; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ImplosionCompressor"; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { - if (mInputCache != null && mOutputCache != null && mCachedRecipe != null) { - if (GT_Utility.areStacksEqual(aStack, mInputCache) && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { - return true; - } + if (mInputCache != null && mOutputCache != null && mCachedRecipe != null) { + if (GT_Utility.areStacksEqual(aStack, mInputCache) + && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { + return true; + } } // clear cache if it was invalid if (aClearOnFailure) { @@ -172,286 +172,284 @@ public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiB } return false; } - + private void cacheItem(ItemStack aInputItem, ItemStack aOutputItem, GTPP_Recipe aRecipe) { mInputCache = aInputItem.copy(); mOutputCache = aOutputItem.copy(); mCachedRecipe = aRecipe; } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { - List results = getItemsForChiseling(from); - for (ItemStack s : results) { - if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { - return true; - } - } - return false; - } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean hasChiselResults(ItemStack from) { - List results = getItemsForChiseling(from); - return results.size() > 0; - } - - private static List getItemsForChiseling(ItemStack aStack){ - return Carving.chisel.getItemsForChiseling(aStack); - } - - private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { - ItemStack tOutput = null; - if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { - tOutput = aTarget; - } - else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { - tOutput = null; - } - else { - tOutput = getItemsForChiseling(aInput).get(0); - } - return tOutput; - } - - private GTPP_Recipe generateChiselRecipe(ItemStack aInput, ItemStack aTarget) { + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { + List results = getItemsForChiseling(from); + for (ItemStack s : results) { + if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { + return true; + } + } + return false; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean hasChiselResults(ItemStack from) { + List results = getItemsForChiseling(from); + return results.size() > 0; + } + + private static List getItemsForChiseling(ItemStack aStack) { + return Carving.chisel.getItemsForChiseling(aStack); + } + + private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { + ItemStack tOutput = null; + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + } else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { + tOutput = null; + } else { + tOutput = getItemsForChiseling(aInput).get(0); + } + return tOutput; + } + + private GTPP_Recipe generateChiselRecipe(ItemStack aInput, ItemStack aTarget) { boolean tIsCached = hasValidCache(aInput, aTarget, true); - if (tIsCached || aInput != null && hasChiselResults(aInput)) { - ItemStack tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); - if (tOutput != null) { - if (mCachedRecipe != null && GT_Utility.areStacksEqual(aInput, mInputCache) && GT_Utility.areStacksEqual(tOutput, mOutputCache)) { - return mCachedRecipe; - } - // We can chisel this - GTPP_Recipe aRecipe = new GTPP_Recipe( - false, - new ItemStack[] {ItemUtils.getSimpleStack(aInput, 1)}, - new ItemStack[] {ItemUtils.getSimpleStack(tOutput, 1)}, - null, - new int[] {10000}, - new FluidStack[] {}, - new FluidStack[] {}, - 20, - 16, - 0); - - // Cache it - cacheItem(aInput, tOutput, aRecipe); - return aRecipe; - } - } - return null; - } - - public boolean checkRecipe(final ItemStack aStack) { - ArrayList aItems = this.getStoredInputs(); - if (!aItems.isEmpty()) { - - GT_Recipe tRecipe = generateChiselRecipe(aItems.get(0), this.getGUIItemStack()); - - if (tRecipe == null) { - log("BAD RETURN - 0"); - return false; - } - - // Based on the Processing Array. A bit overkill, but very flexible. - ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); - FluidStack[] aFluidInputs = new FluidStack[] {}; - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - int aMaxParallelRecipes = getMaxParallelRecipes(); - int aEUPercent = getEuDiscountForParallelism(); - int aSpeedBonusPercent = 200; - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) <= tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } - - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 75; - } - - private static String sChiselSound = null; - - private static final String getChiselSound() { - if (sChiselSound == null) { - sChiselSound = Carving.chisel.getVariationSound(Blocks.stone, 0); - } - return sChiselSound; - } - - @Override - public String getSound() { - return getChiselSound(); - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialChisel; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - -} \ No newline at end of file + if (tIsCached || aInput != null && hasChiselResults(aInput)) { + ItemStack tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); + if (tOutput != null) { + if (mCachedRecipe != null + && GT_Utility.areStacksEqual(aInput, mInputCache) + && GT_Utility.areStacksEqual(tOutput, mOutputCache)) { + return mCachedRecipe; + } + // We can chisel this + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] {ItemUtils.getSimpleStack(aInput, 1)}, + new ItemStack[] {ItemUtils.getSimpleStack(tOutput, 1)}, + null, + new int[] {10000}, + new FluidStack[] {}, + new FluidStack[] {}, + 20, + 16, + 0); + + // Cache it + cacheItem(aInput, tOutput, aRecipe); + return aRecipe; + } + } + return null; + } + + public boolean checkRecipe(final ItemStack aStack) { + ArrayList aItems = this.getStoredInputs(); + if (!aItems.isEmpty()) { + + GT_Recipe tRecipe = generateChiselRecipe(aItems.get(0), this.getGUIItemStack()); + + if (tRecipe == null) { + log("BAD RETURN - 0"); + return false; + } + + // Based on the Processing Array. A bit overkill, but very flexible. + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); + FluidStack[] aFluidInputs = new FluidStack[] {}; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + int aMaxParallelRecipes = getMaxParallelRecipes(); + int aEUPercent = getEuDiscountForParallelism(); + int aSpeedBonusPercent = 200; + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) <= tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + private static String sChiselSound = null; + + private static final String getChiselSound() { + if (sChiselSound == null) { + sChiselSound = Carving.chisel.getVariationSound(Blocks.stone, 0); + } + return sChiselSound; + } + + @Override + public String getSound() { + return getChiselSound(); + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialChisel; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java index de9701283a..8e826a7fc4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -1,5 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -20,226 +27,194 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialCokeOven extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mLevel = 0; - private int mCasing; - private int mCasing1; - private int mCasing2; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialCokeOven(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); - } - - @Override - public String getMachineType() { - return "Coke Oven"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Processes Logs and Coal into Charcoal and Coal Coke.") - .addInfo("Controller Block for the Industrial Coke Oven") - .addInfo("Gain 4% energy discount per voltage tier") - .addInfo("Process 12x materials with Heat Resistant Casings") - .addInfo("Or 24x materials with Heat Proof Casings") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front middle at bottom") - .addCasingInfo("Structural Coke Oven Casings", 8) - .addCasingInfo("Heat Resistant/Proof Coke Oven Casings", 8) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"HHH", "H-H", "HHH"}, - {"C~C", "CCC", "CCC"}, - })) - .addShape(mName + "1", transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"aaa", "a-a", "aaa"}, - {"C~C", "CCC", "CCC"}, - })) - .addShape(mName + "2", transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"bbb", "b-b", "bbb"}, - {"C~C", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialCokeOven.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(1)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 1))) - ) - .addElement( - 'H', - ofChain( - onElementPass( - x -> ++x.mCasing1, - ofBlock( - ModBlocks.blockCasingsMisc, 2 - ) - ), - onElementPass( - x -> ++x.mCasing2, - ofBlock( - ModBlocks.blockCasingsMisc, 3 - ) - ) - ) - ) - .addElement( - 'a', - ofBlock( - ModBlocks.blockCasingsMisc, 2 - ) - ) - .addElement( - 'b', - ofBlock( - ModBlocks.blockCasingsMisc, 3 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - if (stackSize.stackSize == 1) - buildPiece(mName + "1" , stackSize, hintsOnly, 1, 2, 0); - else - buildPiece(mName + "2" , stackSize, hintsOnly, 1, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - if (stackSize.stackSize == 1) - return survivialBuildPiece(mName + "1", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); - else - return survivialBuildPiece(mName + "2", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mCasing1 = 0; - mCasing2 = 0; - mLevel = 0; - if (checkPiece(mName, 1, 2, 0)) { - if (mCasing1 == 8) mLevel = 1; - if (mCasing2 == 8) mLevel = 2; - return mLevel > 0 && mCasing >= 8 && checkHatch(); - } - return false; - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(207)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(1); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "CokeOven"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes; - - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); - } - - @Override - public int getMaxParallelRecipes() { - return this.mLevel * 12; - } - - @Override - public int getEuDiscountForParallelism() { - return (100-(GT_Utility.getTier(this.getMaxInputVoltage())*4)); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCokeOven; - } - - @Override - public int getAmountOfOutputs() { - return 24; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } +public class GregtechMetaTileEntity_IndustrialCokeOven + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mLevel = 0; + private int mCasing; + private int mCasing1; + private int mCasing2; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialCokeOven(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); + } + + @Override + public String getMachineType() { + return "Coke Oven"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Processes Logs and Coal into Charcoal and Coal Coke.") + .addInfo("Controller Block for the Industrial Coke Oven") + .addInfo("Gain 4% energy discount per voltage tier") + .addInfo("Process 12x materials with Heat Resistant Casings") + .addInfo("Or 24x materials with Heat Proof Casings") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front middle at bottom") + .addCasingInfo("Structural Coke Oven Casings", 8) + .addCasingInfo("Heat Resistant/Proof Coke Oven Casings", 8) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addShape(mName + "1", transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"aaa", "a-a", "aaa"}, + {"C~C", "CCC", "CCC"}, + })) + .addShape(mName + "2", transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"bbb", "b-b", "bbb"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialCokeOven.class) + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(1)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 1)))) + .addElement( + 'H', + ofChain( + onElementPass(x -> ++x.mCasing1, ofBlock(ModBlocks.blockCasingsMisc, 2)), + onElementPass(x -> ++x.mCasing2, ofBlock(ModBlocks.blockCasingsMisc, 3)))) + .addElement('a', ofBlock(ModBlocks.blockCasingsMisc, 2)) + .addElement('b', ofBlock(ModBlocks.blockCasingsMisc, 3)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + if (stackSize.stackSize == 1) buildPiece(mName + "1", stackSize, hintsOnly, 1, 2, 0); + else buildPiece(mName + "2", stackSize, hintsOnly, 1, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + if (stackSize.stackSize == 1) + return survivialBuildPiece(mName + "1", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); + else return survivialBuildPiece(mName + "2", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mCasing1 = 0; + mCasing2 = 0; + mLevel = 0; + if (checkPiece(mName, 1, 2, 0)) { + if (mCasing1 == 8) mLevel = 1; + if (mCasing2 == 8) mLevel = 2; + return mLevel > 0 && mCasing >= 8 && checkHatch(); + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(1); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "CokeOven"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + @Override + public int getMaxParallelRecipes() { + return this.mLevel * 12; + } + + @Override + public int getEuDiscountForParallelism() { + return (100 - (GT_Utility.getTier(this.getMaxInputVoltage()) * 4)); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCokeOven; + } + + @Override + public int getAmountOfOutputs() { + return 24; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java index 089b28a046..ac184e175b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -1,5 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -23,199 +29,192 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialCuttingMachine extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private boolean mCuttingMode = true; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialCuttingMachine(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialCuttingMachine(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCuttingMachine(this.mName); - } - - @Override - public String getMachineType() { - return "Cutting Machine / Slicing Machine"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Cutting Factory") - .addInfo("200% faster than using single block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes four items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 5, true) - .addController("Front Center") - .addCasingInfo("Cutting Factory Frames", 26) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC", "CCC", "CCC"}, - {"C~C", "C-C", "C-C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialCuttingMachine.class) - .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 13))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 26 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(29); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialCuttingMachine"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return mCuttingMode ? GT_Recipe.GT_Recipe_Map.sCutterRecipes : GT_Recipe.GT_Recipe_Map.sSlicerRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((4* GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCuttingMachine; - } - - @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - - public byte getCasingMeta() { - return 13; - } - - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(29); - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mCuttingMode = Utils.invertBoolean(mCuttingMode); - String aMode = mCuttingMode ? "Cutting" : "Slicing"; - PlayerUtils.messagePlayer(aPlayer, "Mode: "+aMode); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mCuttingMode", mCuttingMode); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (aNBT.hasKey("mCuttingMode")) { - mCuttingMode = aNBT.getBoolean("mCuttingMode"); - } - else { - mCuttingMode = true; - } - } -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialCuttingMachine + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private boolean mCuttingMode = true; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialCuttingMachine( + final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialCuttingMachine(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCuttingMachine(this.mName); + } + + @Override + public String getMachineType() { + return "Cutting Machine / Slicing Machine"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Cutting Factory") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfo("Cutting Factory Frames", 26) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + {"C~C", "C-C", "C-C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialCuttingMachine.class) + .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 13)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 26 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(29); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialCuttingMachine"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mCuttingMode ? GT_Recipe.GT_Recipe_Map.sCutterRecipes : GT_Recipe.GT_Recipe_Map.sSlicerRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCuttingMachine; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 13; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(29); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mCuttingMode = Utils.invertBoolean(mCuttingMode); + String aMode = mCuttingMode ? "Cutting" : "Slicing"; + PlayerUtils.messagePlayer(aPlayer, "Mode: " + aMode); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mCuttingMode", mCuttingMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("mCuttingMode")) { + mCuttingMode = aNBT.getBoolean("mCuttingMode"); + } else { + mCuttingMode = true; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java index e562e2d29d..c1ed59ce2b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java @@ -1,7 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -23,6 +28,8 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -30,362 +37,363 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofCoil; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_IndustrialDehydrator extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private static int CASING_TEXTURE_ID; - private static String mCasingName = "Vacuum Casing"; - private HeatingCoilLevel mHeatingCapacity; - private boolean mDehydratorMode = false; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialDehydrator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); - } - - public GregtechMetaTileEntity_IndustrialDehydrator(String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialDehydrator(mName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Vacuum Furnace") - .addInfo("Can toggle the operation temperature with a Screwdriver") - .addInfo("All Dehydrator recipes are Low Temp recipes") - .addInfo("Speed: +120% | EU Usage: 50% | Parallel: 4") - .addInfo("Each 900K over the min. Heat Capacity grants 5% speedup (multiplicatively)") - .addInfo("Each 1800K over the min. Heat Capacity allows for one upgraded overclock") - .addInfo("Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 5, 3, true) - .addController("Bottom Center") - .addCasingInfo(mCasingName, 10) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"HHH", "H-H", "HHH"}, - {"HHH", "H-H", "HHH"}, - {"HHH", "H-H", "HHH"}, - {"C~C", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialDehydrator.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 10))) - ) - .addElement( - 'H', - ofCoil( - GregtechMetaTileEntity_IndustrialDehydrator::setCoilLevel, GregtechMetaTileEntity_IndustrialDehydrator::getCoilLevel - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 4, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 4, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - setCoilLevel(HeatingCoilLevel.None); - return checkPiece(mName, 1, 4, 0) && mCasing >= 10 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return mDehydratorMode ? GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes : GTPP_Recipe.GTPP_Recipe_Map.sVacuumFurnaceRecipes; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialDehydrator; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getMachineType() { - return "Vacuum Furnace / Dehydrator"; - } - - @Override - public int getMaxParallelRecipes() { - return 4; - } - - @Override - public int getEuDiscountForParallelism() { - return 50; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "ElectricBlastFurnace"; - } - - public boolean checkRecipe(ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - Logger.WARNING("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = this.getRecipeMap().findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - Logger.WARNING("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { - Logger.WARNING("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - int tHeatCapacityDivTiers = (int) (mHeatingCapacity.getHeat() - tRecipe.mSpecialValue) / 900; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - // Count recipes to do in parallel, consuming input items and fluids and - // considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - Logger.WARNING("Broke at " + parallelRecipes + "."); - break; - } - Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); - int rInt = 2; - - this.mEUt = (int) Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= (tHeatCapacityDivTiers >= rInt ? 4 : 2); - } - } - - if (tHeatCapacityDivTiers > 0) { - this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) - tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - Logger.WARNING("GOOD RETURN - 1"); - return true; - - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mDehydratorMode = Utils.invertBoolean(mDehydratorMode); - String aMode = mDehydratorMode ? "Dehydrator" : "Vacuum Furnace"; - PlayerUtils.messagePlayer(aPlayer, "Mode: "+aMode); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mDehydratorMode", mDehydratorMode); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mDehydratorMode = aNBT.getBoolean("mDehydratorMode"); - } - - public HeatingCoilLevel getCoilLevel() { - return mHeatingCapacity; - } - - public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - mHeatingCapacity = aCoilLevel; - } +public class GregtechMetaTileEntity_IndustrialDehydrator + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private static int CASING_TEXTURE_ID; + private static String mCasingName = "Vacuum Casing"; + private HeatingCoilLevel mHeatingCapacity; + private boolean mDehydratorMode = false; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialDehydrator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); + } + + public GregtechMetaTileEntity_IndustrialDehydrator(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialDehydrator(mName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Vacuum Furnace") + .addInfo("Can toggle the operation temperature with a Screwdriver") + .addInfo("All Dehydrator recipes are Low Temp recipes") + .addInfo("Speed: +120% | EU Usage: 50% | Parallel: 4") + .addInfo("Each 900K over the min. Heat Capacity grants 5% speedup (multiplicatively)") + .addInfo("Each 1800K over the min. Heat Capacity allows for one upgraded overclock") + .addInfo("Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 5, 3, true) + .addController("Bottom Center") + .addCasingInfo(mCasingName, 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialDehydrator.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 10)))) + .addElement( + 'H', + ofCoil( + GregtechMetaTileEntity_IndustrialDehydrator::setCoilLevel, + GregtechMetaTileEntity_IndustrialDehydrator::getCoilLevel)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 4, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 4, 0) && mCasing >= 10 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mDehydratorMode + ? GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes + : GTPP_Recipe.GTPP_Recipe_Map.sVacuumFurnaceRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialDehydrator; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getMachineType() { + return "Vacuum Furnace / Dehydrator"; + } + + @Override + public int getMaxParallelRecipes() { + return 4; + } + + @Override + public int getEuDiscountForParallelism() { + return 50; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + public boolean checkRecipe(ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + Logger.WARNING("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = this.getRecipeMap() + .findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + Logger.WARNING("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { + Logger.WARNING("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + int tHeatCapacityDivTiers = (int) (mHeatingCapacity.getHeat() - tRecipe.mSpecialValue) / 900; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // Count recipes to do in parallel, consuming input items and fluids and + // considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + Logger.WARNING("Broke at " + parallelRecipes + "."); + break; + } + Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + int rInt = 2; + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= (tHeatCapacityDivTiers >= rInt ? 4 : 2); + } + } + + if (tHeatCapacityDivTiers > 0) { + this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.WARNING("GOOD RETURN - 1"); + return true; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mDehydratorMode = Utils.invertBoolean(mDehydratorMode); + String aMode = mDehydratorMode ? "Dehydrator" : "Vacuum Furnace"; + PlayerUtils.messagePlayer(aPlayer, "Mode: " + aMode); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mDehydratorMode", mDehydratorMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mDehydratorMode = aNBT.getBoolean("mDehydratorMode"); + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } } - - diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java index 9f7cbc8859..835b6c6378 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -1,5 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -18,161 +24,157 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialElectrolyzer extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialElectrolyzer(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialElectrolyzer(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); - } - - @Override - public String getMachineType() { - return "Electrolyzer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Electrolyzer") - .addInfo("180% faster than using single block machines of the same voltage") - .addInfo("Only uses 90% of the EU/t normally required") - .addInfo("Processes two items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo("Electrolyzer Casings", 10) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialElectrolyzer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(TAE.GTPP_INDEX(5)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 5))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(5); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialElectrolyzer"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(2* GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialElectrolyzer; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getMaxParallelRecipes() { - return 2* GT_Utility.getTier(this.getMaxInputVoltage()); - } - - @Override - public int getEuDiscountForParallelism() { - return 90; - } -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialElectrolyzer + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialElectrolyzer( + final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialElectrolyzer(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); + } + + @Override + public String getMachineType() { + return "Electrolyzer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Electrolyzer") + .addInfo("180% faster than using single block machines of the same voltage") + .addInfo("Only uses 90% of the EU/t normally required") + .addInfo("Processes two items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Electrolyzer Casings", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialElectrolyzer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(TAE.GTPP_INDEX(5)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 5)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(5); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialElectrolyzer"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(2 * GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialElectrolyzer; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 2 * GT_Utility.getTier(this.getMaxInputVoltage()); + } + + @Override + public int getEuDiscountForParallelism() { + return 90; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java index 4b794506f9..91c232d8fe 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java @@ -1,6 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -19,213 +23,207 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialExtruder extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - - public GregtechMetaTileEntity_IndustrialExtruder(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialExtruder(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialExtruder(this.mName); - } - - @Override - public String getMachineType() { - return "Extruder"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Material Extruder") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Processes four items per voltage tier") - .addInfo("Extrusion Shape for recipe goes in the Input Bus") - .addInfo("Each Input Bus can have a different shape!") - .addInfo("You can use several input buses per multiblock") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 5, true) - .addController("Front Center") - .addCasingInfo("Inconel Reinforced Casings", 28) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Back Center", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC", "CCC", "CCC"}, - {"C~C", "C-C", "C-C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialExtruder.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 28 && checkHatch(); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(203)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(33); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialExtruder"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sExtruderRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tBusItems = new ArrayList(); - tBus.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - ItemStack[] inputs = new ItemStack[tBusItems.size()]; - int slot = 0; - for (ItemStack g : tBusItems) { - inputs[slot++] = g; - } - if (inputs.length > 0) { - int para = (4* GT_Utility.getTier(this.getMaxInputVoltage())); - log("Recipe. ["+inputs.length+"]["+para+"]"); - if (checkRecipeGeneric(inputs, new FluidStack[]{}, para, 100, 250, 10000)) { - log("Recipe 2."); - return true; - } - } - - } - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialExtruder; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta() { - return 1; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(33); - } +public class GregtechMetaTileEntity_IndustrialExtruder + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialExtruder(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialExtruder(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialExtruder(this.mName); + } + + @Override + public String getMachineType() { + return "Extruder"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Material Extruder") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes four items per voltage tier") + .addInfo("Extrusion Shape for recipe goes in the Input Bus") + .addInfo("Each Input Bus can have a different shape!") + .addInfo("You can use several input buses per multiblock") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfo("Inconel Reinforced Casings", 28) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Back Center", 2) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + {"C~C", "C-C", "C-C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialExtruder.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 28 && checkHatch(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(203)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(33); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialExtruder"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sExtruderRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tBusItems = new ArrayList(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + ItemStack[] inputs = new ItemStack[tBusItems.size()]; + int slot = 0; + for (ItemStack g : tBusItems) { + inputs[slot++] = g; + } + if (inputs.length > 0) { + int para = (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + log("Recipe. [" + inputs.length + "][" + para + "]"); + if (checkRecipeGeneric(inputs, new FluidStack[] {}, para, 100, 250, 10000)) { + log("Recipe 2."); + return true; + } + } + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialExtruder; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta() { + return 1; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(33); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java index 292c42930b..f6d65aafe6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java @@ -1,5 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -19,197 +25,191 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialFluidHeater extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing1; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialFluidHeater(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialFluidHeater(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialFluidHeater(this.mName); - } - - @Override - public String getMachineType() { - return "Fluid Heater"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Fluid Heater") - .addInfo("120% faster than using single block machines of the same voltage") - .addInfo("Only uses 90% of the EU/t normally required") - .addInfo("Processes eight items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 6, 5, true) - .addController("Front Center") - .addCasingInfo("Top/Bottom layer: Multi-use Casings", 34) - .addCasingInfo("Middle layers: Thermal Containment Casing", 47) - .addInputBus("Bottom Layer (optional)", 1) - .addInputHatch("Bottom Layer", 1) - .addOutputBus("Top Layer (optional)", 1) - .addOutputHatch("Top Layer", 1) - .addEnergyHatch("Any Multi-use Casing", 1) - .addMaintenanceHatch("Any Multi-use Casing", 1) - .addMufflerHatch("Any Multi-use Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {" TTT ", "TTTTT", "TTTTT", "TTTTT", " TTT "}, - {" XXX ", "X---X", "X---X", "X---X", " XXX "}, - {" XXX ", "X---X", "X---X", "X---X", " XXX "}, - {" XXX ", "X---X", "X---X", "X---X", " XXX "}, - {" X~X ", "X---X", "X---X", "X---X", " XXX "}, - {" BBB ", "BBBBB", "BBBBB", "BBBBB", " BBB "}, - })) - .addElement( - 'B', - buildHatchAdder(GregtechMetaTileEntity_IndustrialFluidHeater.class) - .atLeast(InputBus, InputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2()))) - ) - .addElement('X', ofBlock(getCasingBlock1(), getCasingMeta1())) - .addElement( - 'T', - buildHatchAdder(GregtechMetaTileEntity_IndustrialFluidHeater.class) - .atLeast(OutputBus, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2()))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 2, 4, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 4, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing1 = 0; - boolean didBuild = checkPiece(mName, 2, 4, 0); - log("Built? "+didBuild+", "+mCasing1); - return didBuild && mCasing1 >= 34 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(0, 1); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialThermalCentrifuge"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sFluidHeaterRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 90; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock1() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta1() { - return 11; - } - - public Block getCasingBlock2() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta2() { - return 2; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.getIndexFromPage(2, 2); - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialFluidHeater + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing1; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialFluidHeater(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialFluidHeater(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialFluidHeater(this.mName); + } + + @Override + public String getMachineType() { + return "Fluid Heater"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Fluid Heater") + .addInfo("120% faster than using single block machines of the same voltage") + .addInfo("Only uses 90% of the EU/t normally required") + .addInfo("Processes eight items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 6, 5, true) + .addController("Front Center") + .addCasingInfo("Top/Bottom layer: Multi-use Casings", 34) + .addCasingInfo("Middle layers: Thermal Containment Casing", 47) + .addInputBus("Bottom Layer (optional)", 1) + .addInputHatch("Bottom Layer", 1) + .addOutputBus("Top Layer (optional)", 1) + .addOutputHatch("Top Layer", 1) + .addEnergyHatch("Any Multi-use Casing", 1) + .addMaintenanceHatch("Any Multi-use Casing", 1) + .addMufflerHatch("Any Multi-use Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {" TTT ", "TTTTT", "TTTTT", "TTTTT", " TTT "}, + {" XXX ", "X---X", "X---X", "X---X", " XXX "}, + {" XXX ", "X---X", "X---X", "X---X", " XXX "}, + {" XXX ", "X---X", "X---X", "X---X", " XXX "}, + {" X~X ", "X---X", "X---X", "X---X", " XXX "}, + {" BBB ", "BBBBB", "BBBBB", "BBBBB", " BBB "}, + })) + .addElement( + 'B', + buildHatchAdder(GregtechMetaTileEntity_IndustrialFluidHeater.class) + .atLeast(InputBus, InputHatch, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2())))) + .addElement('X', ofBlock(getCasingBlock1(), getCasingMeta1())) + .addElement( + 'T', + buildHatchAdder(GregtechMetaTileEntity_IndustrialFluidHeater.class) + .atLeast(OutputBus, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 4, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 4, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing1 = 0; + boolean didBuild = checkPiece(mName, 2, 4, 0); + log("Built? " + didBuild + ", " + mCasing1); + return didBuild && mCasing1 >= 34 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(0, 1); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialThermalCentrifuge"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sFluidHeaterRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 90; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock1() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta1() { + return 11; + } + + public Block getCasingBlock2() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta2() { + return 2; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.getIndexFromPage(2, 2); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java index 3fefffda7a..ba31a4753a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java @@ -1,8 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksFlat; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -23,301 +26,304 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksFlat; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialForgeHammer extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private int mAnvil; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialForgeHammer(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialForgeHammer(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - setAnvilBlocks(); - return new GregtechMetaTileEntity_IndustrialForgeHammer(this.mName); - } - - @Override - public String getMachineType() { - return "Forge Hammer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Forge Hammer") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: Tier x Anvil Tier x 8") - .addInfo("T1 - Vanilla Anvil") - .addInfo("Anvil goes in Middle 3x3x3 Structure"); - if (LoadedMods.Railcraft) { - tt.addInfo("T2 - Steel Anvil"); - } - if (LoadedMods.EnderIO) { - tt.addInfo("T3 - Dark Steel Anvil"); - } - if (LoadedMods.ThaumicBases) { - tt.addInfo("T3 - Thaumic Anvil"); - tt.addInfo("T4 - Void Anvil"); - } - tt.addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo("Forge Casing", 10) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - Map aBlockMap = new HashMap(); - aBlockMap.put(sAnvil, 0); - if (LoadedMods.Railcraft) { - aBlockMap.put(sSteelAnvil, 0); - } - if (LoadedMods.EnderIO) { - aBlockMap.put(sDarkSteelAnvil, 0); - } - if (LoadedMods.ThaumicBases) { - aBlockMap.put(sThaumiumAnvil, 0); - aBlockMap.put(sVoidAnvil, 0); - } - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "CAC", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialForgeHammer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(TAE.getIndexFromPage(1, 11)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 6))) - ) - .addElement('A', onElementPass(x -> ++x.mAnvil, ofBlocksFlat(aBlockMap, sAnvil, 0))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - setAnvilBlocks(); - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - setAnvilBlocks(); - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(1); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(1, 11); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "MaterialPress"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sHammerRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - Block aAnvil = this.getBaseMetaTileEntity().getBlockAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (aAnvil != null) { - int aAnvilTier = getAnvilTier(aAnvil); - if (aAnvilTier > 0) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tBusItems = new ArrayList(); - tBus.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), new FluidStack[]{}, getMaxParallelRecipes() * aAnvilTier, 100, 100, 10000)) { - return true; - } - } - } - } - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialForgeHammer; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - private static Block sAnvil; - private static Block sSteelAnvil; - private static Block sDarkSteelAnvil; - private static Block sThaumiumAnvil; - private static Block sVoidAnvil; - - private static void setAnvilBlocks() { - if (sAnvil == null) { - sAnvil = Blocks.anvil; - if (LoadedMods.Railcraft) { - sSteelAnvil = GameRegistry.findBlock("Railcraft", "anvil"); - } - if (LoadedMods.EnderIO) { - sDarkSteelAnvil = GameRegistry.findBlock("EnderIO", "blockDarkSteelAnvil"); - } - if (LoadedMods.ThaumicBases) { - sThaumiumAnvil = GameRegistry.findBlock("thaumicbases", "thaumicAnvil"); - sVoidAnvil = GameRegistry.findBlock("thaumicbases", "voidAnvil"); - } - } - } - - public static boolean isBlockAnvil(Block aBlock) { - setAnvilBlocks(); - if (sAnvil == aBlock) { - return true; - } - if (LoadedMods.Railcraft) { - if (sSteelAnvil == aBlock) { - return true; - } - } - if (LoadedMods.EnderIO) { - if (sDarkSteelAnvil == aBlock) { - return true; - } - } - if (LoadedMods.ThaumicBases) { - if (sThaumiumAnvil == aBlock || sVoidAnvil == aBlock) { - return true; - } - } - return false; - } - - public static int getAnvilTier(Block aBlock) { - if (isBlockAnvil(aBlock)) { - if (sAnvil == aBlock) { - return 1; - } - if (LoadedMods.Railcraft) { - if (sSteelAnvil == aBlock) { - return 2; - } - } - if (LoadedMods.EnderIO) { - if (sDarkSteelAnvil == aBlock) { - return 3; - } - } - if (LoadedMods.ThaumicBases) { - if (sThaumiumAnvil == aBlock) { - return 3; - } - if (sVoidAnvil == aBlock) { - return 4; - } - } - } - return 0; - } - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - setAnvilBlocks(); - super.onFirstTick(aBaseMetaTileEntity); - } - +public class GregtechMetaTileEntity_IndustrialForgeHammer + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private int mAnvil; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialForgeHammer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialForgeHammer(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + setAnvilBlocks(); + return new GregtechMetaTileEntity_IndustrialForgeHammer(this.mName); + } + + @Override + public String getMachineType() { + return "Forge Hammer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Forge Hammer") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: Tier x Anvil Tier x 8") + .addInfo("T1 - Vanilla Anvil") + .addInfo("Anvil goes in Middle 3x3x3 Structure"); + if (LoadedMods.Railcraft) { + tt.addInfo("T2 - Steel Anvil"); + } + if (LoadedMods.EnderIO) { + tt.addInfo("T3 - Dark Steel Anvil"); + } + if (LoadedMods.ThaumicBases) { + tt.addInfo("T3 - Thaumic Anvil"); + tt.addInfo("T4 - Void Anvil"); + } + tt.addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Forge Casing", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + Map aBlockMap = new HashMap(); + aBlockMap.put(sAnvil, 0); + if (LoadedMods.Railcraft) { + aBlockMap.put(sSteelAnvil, 0); + } + if (LoadedMods.EnderIO) { + aBlockMap.put(sDarkSteelAnvil, 0); + } + if (LoadedMods.ThaumicBases) { + aBlockMap.put(sThaumiumAnvil, 0); + aBlockMap.put(sVoidAnvil, 0); + } + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "CAC", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialForgeHammer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(TAE.getIndexFromPage(1, 11)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 6)))) + .addElement('A', onElementPass(x -> ++x.mAnvil, ofBlocksFlat(aBlockMap, sAnvil, 0))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + setAnvilBlocks(); + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + setAnvilBlocks(); + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(1); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(1, 11); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MaterialPress"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sHammerRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + Block aAnvil = this.getBaseMetaTileEntity() + .getBlockAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if (aAnvil != null) { + int aAnvilTier = getAnvilTier(aAnvil); + if (aAnvilTier > 0) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tBusItems = new ArrayList(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + if (checkRecipeGeneric( + tBusItems.toArray(new ItemStack[] {}), + new FluidStack[] {}, + getMaxParallelRecipes() * aAnvilTier, + 100, + 100, + 10000)) { + return true; + } + } + } + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialForgeHammer; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private static Block sAnvil; + private static Block sSteelAnvil; + private static Block sDarkSteelAnvil; + private static Block sThaumiumAnvil; + private static Block sVoidAnvil; + + private static void setAnvilBlocks() { + if (sAnvil == null) { + sAnvil = Blocks.anvil; + if (LoadedMods.Railcraft) { + sSteelAnvil = GameRegistry.findBlock("Railcraft", "anvil"); + } + if (LoadedMods.EnderIO) { + sDarkSteelAnvil = GameRegistry.findBlock("EnderIO", "blockDarkSteelAnvil"); + } + if (LoadedMods.ThaumicBases) { + sThaumiumAnvil = GameRegistry.findBlock("thaumicbases", "thaumicAnvil"); + sVoidAnvil = GameRegistry.findBlock("thaumicbases", "voidAnvil"); + } + } + } + + public static boolean isBlockAnvil(Block aBlock) { + setAnvilBlocks(); + if (sAnvil == aBlock) { + return true; + } + if (LoadedMods.Railcraft) { + if (sSteelAnvil == aBlock) { + return true; + } + } + if (LoadedMods.EnderIO) { + if (sDarkSteelAnvil == aBlock) { + return true; + } + } + if (LoadedMods.ThaumicBases) { + if (sThaumiumAnvil == aBlock || sVoidAnvil == aBlock) { + return true; + } + } + return false; + } + + public static int getAnvilTier(Block aBlock) { + if (isBlockAnvil(aBlock)) { + if (sAnvil == aBlock) { + return 1; + } + if (LoadedMods.Railcraft) { + if (sSteelAnvil == aBlock) { + return 2; + } + } + if (LoadedMods.EnderIO) { + if (sDarkSteelAnvil == aBlock) { + return 3; + } + } + if (LoadedMods.ThaumicBases) { + if (sThaumiumAnvil == aBlock) { + return 3; + } + if (sVoidAnvil == aBlock) { + return 4; + } + } + } + return 0; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + setAnvilBlocks(); + super.onFirstTick(aBaseMetaTileEntity); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java index 43a1686b2e..b06d416fef 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java @@ -1,6 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.Random; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -18,255 +23,248 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.Random; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +public class GregtechMetaTileEntity_IndustrialMacerator + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + private int mCasing; + private int mPerLayer; + private IStructureDefinition STRUCTURE_DEFINITION = null; -public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private int mPerLayer; - private IStructureDefinition STRUCTURE_DEFINITION = null; + public GregtechMetaTileEntity_IndustrialMacerator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } - public GregtechMetaTileEntity_IndustrialMacerator(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } + public GregtechMetaTileEntity_IndustrialMacerator(final String aName) { + super(aName); + } - public GregtechMetaTileEntity_IndustrialMacerator(final String aName) { - super(aName); - } + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); + } - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); - } + @Override + public String getMachineType() { + return "Macerator/Pulverizer"; + } - @Override - public String getMachineType() { - return "Macerator/Pulverizer"; - } + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Maceration Stack") + .addInfo("60% faster than using single block machines of the same voltage") + .addInfo("Processes 8*tier materials at a time") + .addInfo("ULV = Tier 0, LV = Tier 1, etc.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 6, 3, true) + .addController("Bottom Center") + .addCasingInfo("Maceration Stack Casings", 26) + .addInputBus("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addOutputBus("One per layer except bottom layer", 2) + .addMufflerHatch("Any Casing", 2) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Maceration Stack") - .addInfo("60% faster than using single block machines of the same voltage") - .addInfo("Processes 8*tier materials at a time") - .addInfo("ULV = Tier 0, LV = Tier 1, etc.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 6, 3, true) - .addController("Bottom Center") - .addCasingInfo("Maceration Stack Casings", 26) - .addInputBus("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .addOutputBus("One per layer except bottom layer", 2) - .addMufflerHatch("Any Casing", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName + "top", transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + })) + .addShape(mName + "mid", transpose(new String[][] { + {"CCC", "C-C", "CCC"}, + })) + .addShape(mName + "bottom", transpose(new String[][] { + {"B~B", "BBB", "BBB"}, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_IndustrialMacerator.class) + .atLeast(OutputBus) + .shouldReject(t -> t.mPerLayer + 1 == t.mOutputBusses.size()) + .casingIndex(TAE.GTPP_INDEX(7)) + .dot(2) + .build(), + buildHatchAdder(GregtechMetaTileEntity_IndustrialMacerator.class) + .atLeast(Energy, Maintenance, Muffler) + .shouldReject(t -> t.mPerLayer + 1 == t.mOutputBusses.size()) + .casingIndex(TAE.GTPP_INDEX(7)) + .dot(2) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 7)))) + .addElement( + 'B', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_IndustrialMacerator.class) + .atLeast(Energy, Maintenance, InputBus) + .casingIndex(TAE.GTPP_INDEX(7)) + .dot(2) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 7)))) + .build(); + } + return STRUCTURE_DEFINITION; + } - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName + "top", transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - })) - .addShape(mName + "mid", transpose(new String[][]{ - {"CCC", "C-C", "CCC"}, - })) - .addShape(mName + "bottom", transpose(new String[][]{ - {"B~B", "BBB", "BBB"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IndustrialMacerator.class) - .atLeast(OutputBus) - .shouldReject(t -> t.mPerLayer + 1 == t.mOutputBusses.size()) - .casingIndex(TAE.GTPP_INDEX(7)) - .dot(2) - .build(), - buildHatchAdder(GregtechMetaTileEntity_IndustrialMacerator.class) - .atLeast(Energy, Maintenance, Muffler) - .shouldReject(t -> t.mPerLayer + 1 == t.mOutputBusses.size()) - .casingIndex(TAE.GTPP_INDEX(7)) - .dot(2) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasingsMisc, 7 - ) - ) - ) - ) - .addElement( - 'B', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IndustrialMacerator.class) - .atLeast(Energy, Maintenance, InputBus) - .casingIndex(TAE.GTPP_INDEX(7)) - .dot(2) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasingsMisc, 7 - ) - ) - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName + "bottom", stackSize, hintsOnly, 1, 0, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 1, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 2, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 3, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 4, 0); + buildPiece(mName + "top", stackSize, hintsOnly, 1, 5, 0); + } - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName + "bottom", stackSize, hintsOnly, 1, 0, 0); - buildPiece(mName + "mid", stackSize, hintsOnly, 1, 1, 0); - buildPiece(mName + "mid", stackSize, hintsOnly, 1, 2, 0); - buildPiece(mName + "mid", stackSize, hintsOnly, 1, 3, 0); - buildPiece(mName + "mid", stackSize, hintsOnly, 1, 4, 0); - buildPiece(mName + "top", stackSize, hintsOnly, 1, 5, 0); - } + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + int built; + built = survivialBuildPiece(mName + "bottom", stackSize, 1, 0, 0, elementBudget, source, actor, false, true); + mPerLayer = 0; + if (built >= 0) return built; + built = survivialBuildPiece(mName + "mid", stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + mPerLayer = 1; + if (built >= 0) return built; + built = survivialBuildPiece(mName + "mid", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + mPerLayer = 2; + built = survivialBuildPiece(mName + "mid", stackSize, 1, 3, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + mPerLayer = 3; + built = survivialBuildPiece(mName + "mid", stackSize, 1, 4, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + return survivialBuildPiece(mName + "top", stackSize, 1, 5, 0, elementBudget, source, actor, false, true); + } - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - int built; - built = survivialBuildPiece(mName + "bottom", stackSize, 1, 0, 0, elementBudget, source, actor, false, true); - mPerLayer = 0; - if (built >= 0) return built; - built = survivialBuildPiece(mName + "mid", stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - mPerLayer = 1; - if (built >= 0) return built; - built = survivialBuildPiece(mName + "mid", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - mPerLayer = 2; - built = survivialBuildPiece(mName + "mid", stackSize, 1, 3, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - mPerLayer = 3; - built = survivialBuildPiece(mName + "mid", stackSize, 1, 4, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - return survivialBuildPiece(mName + "top", stackSize, 1, 5, 0, elementBudget, source, actor, false, true); - } + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mPerLayer = 0; + if (checkPiece(mName + "bottom", 1, 0, 0)) { + while (mPerLayer < 4) { + if (!checkPiece(mName + "mid", 1, mPerLayer + 1, 0) || mPerLayer + 1 != mOutputBusses.size()) + return false; + mPerLayer++; + } + return checkPiece(mName + "top", 1, 5, 0) && mOutputBusses.size() == 5 && mCasing >= 26 && checkHatch(); + } + return false; + } - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mPerLayer = 0; - if (checkPiece(mName + "bottom", 1, 0 ,0)) { - while (mPerLayer < 4) { - if (!checkPiece(mName + "mid", 1, mPerLayer + 1, 0) || - mPerLayer + 1 != mOutputBusses.size()) return false; - mPerLayer ++; - } - return checkPiece(mName + "top", 1, 5, 0) && mOutputBusses.size() == 5 && mCasing >= 26 && checkHatch(); - } - return false; - } + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(201)); + } - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(201)); - } + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab_Active; + } - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab_Active; - } + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab; + } - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab; - } + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(7); + } - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(7); - } + @Override + public boolean hasSlotInGUI() { + return false; + } - @Override - public boolean hasSlotInGUI() { - return false; - } + @Override + public String getCustomGUIResourceName() { + return "MacerationStack"; + } - @Override - public String getCustomGUIResourceName() { - return "MacerationStack"; - } + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; - } + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) + && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) + && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "smoke", + (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), + 0.0D, + 0.0D, + 0.0D); + } + } - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); - } - } + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 60, 7500); + } - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 60, 7500); - } - - @Override - protected boolean doesMachineBoostOutput() { - return true; - } - - @Override - public int getMaxParallelRecipes() { - final long tVoltage = getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - return Math.max(1, 8 * tTier); - } + @Override + protected boolean doesMachineBoostOutput() { + return true; + } - @Override - public int getEuDiscountForParallelism() { - return 100; - } + @Override + public int getMaxParallelRecipes() { + final long tVoltage = getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + return Math.max(1, 8 * tTier); + } - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } + @Override + public int getEuDiscountForParallelism() { + return 100; + } - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMacerator; - } + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } - @Override - public int getAmountOfOutputs() { - return 16; - } + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMacerator; + } - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } + @Override + public int getAmountOfOutputs() { + return 16; + } - @Override - public boolean isOverclockerUpgradable() { - return true; - } + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } -} \ No newline at end of file + @Override + public boolean isOverclockerUpgradable() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java index 03a71ea918..356d72ff88 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java @@ -1,6 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -19,210 +23,198 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialMixer extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - public static String mCasingName = "Multi-Use Casing"; - public static String mCasingName2 = "Titanium Turbine Casing"; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - - public GregtechMetaTileEntity_IndustrialMixer(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); - } - - public GregtechMetaTileEntity_IndustrialMixer(final String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMixer(this.mName); - } - - @Override - public String getMachineType() { - return "Mixer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Mixer") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Processes eight recipes per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 4, 3, false) - .addController("Second Layer Center") - .addCasingInfo(mCasingName, 16) - .addCasingInfo(mCasingName2, 2) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"CCC", "CMC", "CCC"}, - {"C~C", "CMC", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialMixer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2))) - ) - .addElement( - 'M', - ofBlock( - GregTech_API.sBlockCasings4, 11 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 2, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 2, 0) && mCasing >= 16 && checkHatch(); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(203)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialMixer"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map.sMultiblockMixerRecipes_GT; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tBusItems = new ArrayList(); - tBus.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - ItemStack[] inputs = new ItemStack[tBusItems.size()]; - int slot = 0; - for (ItemStack g : tBusItems) { - inputs[slot++] = g; - } - log("Recipe. ["+inputs.length+"]["+getMaxParallelRecipes()+"]"); - FluidStack[] fluid = this.getStoredFluids().toArray(new FluidStack[] {}); - if (checkRecipeGeneric(inputs,fluid , getMaxParallelRecipes(), getEuDiscountForParallelism(), 250, 10000)) { - log("Recipe 2."); - return true; - } - - } - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMixer; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } +public class GregtechMetaTileEntity_IndustrialMixer + extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + public static String mCasingName = "Multi-Use Casing"; + public static String mCasingName2 = "Titanium Turbine Casing"; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialMixer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); + } + + public GregtechMetaTileEntity_IndustrialMixer(final String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMixer(this.mName); + } + + @Override + public String getMachineType() { + return "Mixer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Mixer") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes eight recipes per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, false) + .addController("Second Layer Center") + .addCasingInfo(mCasingName, 16) + .addCasingInfo(mCasingName2, 2) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"CCC", "CMC", "CCC"}, + {"C~C", "CMC", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialMixer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2)))) + .addElement('M', ofBlock(GregTech_API.sBlockCasings4, 11)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 2, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 2, 0) && mCasing >= 16 && checkHatch(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(203)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialMixer"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map.sMultiblockMixerRecipes_GT; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tBusItems = new ArrayList(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + ItemStack[] inputs = new ItemStack[tBusItems.size()]; + int slot = 0; + for (ItemStack g : tBusItems) { + inputs[slot++] = g; + } + log("Recipe. [" + inputs.length + "][" + getMaxParallelRecipes() + "]"); + FluidStack[] fluid = this.getStoredFluids().toArray(new FluidStack[] {}); + if (checkRecipeGeneric(inputs, fluid, getMaxParallelRecipes(), getEuDiscountForParallelism(), 250, 10000)) { + log("Recipe 2."); + return true; + } + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMixer; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java index d4a505cc2e..dcca512e1a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java @@ -1,5 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -21,226 +26,224 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialMolecularTransformer extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private static final int CASING_TEXTURE_ID = 48; - private int mCasing = 0; - - public GregtechMetaTileEntity_IndustrialMolecularTransformer(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialMolecularTransformer(final String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMolecularTransformer(this.mName); - } - - @Override - public String getMachineType() { - return "Molecular Transformer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Changes the structure of items to produce new ones") - .addInfo("Maximum 1x of each bus/hatch.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(7, 7, 7, false) - .addController("Top Center") - .addCasingInfo("Robust Tungstensteel Machine Casing", 40) - .addCasingInfo("Tungstensteel Coils", 16) - .addCasingInfo("Molecular Containment Casing", 52) - .addCasingInfo("High Voltage Current Capacitor", 32) - .addCasingInfo("Particle Containment Casing", 4) - .addCasingInfo("Resonance Chamber I", 5) - .addCasingInfo("Modulator I", 4) - .addInputBus("Any Robust Tungstensteel Machine Casing", 1) - .addOutputBus("Any Robust Tungstensteel Machine Casing", 1) - .addEnergyHatch("Any Robust Tungstensteel Machine Casing", 1) - .addMaintenanceHatch("Any Robust Tungstensteel Machine Casing", 1) - .addMufflerHatch("Any Robust Tungstensteel Machine Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - - private static final String STRUCTURE_PIECE_MAIN = "main"; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, (new String[][]{ - {" ", " ", " xxx ", " x~x ", " xxx ", " ", " "}, - {" ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " "}, - {" ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " "}, - {" ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " "}, - {" t ", " ttxtt ", " tyyyt ", "txyzyxt", " tyyyt ", " ttxtt ", " t "}, - {" c ", " ccecc ", " cxfxc ", "cefefec", " cxfxc ", " ccecc ", " c "}, - {" h ", " hhhhh ", " hhhhh ", "hhhhhhh", " hhhhh ", " hhhhh ", " h "}, - })) - - .addElement('x', ofBlock(getCasingBlock(), getCasingMeta())) - .addElement('y', ofBlock(getCasingBlock(), getCasingMeta2())) - .addElement('z', ofBlock(getCasingBlock(), getCasingMeta3())) - .addElement('e', ofBlock(getCasingBlock2(), 0)) - .addElement('f', ofBlock(getCasingBlock2(), 4)) - .addElement('c', ofBlock(getCoilBlock(), 3)) - .addElement('t', ofBlock(getCasingBlock3(), getTungstenCasingMeta())) - .addElement('h', buildHatchAdder(GregtechMetaTileEntity_IndustrialMolecularTransformer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock3(), getTungstenCasingMeta()))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); - if (this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 1 || this.mEnergyHatches.size() != 1) { - return false; - } - // there are 16 slot that only allow casing, so we subtract this from the grand total required - return aDidBuild && mCasing >= 40 - 16 && checkHatch(); - } - - protected static int getCasingTextureIndex() { - return CASING_TEXTURE_ID; - } - - protected static Block getCasingBlock() { - return ModBlocks.blockSpecialMultiCasings; - } - - protected static Block getCasingBlock2() { - return ModBlocks.blockSpecialMultiCasings2; - } - - protected static Block getCasingBlock3() { - return GregTech_API.sBlockCasings4; - } - - protected static Block getCoilBlock() { - return GregTech_API.sBlockCasings5; - } - - protected static int getCasingMeta() { - return 11; - } - - protected static int getCasingMeta2() { - return 12; - } - - protected static int getCasingMeta3() { - return 13; - } - - protected static int getTungstenCasingMeta() { - return 0; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return 44; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe_Map.sMolecularTransformerRecipes; - } - - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(); - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; - } - - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public boolean isNewExtendedFacingValid(ExtendedFacing alignment) { - return alignment.getDirection() == ForgeDirection.UP && super.isNewExtendedFacingValid(alignment); - } +public class GregtechMetaTileEntity_IndustrialMolecularTransformer + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private static final int CASING_TEXTURE_ID = 48; + private int mCasing = 0; + + public GregtechMetaTileEntity_IndustrialMolecularTransformer( + final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialMolecularTransformer(final String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMolecularTransformer(this.mName); + } + + @Override + public String getMachineType() { + return "Molecular Transformer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Changes the structure of items to produce new ones") + .addInfo("Maximum 1x of each bus/hatch.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(7, 7, 7, false) + .addController("Top Center") + .addCasingInfo("Robust Tungstensteel Machine Casing", 40) + .addCasingInfo("Tungstensteel Coils", 16) + .addCasingInfo("Molecular Containment Casing", 52) + .addCasingInfo("High Voltage Current Capacitor", 32) + .addCasingInfo("Particle Containment Casing", 4) + .addCasingInfo("Resonance Chamber I", 5) + .addCasingInfo("Modulator I", 4) + .addInputBus("Any Robust Tungstensteel Machine Casing", 1) + .addOutputBus("Any Robust Tungstensteel Machine Casing", 1) + .addEnergyHatch("Any Robust Tungstensteel Machine Casing", 1) + .addMaintenanceHatch("Any Robust Tungstensteel Machine Casing", 1) + .addMufflerHatch("Any Robust Tungstensteel Machine Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static IStructureDefinition STRUCTURE_DEFINITION = + null; + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, (new String[][] { + {" ", " ", " xxx ", " x~x ", " xxx ", " ", " "}, + {" ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " "}, + {" ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " "}, + {" ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " "}, + {" t ", " ttxtt ", " tyyyt ", "txyzyxt", " tyyyt ", " ttxtt ", " t "}, + {" c ", " ccecc ", " cxfxc ", "cefefec", " cxfxc ", " ccecc ", " c "}, + {" h ", " hhhhh ", " hhhhh ", "hhhhhhh", " hhhhh ", " hhhhh ", " h "}, + })) + .addElement('x', ofBlock(getCasingBlock(), getCasingMeta())) + .addElement('y', ofBlock(getCasingBlock(), getCasingMeta2())) + .addElement('z', ofBlock(getCasingBlock(), getCasingMeta3())) + .addElement('e', ofBlock(getCasingBlock2(), 0)) + .addElement('f', ofBlock(getCasingBlock2(), 4)) + .addElement('c', ofBlock(getCoilBlock(), 3)) + .addElement('t', ofBlock(getCasingBlock3(), getTungstenCasingMeta())) + .addElement( + 'h', + buildHatchAdder(GregtechMetaTileEntity_IndustrialMolecularTransformer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock3(), getTungstenCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); + if (this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 1 || this.mEnergyHatches.size() != 1) { + return false; + } + // there are 16 slot that only allow casing, so we subtract this from the grand total required + return aDidBuild && mCasing >= 40 - 16 && checkHatch(); + } + + protected static int getCasingTextureIndex() { + return CASING_TEXTURE_ID; + } + + protected static Block getCasingBlock() { + return ModBlocks.blockSpecialMultiCasings; + } + + protected static Block getCasingBlock2() { + return ModBlocks.blockSpecialMultiCasings2; + } + + protected static Block getCasingBlock3() { + return GregTech_API.sBlockCasings4; + } + + protected static Block getCoilBlock() { + return GregTech_API.sBlockCasings5; + } + + protected static int getCasingMeta() { + return 11; + } + + protected static int getCasingMeta2() { + return 12; + } + + protected static int getCasingMeta3() { + return 13; + } + + protected static int getTungstenCasingMeta() { + return 0; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return 44; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe_Map.sMolecularTransformerRecipes; + } + + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(); + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; + } + + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean isNewExtendedFacingValid(ExtendedFacing alignment) { + return alignment.getDirection() == ForgeDirection.UP && super.isNewExtendedFacingValid(alignment); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java index 4fe8848397..f3e54a3f1a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java @@ -1,7 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -21,6 +25,8 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -29,500 +35,493 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_IndustrialMultiMachine extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected int mInternalMode = 0; - protected GT_Recipe[] mLastRecipeExtended = new GT_Recipe[9]; - private static final int MODE_COMPRESSOR = 0; - private static final int MODE_LATHE = 1; - private static final int MODE_MAGNETIC = 2; - private static final int MODE_FERMENTER = 3; - private static final int MODE_FLUIDEXTRACT = 4; - private static final int MODE_EXTRACTOR = 5; - private static final int MODE_LASER = 6; - private static final int MODE_AUTOCLAVE = 7; - private static final int MODE_FLUIDSOLIDIFY = 8; - private static final int[][] MODE_MAP = new int[][] {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}}; - public static final String[] aToolTipNames = new String[9]; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - static { - for (int id = 0; id < 9; id++) { - GT_Recipe.GT_Recipe_Map recipeMap = getRecipeMap(id); - if (recipeMap != null) { - String aNEI = GT_LanguageManager.getTranslation(getRecipeMap(id).mNEIName); - aToolTipNames[id] = aNEI != null ? aNEI : "BAD NEI NAME (Report to Github)"; - } - } - } - - - public GregtechMetaTileEntity_IndustrialMultiMachine(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialMultiMachine(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMultiMachine(this.mName); - } - - @Override - public String getMachineType() { - return "Nine in One"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - String[] aBuiltStrings = new String[3]; - aBuiltStrings[0] = aToolTipNames[0] + ", " + aToolTipNames[1] + ", " + aToolTipNames[2]; - aBuiltStrings[1] = aToolTipNames[3] + ", " + aToolTipNames[4] + ", " + aToolTipNames[5]; - aBuiltStrings[2] = aToolTipNames[6] + ", " + aToolTipNames[7] + ", " + aToolTipNames[8]; - - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Multi-Machine") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Only uses 80% of the EU/t normally required") - .addInfo("Processes two items per voltage tier") - .addInfo("Machine Type: [A] - " + EnumChatFormatting.YELLOW + aBuiltStrings[0] + EnumChatFormatting.RESET) - .addInfo("Machine Type: [B] - " + EnumChatFormatting.YELLOW + aBuiltStrings[1] + EnumChatFormatting.RESET) - .addInfo("Machine Type: [C] - " + EnumChatFormatting.YELLOW + aBuiltStrings[2] + EnumChatFormatting.RESET) - .addInfo("Read Multi-Machine Manual for extra information") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo("Multi-Use Casings", 6) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialMultiMachine.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(getTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return getTextureIndex(); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "Generic3By3"; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - ArrayList tFluids = getStoredFluids(); - //Logger.MACHINE_INFO("1"); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tBusItems = new ArrayList(); - tBus.mRecipeMap = getRecipeMap(); - //Logger.MACHINE_INFO("2"); - if (isValidMetaTileEntity(tBus)) { - //Logger.MACHINE_INFO("3"); - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - - boolean aFoundCircuitInBus = false; - for (ItemStack aBusItem : tBusItems) { - if (ItemUtils.isControlCircuit(aBusItem)) { - aFoundCircuitInBus = true; - } - } - if (!aFoundCircuitInBus) { - continue; - } - - Object[] tempArray = tFluids.toArray(new FluidStack[] {}); - FluidStack[] properArray; - properArray = ((tempArray != null && tempArray.length > 0) ? (FluidStack[]) tempArray : new FluidStack[] {}); - - //Logger.MACHINE_INFO("4"); - if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), properArray, - (2*GT_Utility.getTier(this.getMaxInputVoltage())), 80, 250, 10000)) return true; - } - return false; - - //return checkRecipeGeneric(2*GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); - } - - @Override - public int getMaxParallelRecipes() { - return (2 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 80; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - if (mInternalMode == 0) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal; - } - else if (mInternalMode == 1) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid; - } - else { //config 2 - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc; - } - } - - public int getTextureIndex() { - return TAE.getIndexFromPage(2, 2); - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - private ItemStack getCircuit(ItemStack[] t) { - for (ItemStack j : t) { - if (j.getItem() == CI.getNumberedCircuit(0).getItem()) { - if (j.getItemDamage() >= 20 && j.getItemDamage() <= 22) { - return j; - } - } - } - return null; - } - - private final int getCircuitID(ItemStack circuit) { - int H = circuit.getItemDamage(); - int T = (H == 20 ? 0 : (H == 21 ? 1 : (H == 22 ? 2 : -1))); - return MODE_MAP[this.mInternalMode][T]; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - private final GT_Recipe.GT_Recipe_Map getRecipeMap(ItemStack circuit) { - return getRecipeMap(getCircuitID(circuit)); - } - - private static final GT_Recipe.GT_Recipe_Map getRecipeMap(int aMode) { - if (aMode == MODE_COMPRESSOR) { - return GT_Recipe.GT_Recipe_Map.sCompressorRecipes; - } - else if (aMode == MODE_LATHE) { - return GT_Recipe.GT_Recipe_Map.sLatheRecipes; - } - else if (aMode == MODE_MAGNETIC) { - return GT_Recipe.GT_Recipe_Map.sPolarizerRecipes; - } - else if (aMode == MODE_FERMENTER) { - return GT_Recipe.GT_Recipe_Map.sFermentingRecipes; - } - else if (aMode == MODE_FLUIDEXTRACT) { - return GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes; - } - else if (aMode == MODE_EXTRACTOR) { - return GT_Recipe.GT_Recipe_Map.sExtractorRecipes; - } - else if (aMode == MODE_LASER) { - return GT_Recipe.GT_Recipe_Map.sLaserEngraverRecipes; - } - else if (aMode == MODE_AUTOCLAVE) { - return GT_Recipe.GT_Recipe_Map.sAutoclaveRecipes; - } - else if (aMode == MODE_FLUIDSOLIDIFY) { - return GT_Recipe.GT_Recipe_Map.sFluidSolidficationRecipes; - } - else { - return null; - } - } - - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - - // Based on the Processing Array. A bit overkill, but very flexible. - - // Get Circuit info for this recipe. - ItemStack tCircuit = getCircuit(aItemInputs); - int tCircuitID = getCircuitID(tCircuit); - - Logger.MACHINE_INFO("Mode: "+tCircuitID); - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe.GT_Recipe_Map tRecipeMap = this.getRecipeMap(tCircuit); - if (tRecipeMap == null) - return false; - GT_Recipe tRecipe = tRecipeMap.findRecipe( - getBaseMetaTileEntity(), this.mLastRecipeExtended[tCircuitID], false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - //this.mLastRecipe = tRecipe; //Let's not do this, it's bad. - //Instead, how about I use a array for types? - this.mLastRecipeExtended[tCircuitID] = tRecipe; - - if (tRecipe == null) { - Logger.MACHINE_INFO("BAD RETURN - 1|"+tCircuitID); - - if (aItemInputs.length > 0) { - Logger.MACHINE_INFO("Input Items: "+ItemUtils.getArrayStackNames(aItemInputs)); - } - if (aFluidInputs.length > 0) { - Logger.MACHINE_INFO("Input Fluids: "+ItemUtils.getFluidArrayStackNames(aFluidInputs)); - } - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - Logger.MACHINE_INFO("BAD RETURN - 2|"+tCircuitID); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - Logger.WARNING("parallelRecipes: "+parallelRecipes); - Logger.WARNING("aMaxParallelRecipes: "+aMaxParallelRecipes); - Logger.WARNING("tTotalEUt: "+tTotalEUt); - Logger.WARNING("tVoltage: "+tVoltage); - Logger.WARNING("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - Logger.WARNING("Broke at "+parallelRecipes+"."); - break; - } - Logger.WARNING("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - Logger.MACHINE_INFO("BAD RETURN - 3|"+tCircuitID); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - Logger.MACHINE_INFO("GOOD RETURN - 1|"+tCircuitID); - return true; - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (mInternalMode < 2) { - mInternalMode++; - } - else { - mInternalMode = 0; - } - String mModeString = (mInternalMode == 0 ? "Metal" : mInternalMode == 1 ? "Fluid" : mInternalMode == 2 ? "Misc." : "null"); - PlayerUtils.messagePlayer(aPlayer, "Multi-Machine is now in "+mModeString+" mode."); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mInternalMode", mInternalMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mInternalMode = aNBT.getInteger("mInternalMode"); - super.loadNBTData(aNBT); - } - - -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialMultiMachine + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + protected int mInternalMode = 0; + protected GT_Recipe[] mLastRecipeExtended = new GT_Recipe[9]; + private static final int MODE_COMPRESSOR = 0; + private static final int MODE_LATHE = 1; + private static final int MODE_MAGNETIC = 2; + private static final int MODE_FERMENTER = 3; + private static final int MODE_FLUIDEXTRACT = 4; + private static final int MODE_EXTRACTOR = 5; + private static final int MODE_LASER = 6; + private static final int MODE_AUTOCLAVE = 7; + private static final int MODE_FLUIDSOLIDIFY = 8; + private static final int[][] MODE_MAP = new int[][] {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}}; + public static final String[] aToolTipNames = new String[9]; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + static { + for (int id = 0; id < 9; id++) { + GT_Recipe.GT_Recipe_Map recipeMap = getRecipeMap(id); + if (recipeMap != null) { + String aNEI = GT_LanguageManager.getTranslation(getRecipeMap(id).mNEIName); + aToolTipNames[id] = aNEI != null ? aNEI : "BAD NEI NAME (Report to Github)"; + } + } + } + + public GregtechMetaTileEntity_IndustrialMultiMachine( + final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialMultiMachine(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMultiMachine(this.mName); + } + + @Override + public String getMachineType() { + return "Nine in One"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + String[] aBuiltStrings = new String[3]; + aBuiltStrings[0] = aToolTipNames[0] + ", " + aToolTipNames[1] + ", " + aToolTipNames[2]; + aBuiltStrings[1] = aToolTipNames[3] + ", " + aToolTipNames[4] + ", " + aToolTipNames[5]; + aBuiltStrings[2] = aToolTipNames[6] + ", " + aToolTipNames[7] + ", " + aToolTipNames[8]; + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Multi-Machine") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Only uses 80% of the EU/t normally required") + .addInfo("Processes two items per voltage tier") + .addInfo("Machine Type: [A] - " + EnumChatFormatting.YELLOW + aBuiltStrings[0] + + EnumChatFormatting.RESET) + .addInfo("Machine Type: [B] - " + EnumChatFormatting.YELLOW + aBuiltStrings[1] + + EnumChatFormatting.RESET) + .addInfo("Machine Type: [C] - " + EnumChatFormatting.YELLOW + aBuiltStrings[2] + + EnumChatFormatting.RESET) + .addInfo("Read Multi-Machine Manual for extra information") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Multi-Use Casings", 6) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialMultiMachine.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(getTextureIndex()) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return getTextureIndex(); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + ArrayList tFluids = getStoredFluids(); + // Logger.MACHINE_INFO("1"); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tBusItems = new ArrayList(); + tBus.mRecipeMap = getRecipeMap(); + // Logger.MACHINE_INFO("2"); + if (isValidMetaTileEntity(tBus)) { + // Logger.MACHINE_INFO("3"); + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + + boolean aFoundCircuitInBus = false; + for (ItemStack aBusItem : tBusItems) { + if (ItemUtils.isControlCircuit(aBusItem)) { + aFoundCircuitInBus = true; + } + } + if (!aFoundCircuitInBus) { + continue; + } + + Object[] tempArray = tFluids.toArray(new FluidStack[] {}); + FluidStack[] properArray; + properArray = + ((tempArray != null && tempArray.length > 0) ? (FluidStack[]) tempArray : new FluidStack[] {}); + + // Logger.MACHINE_INFO("4"); + if (checkRecipeGeneric( + tBusItems.toArray(new ItemStack[] {}), + properArray, + (2 * GT_Utility.getTier(this.getMaxInputVoltage())), + 80, + 250, + 10000)) return true; + } + return false; + + // return checkRecipeGeneric(2*GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); + } + + @Override + public int getMaxParallelRecipes() { + return (2 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 80; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (mInternalMode == 0) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal; + } else if (mInternalMode == 1) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid; + } else { // config 2 + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc; + } + } + + public int getTextureIndex() { + return TAE.getIndexFromPage(2, 2); + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private ItemStack getCircuit(ItemStack[] t) { + for (ItemStack j : t) { + if (j.getItem() == CI.getNumberedCircuit(0).getItem()) { + if (j.getItemDamage() >= 20 && j.getItemDamage() <= 22) { + return j; + } + } + } + return null; + } + + private final int getCircuitID(ItemStack circuit) { + int H = circuit.getItemDamage(); + int T = (H == 20 ? 0 : (H == 21 ? 1 : (H == 22 ? 2 : -1))); + return MODE_MAP[this.mInternalMode][T]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + private final GT_Recipe.GT_Recipe_Map getRecipeMap(ItemStack circuit) { + return getRecipeMap(getCircuitID(circuit)); + } + + private static final GT_Recipe.GT_Recipe_Map getRecipeMap(int aMode) { + if (aMode == MODE_COMPRESSOR) { + return GT_Recipe.GT_Recipe_Map.sCompressorRecipes; + } else if (aMode == MODE_LATHE) { + return GT_Recipe.GT_Recipe_Map.sLatheRecipes; + } else if (aMode == MODE_MAGNETIC) { + return GT_Recipe.GT_Recipe_Map.sPolarizerRecipes; + } else if (aMode == MODE_FERMENTER) { + return GT_Recipe.GT_Recipe_Map.sFermentingRecipes; + } else if (aMode == MODE_FLUIDEXTRACT) { + return GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes; + } else if (aMode == MODE_EXTRACTOR) { + return GT_Recipe.GT_Recipe_Map.sExtractorRecipes; + } else if (aMode == MODE_LASER) { + return GT_Recipe.GT_Recipe_Map.sLaserEngraverRecipes; + } else if (aMode == MODE_AUTOCLAVE) { + return GT_Recipe.GT_Recipe_Map.sAutoclaveRecipes; + } else if (aMode == MODE_FLUIDSOLIDIFY) { + return GT_Recipe.GT_Recipe_Map.sFluidSolidficationRecipes; + } else { + return null; + } + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Get Circuit info for this recipe. + ItemStack tCircuit = getCircuit(aItemInputs); + int tCircuitID = getCircuitID(tCircuit); + + Logger.MACHINE_INFO("Mode: " + tCircuitID); + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + + GT_Recipe.GT_Recipe_Map tRecipeMap = this.getRecipeMap(tCircuit); + if (tRecipeMap == null) return false; + GT_Recipe tRecipe = tRecipeMap.findRecipe( + getBaseMetaTileEntity(), + this.mLastRecipeExtended[tCircuitID], + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + // Remember last recipe - an optimization for findRecipe() + // this.mLastRecipe = tRecipe; //Let's not do this, it's bad. + // Instead, how about I use a array for types? + this.mLastRecipeExtended[tCircuitID] = tRecipe; + + if (tRecipe == null) { + Logger.MACHINE_INFO("BAD RETURN - 1|" + tCircuitID); + + if (aItemInputs.length > 0) { + Logger.MACHINE_INFO("Input Items: " + ItemUtils.getArrayStackNames(aItemInputs)); + } + if (aFluidInputs.length > 0) { + Logger.MACHINE_INFO("Input Fluids: " + ItemUtils.getFluidArrayStackNames(aFluidInputs)); + } + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.MACHINE_INFO("BAD RETURN - 2|" + tCircuitID); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + Logger.WARNING("parallelRecipes: " + parallelRecipes); + Logger.WARNING("aMaxParallelRecipes: " + aMaxParallelRecipes); + Logger.WARNING("tTotalEUt: " + tTotalEUt); + Logger.WARNING("tVoltage: " + tVoltage); + Logger.WARNING("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + Logger.WARNING("Broke at " + parallelRecipes + "."); + break; + } + Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.MACHINE_INFO("BAD RETURN - 3|" + tCircuitID); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.MACHINE_INFO("GOOD RETURN - 1|" + tCircuitID); + return true; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (mInternalMode < 2) { + mInternalMode++; + } else { + mInternalMode = 0; + } + String mModeString = + (mInternalMode == 0 ? "Metal" : mInternalMode == 1 ? "Fluid" : mInternalMode == 2 ? "Misc." : "null"); + PlayerUtils.messagePlayer(aPlayer, "Multi-Machine is now in " + mModeString + " mode."); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mInternalMode", mInternalMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mInternalMode = aNBT.getInteger("mInternalMode"); + super.loadNBTData(aNBT); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java index 7f826575cc..a5d009f7b1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java @@ -1,6 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -20,214 +24,214 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialPlatePress extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private boolean mFormingMode = false; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialPlatePress(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); - } - - @Override - public String getMachineType() { - return "Bending Machine, Forming Press"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for Advanced Bending & Forming") - .addInfo("500% faster than using single block machines of the same voltage") - .addInfo("Processes four items per voltage tier") - .addInfo("Circuit for recipe goes in the Input Bus") - .addInfo("Each Input Bus can have a different Circuit/Shape!") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo("Material Press Machine Casings", 10) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialPlatePress.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(50) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 4))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(203); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return 50; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "MaterialPress"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return mFormingMode ? GT_Recipe.GT_Recipe_Map.sPressRecipes : GT_Recipe.GT_Recipe_Map.sBenderRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tBusItems = new ArrayList(); - tBus.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - - if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), new FluidStack[]{}, - (4* GT_Utility.getTier(this.getMaxInputVoltage())), 100, 500, 10000)) return true; - } - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - if (this.mFormingMode) return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeForming; - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeBending; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mFormingMode", mFormingMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFormingMode = aNBT.getBoolean("mFormingMode"); - super.loadNBTData(aNBT); - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mFormingMode = Utils.invertBoolean(mFormingMode); - if (mFormingMode){ - PlayerUtils.messagePlayer(aPlayer, "Now running in Forming Press Mode."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Now running in Bending Mode."); - } - } +public class GregtechMetaTileEntity_IndustrialPlatePress + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private boolean mFormingMode = false; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialPlatePress(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); + } + + @Override + public String getMachineType() { + return "Bending Machine, Forming Press"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for Advanced Bending & Forming") + .addInfo("500% faster than using single block machines of the same voltage") + .addInfo("Processes four items per voltage tier") + .addInfo("Circuit for recipe goes in the Input Bus") + .addInfo("Each Input Bus can have a different Circuit/Shape!") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Material Press Machine Casings", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialPlatePress.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(50) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 4)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(203); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return 50; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MaterialPress"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mFormingMode ? GT_Recipe.GT_Recipe_Map.sPressRecipes : GT_Recipe.GT_Recipe_Map.sBenderRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tBusItems = new ArrayList(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + + if (checkRecipeGeneric( + tBusItems.toArray(new ItemStack[] {}), + new FluidStack[] {}, + (4 * GT_Utility.getTier(this.getMaxInputVoltage())), + 100, + 500, + 10000)) return true; + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (this.mFormingMode) return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeForming; + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeBending; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mFormingMode", mFormingMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFormingMode = aNBT.getBoolean("mFormingMode"); + super.loadNBTData(aNBT); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mFormingMode = Utils.invertBoolean(mFormingMode); + if (mFormingMode) { + PlayerUtils.messagePlayer(aPlayer, "Now running in Forming Press Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Now running in Bending Mode."); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java index 74d0a63aed..bd62bb495f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java @@ -1,6 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.Random; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -17,201 +21,199 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.Random; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialSifter extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialSifter(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialSifter(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialSifter(this.mName); - } - - @Override - public String getMachineType() { - return "Sifter"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Sifter") - .addInfo("400% faster than single-block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes four items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 3, 5, false) - .addController("Bottom Center") - .addCasingInfo("Sieve Grate", 18) - .addCasingInfo("Sieve Casings", 35) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing (x4)", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC"}, - {"CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC"}, - {"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialSifter.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(TAE.GTPP_INDEX(21)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 5))) - ) - .addElement( - 'M', - ofBlock( - ModBlocks.blockCasings2Misc, 6 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 2, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 2, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 2, 2, 0) && mCasing >= 35 && mOutputBusses.size() >= 4 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(21); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialSifter"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sSifterRecipes; - } - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - if (tRandom.nextFloat() > 0.4) return; - - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", - (aBaseMetaTileEntity.getXCoord() + xDir + 2.1F) - (tRandom.nextFloat() * 3.2F), - aBaseMetaTileEntity.getYCoord() + 2.5f + (tRandom.nextFloat() * 1.2F), - (aBaseMetaTileEntity.getZCoord() + zDir + 2.1F) - (tRandom.nextFloat() * 3.2F), - 0.0, 0.0, 0.0); - - } - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((4* GT_Utility.getTier(this.getMaxInputVoltage())), 75, 400, 10000); - } - - @Override - protected boolean doesMachineBoostOutput() { - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialSifter; - } - - @Override - public int getAmountOfOutputs() { - return 16; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return true; - } +public class GregtechMetaTileEntity_IndustrialSifter + extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialSifter(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialSifter(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialSifter(this.mName); + } + + @Override + public String getMachineType() { + return "Sifter"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Sifter") + .addInfo("400% faster than single-block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 3, 5, false) + .addController("Bottom Center") + .addCasingInfo("Sieve Grate", 18) + .addCasingInfo("Sieve Casings", 35) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing (x4)", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC"}, + {"CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC"}, + {"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialSifter.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(TAE.GTPP_INDEX(21)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 5)))) + .addElement('M', ofBlock(ModBlocks.blockCasings2Misc, 6)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 2, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 2, 0) && mCasing >= 35 && mOutputBusses.size() >= 4 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(21); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialSifter"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sSifterRecipes; + } + + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) + && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) + && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + if (tRandom.nextFloat() > 0.4) return; + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "smoke", + (aBaseMetaTileEntity.getXCoord() + xDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + aBaseMetaTileEntity.getYCoord() + 2.5f + (tRandom.nextFloat() * 1.2F), + (aBaseMetaTileEntity.getZCoord() + zDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + 0.0, + 0.0, + 0.0); + } + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 75, 400, 10000); + } + + @Override + protected boolean doesMachineBoostOutput() { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialSifter; + } + + @Override + public int getAmountOfOutputs() { + return 16; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSinter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSinter.java index 5a62c6c335..91698e4a0c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSinter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSinter.java @@ -1,30 +1,6 @@ /* package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -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 gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_MultiBlockBase { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java index 4e4e5009fc..08758e22bb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java @@ -1,5 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -20,203 +27,173 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialThermalCentrifuge extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialThermalCentrifuge(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialThermalCentrifuge(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialThermalCentrifuge(this.mName); - } - - @Override - public String getMachineType() { - return "Thermal Centrifuge"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Thermal Centrifuge") - .addInfo("150% faster than using single block machines of the same voltage") - .addInfo("Only uses 80% of the EU/t normally required") - .addInfo("Processes eight items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 2, 3, false) - .addController("Front Center") - .addCasingInfo("Thermal Processing Casings/Noise Hazard Sign Blocks", 8) - .addInputBus("Bottom Casing", 1) - .addOutputBus("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .addMufflerHatch("Bottom Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"X~X", "XXX", "XXX"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IndustrialThermalCentrifuge.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasings2Misc, 0 - ) - ), - onElementPass( - x -> ++x.mCasing, - ofBlock( - GregTech_API.sBlockCasings3, 9 - ) - ) - ) - ) - .addElement( - 'X', - ofChain( - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasings2Misc, 0 - ) - ), - onElementPass( - x -> ++x.mCasing, - ofBlock( - GregTech_API.sBlockCasings3, 9 - ) - ) - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 0, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 0, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 0, 0) && mCasing >= 8 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialThermalCentrifuge"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((8* GT_Utility.getTier(this.getMaxInputVoltage())), 80, 150); - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 80; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta() { - return 0; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(16); - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialThermalCentrifuge + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialThermalCentrifuge( + final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialThermalCentrifuge(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialThermalCentrifuge(this.mName); + } + + @Override + public String getMachineType() { + return "Thermal Centrifuge"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Thermal Centrifuge") + .addInfo("150% faster than using single block machines of the same voltage") + .addInfo("Only uses 80% of the EU/t normally required") + .addInfo("Processes eight items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 2, 3, false) + .addController("Front Center") + .addCasingInfo("Thermal Processing Casings/Noise Hazard Sign Blocks", 8) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addMufflerHatch("Bottom Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"X~X", "XXX", "XXX"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_IndustrialThermalCentrifuge.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings3, 9)))) + .addElement( + 'X', + ofChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings3, 9)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 0, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 0, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 0, 0) && mCasing >= 8 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureIndex(); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialThermalCentrifuge"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((8 * GT_Utility.getTier(this.getMaxInputVoltage())), 80, 150); + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 80; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(16); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java index 3f94e4d647..283942ff6d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -1,6 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -19,247 +24,244 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - public static String mCryoFuelName = "Gelid Cryotheum"; - public static String mCasingName = "Advanced Cryogenic Casing"; - public static String mHatchName = "Cryotheum Hatch"; - public static FluidStack mFuelStack; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - private final ArrayList mCryotheumHatches = new ArrayList<>(); - - - public GregtechMetaTileEntity_IndustrialVacuumFreezer(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); - } - - public GregtechMetaTileEntity_IndustrialVacuumFreezer(final String aName) { - super(aName); - mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); - } - - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return (IMetaTileEntity) new GregtechMetaTileEntity_IndustrialVacuumFreezer(this.mName); - } - - @Override - public String getMachineType() { - return "Vacuum Freezer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Advanced Vacuum Freezer") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 4") - .addInfo("Consumes 1L of " + mCryoFuelName + "/t during operation") - .addInfo("Constructed exactly the same as a normal Vacuum Freezer") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo(mCasingName, 10) - .addStructureHint(mHatchName, 1) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IndustrialVacuumFreezer.class) - .adder(GregtechMetaTileEntity_IndustrialVacuumFreezer::addCryotheumHatch) - .hatchId(967) - .shouldReject(t -> !t.mCryotheumHatches.isEmpty()) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_IndustrialVacuumFreezer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasings3Misc, 10 - ) - ) - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mCryotheumHatches.clear(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - public boolean checkHatch() { - return super.checkHatch() && !mCryotheumHatches.isEmpty(); - } - - private boolean addCryotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 967) { - return addToMachineListInternal(mCryotheumHatches, aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public void updateSlots() { - for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mCryotheumHatches) - if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); - super.updateSlots(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "VacuumFreezer"; - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT; - } - - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - public boolean checkRecipe(final ItemStack aStack) { - return this.checkRecipeGeneric(4, 100, 100); - } - - @Override - public int getMaxParallelRecipes() { - return 4; - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialVacuumFreezer; - } - - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - private int mGraceTimer = 2; - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - /*if (this.getBaseMetaTileEntity().isActive()) { - if (!this.depleteInput(mFuelStack.copy())) { - this.getBaseMetaTileEntity().setActive(false); - } - } */ - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (this.mStartUpCheck < 0) { - if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - if (!this.depleteInputFromRestrictedHatches(this.mCryotheumHatches, 10)) { - if (mGraceTimer-- == 0) { - this.causeMaintenanceIssue(); - this.stopMachine(); - mGraceTimer = 2; - } - } - } - } - } - } -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialVacuumFreezer + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + public static String mCryoFuelName = "Gelid Cryotheum"; + public static String mCasingName = "Advanced Cryogenic Casing"; + public static String mHatchName = "Cryotheum Hatch"; + public static FluidStack mFuelStack; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + private final ArrayList mCryotheumHatches = new ArrayList<>(); + + public GregtechMetaTileEntity_IndustrialVacuumFreezer( + final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); + } + + public GregtechMetaTileEntity_IndustrialVacuumFreezer(final String aName) { + super(aName); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GregtechMetaTileEntity_IndustrialVacuumFreezer(this.mName); + } + + @Override + public String getMachineType() { + return "Vacuum Freezer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Vacuum Freezer") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 4") + .addInfo("Consumes 1L of " + mCryoFuelName + "/t during operation") + .addInfo("Constructed exactly the same as a normal Vacuum Freezer") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo(mCasingName, 10) + .addStructureHint(mHatchName, 1) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_IndustrialVacuumFreezer.class) + .adder(GregtechMetaTileEntity_IndustrialVacuumFreezer::addCryotheumHatch) + .hatchId(967) + .shouldReject(t -> !t.mCryotheumHatches.isEmpty()) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + buildHatchAdder(GregtechMetaTileEntity_IndustrialVacuumFreezer.class) + .atLeast( + InputBus, + OutputBus, + Maintenance, + Energy, + Muffler, + InputHatch, + OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 10)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mCryotheumHatches.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + public boolean checkHatch() { + return super.checkHatch() && !mCryotheumHatches.isEmpty(); + } + + private boolean addCryotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase + && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 967) { + return addToMachineListInternal(mCryotheumHatches, aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void updateSlots() { + for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mCryotheumHatches) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + super.updateSlots(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "VacuumFreezer"; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT; + } + + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + public boolean checkRecipe(final ItemStack aStack) { + return this.checkRecipeGeneric(4, 100, 100); + } + + @Override + public int getMaxParallelRecipes() { + return 4; + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialVacuumFreezer; + } + + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private int mGraceTimer = 2; + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + /*if (this.getBaseMetaTileEntity().isActive()) { + if (!this.depleteInput(mFuelStack.copy())) { + this.getBaseMetaTileEntity().setActive(false); + } + } */ + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (this.mStartUpCheck < 0) { + if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 + || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (!this.depleteInputFromRestrictedHatches(this.mCryotheumHatches, 10)) { + if (mGraceTimer-- == 0) { + this.causeMaintenanceIssue(); + this.stopMachine(); + mGraceTimer = 2; + } + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java index a63ffa36cd..7af022fffc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java @@ -1,5 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -31,314 +37,309 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialWashPlant extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mMode = 0; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialWashPlant(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialWashPlant(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialWashPlant(this.mName); - } - - @Override - public String getMachineType() { - return "Ore Washer, Simple Washer, Chemical Bath"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Wash Plant") - .addInfo("Can be configured with a screwdriver to also do Simple Washer and process Chemical Bathing") - .addInfo("400% faster than using single block machines of the same voltage") - .addInfo("Processes four item per voltage tier") - .addInfo("Always requires an Input Hatch full of water to refill structure") - .addInfo("Need to be filled with water.") - .addInfo("Will automatically fill water from input hatch.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 3, 7, true) - .addController("Front Center") - .addCasingInfo("Wash Plant Casings", 40) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCCCC", "C C", "C C", "C C", "C C", "C C", "CCCCC"}, - {"CC~CC", "C C", "C C", "C C", "C C", "C C", "CCCCC"}, - {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialWashPlant.class) - .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 2, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 2, 1, 0) && mCasing >= 40 && checkHatch(); - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // don't rotate a washer, water will flow out. - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialWashPlant"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return mMode == 0 ? GT_Recipe.GT_Recipe_Map.sOreWasherRecipes : mMode == 1 ? GTPP_Recipe_Map.sSimpleWasherRecipes : GT_Recipe.GT_Recipe_Map.sChemicalBathRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - if (checkForWater()) { - return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 100, 400); - } - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (4* GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - if (mMode == 2) return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath; - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeWasher; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - - public byte getCasingMeta() { - return 4; - } - - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(11); - } - - public boolean checkForWater() { - - //Get Facing direction - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - if (mDirectionX == 0){ - mCurrentDirectionX = 2; - mCurrentDirectionZ = 3; - mOffsetX_Lower = -2; - mOffsetX_Upper = 2; - mOffsetZ_Lower = -3; - mOffsetZ_Upper = 3; - } - else { - mCurrentDirectionX = 3; - mCurrentDirectionZ = 2; - mOffsetX_Lower = -3; - mOffsetX_Upper = 3; - mOffsetZ_Lower = -2; - mOffsetZ_Upper = 2; - } - - //if (aBaseMetaTileEntity.fac) - - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * mCurrentDirectionX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * mCurrentDirectionZ; - - int tAmount = 0; - for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { - for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { - for (int h = 0; h < 2; ++h) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == Blocks.water) { - if (this.getStoredFluids() != null) { - for (FluidStack stored : this.getStoredFluids()) { - if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { - if (stored.amount >= 1000) { - //Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); - stored.amount -= 1000; - Block fluidUsed = null; - if (tBlock == Blocks.air || tBlock == Blocks.flowing_water) { - fluidUsed = Blocks.water; - } - if (tBlock == Blocks.water) { - fluidUsed = BlocksItems.getFluidBlock(InternalName.fluidDistilledWater); - } - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord() + xDir + i, aBaseMetaTileEntity.getYCoord() + h, aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); - - - } - } - } - } - } - if (tBlock == Blocks.water) { - ++tAmount; - //Utils.LOG_WARNING("Found Water"); - } else if (tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { - ++tAmount; - ++tAmount; - //Utils.LOG_WARNING("Found Distilled Water"); - } - } - } - } - - boolean isValidWater = tAmount >= 45; - if (isValidWater){ - Logger.WARNING("Filled structure."); - } - else { - Logger.WARNING("Did not fill structure."); - } - return isValidWater; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mMode", mMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mChemicalMode")) { - boolean aTempMode = aNBT.getBoolean("mChemicalMode"); - if (aTempMode) { - mMode = 2; - } - else { - mMode = 0; - } - aNBT.removeTag("mChemicalMode"); - } - if (aNBT.hasKey("mMode")) { - mMode = aNBT.getInteger("mMode"); - } - super.loadNBTData(aNBT); - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mMode++; - if (mMode > 2) { - mMode = 0; - } - if (mMode == 0){ - PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Ore Washer Mode."); - } - else if (mMode == 1){ - PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Simple Washer Mode."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Chemical Bath Mode."); - } - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialWashPlant + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mMode = 0; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialWashPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialWashPlant(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWashPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Ore Washer, Simple Washer, Chemical Bath"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Wash Plant") + .addInfo("Can be configured with a screwdriver to also do Simple Washer and process Chemical Bathing") + .addInfo("400% faster than using single block machines of the same voltage") + .addInfo("Processes four item per voltage tier") + .addInfo("Always requires an Input Hatch full of water to refill structure") + .addInfo("Need to be filled with water.") + .addInfo("Will automatically fill water from input hatch.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 3, 7, true) + .addController("Front Center") + .addCasingInfo("Wash Plant Casings", 40) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCCCC", "C C", "C C", "C C", "C C", "C C", "CCCCC"}, + {"CC~CC", "C C", "C C", "C C", "C C", "C C", "CCCCC"}, + {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialWashPlant.class) + .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 1, 0) && mCasing >= 40 && checkHatch(); + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a washer, water will flow out. + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureIndex(); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialWashPlant"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mMode == 0 + ? GT_Recipe.GT_Recipe_Map.sOreWasherRecipes + : mMode == 1 ? GTPP_Recipe_Map.sSimpleWasherRecipes : GT_Recipe.GT_Recipe_Map.sChemicalBathRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + if (checkForWater()) { + return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 100, 400); + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (mMode == 2) return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath; + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeWasher; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 4; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(11); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + if (mDirectionX == 0) { + mCurrentDirectionX = 2; + mCurrentDirectionZ = 3; + mOffsetX_Lower = -2; + mOffsetX_Upper = 2; + mOffsetZ_Lower = -3; + mOffsetZ_Upper = 3; + } else { + mCurrentDirectionX = 3; + mCurrentDirectionZ = 2; + mOffsetX_Lower = -3; + mOffsetX_Upper = 3; + mOffsetZ_Lower = -2; + mOffsetZ_Upper = 2; + } + + // if (aBaseMetaTileEntity.fac) + + final int xDir = + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * mCurrentDirectionX; + final int zDir = + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; ++h) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == Blocks.water) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = null; + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water) { + fluidUsed = Blocks.water; + } + if (tBlock == Blocks.water) { + fluidUsed = BlocksItems.getFluidBlock(InternalName.fluidDistilledWater); + } + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + fluidUsed); + } + } + } + } + } + if (tBlock == Blocks.water) { + ++tAmount; + // Utils.LOG_WARNING("Found Water"); + } else if (tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + ++tAmount; + ++tAmount; + // Utils.LOG_WARNING("Found Distilled Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 45; + if (isValidWater) { + Logger.WARNING("Filled structure."); + } else { + Logger.WARNING("Did not fill structure."); + } + return isValidWater; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mMode", mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mChemicalMode")) { + boolean aTempMode = aNBT.getBoolean("mChemicalMode"); + if (aTempMode) { + mMode = 2; + } else { + mMode = 0; + } + aNBT.removeTag("mChemicalMode"); + } + if (aNBT.hasKey("mMode")) { + mMode = aNBT.getInteger("mMode"); + } + super.loadNBTData(aNBT); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mMode++; + if (mMode > 2) { + mMode = 0; + } + if (mMode == 0) { + PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Ore Washer Mode."); + } else if (mMode == 1) { + PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Simple Washer Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Chemical Bath Mode."); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java index c6292020f7..88a0a849dd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java @@ -1,5 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -20,176 +26,171 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialWireMill(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialWireMill(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); - } - - @Override - public String getMachineType() { - return "Wiremill"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Wire Factory") - .addInfo("200% faster than using single block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes four items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 5, true) - .addController("Front Center") - .addCasingInfo("Wire Factory Casings", 32) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC", "CCC", "CCC"}, - {"C~C", "C-C", "C-C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialWireMill.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 32 && checkHatch(); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(204); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(6); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "IndustrialWireFactory"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((4* GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); - } - - @Override - public int getMaxParallelRecipes() { - return (4* GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWireMill; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasingsMisc; - } - - public byte getCasingMeta() { - return 6; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(6); - } -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialWireMill + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialWireMill(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialWireMill(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); + } + + @Override + public String getMachineType() { + return "Wiremill"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Wire Factory") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfo("Wire Factory Casings", 32) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + {"C~C", "C-C", "C-C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialWireMill.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 32 && checkHatch(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(204); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(6); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialWireFactory"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWireMill; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + public byte getCasingMeta() { + return 6; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(6); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java index 5d6904bd46..439ab234cf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java @@ -1,12 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; @@ -18,386 +11,527 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_IronBlastFurnace; import gtPlusPlus.xmod.gregtech.api.gui.GUI_IronBlastFurnace; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class GregtechMetaTileEntity_IronBlastFurnace -extends MetaTileEntity { - private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; - private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; - private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; - public int mMaxProgresstime = 0; - public int mUpdate = 30; - public int mProgresstime = 0; - public boolean mMachine = false; - public ItemStack mOutputItem1; - public ItemStack mOutputItem2; - - public GregtechMetaTileEntity_IronBlastFurnace(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 4); - } - - public GregtechMetaTileEntity_IronBlastFurnace(final String aName) { - super(aName, 4); - } - - @Override - public String[] getDescription() { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return new String[]{"Iron is a much better furnace material!", - "Can be Automated", - "Multiblock: 3x3x5 hollow with opening on top", - "Same shape as Bronze/Bricked blast furnace, except one ring of 8 taller.", - "40 Iron Plated Bricks required", - }; - } - else { - return new String[]{"Sloooowly, Skip the Bronze age, Get some Steel!", - "Multiblock: 3x3x5 hollow with opening on top", - "40 Iron Plated Bricks required", - "----", - "Even though Iron melts hotter than bronze,", - "this machine is to help players skip looking", - "for tin and copper, which are not as common", - "as Iron is. This machine takes 5x longer than the bronze", - "blast furnace as a result.", - "----", - }; - } - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return aActive ? FACING_ACTIVE : FACING_FRONT; - } - return FACING_SIDE; - } - - @Override - public boolean isSteampowered() { - return false; - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public boolean isPneumatic() { - return false; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final byte aSide) { - return false; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public int getProgresstime() { - return this.mProgresstime; - } - - @Override - public int maxProgresstime() { - return this.mMaxProgresstime; - } - - @Override - public int increaseProgress(final int aProgress) { - this.mProgresstime += aProgress; - return this.mMaxProgresstime - this.mProgresstime; - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { - return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - if (this.mOutputItem1 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem1.writeToNBT(tNBT); - aNBT.setTag("mOutputItem1", tNBT); - } - if (this.mOutputItem2 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem2.writeToNBT(tNBT); - aNBT.setTag("mOutputItem2", tNBT); - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mUpdate = 30; - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); - this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - private boolean checkMachine() { - final int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 4; j++) { //This is height - for (int k = -1; k < 2; k++) { - if (((xDir + i) != 0) || (j != 0) || ((zDir + k) != 0)) { - if ((i != 0) || (j == -1) || (k != 0)) { - if ((this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != ModBlocks.blockCasingsMisc) || (this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { - return false; - } - } else if ((!GT_Utility.arrayContains(this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!this.getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { - return false; - } - } - } - } - } - return true; - } - - @Override - public void onMachineBlockUpdate() { - this.mUpdate = 30; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if ((aBaseMetaTileEntity.isClientSide()) && - (aBaseMetaTileEntity.isActive())) { - aBaseMetaTileEntity.getWorld().spawnParticle("cloud", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D); - } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate-- == 0) { - this.mMachine = this.checkMachine(); - } - if (this.mMachine) { - if (this.mMaxProgresstime > 0) { - if (++this.mProgresstime >= this.mMaxProgresstime) { - this.addOutputProducts(); - this.mOutputItem1 = null; - this.mOutputItem2 = null; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - try { - GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); - } catch (final Exception e) { - } - } - } else if (aBaseMetaTileEntity.isAllowedToWork()) { - this.checkRecipe(); - } - } - aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); - if (aBaseMetaTileEntity.isActive()) { - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - } else { - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - } - } - } - - private void addOutputProducts() { - if (this.mOutputItem1 != null) { - if (this.mInventory[2] == null) { - this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1}); - } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { - this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize); - } - } - if (this.mOutputItem2 != null) { - if (this.mInventory[3] == null) { - this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2}); - } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { - this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize); - } - } - } - - private boolean spaceForOutput(final ItemStack aStack1, final ItemStack aStack2) { - if (((this.mInventory[2] == null) || (aStack1 == null) || (((this.mInventory[2].stackSize + aStack1.stackSize) <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && ( - (this.mInventory[3] == null) || (aStack2 == null) || (((this.mInventory[3].stackSize + aStack2.stackSize) <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { - return true; - } - return false; - } - - private int getProperTime(int time) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return (int) (time/3); - } - else { - return time; - } - } - - private boolean checkRecipe() { - - if (!this.mMachine) { - return false; - } - if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = getProperTime(36000); - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = getProperTime(4800); - return true; - } - if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = getProperTime(64800); - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = getProperTime(3600); - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 1*3); - this.mMaxProgresstime = getProperTime(2400); - return true; - } - if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = getProperTime(32400); - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 64); - this.mMaxProgresstime = getProperTime(64800); - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 18*3); - this.mMaxProgresstime = getProperTime(43200); - return true; - } - if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = getProperTime(64800); - return true; - } - } - } - this.mOutputItem1 = null; - this.mOutputItem2 = null; - return false; - } - - @Override - public boolean isGivingInformation() { - return false; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return aIndex > 1; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - if (aIndex < 2) { - } - return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } +public class GregtechMetaTileEntity_IronBlastFurnace extends MetaTileEntity { + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) + }; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) + }; + public int mMaxProgresstime = 0; + public int mUpdate = 30; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + + public GregtechMetaTileEntity_IronBlastFurnace(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 4); + } + + public GregtechMetaTileEntity_IronBlastFurnace(final String aName) { + super(aName, 4); + } + + @Override + public String[] getDescription() { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return new String[] { + "Iron is a much better furnace material!", + "Can be Automated", + "Multiblock: 3x3x5 hollow with opening on top", + "Same shape as Bronze/Bricked blast furnace, except one ring of 8 taller.", + "40 Iron Plated Bricks required", + }; + } else { + return new String[] { + "Sloooowly, Skip the Bronze age, Get some Steel!", + "Multiblock: 3x3x5 hollow with opening on top", + "40 Iron Plated Bricks required", + "----", + "Even though Iron melts hotter than bronze,", + "this machine is to help players skip looking", + "for tin and copper, which are not as common", + "as Iron is. This machine takes 5x longer than the bronze", + "blast furnace as a result.", + "----", + }; + } + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return aActive ? FACING_ACTIVE : FACING_FRONT; + } + return FACING_SIDE; + } + + @Override + public boolean isSteampowered() { + return false; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return false; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return this.mProgresstime; + } + + @Override + public int maxProgresstime() { + return this.mMaxProgresstime; + } + + @Override + public int increaseProgress(final int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } + + @Override + public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) + && (super.allowCoverOnSide(aSide, aCoverID)); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", this.mProgresstime); + aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); + if (this.mOutputItem1 != null) { + final NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem1.writeToNBT(tNBT); + aNBT.setTag("mOutputItem1", tNBT); + } + if (this.mOutputItem2 != null) { + final NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem2.writeToNBT(tNBT); + aNBT.setTag("mOutputItem2", tNBT); + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mUpdate = 30; + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); + this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + private boolean checkMachine() { + final int xDir = + ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; + final int zDir = + ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 4; j++) { // This is height + for (int k = -1; k < 2; k++) { + if (((xDir + i) != 0) || (j != 0) || ((zDir + k) != 0)) { + if ((i != 0) || (j == -1) || (k != 0)) { + if ((this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) + != ModBlocks.blockCasingsMisc) + || (this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { + return false; + } + } else if ((!GT_Utility.arrayContains( + this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), + new Object[] {Blocks.lava, Blocks.flowing_lava, null})) + && (!this.getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { + return false; + } + } + } + } + } + return true; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 30; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + aBaseMetaTileEntity + .getWorld() + .spawnParticle( + "cloud", + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), + aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), + 0.0D, + 0.3D, + 0.0D); + } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate-- == 0) { + this.mMachine = this.checkMachine(); + } + if (this.mMachine) { + if (this.mMaxProgresstime > 0) { + if (++this.mProgresstime >= this.mMaxProgresstime) { + this.addOutputProducts(); + this.mOutputItem1 = null; + this.mOutputItem2 = null; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + try { + GT_Mod.instance.achievements.issueAchievement( + aBaseMetaTileEntity + .getWorld() + .getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), + "steel"); + } catch (final Exception e) { + } + } + } else if (aBaseMetaTileEntity.isAllowedToWork()) { + this.checkRecipe(); + } + } + aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); + if (aBaseMetaTileEntity.isActive()) { + if (aBaseMetaTileEntity.getAir( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.lava, + 1, + 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getAir( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.lava, + 1, + 2); + this.mUpdate = 1; + } + } else { + if (aBaseMetaTileEntity.getBlock( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) + == Blocks.lava) { + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.air, + 0, + 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getBlock( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) + == Blocks.lava) { + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.air, + 0, + 2); + this.mUpdate = 1; + } + } + } + } + + private void addOutputProducts() { + if (this.mOutputItem1 != null) { + if (this.mInventory[2] == null) { + this.mInventory[2] = GT_Utility.copy(new Object[] {this.mOutputItem1}); + } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { + this.mInventory[2].stackSize = Math.min( + this.mOutputItem1.getMaxStackSize(), + this.mOutputItem1.stackSize + this.mInventory[2].stackSize); + } + } + if (this.mOutputItem2 != null) { + if (this.mInventory[3] == null) { + this.mInventory[3] = GT_Utility.copy(new Object[] {this.mOutputItem2}); + } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { + this.mInventory[3].stackSize = Math.min( + this.mOutputItem2.getMaxStackSize(), + this.mOutputItem2.stackSize + this.mInventory[3].stackSize); + } + } + } + + private boolean spaceForOutput(final ItemStack aStack1, final ItemStack aStack2) { + if (((this.mInventory[2] == null) + || (aStack1 == null) + || (((this.mInventory[2].stackSize + aStack1.stackSize) <= this.mInventory[2].getMaxStackSize()) + && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) + && ((this.mInventory[3] == null) + || (aStack2 == null) + || (((this.mInventory[3].stackSize + aStack2.stackSize) <= this.mInventory[3].getMaxStackSize()) + && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { + return true; + } + return false; + } + + private int getProperTime(int time) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return (int) (time / 3); + } else { + return time; + } + } + + private boolean checkRecipe() { + + if (!this.mMachine) { + return false; + } + if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) + || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { + if ((this.mInventory[1].getItem() == Items.coal) + && (this.mInventory[1].stackSize >= 4) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); + this.mMaxProgresstime = getProperTime(36000); + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) + && (this.mInventory[1].stackSize >= 2) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); + this.mMaxProgresstime = getProperTime(4800); + return true; + } + if ((this.mInventory[0].stackSize >= 9) + && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) + || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) + && (this.mInventory[1].stackSize >= 4) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 9); + this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); + this.mMaxProgresstime = getProperTime(64800); + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { + if ((this.mInventory[1].getItem() == Items.coal) + && (this.mInventory[1].stackSize >= 2) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); + this.mMaxProgresstime = getProperTime(3600); + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) + && (this.mInventory[1].stackSize >= 1) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 1 * 3); + this.mMaxProgresstime = getProperTime(2400); + return true; + } + if ((this.mInventory[0].stackSize >= 9) + && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) + || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) + && (this.mInventory[1].stackSize >= 2) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 9); + this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); + this.mMaxProgresstime = getProperTime(32400); + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { + if ((this.mInventory[1].getItem() == Items.coal) + && (this.mInventory[1].stackSize >= 36) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 64); + this.mMaxProgresstime = getProperTime(64800); + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) + && (this.mInventory[1].stackSize >= 18) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), + this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 18 * 3); + this.mMaxProgresstime = getProperTime(43200); + return true; + } + if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) + || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) + && (this.mInventory[1].stackSize >= 4) + && (this.spaceForOutput( + this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), + this.mOutputItem2 = + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); + this.mMaxProgresstime = getProperTime(64800); + return true; + } + } + } + this.mOutputItem1 = null; + this.mOutputItem2 = null; + return false; + } + + @Override + public boolean isGivingInformation() { + return false; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex > 1; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + if (aIndex < 2) {} + return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); + } + + @Override + public byte getTileEntityBaseType() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java index 17687ff4c7..49713b3592 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java @@ -1,8 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -29,6 +33,9 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -41,661 +48,648 @@ import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected boolean boostEu = false; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - private static final IIconContainer frontFaceActive = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5"); - private static final IIconContainer frontFace = new CustomIcon("iconsets/Grinder/GRINDER5"); - - private final ArrayList mMillingBallBuses = new ArrayList(); - private static final DamageSource mIsaMillDamageSource = new DamageSource("gtpp.grinder").setDamageBypassesArmor(); - - public GregtechMetaTileEntity_IsaMill(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IsaMill(String aName) { - super(aName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Large Grinding Machine") - .addInfo("Grind ores.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 7, false) - .addController("Front Center") - .addCasingInfo("IsaMill Exterior Casing", 40) +public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + protected boolean boostEu = false; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + private static final IIconContainer frontFaceActive = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5"); + private static final IIconContainer frontFace = new CustomIcon("iconsets/Grinder/GRINDER5"); + + private final ArrayList mMillingBallBuses = + new ArrayList(); + private static final DamageSource mIsaMillDamageSource = new DamageSource("gtpp.grinder").setDamageBypassesArmor(); + + public GregtechMetaTileEntity_IsaMill(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IsaMill(String aName) { + super(aName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Grinding Machine") + .addInfo("Grind ores.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 7, false) + .addController("Front Center") + .addCasingInfo("IsaMill Exterior Casing", 40) .addOtherStructurePart("IsaMill Gearbox", "5x, Inner Blocks") .addOtherStructurePart("IsaMill Piping", "8x, ring around controller") .addStructureInfo("IsaMill Pipings must not be obstructed in front (only air blocks)") - .addOtherStructurePart("Milling Ball Hatch", "Any Casing") - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC"}, - {"D~D", "CGC", "CGC", "CGC", "CGC", "CGC", "CCC"}, - {"DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IsaMill.class) - .adder(GregtechMetaTileEntity_IsaMill::addMillingBallsHatch) - .hatchClass(GT_MetaTileEntity_Hatch_MillingBalls.class) - .shouldReject(t -> !t.mMillingBallBuses.isEmpty()) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_IsaMill.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - getCasingBlock(), getCasingMeta() - ) - ) - ) - ) - .addElement( - 'D', - ofBlock( - getIntakeBlock(), getIntakeMeta() - ) - ) - .addElement( - 'G', - ofBlock( - getGearboxBlock(), getGearboxMeta() - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mMillingBallBuses.clear(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 48 - 8 && checkHatch(); - } - - @Override - public boolean checkHatch() { - return super.checkHatch() && mMillingBallBuses.size() == 1; - } - - @Override - protected IIconContainer getActiveOverlay() { - return frontFaceActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return frontFace; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(2); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return getMaxEfficiency(aStack) > 0; - } - - private boolean addMillingBallsHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { - return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { - log("Found GT_MetaTileEntity_Hatch_MillingBalls"); - return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); - } - return super.addToMachineList(aTileEntity, aBaseCasingIndex); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sOreMillRecipes; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mMillingBallBuses.clear(); - } - } - if (aTick % 20 == 0) { - checkForEntities(aBaseMetaTileEntity, aTick); - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - private final AutoMap mFrontBlockPosCache = new AutoMap(); - - public void checkForEntities(IGregTechTileEntity aBaseMetaTileEntity, long aTime) { - - if (aTime % 100 == 0) { - mFrontBlockPosCache.clear(); - } - if (mFrontBlockPosCache.isEmpty()) { - byte tSide = aBaseMetaTileEntity.getBackFacing(); - int aTileX = aBaseMetaTileEntity.getXCoord(); - int aTileY = aBaseMetaTileEntity.getYCoord(); - int aTileZ = aBaseMetaTileEntity.getZCoord(); - boolean xFacing = (tSide == 4 || tSide == 5); - boolean zFacing = (tSide == 2 || tSide == 3); - - // Check Casings - int aDepthOffset = (tSide == 2 || tSide == 4) ? 1 : -1; - for (int aHorizontalOffset = -1; aHorizontalOffset < 2; aHorizontalOffset++) { - for (int aVerticalOffset = -1; aVerticalOffset < 2; aVerticalOffset++) { - int aX = !xFacing ? (aTileX + aHorizontalOffset) : (aTileX + aDepthOffset); - int aY = aTileY + aVerticalOffset; - int aZ = !zFacing ? (aTileZ + aHorizontalOffset) : (aTileZ + aDepthOffset); - mFrontBlockPosCache.add(new BlockPos(aX, aY, aZ, aBaseMetaTileEntity.getWorld())); - } - } - } - - AutoMap aEntities = getEntities(mFrontBlockPosCache, aBaseMetaTileEntity.getWorld()); - if (!aEntities.isEmpty()) { - for (EntityLivingBase aFoundEntity : aEntities) { - if (aFoundEntity instanceof EntityPlayer) { - EntityPlayer aPlayer = (EntityPlayer) aFoundEntity; - if (PlayerUtils.isCreative(aPlayer) || !PlayerUtils.canTakeDamage(aPlayer)) { - continue; - } - else { - if (aFoundEntity.getHealth() > 0) { - EntityUtils.doDamage(aFoundEntity, mIsaMillDamageSource, (int) (aFoundEntity.getMaxHealth() / 5)); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { - generateParticles(aFoundEntity); - } - } - } - } - if (aFoundEntity.getHealth() > 0) { - EntityUtils.doDamage(aFoundEntity, mIsaMillDamageSource, Math.max(1, (int) (aFoundEntity.getMaxHealth() / 3))); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { - generateParticles(aFoundEntity); - } - } - } - } - } - - private static final AutoMap getEntities(AutoMap aPositionsToCheck, World aWorld){ - AutoMap aEntities = new AutoMap(); - HashSet aChunksToCheck = new HashSet(); - if (!aPositionsToCheck.isEmpty()) { - Chunk aLocalChunk; - for (BlockPos aPos : aPositionsToCheck) { - aLocalChunk = aWorld.getChunkFromBlockCoords(aPos.xPos, aPos.zPos); - aChunksToCheck.add(aLocalChunk); - } - } - if (!aChunksToCheck.isEmpty()) { - AutoMap aEntitiesFound = new AutoMap(); - for (Chunk aChunk : aChunksToCheck) { - if (aChunk.isChunkLoaded) { - List[] aEntityLists = aChunk.entityLists; - for (List aEntitySubList : aEntityLists) { - for (Object aEntity : aEntitySubList) { - if (aEntity instanceof EntityLivingBase) { - EntityLivingBase aPlayer = (EntityLivingBase) aEntity; - aEntitiesFound.add(aPlayer); - } - } - } - } - } - if (!aEntitiesFound.isEmpty()) { - for (EntityLivingBase aEntity : aEntitiesFound) { - BlockPos aPlayerPos = EntityUtils.findBlockPosOfEntity(aEntity); - for (BlockPos aBlockSpaceToCheck : aPositionsToCheck) { - if (aBlockSpaceToCheck.equals(aPlayerPos)) { - aEntities.add(aEntity); - } - } - } - } - } - return aEntities; - } - - private static void generateParticles(EntityLivingBase aEntity) { - BlockPos aPlayerPosBottom = EntityUtils.findBlockPosOfEntity(aEntity); - BlockPos aPlayerPosTop = aPlayerPosBottom.getUp(); - AutoMap aEntityPositions = new AutoMap(); - aEntityPositions.add(aPlayerPosBottom); - aEntityPositions.add(aPlayerPosTop); - for (int i = 0; i < 64; i++) { - BlockPos aEffectPos = aEntityPositions.get(aEntity.height > 1f ? MathUtils.randInt(0, 1) : 0); - float aOffsetX = MathUtils.randFloat(-0.35f, 0.35f); - float aOffsetY = MathUtils.randFloat(-0.25f, 0.35f); - float aOffsetZ = MathUtils.randFloat(-0.35f, 0.35f); - aEntity.worldObj.spawnParticle("reddust", aEffectPos.xPos + aOffsetX, aEffectPos.yPos + 0.3f + aOffsetY, aEffectPos.zPos + aOffsetZ, 0.0D, 0.0D, 0.0D); - } - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - return checkRecipeGeneric(); - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings5Misc; - } - - public byte getCasingMeta() { - return 0; - } - - public Block getIntakeBlock() { - return ModBlocks.blockCasings5Misc; - } - - public byte getIntakeMeta() { - return 1; - } - - public Block getGearboxBlock() { - return ModBlocks.blockCasings5Misc; - } - - public byte getGearboxMeta() { - return 2; - } - - public byte getCasingTextureIndex() { - return 66; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IsaMill(this.mName); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIsaMill; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public String[] getExtraInfoData() { - return new String[]{ - "IsaMill Grinding Machine", - "Current Efficiency: " + (mEfficiency / 100) + "%", - getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" - }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Grinding Machine"; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - /* - * Milling Ball Handling - */ - - @Override + .addOtherStructurePart("Milling Ball Hatch", "Any Casing") + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC"}, + {"D~D", "CGC", "CGC", "CGC", "CGC", "CGC", "CCC"}, + {"DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_IsaMill.class) + .adder(GregtechMetaTileEntity_IsaMill::addMillingBallsHatch) + .hatchClass(GT_MetaTileEntity_Hatch_MillingBalls.class) + .shouldReject(t -> !t.mMillingBallBuses.isEmpty()) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + buildHatchAdder(GregtechMetaTileEntity_IsaMill.class) + .atLeast( + InputBus, + OutputBus, + InputHatch, + OutputHatch, + Maintenance, + Energy, + Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('D', ofBlock(getIntakeBlock(), getIntakeMeta())) + .addElement('G', ofBlock(getGearboxBlock(), getGearboxMeta())) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mMillingBallBuses.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 48 - 8 && checkHatch(); + } + + @Override + public boolean checkHatch() { + return super.checkHatch() && mMillingBallBuses.size() == 1; + } + + @Override + protected IIconContainer getActiveOverlay() { + return frontFaceActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return frontFace; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(2); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + private boolean addMillingBallsHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { + return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { + log("Found GT_MetaTileEntity_Hatch_MillingBalls"); + return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sOreMillRecipes; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mMillingBallBuses.clear(); + } + } + if (aTick % 20 == 0) { + checkForEntities(aBaseMetaTileEntity, aTick); + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + private final AutoMap mFrontBlockPosCache = new AutoMap(); + + public void checkForEntities(IGregTechTileEntity aBaseMetaTileEntity, long aTime) { + + if (aTime % 100 == 0) { + mFrontBlockPosCache.clear(); + } + if (mFrontBlockPosCache.isEmpty()) { + byte tSide = aBaseMetaTileEntity.getBackFacing(); + int aTileX = aBaseMetaTileEntity.getXCoord(); + int aTileY = aBaseMetaTileEntity.getYCoord(); + int aTileZ = aBaseMetaTileEntity.getZCoord(); + boolean xFacing = (tSide == 4 || tSide == 5); + boolean zFacing = (tSide == 2 || tSide == 3); + + // Check Casings + int aDepthOffset = (tSide == 2 || tSide == 4) ? 1 : -1; + for (int aHorizontalOffset = -1; aHorizontalOffset < 2; aHorizontalOffset++) { + for (int aVerticalOffset = -1; aVerticalOffset < 2; aVerticalOffset++) { + int aX = !xFacing ? (aTileX + aHorizontalOffset) : (aTileX + aDepthOffset); + int aY = aTileY + aVerticalOffset; + int aZ = !zFacing ? (aTileZ + aHorizontalOffset) : (aTileZ + aDepthOffset); + mFrontBlockPosCache.add(new BlockPos(aX, aY, aZ, aBaseMetaTileEntity.getWorld())); + } + } + } + + AutoMap aEntities = getEntities(mFrontBlockPosCache, aBaseMetaTileEntity.getWorld()); + if (!aEntities.isEmpty()) { + for (EntityLivingBase aFoundEntity : aEntities) { + if (aFoundEntity instanceof EntityPlayer) { + EntityPlayer aPlayer = (EntityPlayer) aFoundEntity; + if (PlayerUtils.isCreative(aPlayer) || !PlayerUtils.canTakeDamage(aPlayer)) { + continue; + } else { + if (aFoundEntity.getHealth() > 0) { + EntityUtils.doDamage( + aFoundEntity, mIsaMillDamageSource, (int) (aFoundEntity.getMaxHealth() / 5)); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + generateParticles(aFoundEntity); + } + } + } + } + if (aFoundEntity.getHealth() > 0) { + EntityUtils.doDamage( + aFoundEntity, mIsaMillDamageSource, Math.max(1, (int) (aFoundEntity.getMaxHealth() / 3))); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + generateParticles(aFoundEntity); + } + } + } + } + } + + private static final AutoMap getEntities(AutoMap aPositionsToCheck, World aWorld) { + AutoMap aEntities = new AutoMap(); + HashSet aChunksToCheck = new HashSet(); + if (!aPositionsToCheck.isEmpty()) { + Chunk aLocalChunk; + for (BlockPos aPos : aPositionsToCheck) { + aLocalChunk = aWorld.getChunkFromBlockCoords(aPos.xPos, aPos.zPos); + aChunksToCheck.add(aLocalChunk); + } + } + if (!aChunksToCheck.isEmpty()) { + AutoMap aEntitiesFound = new AutoMap(); + for (Chunk aChunk : aChunksToCheck) { + if (aChunk.isChunkLoaded) { + List[] aEntityLists = aChunk.entityLists; + for (List aEntitySubList : aEntityLists) { + for (Object aEntity : aEntitySubList) { + if (aEntity instanceof EntityLivingBase) { + EntityLivingBase aPlayer = (EntityLivingBase) aEntity; + aEntitiesFound.add(aPlayer); + } + } + } + } + } + if (!aEntitiesFound.isEmpty()) { + for (EntityLivingBase aEntity : aEntitiesFound) { + BlockPos aPlayerPos = EntityUtils.findBlockPosOfEntity(aEntity); + for (BlockPos aBlockSpaceToCheck : aPositionsToCheck) { + if (aBlockSpaceToCheck.equals(aPlayerPos)) { + aEntities.add(aEntity); + } + } + } + } + } + return aEntities; + } + + private static void generateParticles(EntityLivingBase aEntity) { + BlockPos aPlayerPosBottom = EntityUtils.findBlockPosOfEntity(aEntity); + BlockPos aPlayerPosTop = aPlayerPosBottom.getUp(); + AutoMap aEntityPositions = new AutoMap(); + aEntityPositions.add(aPlayerPosBottom); + aEntityPositions.add(aPlayerPosTop); + for (int i = 0; i < 64; i++) { + BlockPos aEffectPos = aEntityPositions.get(aEntity.height > 1f ? MathUtils.randInt(0, 1) : 0); + float aOffsetX = MathUtils.randFloat(-0.35f, 0.35f); + float aOffsetY = MathUtils.randFloat(-0.25f, 0.35f); + float aOffsetZ = MathUtils.randFloat(-0.35f, 0.35f); + aEntity.worldObj.spawnParticle( + "reddust", + aEffectPos.xPos + aOffsetX, + aEffectPos.yPos + 0.3f + aOffsetY, + aEffectPos.zPos + aOffsetZ, + 0.0D, + 0.0D, + 0.0D); + } + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + return checkRecipeGeneric(); + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public Block getIntakeBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getIntakeMeta() { + return 1; + } + + public Block getGearboxBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getGearboxMeta() { + return 2; + } + + public byte getCasingTextureIndex() { + return 66; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IsaMill(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIsaMill; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { + "IsaMill Grinding Machine", + "Current Efficiency: " + (mEfficiency / 100) + "%", + getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Grinding Machine"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + /* + * Milling Ball Handling + */ + + @Override public ArrayList getStoredInputs() { - ArrayList tItems = super.getStoredInputs(); + ArrayList tItems = super.getStoredInputs(); for (GT_MetaTileEntity_Hatch_MillingBalls tHatch : mMillingBallBuses) { tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - tItems.addAll(tHatch.getContentUsageSlots()); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } + return tItems; + } + + public int getMaxBallDurability(ItemStack aStack) { + return ItemGenericChemBase.getMaxBallDurability(aStack); + } + + private ItemStack findMillingBall(ItemStack[] aItemInputs) { + if (mMillingBallBuses.size() != 1) { + return null; + } else { + GT_MetaTileEntity_Hatch_MillingBalls aBus = mMillingBallBuses.get(0); + if (aBus != null) { + AutoMap aAvailableItems = aBus.getContentUsageSlots(); + if (!aAvailableItems.isEmpty()) { + for (final ItemStack aInput : aItemInputs) { + if (ItemUtils.isMillingBall(aInput)) { + for (ItemStack aBall : aAvailableItems) { + if (GT_Utility.areStacksEqual(aBall, aInput, true)) { + Logger.INFO("Found a valid milling ball to use."); + return aBall; + } + } + } + } + } + } + } + return null; + } + + private void damageMillingBall(ItemStack aStack) { + if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * 1))) { + int damage = getMillingBallDamage(aStack) + 1; + log("damage milling ball " + damage); + if (damage >= getMaxBallDurability(aStack)) { + log("consuming milling ball"); + aStack.stackSize -= 1; + } else { + setDamage(aStack, damage); + } + } else { + log("not damaging milling ball"); + } + } + + private int getMillingBallDamage(ItemStack aStack) { + return ItemGenericChemBase.getMillingBallDamage(aStack); + } + + private void setDamage(ItemStack aStack, int aAmount) { + ItemGenericChemBase.setMillingBallDamage(aStack, aAmount); + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + // checks if it has a milling ball with enough durability + ItemStack tMillingBallRecipe = findMillingBall(aItemInputs); + if (tMillingBallRecipe == null) { + log("does not have milling ball"); + return false; + } + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + log("aEUPercent " + aEUPercent); + log("mEUt " + tRecipe.mEUt); + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + 1); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tEnergy: " + tEnergy); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < 1 && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 4; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } } } - return tItems; - } - - - public int getMaxBallDurability(ItemStack aStack) { - return ItemGenericChemBase.getMaxBallDurability(aStack); - } - - private ItemStack findMillingBall(ItemStack[] aItemInputs) { - if (mMillingBallBuses.size() != 1) { - return null; - } - else { - GT_MetaTileEntity_Hatch_MillingBalls aBus = mMillingBallBuses.get(0); - if (aBus != null) { - AutoMap aAvailableItems = aBus.getContentUsageSlots(); - if (!aAvailableItems.isEmpty()) { - for (final ItemStack aInput : aItemInputs) { - if (ItemUtils.isMillingBall(aInput)) { - for (ItemStack aBall : aAvailableItems) { - if (GT_Utility.areStacksEqual(aBall, aInput, true)) { - Logger.INFO("Found a valid milling ball to use."); - return aBall; - } - } - } - } - } - } - } - return null; - } - - - private void damageMillingBall(ItemStack aStack) { - if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * 1))) { - int damage = getMillingBallDamage(aStack) + 1; - log("damage milling ball "+damage); - if (damage >= getMaxBallDurability(aStack)) { - log("consuming milling ball"); - aStack.stackSize -= 1; - } - else { - setDamage(aStack,damage); - } - } - else { - log("not damaging milling ball"); - } - } - - private int getMillingBallDamage(ItemStack aStack) { - return ItemGenericChemBase.getMillingBallDamage(aStack); - } - - private void setDamage(ItemStack aStack,int aAmount) { - ItemGenericChemBase.setMillingBallDamage(aStack, aAmount); - } - - - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - // checks if it has a milling ball with enough durability - ItemStack tMillingBallRecipe = findMillingBall(aItemInputs); - if (tMillingBallRecipe == null) { - log("does not have milling ball"); - return false; - } - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - log("aEUPercent "+aEUPercent); - log("mEUt "+tRecipe.mEUt); - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+1); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tEnergy: "+tEnergy); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < 1 && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 4; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - - // Damage Milling ball once all is said and done. - if (tMillingBallRecipe != null) { - log("damaging milling ball"); - damageMillingBall(tMillingBallRecipe); - } - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Damage Milling ball once all is said and done. + if (tMillingBallRecipe != null) { + log("damaging milling ball"); + damageMillingBall(tMillingBallRecipe); + } + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java index 23d28bb3dc..2ca76f5353 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java @@ -1,7 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -23,418 +25,447 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - -public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected static final String STRUCTURE_PIECE_BASE = "base"; - protected static final String STRUCTURE_PIECE_LAYER = "layer"; - protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; - protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; - private static final IStructureDefinition STRUCTURE_DEFINITION; - - static { - IHatchElement layeredOutputHatch = OutputHatch - .withCount(GregtechMetaTileEntity_SpargeTower::getCurrentLayerOutputHatchCount) - .withAdder(GregtechMetaTileEntity_SpargeTower::addLayerOutputHatch); - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][]{ - {"b~b", "bbb", "bbb"}, - })) - .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][]{ - {"lll", "lcl", "lll"} - })) - .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][]{ - {"lll", "l-l", "lll"} - })) - .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][]{ - {"lll", "lll", "lll"} - })) - .addElement('b', buildHatchAdder(GregtechMetaTileEntity_SpargeTower.class) - .atLeast(Energy, InputHatch, InputBus, Maintenance) - .casingIndex(getCasingIndex()) - .dot(1) - .buildAndChain(onElementPass(GregtechMetaTileEntity_SpargeTower::onCasingFound, ofBlock(ModBlocks.blockCasings5Misc, 4))) - ) - .addElement('l', ofChain( - buildHatchAdder(GregtechMetaTileEntity_SpargeTower.class) - .atLeast(layeredOutputHatch) - .casingIndex(getCasingIndex()) - .dot(2) - .build(), - ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addEnergyInputToMachineList, getCasingIndex(), 2), - ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, getCasingIndex(), 2), - onElementPass(GregtechMetaTileEntity_SpargeTower::onCasingFound, ofBlock(ModBlocks.blockCasings5Misc, 4)) - )) - .addElement('c', ofChain( - onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addOutputToMachineList, getCasingIndex(), 3)), - onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, getCasingIndex(), 3)), - onElementPass(t -> t.onTopLayerFound(true), ofBlock(ModBlocks.blockCasings5Misc, 4)), - isAir() - )) - .build(); - } - - protected final List> mOutputHatchesByLayer = new ArrayList<>(); - protected int mHeight; - protected int mCasing; - protected boolean mTopLayerFound; - - public GregtechMetaTileEntity_SpargeTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_SpargeTower(String aName) { - super(aName); - } - - public static int getCasingIndex() { - return 68; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SpargeTower(this.mName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Gas Sparge Tower") - .addInfo("Controller block for the Sparging Tower") - .addInfo("Fluids are only put out at the correct height") - .addInfo("The correct height equals the slot number in the NEI recipe") - .addSeparator() - .beginStructureBlock(3, 8, 3, true) - .addController("Front bottom") - .addOtherStructurePart("Sparge Tower Exterior Casing", "45 (minimum)") - .addEnergyHatch("Any casing", 1, 2) - .addMaintenanceHatch("Any casing", 1, 2, 3) - .addInputHatch("2x Input Hatches (Any bottom layer casing)", 1) - .addOutputHatch("6x Output Hatches (At least one per layer except bottom layer)", 2, 3) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return getCasingIndex(); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DistillationTower.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - if (GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty()) { - generateRecipes(); - } - return GTPP_Recipe_Map.sSpargeTowerRecipes; - } - - private static boolean generateRecipes() { - for (GasSpargingRecipe aRecipe : GasSpargingRecipeMap.mRecipes) { - GTPP_Recipe newRecipe = new GTPP_Recipe( - false, - new ItemStack[] {}, - new ItemStack[] {}, - null, - null, - aRecipe.mFluidInputs.clone(), - new FluidStack[] {}, - aRecipe.mDuration, - aRecipe.mEUt, - 0); - GTPP_Recipe_Map.sSpargeTowerRecipes.add(newRecipe); - } - if (GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty()) { - return false; - } - return true; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluidList = getStoredFluids(); - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(0, GT_Utility.getTier(tVoltage)); - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); - if (tFluids.length > 0) { - Logger.INFO("Found "+tFluids.length+" input fluids. Searching "+GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.size()+" recipes."); - GT_Recipe tRecipe = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids); - if (tRecipe != null) { - Logger.INFO("Found recipe!"); - if (tRecipe.isRecipeInputEqual(true, tFluids)) { - Logger.INFO("Found recipe that matches!"); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Reset outputs and progress stats - this.mEUt = 0; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - this.mLastRecipe = tRecipe; - - calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - int aDevProgress = this.mMaxProgresstime / 10; - this.mMaxProgresstime = Math.max(1, aDevProgress); - this.mOutputItems = new ItemStack[]{}; - ArrayList aFluidOutputs = getByproductsOfSparge(tRecipe.mFluidInputs[0], tRecipe.mFluidInputs[1]); - this.mOutputFluids = (FluidStack[]) aFluidOutputs.toArray(new FluidStack[0]); - updateSlots(); - Logger.INFO("Done!"); - return true; - } - } - else { - Logger.INFO("Did not find recipe!"); - } - } - this.mEUt = 0; - this.mEfficiency = 0; - Logger.INFO("Did not find recipe! (2)"); - return false; - } - - private static ArrayList getByproductsOfSparge(final FluidStack aSpargeGas, final FluidStack aSpentFuel){ - GasSpargingRecipe aSpargeRecipe = GasSpargingRecipeMap.findRecipe(aSpargeGas, aSpentFuel); - ArrayList aOutputGases = new ArrayList(); - if (aSpargeRecipe == null) { - Logger.INFO("Did not find sparge recipe!"); - return aOutputGases; - } - int aSpargeGasAmount = aSpargeRecipe.mInputGas.amount; - - aOutputGases.add(aSpargeRecipe.mOutputSpargedFuel.copy()); - ArrayList aTempMap = new ArrayList(); - for (int i=2;i 0) { - aSpargeOutput = new FluidStack(aOutput.getFluid(), aGasAmount); - } - aTempMap.add(aSpargeOutput); - } - Logger.INFO("Sparge gas left: "+aSpargeGasAmount); - if (aSpargeGasAmount > 0) { - aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeGasAmount)); - } - //Logger.INFO("Sparge Outputs: "+ItemUtils.getArrayStackNames(aTempMap)); - aOutputGases.addAll(aTempMap); - Logger.INFO("Sparge output size: "+aOutputGases.size()); - //Logger.INFO("Output of sparging: "+ItemUtils.getArrayStackNames(aOutputGases)); - return aOutputGases; - } - - protected void onCasingFound() { - mCasing++; - } - - protected void onTopLayerFound(boolean aIsCasing) { - mTopLayerFound = true; - if (aIsCasing) { - onCasingFound(); - } - } - - protected int getCurrentLayerOutputHatchCount() { - return mOutputHatchesByLayer.size() < mHeight ? 0 : mOutputHatchesByLayer.get(mHeight - 1).size(); - } - - protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) { - Logger.INFO("Bad Output Hatch"); - return false; - } - while (mOutputHatchesByLayer.size() < mHeight) { - mOutputHatchesByLayer.add(new ArrayList<>()); - } - GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); - tHatch.updateTexture(aBaseCasingIndex); - boolean addedHatch = mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); - Logger.INFO("Added Hatch: "+addedHatch); - return addedHatch; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // don't rotate a freaking tower, it won't work - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - // reset - mOutputHatchesByLayer.forEach(List::clear); - mHeight = 1; - mTopLayerFound = false; - mCasing = 0; - - // check base - if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) { - Logger.INFO("Bad Base. Height: "+mHeight); - return false; - } - - // check each layer - while (mHeight < 8 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) { - if (mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) { - // layer without output hatch - Logger.INFO("Height: "+mHeight + " - Missing output on "+(mHeight - 1)); - return false; - } - // not top - mHeight++; - } - - // validate final invariants... - Logger.INFO("Height: "+mHeight); - Logger.INFO("Casings: "+mCasing); - Logger.INFO("Required: "+(7 * mHeight - 5)); - Logger.INFO("Found Top: "+mTopLayerFound); - return mCasing >= 45 && mTopLayerFound && mMaintenanceHatches.size() == 1; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { - FluidStack tStack = mOutputFluids2[i] != null ? mOutputFluids2[i].copy() : null; - if (tStack == null) { - continue; - } - if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) { - dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); - } - } - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); - int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); - } - buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - mHeight = 0; - int built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - mHeight = i; - built = survivialBuildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, 1, i, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - } - mHeight = tTotalHeight - 1; - return survivialBuildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, 1, tTotalHeight - 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getMachineType() { - return "Gas Sparger"; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public boolean onPlungerRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - int aLayerIndex = 0; - PlayerUtils.messagePlayer(aPlayer, "Trying to clear "+mOutputHatchesByLayer.size()+" layers of output hatches."); - for (List layer : this.mOutputHatchesByLayer) { - int aHatchIndex = 0; - for (GT_MetaTileEntity_Hatch_Output hatch : layer) { - if (hatch.mFluid != null) { - PlayerUtils.messagePlayer(aPlayer, "Clearing "+hatch.mFluid.amount+"L of "+hatch.mFluid.getLocalizedName()+" from hatch "+aHatchIndex+" on layer "+aLayerIndex+"."); - hatch.mFluid = null; - } - aHatchIndex++; - } - aLayerIndex++; - } - return aLayerIndex > 0; - } +public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; + private static final IStructureDefinition STRUCTURE_DEFINITION; + + static { + IHatchElement layeredOutputHatch = OutputHatch.withCount( + GregtechMetaTileEntity_SpargeTower::getCurrentLayerOutputHatchCount) + .withAdder(GregtechMetaTileEntity_SpargeTower::addLayerOutputHatch); + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { + {"b~b", "bbb", "bbb"}, + })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] {{"lll", "lcl", "lll"}})) + .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][] {{"lll", "l-l", "lll"}})) + .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][] {{"lll", "lll", "lll"}})) + .addElement( + 'b', + buildHatchAdder(GregtechMetaTileEntity_SpargeTower.class) + .atLeast(Energy, InputHatch, InputBus, Maintenance) + .casingIndex(getCasingIndex()) + .dot(1) + .buildAndChain(onElementPass( + GregtechMetaTileEntity_SpargeTower::onCasingFound, + ofBlock(ModBlocks.blockCasings5Misc, 4)))) + .addElement( + 'l', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_SpargeTower.class) + .atLeast(layeredOutputHatch) + .casingIndex(getCasingIndex()) + .dot(2) + .build(), + ofHatchAdder( + GregtechMetaTileEntity_SpargeTower::addEnergyInputToMachineList, + getCasingIndex(), + 2), + ofHatchAdder( + GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, + getCasingIndex(), + 2), + onElementPass( + GregtechMetaTileEntity_SpargeTower::onCasingFound, + ofBlock(ModBlocks.blockCasings5Misc, 4)))) + .addElement( + 'c', + ofChain( + onElementPass( + t -> t.onTopLayerFound(false), + ofHatchAdder( + GregtechMetaTileEntity_SpargeTower::addOutputToMachineList, + getCasingIndex(), + 3)), + onElementPass( + t -> t.onTopLayerFound(false), + ofHatchAdder( + GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, + getCasingIndex(), + 3)), + onElementPass(t -> t.onTopLayerFound(true), ofBlock(ModBlocks.blockCasings5Misc, 4)), + isAir())) + .build(); + } + + protected final List> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; + + public GregtechMetaTileEntity_SpargeTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_SpargeTower(String aName) { + super(aName); + } + + public static int getCasingIndex() { + return 68; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_SpargeTower(this.mName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Gas Sparge Tower") + .addInfo("Controller block for the Sparging Tower") + .addInfo("Fluids are only put out at the correct height") + .addInfo("The correct height equals the slot number in the NEI recipe") + .addSeparator() + .beginStructureBlock(3, 8, 3, true) + .addController("Front bottom") + .addOtherStructurePart("Sparge Tower Exterior Casing", "45 (minimum)") + .addEnergyHatch("Any casing", 1, 2) + .addMaintenanceHatch("Any casing", 1, 2, 3) + .addInputHatch("2x Input Hatches (Any bottom layer casing)", 1) + .addOutputHatch("6x Output Hatches (At least one per layer except bottom layer)", 2, 3) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return getCasingIndex(); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DistillationTower.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty()) { + generateRecipes(); + } + return GTPP_Recipe_Map.sSpargeTowerRecipes; + } + + private static boolean generateRecipes() { + for (GasSpargingRecipe aRecipe : GasSpargingRecipeMap.mRecipes) { + GTPP_Recipe newRecipe = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, + null, + aRecipe.mFluidInputs.clone(), + new FluidStack[] {}, + aRecipe.mDuration, + aRecipe.mEUt, + 0); + GTPP_Recipe_Map.sSpargeTowerRecipes.add(newRecipe); + } + if (GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty()) { + return false; + } + return true; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tFluidList = getStoredFluids(); + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(0, GT_Utility.getTier(tVoltage)); + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); + if (tFluids.length > 0) { + Logger.INFO("Found " + tFluids.length + " input fluids. Searching " + + GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.size() + " recipes."); + GT_Recipe tRecipe = getRecipeMap() + .findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids); + if (tRecipe != null) { + Logger.INFO("Found recipe!"); + if (tRecipe.isRecipeInputEqual(true, tFluids)) { + Logger.INFO("Found recipe that matches!"); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + this.mLastRecipe = tRecipe; + + calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + int aDevProgress = this.mMaxProgresstime / 10; + this.mMaxProgresstime = Math.max(1, aDevProgress); + this.mOutputItems = new ItemStack[] {}; + ArrayList aFluidOutputs = + getByproductsOfSparge(tRecipe.mFluidInputs[0], tRecipe.mFluidInputs[1]); + this.mOutputFluids = (FluidStack[]) aFluidOutputs.toArray(new FluidStack[0]); + updateSlots(); + Logger.INFO("Done!"); + return true; + } + } else { + Logger.INFO("Did not find recipe!"); + } + } + this.mEUt = 0; + this.mEfficiency = 0; + Logger.INFO("Did not find recipe! (2)"); + return false; + } + + private static ArrayList getByproductsOfSparge( + final FluidStack aSpargeGas, final FluidStack aSpentFuel) { + GasSpargingRecipe aSpargeRecipe = GasSpargingRecipeMap.findRecipe(aSpargeGas, aSpentFuel); + ArrayList aOutputGases = new ArrayList(); + if (aSpargeRecipe == null) { + Logger.INFO("Did not find sparge recipe!"); + return aOutputGases; + } + int aSpargeGasAmount = aSpargeRecipe.mInputGas.amount; + + aOutputGases.add(aSpargeRecipe.mOutputSpargedFuel.copy()); + ArrayList aTempMap = new ArrayList(); + for (int i = 2; i < aSpargeRecipe.mFluidOutputs.length; i++) { + int aGasAmount = MathUtils.randInt(0, (aSpargeRecipe.mMaxOutputQuantity[i - 2] / 100)); + FluidStack aOutput = aSpargeRecipe.mFluidOutputs[i].copy(); + aSpargeGasAmount -= aGasAmount; + FluidStack aSpargeOutput = null; + if (aGasAmount > 0) { + aSpargeOutput = new FluidStack(aOutput.getFluid(), aGasAmount); + } + aTempMap.add(aSpargeOutput); + } + Logger.INFO("Sparge gas left: " + aSpargeGasAmount); + if (aSpargeGasAmount > 0) { + aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeGasAmount)); + } + // Logger.INFO("Sparge Outputs: "+ItemUtils.getArrayStackNames(aTempMap)); + aOutputGases.addAll(aTempMap); + Logger.INFO("Sparge output size: " + aOutputGases.size()); + // Logger.INFO("Output of sparging: "+ItemUtils.getArrayStackNames(aOutputGases)); + return aOutputGases; + } + + protected void onCasingFound() { + mCasing++; + } + + protected void onTopLayerFound(boolean aIsCasing) { + mTopLayerFound = true; + if (aIsCasing) { + onCasingFound(); + } + } + + protected int getCurrentLayerOutputHatchCount() { + return mOutputHatchesByLayer.size() < mHeight + ? 0 + : mOutputHatchesByLayer.get(mHeight - 1).size(); + } + + protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null + || aTileEntity.isDead() + || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) { + Logger.INFO("Bad Output Hatch"); + return false; + } + while (mOutputHatchesByLayer.size() < mHeight) { + mOutputHatchesByLayer.add(new ArrayList<>()); + } + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); + tHatch.updateTexture(aBaseCasingIndex); + boolean addedHatch = mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); + Logger.INFO("Added Hatch: " + addedHatch); + return addedHatch; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a freaking tower, it won't work + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + mOutputHatchesByLayer.forEach(List::clear); + mHeight = 1; + mTopLayerFound = false; + mCasing = 0; + + // check base + if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) { + Logger.INFO("Bad Base. Height: " + mHeight); + return false; + } + + // check each layer + while (mHeight < 8 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) { + if (mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) { + // layer without output hatch + Logger.INFO("Height: " + mHeight + " - Missing output on " + (mHeight - 1)); + return false; + } + // not top + mHeight++; + } + + // validate final invariants... + Logger.INFO("Height: " + mHeight); + Logger.INFO("Casings: " + mCasing); + Logger.INFO("Required: " + (7 * mHeight - 5)); + Logger.INFO("Found Top: " + mTopLayerFound); + return mCasing >= 45 && mTopLayerFound && mMaintenanceHatches.size() == 1; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i] != null ? mOutputFluids2[i].copy() : null; + if (tStack == null) { + continue; + } + if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) { + dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); + } + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); + int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); + } + buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + mHeight = 0; + int built = survivialBuildPiece( + STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + mHeight = i; + built = survivialBuildPiece( + STRUCTURE_PIECE_LAYER_HINT, stackSize, 1, i, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + } + mHeight = tTotalHeight - 1; + return survivialBuildPiece( + STRUCTURE_PIECE_TOP_HINT, stackSize, 1, tTotalHeight - 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getMachineType() { + return "Gas Sparger"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean onPlungerRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + int aLayerIndex = 0; + PlayerUtils.messagePlayer( + aPlayer, "Trying to clear " + mOutputHatchesByLayer.size() + " layers of output hatches."); + for (List layer : this.mOutputHatchesByLayer) { + int aHatchIndex = 0; + for (GT_MetaTileEntity_Hatch_Output hatch : layer) { + if (hatch.mFluid != null) { + PlayerUtils.messagePlayer( + aPlayer, + "Clearing " + hatch.mFluid.amount + "L of " + hatch.mFluid.getLocalizedName() + + " from hatch " + aHatchIndex + " on layer " + aLayerIndex + "."); + hatch.mFluid = null; + } + aHatchIndex++; + } + aLayerIndex++; + } + return aLayerIndex > 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_AssemblyLine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_AssemblyLine.java index be7aa8b98a..70551220ca 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_AssemblyLine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_AssemblyLine.java @@ -1,9 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; -import java.util.ArrayList; - import com.gtnewhorizon.structurelib.structure.IStructureDefinition; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; @@ -23,6 +20,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.LangUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -31,640 +29,666 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_Adv_AssemblyLine extends GregtechMeta_MultiBlockBase { - - public ArrayList mDataAccessHatches = new ArrayList(); - - public static String[] mCasingName = new String[5]; - private final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 13); - private final int META_BaseCasing = 0; //4 - private final int META_ContainmentCasing = 15; //3 - private final int META_Shielding = 13; //1 - private final int META_PipeCasing = 1; //4 - private final int META_IntegralCasing = 6; //0 - private final int META_ContainmentChamberCasing = 2; //4 - - - public GregtechMetaTileEntity_Adv_AssemblyLine(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); - mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); - mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); - mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); - mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); - } - - public GregtechMetaTileEntity_Adv_AssemblyLine(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_AssemblyLine(this.mName); - } - - /* public String[] getTooltip() { - if (mCasingName[0].toLowerCase().contains(".name")) { - mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); - } - if (mCasingName[1].toLowerCase().contains(".name")) { - mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); - } - if (mCasingName[2].toLowerCase().contains(".name")) { - mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); - } - if (mCasingName[3].toLowerCase().contains(".name")) { - mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); - } - if (mCasingName[4].toLowerCase().contains(".name")) { - mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); - } - return new String[]{ - "Advanced Integrated Assembly Line" - }; - }*/ - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - private Block getCasing(int casingID) { - if (casingID == 1) { - return ModBlocks.blockCasingsMisc; - } - else if (casingID == 2) { - return ModBlocks.blockCasings2Misc; - } - else if (casingID == 3) { - return ModBlocks.blockCasings3Misc; - } - else if (casingID == 4) { - return ModBlocks.blockCasings4Misc; - } - else { - return ModBlocks.blockCasingsTieredGTPP; - } - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE; - } - - @Override - protected int getCasingTextureId() { - return 16; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "AssemblyLine.png"); - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - public boolean checkRecipe(ItemStack aStack) { - if(GT_Values.D1)System.out.println("Start ALine recipe check"); - ArrayList tDataStickList = getDataItems(2); - if (tDataStickList.size() == 0) return false; - if(GT_Values.D1)System.out.println("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); - - ItemStack tStack[] = new ItemStack[15]; - FluidStack[] tFluids = new FluidStack[4]; - boolean findRecipe = false; - nextDS:for (ItemStack tDataStick : tDataStickList){ - NBTTagCompound tTag = tDataStick.getTagCompound(); - if (tTag == null) continue; - for (int i = 0; i < 15; i++) { - int count = tTag.getInteger("a"+i); - if (!tTag.hasKey("" + i) && count <= 0) continue; - if (mInputBusses.get(i) == null) { - continue nextDS; - } - - ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); - boolean flag = true; - if (count > 0) { - for (int j = 0; j < count; j++) { - tStack[i] = GT_Utility.loadItem(tTag, "a" + i + ":" + j); - if (tStack[i] == null) continue; - if(GT_Values.D1)System.out.println("Item "+i+" : "+tStack[i].getUnlocalizedName()); - if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { - flag = false; - break; - } - } - } - if (flag) { - tStack[i] = GT_Utility.loadItem(tTag, "" + i); - if (tStack[i] == null) { - flag = false; - continue; - } - if(GT_Values.D1)System.out.println("Item "+i+" : "+tStack[i].getUnlocalizedName()); - if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { - flag = false; - } - } - if(GT_Values.D1) System.out.println(i + (flag ? " not accepted" : " accepted")); - if (flag) continue nextDS; - } - - if(GT_Values.D1)System.out.println("All Items done, start fluid check"); - for (int i = 0; i < 4; i++) { - if (!tTag.hasKey("f" + i)) continue; - tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i); - if (tFluids[i] == null) continue; - if(GT_Values.D1)System.out.println("Fluid "+i+" "+tFluids[i].getUnlocalizedName()); - if (mInputHatches.get(i) == null) { - continue nextDS; - } - FluidStack fluidInHatch = mInputHatches.get(i).mFluid; - if (fluidInHatch == null || !GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) { - if(GT_Values.D1)System.out.println(i+" not accepted"); - continue nextDS; - } - if(GT_Values.D1)System.out.println(i+" accepted"); - } - - if(GT_Values.D1)System.out.println("Input accepted, check other values"); - if (!tTag.hasKey("output")) continue; - mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")}; - if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0])) - continue; - - if (!tTag.hasKey("time")) continue; - mMaxProgresstime = tTag.getInteger("time"); - if (mMaxProgresstime <= 0) continue; - - if (!tTag.hasKey("eu")) continue; - mEUt = tTag.getInteger("eu"); - - if(GT_Values.D1)System.out.println("Find avaiable recipe"); - findRecipe = true; - break; - } - if (!findRecipe) return false; - - if(GT_Values.D1)System.out.println("All checked start consuming inputs"); - for (int i = 0; i < 15; i++) { - if (tStack[i] == null) continue; - ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); - stackInSlot.stackSize -= tStack[i].stackSize; - } - - for (int i = 0; i < 4; i++) { - if (tFluids[i] == null) continue; - mInputHatches.get(i).mFluid.amount -= tFluids[i].amount; - if (mInputHatches.get(i).mFluid.amount <= 0) { - mInputHatches.get(i).mFluid = null; - } - } - if(GT_Values.D1)System.out.println("Check overclock"); - - byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (mEUt <= 16) { - this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - updateSlots(); - if(GT_Values.D1)System.out.println("Recipe sucessfull"); - return true; - } - - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ); - } - } - - public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 4; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 4; - - // Counts for all Casing Types - int aBaseCasingCount = 0; - int aContainmentCasingCount = 0; - int aShieldingCount = 0; - int aPipeCount = 0; - int aIntegralCasingCount = 0; - int aContainmentChamberCount = 0; - - // Bottom Layer - aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, -7, xDir, zDir); - log("Bottom Layer is Valid. Moving to Layer 1."); - - // Layer 1 - aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -6, xDir, zDir); - aIntegralCasingCount += checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -6, xDir, zDir); - aContainmentChamberCount += checkContainmentRing(aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -6, xDir, zDir); - log("Layer 1 is Valid. Moving to Layer 2."); - - // Layer 2 - aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -5, xDir, zDir); - aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -5, xDir, zDir); - log("Layer 2 is Valid. Moving to Layer 3."); - - // Layer 3 - aContainmentCasingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -4, xDir, zDir); - aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -4, xDir, zDir); - log("Layer 3 is Valid. Moving to Layer 4."); - - // Layer 4 - aContainmentCasingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -3, xDir, zDir); - aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -3, xDir, zDir); - log("Layer 4 is Valid. Moving to Layer 5."); - - // Layer 5 - aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -2, xDir, zDir); - aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -2, xDir, zDir); - log("Layer 5 is Valid. Moving to Layer 6."); - - // Layer 6 - aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -1, xDir, zDir); - aIntegralCasingCount += checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -1, xDir, zDir); - aContainmentChamberCount += checkContainmentRing(aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -1, xDir, zDir); - log("Layer 6 is Valid. Moving to Top Layer."); - - // Top Layer - aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, 0, xDir, zDir); - - log("Found "+aBaseCasingCount+" "+mCasingName[0]+"s"); - log("Found "+aShieldingCount+" "+mCasingName[4]+"s"); - log("Found "+aPipeCount+" "+mCasingName[1]+"s"); - log("Found "+aContainmentCasingCount+" "+mCasingName[3]+"s"); - log("Found "+aIntegralCasingCount+" "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s"); - log("Found "+aContainmentChamberCount+" "+mCasingName[2]+"s"); - - // Try mesage player - String aOwnerName = this.getBaseMetaTileEntity().getOwnerName(); - EntityPlayer aOwner = null; - if (aOwnerName != null && aOwnerName.length() > 0) { - aOwner = PlayerUtils.getPlayer(aOwnerName); - } - - if (aShieldingCount != 128) { - log("Not enough "+mCasingName[4]+"s, require 128."); - if (aOwner != null) { - PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[4]+"s, require 128."); - } - return false; - } - if (aPipeCount != 20) { - log("Not enough "+mCasingName[1]+"s, require 20."); - if (aOwner != null) { - PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[1]+"s, require 20."); - } - return false; - } - if (aContainmentCasingCount != 64) { - log("Not enough "+mCasingName[3]+"s, require 64."); - if (aOwner != null) { - PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[3]+"s, require 64."); - } - return false; - } - if (aContainmentChamberCount != 42) { - log("Not enough "+mCasingName[2]+"s, require 42."); - if (aOwner != null) { - PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[2]+"s, require 42."); - } - return false; - } - if (aBaseCasingCount < 140) { - log("Not enough "+mCasingName[0]+"s, require 140 at a minimum."); - if (aOwner != null) { - PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[0]+"s, require 140 at a minimum."); - } - return false; - } - if (aIntegralCasingCount != 48) { - log("Not enough "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s, require 48."); - if (aOwner != null) { - PlayerUtils.messagePlayer(aOwner, "Not enough "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s, require 48."); - } - return false; - } - log("LNR Formed."); - if (aOwner != null) { - PlayerUtils.messagePlayer(aOwner, "Large Naquadah Reactor has formed successfully."); - } - return true; - } - - public boolean addNaquadahHatchToMachineInput(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); - } - return false; - } - - public int checkEntireLayer(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { - int aCasingCount = 0; - for (int x = -4; x < 5; x++) { - for (int z = -4; z < 5; z++) { - int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; - int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; - //Skip the corners - if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { - continue; - } - // Skip controller - if (aY == 0 && x == 0 && z == 0) { - continue; - } - - Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); - int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); - if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { - aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); - if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { - log("Layer has error. Height: "+aY); - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); - return 0; - } - } - } - return aCasingCount; - } - - public int checkOuterRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { - int aCasingCount = 0; - for (int x = -4; x < 5; x++) { - for (int z = -4; z < 5; z++) { - int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; - int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; - //Skip the corners - if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { - continue; - } - - // If we are on the 5x5 ring, proceed - if ((x > -4 && x < 4 ) && (z > -4 && z < 4)) { - if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); - } - else { - continue; - } - } - - Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); - int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); - if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { - aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); - if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { - log("Layer has error. Height: "+aY); - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); - return 0; - } - } - } - return aCasingCount; - } - public int checkIntegralRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { - int aCasingCount = 0; - for (int x = -3; x < 4; x++) { - for (int z = -3; z < 4; z++) { - int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; - int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; - //Skip the corners - if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { - continue; - } - - // If we are on the 5x5 ring, proceed - if ((x > -3 && x < 3 ) && (z > -3 && z < 3)) { - if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); - } - else { - continue; - } - } - - Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); - int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); - if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { - aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); - if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { - log("Layer has error. Height: "+aY); - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); - return 0; - } - } - } - return aCasingCount; - } - - public int checkPipes(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { - int aCasingCount = 0; - for (int x = -1; x < 2; x++) { - for (int z = -1; z < 2; z++) { - int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; - int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; - //Skip the corners - if ((x == 1 && z == 1) || (x == -1 && z == -1) || (x == 1 && z == -1) || (x == -1 && z == 1) || (x == 0 && z == 0)) { - Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); - int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); - if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { - aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); - if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { - log("Pipe has error. Height: "+aY); - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); - return 0; - }; - } - } - } - return aCasingCount; - } - - public int checkContainmentRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { - int aCasingCount = 0; - for (int x = -2; x < 3; x++) { - for (int z = -2; z < 3; z++) { - int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; - int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; - //Skip the corners - if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { - continue; - } - - Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); - int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); - if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { - aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); - if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { - log("Layer has error. Height: "+aY); - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); - return 0; - } - } - } - return aCasingCount; - } - - /** - * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb - */ - - private boolean isCorrectDataItem(ItemStack aStack, int state){ - if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true; - if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true; - if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true; - return false; - } - - /** - * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb - */ - - public ArrayList getDataItems(int state) { - ArrayList rList = new ArrayList(); - if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) { - rList.add(mInventory[1]); - } - for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) { - if (isValidMetaTileEntity(tHatch)) { - for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null - && isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state)) - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - return rList; - } - - public boolean addDataAccessToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); - } - return false; - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Assembly Line"; - } - - @Override - public int getMaxParallelRecipes() { - return 0; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - // Fix GT bug - if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { - log("Fixing Bad Facing. (GT Bug)"); - this.getBaseMetaTileEntity().setFrontFacing((byte) 1); - } - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - // TODO Auto-generated method stub - - } - - @Override - public IStructureDefinition getStructureDefinition() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean checkMachine( - IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack - ) { - // TODO Auto-generated method stub - return false; - } +public class GregtechMetaTileEntity_Adv_AssemblyLine + extends GregtechMeta_MultiBlockBase { + + public ArrayList mDataAccessHatches = + new ArrayList(); + + public static String[] mCasingName = new String[5]; + private final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 13); + private final int META_BaseCasing = 0; // 4 + private final int META_ContainmentCasing = 15; // 3 + private final int META_Shielding = 13; // 1 + private final int META_PipeCasing = 1; // 4 + private final int META_IntegralCasing = 6; // 0 + private final int META_ContainmentChamberCasing = 2; // 4 + + public GregtechMetaTileEntity_Adv_AssemblyLine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); + } + + public GregtechMetaTileEntity_Adv_AssemblyLine(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_AssemblyLine(this.mName); + } + + /* public String[] getTooltip() { + if (mCasingName[0].toLowerCase().contains(".name")) { + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); + } + if (mCasingName[1].toLowerCase().contains(".name")) { + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); + } + if (mCasingName[2].toLowerCase().contains(".name")) { + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); + } + if (mCasingName[3].toLowerCase().contains(".name")) { + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); + } + if (mCasingName[4].toLowerCase().contains(".name")) { + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); + } + return new String[]{ + "Advanced Integrated Assembly Line" + }; + }*/ + + @Override + protected final GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()).toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + private Block getCasing(int casingID) { + if (casingID == 1) { + return ModBlocks.blockCasingsMisc; + } else if (casingID == 2) { + return ModBlocks.blockCasings2Misc; + } else if (casingID == 3) { + return ModBlocks.blockCasings3Misc; + } else if (casingID == 4) { + return ModBlocks.blockCasings4Misc; + } else { + return ModBlocks.blockCasingsTieredGTPP; + } + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE; + } + + @Override + protected int getCasingTextureId() { + return 16; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "AssemblyLine.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean checkRecipe(ItemStack aStack) { + if (GT_Values.D1) System.out.println("Start ALine recipe check"); + ArrayList tDataStickList = getDataItems(2); + if (tDataStickList.size() == 0) return false; + if (GT_Values.D1) System.out.println("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); + + ItemStack tStack[] = new ItemStack[15]; + FluidStack[] tFluids = new FluidStack[4]; + boolean findRecipe = false; + nextDS: + for (ItemStack tDataStick : tDataStickList) { + NBTTagCompound tTag = tDataStick.getTagCompound(); + if (tTag == null) continue; + for (int i = 0; i < 15; i++) { + int count = tTag.getInteger("a" + i); + if (!tTag.hasKey("" + i) && count <= 0) continue; + if (mInputBusses.get(i) == null) { + continue nextDS; + } + + ItemStack stackInSlot = + mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); + boolean flag = true; + if (count > 0) { + for (int j = 0; j < count; j++) { + tStack[i] = GT_Utility.loadItem(tTag, "a" + i + ":" + j); + if (tStack[i] == null) continue; + if (GT_Values.D1) System.out.println("Item " + i + " : " + tStack[i].getUnlocalizedName()); + if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) + && tStack[i].stackSize <= stackInSlot.stackSize) { + flag = false; + break; + } + } + } + if (flag) { + tStack[i] = GT_Utility.loadItem(tTag, "" + i); + if (tStack[i] == null) { + flag = false; + continue; + } + if (GT_Values.D1) System.out.println("Item " + i + " : " + tStack[i].getUnlocalizedName()); + if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) + && tStack[i].stackSize <= stackInSlot.stackSize) { + flag = false; + } + } + if (GT_Values.D1) System.out.println(i + (flag ? " not accepted" : " accepted")); + if (flag) continue nextDS; + } + + if (GT_Values.D1) System.out.println("All Items done, start fluid check"); + for (int i = 0; i < 4; i++) { + if (!tTag.hasKey("f" + i)) continue; + tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i); + if (tFluids[i] == null) continue; + if (GT_Values.D1) System.out.println("Fluid " + i + " " + tFluids[i].getUnlocalizedName()); + if (mInputHatches.get(i) == null) { + continue nextDS; + } + FluidStack fluidInHatch = mInputHatches.get(i).mFluid; + if (fluidInHatch == null + || !GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) + || fluidInHatch.amount < tFluids[i].amount) { + if (GT_Values.D1) System.out.println(i + " not accepted"); + continue nextDS; + } + if (GT_Values.D1) System.out.println(i + " accepted"); + } + + if (GT_Values.D1) System.out.println("Input accepted, check other values"); + if (!tTag.hasKey("output")) continue; + mOutputItems = new ItemStack[] {GT_Utility.loadItem(tTag, "output")}; + if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0])) continue; + + if (!tTag.hasKey("time")) continue; + mMaxProgresstime = tTag.getInteger("time"); + if (mMaxProgresstime <= 0) continue; + + if (!tTag.hasKey("eu")) continue; + mEUt = tTag.getInteger("eu"); + + if (GT_Values.D1) System.out.println("Find avaiable recipe"); + findRecipe = true; + break; + } + if (!findRecipe) return false; + + if (GT_Values.D1) System.out.println("All checked start consuming inputs"); + for (int i = 0; i < 15; i++) { + if (tStack[i] == null) continue; + ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); + stackInSlot.stackSize -= tStack[i].stackSize; + } + + for (int i = 0; i < 4; i++) { + if (tFluids[i] == null) continue; + mInputHatches.get(i).mFluid.amount -= tFluids[i].amount; + if (mInputHatches.get(i).mFluid.amount <= 0) { + mInputHatches.get(i).mFluid = null; + } + } + if (GT_Values.D1) System.out.println("Check overclock"); + + byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (mEUt <= 16) { + this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = -this.mEUt; + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + updateSlots(); + if (GT_Values.D1) System.out.println("Recipe sucessfull"); + return true; + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ); + } + } + + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 4; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 4; + + // Counts for all Casing Types + int aBaseCasingCount = 0; + int aContainmentCasingCount = 0; + int aShieldingCount = 0; + int aPipeCount = 0; + int aIntegralCasingCount = 0; + int aContainmentChamberCount = 0; + + // Bottom Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, -7, xDir, zDir); + log("Bottom Layer is Valid. Moving to Layer 1."); + + // Layer 1 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -6, xDir, zDir); + aIntegralCasingCount += + checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -6, xDir, zDir); + aContainmentChamberCount += checkContainmentRing( + aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -6, xDir, zDir); + log("Layer 1 is Valid. Moving to Layer 2."); + + // Layer 2 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -5, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -5, xDir, zDir); + log("Layer 2 is Valid. Moving to Layer 3."); + + // Layer 3 + aContainmentCasingCount += + checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -4, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -4, xDir, zDir); + log("Layer 3 is Valid. Moving to Layer 4."); + + // Layer 4 + aContainmentCasingCount += + checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -3, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -3, xDir, zDir); + log("Layer 4 is Valid. Moving to Layer 5."); + + // Layer 5 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -2, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -2, xDir, zDir); + log("Layer 5 is Valid. Moving to Layer 6."); + + // Layer 6 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -1, xDir, zDir); + aIntegralCasingCount += + checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -1, xDir, zDir); + aContainmentChamberCount += checkContainmentRing( + aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -1, xDir, zDir); + log("Layer 6 is Valid. Moving to Top Layer."); + + // Top Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, 0, xDir, zDir); + + log("Found " + aBaseCasingCount + " " + mCasingName[0] + "s"); + log("Found " + aShieldingCount + " " + mCasingName[4] + "s"); + log("Found " + aPipeCount + " " + mCasingName[1] + "s"); + log("Found " + aContainmentCasingCount + " " + mCasingName[3] + "s"); + log("Found " + aIntegralCasingCount + " " + LangUtils.getLocalizedNameOfBlock(getCasing(0), 6) + "s"); + log("Found " + aContainmentChamberCount + " " + mCasingName[2] + "s"); + + // Try mesage player + String aOwnerName = this.getBaseMetaTileEntity().getOwnerName(); + EntityPlayer aOwner = null; + if (aOwnerName != null && aOwnerName.length() > 0) { + aOwner = PlayerUtils.getPlayer(aOwnerName); + } + + if (aShieldingCount != 128) { + log("Not enough " + mCasingName[4] + "s, require 128."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough " + mCasingName[4] + "s, require 128."); + } + return false; + } + if (aPipeCount != 20) { + log("Not enough " + mCasingName[1] + "s, require 20."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough " + mCasingName[1] + "s, require 20."); + } + return false; + } + if (aContainmentCasingCount != 64) { + log("Not enough " + mCasingName[3] + "s, require 64."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough " + mCasingName[3] + "s, require 64."); + } + return false; + } + if (aContainmentChamberCount != 42) { + log("Not enough " + mCasingName[2] + "s, require 42."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough " + mCasingName[2] + "s, require 42."); + } + return false; + } + if (aBaseCasingCount < 140) { + log("Not enough " + mCasingName[0] + "s, require 140 at a minimum."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough " + mCasingName[0] + "s, require 140 at a minimum."); + } + return false; + } + if (aIntegralCasingCount != 48) { + log("Not enough " + LangUtils.getLocalizedNameOfBlock(getCasing(0), 6) + "s, require 48."); + if (aOwner != null) { + PlayerUtils.messagePlayer( + aOwner, "Not enough " + LangUtils.getLocalizedNameOfBlock(getCasing(0), 6) + "s, require 48."); + } + return false; + } + log("LNR Formed."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Large Naquadah Reactor has formed successfully."); + } + return true; + } + + public boolean addNaquadahHatchToMachineInput(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); + } + return false; + } + + public int checkEntireLayer( + IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -4; x < 5; x++) { + for (int z = -4; z < 5; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + // Skip the corners + if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { + continue; + } + // Skip controller + if (aY == 0 && x == 0 && z == 0) { + continue; + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = + aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure( + tTileEntity, CASING_TEXTURE_ID, true, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: " + aY); + // this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int checkOuterRing( + IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -4; x < 5; x++) { + for (int z = -4; z < 5; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + // Skip the corners + if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { + continue; + } + + // If we are on the 5x5 ring, proceed + if ((x > -4 && x < 4) && (z > -4 && z < 4)) { + if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { + // this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, + // 3); + } else { + continue; + } + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = + aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure( + tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: " + aY); + // this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int checkIntegralRing( + IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -3; x < 4; x++) { + for (int z = -3; z < 4; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + // Skip the corners + if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { + continue; + } + + // If we are on the 5x5 ring, proceed + if ((x > -3 && x < 3) && (z > -3 && z < 3)) { + if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { + // this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, + // 3); + } else { + continue; + } + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = + aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure( + tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: " + aY); + // this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int checkPipes( + IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -1; x < 2; x++) { + for (int z = -1; z < 2; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + // Skip the corners + if ((x == 1 && z == 1) + || (x == -1 && z == -1) + || (x == 1 && z == -1) + || (x == -1 && z == 1) + || (x == 0 && z == 0)) { + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = + aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure( + tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Pipe has error. Height: " + aY); + // this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, + // 3); + return 0; + } + ; + } + } + } + return aCasingCount; + } + + public int checkContainmentRing( + IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -2; x < 3; x++) { + for (int z = -2; z < 3; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + // Skip the corners + if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { + continue; + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = + aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure( + tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: " + aY); + // this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + /** + * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb + */ + private boolean isCorrectDataItem(ItemStack aStack, int state) { + if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true; + if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true; + if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true; + return false; + } + + /** + * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb + */ + public ArrayList getDataItems(int state) { + ArrayList rList = new ArrayList(); + if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) { + rList.add(mInventory[1]); + } + for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null + && isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state)) + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + public boolean addDataAccessToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); + } + return false; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Assembly Line"; + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Fix GT bug + if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { + log("Fixing Bad Facing. (GT Bug)"); + this.getBaseMetaTileEntity().setFrontFacing((byte) 1); + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + // TODO Auto-generated method stub + + } + + @Override + public IStructureDefinition getStructureDefinition() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } } - diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java index 8b24bb2d0d..6058d23996 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java @@ -1,7 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -26,6 +28,8 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -33,433 +37,454 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - -public class GregtechMetaTileEntity_Adv_DistillationTower extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private Mode mMode = Mode.DistillationTower; - private boolean mUpgraded = false; - - protected static final String STRUCTURE_PIECE_BASE = "base"; - protected static final String STRUCTURE_PIECE_LAYER = "layer"; - protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; - protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; - - protected final List> mOutputHatchesByLayer = new ArrayList<>(); - protected int mHeight; - protected int mCasing; - protected boolean mTopLayerFound; - - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Adv_DistillationTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Adv_DistillationTower(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_DistillationTower(this.mName); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - IHatchElement layeredOutputHatch = OutputHatch - .withCount(GregtechMetaTileEntity_Adv_DistillationTower::getCurrentLayerOutputHatchCount) - .withAdder(GregtechMetaTileEntity_Adv_DistillationTower::addLayerOutputHatch); - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][]{ - {"b~b", "bbb", "bbb"}, - })) - .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][]{ - {"lll", "lcl", "lll"} - })) - .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][]{ - {"lll", "l-l", "lll"} - })) - .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][]{ - {"ttt", "ttt", "ttt"} - })) - .addElement('b', ofChain( - buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) - .atLeast(Energy, OutputBus, InputHatch, InputBus, Maintenance) - .casingIndex(getCasingTextureId()) - .dot(1) - .build(), - ofBlock(GregTech_API.sBlockCasings4, 1) - )) - .addElement('l', buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) - .atLeast(layeredOutputHatch, Muffler, Energy, Maintenance) - .casingIndex(getCasingTextureId()) - .dot(2) - .buildAndChain(GregTech_API.sBlockCasings4, 1) - ) - .addElement('c', ofChain( - onElementPass(GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, ofHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower::addMufflerToMachineList, getCasingTextureId(), 3)), - onElementPass(GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, ofHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower::addOutputToMachineList, getCasingTextureId(), 3)), - onElementPass(GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, ofHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower::addMaintenanceToMachineList, getCasingTextureId(), 3)), - onElementPass(GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, ofBlock(GregTech_API.sBlockCasings4, 1)), - isAir() - )) - .addElement('t', buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) - .atLeast(layeredOutputHatch, Muffler) - .casingIndex(getCasingTextureId()) - .dot(2) - .buildAndChain(GregTech_API.sBlockCasings4, 1) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - - protected int getCurrentLayerOutputHatchCount() { - return mOutputHatchesByLayer.size() < mHeight ? 0 : mOutputHatchesByLayer.get(mHeight - 1).size(); - } - - protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) - return false; - while (mOutputHatchesByLayer.size() < mHeight) - mOutputHatchesByLayer.add(new ArrayList<>()); - GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); - tHatch.updateTexture(aBaseCasingIndex); - return mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); - } - - protected void onTopLayerFound() { - mTopLayerFound = true; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Advanced Distillation Tower") - .addInfo("Use 15% less energy in distillery mode") - .addInfo("250%/100% faster in DT/distillery mode") - .addInfo("Right click the controller with screwdriver to change mode.") - .addInfo("Max parallel dictated by tower tier and mode") - .addInfo("DTower Mode: T1=4, T2=12") - .addInfo("Distilery Mode: Tower Tier * (4*InputTier)") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addCasingInfo("Clean Stainless Steel Machine Casing", 7) - .addInputBus("Bottom Casing", 1) - .addOutputBus("Bottom Casing", 1) - .addInputHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addOutputHatch("One per layer except bottom", 2) - .addMufflerHatch("Top Casing", 3) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); - int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); - } - buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - mHeight = 0; - int built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - mHeight = i; - built = survivialBuildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, 1, i, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - } - mHeight = tTotalHeight; - return survivialBuildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, 1, tTotalHeight - 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - // reset - mOutputHatchesByLayer.forEach(List::clear); - mHeight = 1; - mTopLayerFound = false; - - // check base - if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) - return false; - - // check each layer - while (mHeight < 12) { - if (!checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) { - return false; - } - if (mOutputHatchesByLayer.size() < mHeight || mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) - // layer without output hatch - return false; - if (mTopLayerFound || !mMufflerHatches.isEmpty()) { - break; - } - // not top - mHeight++; - } - return mTopLayerFound && mHeight >= 2 && checkHatch(); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName()+(mUpgraded ? " T2" : ""), "MultiblockDisplay.png"); - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return mMode.getRecipeMap(); - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // don't rotate a freaking tower, it won't work - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(ItemStack aStack) { - if (this.mMode == Mode.Distillery) return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDistillery; - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDT; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mMode", (byte) mMode.ordinal()); - aNBT.setBoolean("mUpgraded", mUpgraded); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mMode = Mode.values()[aNBT.getByte("mMode")]; - mUpgraded = aNBT.getBoolean("mUpgraded"); - super.loadNBTData(aNBT); - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mMode = mMode.next(); - PlayerUtils.messagePlayer(aPlayer, "Now running in " + mMode + " Mode."); - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public boolean addOutput(FluidStack aLiquid) { - if (aLiquid == null) return false; - FluidStack copiedFluidStack = aLiquid.copy(); - for (List hatches : mOutputHatchesByLayer) { - if (dumpFluid(hatches, copiedFluidStack, true)) - return true; - } - for (List hatches : mOutputHatchesByLayer) { - if (dumpFluid(hatches, copiedFluidStack, false)) - return true; - } - return false; - } - - @Override - protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - if (mMode == Mode.DistillationTower) { - // dt mode - for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { - FluidStack tStack = mOutputFluids2[i].copy(); - if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) - dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); - } - } else { - // distillery mode - for (FluidStack outputFluidStack : mOutputFluids2) { - addOutput(outputFluidStack); - } - } - } - - @Override - public int canBufferOutputs(ItemStack[] aItemOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { - // do void excess checks - if (mVoidExcess) return aParallelRecipes; - // sb mode. no need to check layered outputs - if (mMode == Mode.Distillery) return super.canBufferOutputs(aItemOutputs, aFluidOutputs, aParallelRecipes); - // not enough output hatches - if (mOutputHatchesByLayer.size() < aFluidOutputs.length) { - log("Not enough output layers for distillation towers"); - return 0; - } - // first check if item output can be held. We delegate this to super class since we do not have special item hatches - aParallelRecipes = super.canBufferOutputs(aItemOutputs, new FluidStack[0], aParallelRecipes); - if (aParallelRecipes == 0) return 0; - for (int i = 0; i < aFluidOutputs.length; i++) { - FluidStack tFluidOutput = aFluidOutputs[i]; - FluidStack tCopied = new FluidStack(tFluidOutput, 0); - int toFill = tFluidOutput.amount * aParallelRecipes; - for (GT_MetaTileEntity_Hatch_Output hatch : mOutputHatchesByLayer.get(i)) { - boolean fluidMatch = - hatch.isFluidLocked() ? - tFluidOutput.getFluid().getName().equals(hatch.getLockedFluidName()) : - hatch.getFluid() == null || hatch.getFluid().isFluidEqual(tFluidOutput); - - if (fluidMatch) { - tCopied.amount = toFill; - toFill -= hatch.fill(tCopied, false); - if (toFill == 0) - // no more current fluid to fill. break out to go to next fluid - break; - } - } - // use ceil div - aParallelRecipes -= (toFill + tFluidOutput.amount - 1) / tFluidOutput.amount; - } - return aParallelRecipes; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "DistillationTower"; - } - - @Override - public String getMachineType() { - return "Distillery, Distillation Tower"; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - // Run standard recipe handling for distillery recipes - if (mMode == Mode.Distillery) { - return this.checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 100); - } - else { - ItemStack[] inputs = getCompactedInputs(); - - for (GT_MetaTileEntity_Hatch_Input hatch : mInputHatches) { - FluidStack tFluid = hatch.getFluid(); - if (tFluid != null) { - if (checkRecipeGeneric(inputs, new FluidStack[]{tFluid}, getMaxParallelRecipes(), 100, 250, 10000)) { - return true; - } - } - } - return false; - } - } - - @Override - public int getMaxParallelRecipes() { - switch (mMode) { - case DistillationTower: - return getTierOfTower() == 1 ? 4 : getTierOfTower() == 2 ? 12 : 0; - case Distillery: - return getTierOfTower() * (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - default: - return 0; - } - } - - @Override - public int getEuDiscountForParallelism() { - return 15; - } - - private int getTierOfTower() { - return mUpgraded ? 2 : 1; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; - } - - @Override - protected int getCasingTextureId() { - return 49; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aTick % 20 == 0 && !mUpgraded) { - ItemStack aGuiStack = this.getGUIItemStack(); - if (aGuiStack != null) { - if (GT_Utility.areStacksEqual(aGuiStack, GregtechItemList.Distillus_Upgrade_Chip.get(1))) { - this.mUpgraded = true; - ItemUtils.depleteStack(aGuiStack); - } - } - } - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - aNBT.setBoolean("mUpgraded", mUpgraded); - super.setItemNBT(aNBT); - } - - private enum Mode { - DistillationTower(GT_Recipe_Map.sDistillationRecipes), - Distillery(GT_Recipe_Map.sDistilleryRecipes), - ; - static final Mode[] VALUES = values(); - private final GT_Recipe_Map recipeMap; - - Mode(GT_Recipe_Map recipeMap) { - this.recipeMap = recipeMap; - } - - public GT_Recipe_Map getRecipeMap() { - return recipeMap; - } - - public Mode next() { - return VALUES[ordinal() + 1 % VALUES.length]; - } - } -} \ No newline at end of file +public class GregtechMetaTileEntity_Adv_DistillationTower + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private Mode mMode = Mode.DistillationTower; + private boolean mUpgraded = false; + + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; + + protected final List> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; + + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Adv_DistillationTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_Adv_DistillationTower(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_DistillationTower(this.mName); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + IHatchElement layeredOutputHatch = OutputHatch.withCount( + GregtechMetaTileEntity_Adv_DistillationTower::getCurrentLayerOutputHatchCount) + .withAdder(GregtechMetaTileEntity_Adv_DistillationTower::addLayerOutputHatch); + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { + {"b~b", "bbb", "bbb"}, + })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] {{"lll", "lcl", "lll"}})) + .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][] {{"lll", "l-l", "lll"}})) + .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][] {{"ttt", "ttt", "ttt"}})) + .addElement( + 'b', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) + .atLeast(Energy, OutputBus, InputHatch, InputBus, Maintenance) + .casingIndex(getCasingTextureId()) + .dot(1) + .build(), + ofBlock(GregTech_API.sBlockCasings4, 1))) + .addElement( + 'l', + buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) + .atLeast(layeredOutputHatch, Muffler, Energy, Maintenance) + .casingIndex(getCasingTextureId()) + .dot(2) + .buildAndChain(GregTech_API.sBlockCasings4, 1)) + .addElement( + 'c', + ofChain( + onElementPass( + GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, + ofHatchAdder( + GregtechMetaTileEntity_Adv_DistillationTower + ::addMufflerToMachineList, + getCasingTextureId(), + 3)), + onElementPass( + GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, + ofHatchAdder( + GregtechMetaTileEntity_Adv_DistillationTower + ::addOutputToMachineList, + getCasingTextureId(), + 3)), + onElementPass( + GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, + ofHatchAdder( + GregtechMetaTileEntity_Adv_DistillationTower + ::addMaintenanceToMachineList, + getCasingTextureId(), + 3)), + onElementPass( + GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, + ofBlock(GregTech_API.sBlockCasings4, 1)), + isAir())) + .addElement( + 't', + buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) + .atLeast(layeredOutputHatch, Muffler) + .casingIndex(getCasingTextureId()) + .dot(2) + .buildAndChain(GregTech_API.sBlockCasings4, 1)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + protected int getCurrentLayerOutputHatchCount() { + return mOutputHatchesByLayer.size() < mHeight + ? 0 + : mOutputHatchesByLayer.get(mHeight - 1).size(); + } + + protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null + || aTileEntity.isDead() + || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) return false; + while (mOutputHatchesByLayer.size() < mHeight) mOutputHatchesByLayer.add(new ArrayList<>()); + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); + } + + protected void onTopLayerFound() { + mTopLayerFound = true; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Advanced Distillation Tower") + .addInfo("Use 15% less energy in distillery mode") + .addInfo("250%/100% faster in DT/distillery mode") + .addInfo("Right click the controller with screwdriver to change mode.") + .addInfo("Max parallel dictated by tower tier and mode") + .addInfo("DTower Mode: T1=4, T2=12") + .addInfo("Distilery Mode: Tower Tier * (4*InputTier)") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addCasingInfo("Clean Stainless Steel Machine Casing", 7) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addOutputHatch("One per layer except bottom", 2) + .addMufflerHatch("Top Casing", 3) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); + int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); + } + buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + mHeight = 0; + int built = survivialBuildPiece( + STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + mHeight = i; + built = survivialBuildPiece( + STRUCTURE_PIECE_LAYER_HINT, stackSize, 1, i, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + } + mHeight = tTotalHeight; + return survivialBuildPiece( + STRUCTURE_PIECE_TOP_HINT, stackSize, 1, tTotalHeight - 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + mOutputHatchesByLayer.forEach(List::clear); + mHeight = 1; + mTopLayerFound = false; + + // check base + if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) return false; + + // check each layer + while (mHeight < 12) { + if (!checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) { + return false; + } + if (mOutputHatchesByLayer.size() < mHeight + || mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) + // layer without output hatch + return false; + if (mTopLayerFound || !mMufflerHatches.isEmpty()) { + break; + } + // not top + mHeight++; + } + return mTopLayerFound && mHeight >= 2 && checkHatch(); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, + aBaseMetaTileEntity, + getLocalName() + (mUpgraded ? " T2" : ""), + "MultiblockDisplay.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mMode.getRecipeMap(); + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a freaking tower, it won't work + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + if (this.mMode == Mode.Distillery) + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDistillery; + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDT; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mMode", (byte) mMode.ordinal()); + aNBT.setBoolean("mUpgraded", mUpgraded); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mMode = Mode.values()[aNBT.getByte("mMode")]; + mUpgraded = aNBT.getBoolean("mUpgraded"); + super.loadNBTData(aNBT); + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mMode = mMode.next(); + PlayerUtils.messagePlayer(aPlayer, "Now running in " + mMode + " Mode."); + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack copiedFluidStack = aLiquid.copy(); + for (List hatches : mOutputHatchesByLayer) { + if (dumpFluid(hatches, copiedFluidStack, true)) return true; + } + for (List hatches : mOutputHatchesByLayer) { + if (dumpFluid(hatches, copiedFluidStack, false)) return true; + } + return false; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + if (mMode == Mode.DistillationTower) { + // dt mode + for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i].copy(); + if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) + dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); + } + } else { + // distillery mode + for (FluidStack outputFluidStack : mOutputFluids2) { + addOutput(outputFluidStack); + } + } + } + + @Override + public int canBufferOutputs(ItemStack[] aItemOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { + // do void excess checks + if (mVoidExcess) return aParallelRecipes; + // sb mode. no need to check layered outputs + if (mMode == Mode.Distillery) return super.canBufferOutputs(aItemOutputs, aFluidOutputs, aParallelRecipes); + // not enough output hatches + if (mOutputHatchesByLayer.size() < aFluidOutputs.length) { + log("Not enough output layers for distillation towers"); + return 0; + } + // first check if item output can be held. We delegate this to super class since we do not have special item + // hatches + aParallelRecipes = super.canBufferOutputs(aItemOutputs, new FluidStack[0], aParallelRecipes); + if (aParallelRecipes == 0) return 0; + for (int i = 0; i < aFluidOutputs.length; i++) { + FluidStack tFluidOutput = aFluidOutputs[i]; + FluidStack tCopied = new FluidStack(tFluidOutput, 0); + int toFill = tFluidOutput.amount * aParallelRecipes; + for (GT_MetaTileEntity_Hatch_Output hatch : mOutputHatchesByLayer.get(i)) { + boolean fluidMatch = hatch.isFluidLocked() + ? tFluidOutput.getFluid().getName().equals(hatch.getLockedFluidName()) + : hatch.getFluid() == null || hatch.getFluid().isFluidEqual(tFluidOutput); + + if (fluidMatch) { + tCopied.amount = toFill; + toFill -= hatch.fill(tCopied, false); + if (toFill == 0) + // no more current fluid to fill. break out to go to next fluid + break; + } + } + // use ceil div + aParallelRecipes -= (toFill + tFluidOutput.amount - 1) / tFluidOutput.amount; + } + return aParallelRecipes; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "DistillationTower"; + } + + @Override + public String getMachineType() { + return "Distillery, Distillation Tower"; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + // Run standard recipe handling for distillery recipes + if (mMode == Mode.Distillery) { + return this.checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 100); + } else { + ItemStack[] inputs = getCompactedInputs(); + + for (GT_MetaTileEntity_Hatch_Input hatch : mInputHatches) { + FluidStack tFluid = hatch.getFluid(); + if (tFluid != null) { + if (checkRecipeGeneric( + inputs, new FluidStack[] {tFluid}, getMaxParallelRecipes(), 100, 250, 10000)) { + return true; + } + } + } + return false; + } + } + + @Override + public int getMaxParallelRecipes() { + switch (mMode) { + case DistillationTower: + return getTierOfTower() == 1 ? 4 : getTierOfTower() == 2 ? 12 : 0; + case Distillery: + return getTierOfTower() * (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + default: + return 0; + } + } + + @Override + public int getEuDiscountForParallelism() { + return 15; + } + + private int getTierOfTower() { + return mUpgraded ? 2 : 1; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; + } + + @Override + protected int getCasingTextureId() { + return 49; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aTick % 20 == 0 && !mUpgraded) { + ItemStack aGuiStack = this.getGUIItemStack(); + if (aGuiStack != null) { + if (GT_Utility.areStacksEqual(aGuiStack, GregtechItemList.Distillus_Upgrade_Chip.get(1))) { + this.mUpgraded = true; + ItemUtils.depleteStack(aGuiStack); + } + } + } + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + aNBT.setBoolean("mUpgraded", mUpgraded); + super.setItemNBT(aNBT); + } + + private enum Mode { + DistillationTower(GT_Recipe_Map.sDistillationRecipes), + Distillery(GT_Recipe_Map.sDistilleryRecipes), + ; + static final Mode[] VALUES = values(); + private final GT_Recipe_Map recipeMap; + + Mode(GT_Recipe_Map recipeMap) { + this.recipeMap = recipeMap; + } + + public GT_Recipe_Map getRecipeMap() { + return recipeMap; + } + + public Mode next() { + return VALUES[ordinal() + 1 % VALUES.length]; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index 5c16be3e88..d493b695a6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -1,7 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -19,10 +25,11 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -31,473 +38,473 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofCoil; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - public static String mHotFuelName = "Blazing Pyrotheum"; - public static String mCasingName = "Volcanus Casing"; - public static String mHatchName = "Pyrotheum Hatch"; - private IStructureDefinition STRUCTURE_DEFINITION = null; - private int mCasing; - private final ArrayList mPyrotheumHatches = new ArrayList<>(); - - private HeatingCoilLevel mHeatingCapacity; - private boolean isBussesSeparate = false; - - public GregtechMetaTileEntity_Adv_EBF(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); - } - - public GregtechMetaTileEntity_Adv_EBF(String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); - } - - @Override - public String getMachineType() { - return "Blast Furnace"; - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_EBF(this.mName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Advanced Blast Furnace") - .addInfo("Speed: +120% | EU Usage: 90% | Parallel: 8") - .addInfo("Consumes 10L of " + mHotFuelName + " per second during operation") - .addInfo("Constructed exactly the same as a normal EBF") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addController("Bottom center") - .addCasingInfo(mCasingName, 9) - .addInputHatch("Any Casing", 1) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addStructureHint(mHatchName, 1) - .addEnergyHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"HHH", "H-H", "HHH"}, - {"HHH", "H-H", "HHH"}, - {"C~C", "CCC", "CCC"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_Adv_EBF.class) - .adder(GregtechMetaTileEntity_Adv_EBF::addPyrotheumHatch) - .hatchId(968) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_Adv_EBF.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasings3Misc, 11 - ) - ) - ) - ) - .addElement( - 'H', - ofCoil( - GregtechMetaTileEntity_Adv_EBF::setCoilLevel, GregtechMetaTileEntity_Adv_EBF::getCoilLevel - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mPyrotheumHatches.clear(); - setCoilLevel(HeatingCoilLevel.None); - return checkPiece(mName, 1, 3, 0) && mCasing >= 9 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); - } - - @Override - public boolean checkHatch() { - return super.checkHatch() || !mPyrotheumHatches.isEmpty(); - } - - private boolean addPyrotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 968) { - return addToMachineListInternal(mPyrotheumHatches, aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public void updateSlots() { - for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mPyrotheumHatches) - if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); - super.updateSlots(); - } - - private boolean depleteFuel(int aAmount) { - for (final GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : this.mPyrotheumHatches) { - if (isValidMetaTileEntity(tHatch)) { - FluidStack tLiquid = tHatch.getFluid(); - if (tLiquid == null || tLiquid.amount < aAmount) { - continue; - } - tLiquid = tHatch.drain(aAmount, false); - if (tLiquid != null && tLiquid.amount >= aAmount) { - tLiquid = tHatch.drain(aAmount, true); - return tLiquid != null && tLiquid.amount >= aAmount; - } - } - } - return false; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "ElectricBlastFurnace"; - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBlastRecipes; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - if (isBussesSeparate) { - FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tInputs = new ArrayList<>(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - if (tInputs.size() > 0) { - if (checkRecipeGeneric(tInputs.toArray(new ItemStack[0]), tFluids, 8, 90, 120, 10000)) { - return true; - } - } - } - return false; - } else { - return checkRecipeGeneric(8, 90, 120); - } - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvEBF; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - Logger.WARNING("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = this.getRecipeMap().findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - Logger.WARNING("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { - Logger.WARNING("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - int tHeatCapacityDivTiers = (int) (mHeatingCapacity.getHeat() - tRecipe.mSpecialValue) / 900; - if (tHeatCapacityDivTiers > 0) - tRecipeEUt = (int) (tRecipeEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - // Count recipes to do in parallel, consuming input items and fluids and - // considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - Logger.WARNING("Broke at " + parallelRecipes + "."); - break; - } - Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); - int tHalfHeatCapacityDivTiers = tHeatCapacityDivTiers / 2; - - this.mEUt = (int) Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - if (tHalfHeatCapacityDivTiers > 0) { - this.mMaxProgresstime = mMaxProgresstime / 4; - tHalfHeatCapacityDivTiers--; - } else { - this.mMaxProgresstime = mMaxProgresstime / 2; - } - if (this.mMaxProgresstime <= 1) { - break; - } - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) - tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - Logger.WARNING("GOOD RETURN - 1"); - return true; - - } - - private int mGraceTimer = 2; - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - //Try dry Pyrotheum after all other logic - if (this.mStartUpCheck < 0) { - if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - if (!this.depleteInputFromRestrictedHatches(this.mPyrotheumHatches, 5)) { - if (mGraceTimer-- == 0) { - this.causeMaintenanceIssue(); - this.stopMachine(); - mGraceTimer = 2; - } - } - } - } - } - - } - - @Override - public int getMaxParallelRecipes() { - return 8; - } - - @Override - public int getEuDiscountForParallelism() { - return 90; - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - isBussesSeparate = !isBussesSeparate; - aPlayer.addChatMessage(new ChatComponentTranslation(isBussesSeparate ? "interaction.separateBusses.enabled" : "interaction.separateBusses.disabled")); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("isBussesSeparate", isBussesSeparate); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - isBussesSeparate = aNBT.getBoolean("isBussesSeparate"); - super.loadNBTData(aNBT); - } - - public HeatingCoilLevel getCoilLevel() { - return mHeatingCapacity; - } - - public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - mHeatingCapacity = aCoilLevel; - } +public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + public static String mHotFuelName = "Blazing Pyrotheum"; + public static String mCasingName = "Volcanus Casing"; + public static String mHatchName = "Pyrotheum Hatch"; + private IStructureDefinition STRUCTURE_DEFINITION = null; + private int mCasing; + private final ArrayList mPyrotheumHatches = new ArrayList<>(); + + private HeatingCoilLevel mHeatingCapacity; + private boolean isBussesSeparate = false; + + public GregtechMetaTileEntity_Adv_EBF(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); + } + + public GregtechMetaTileEntity_Adv_EBF(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); + } + + @Override + public String getMachineType() { + return "Blast Furnace"; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_EBF(this.mName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Blast Furnace") + .addInfo("Speed: +120% | EU Usage: 90% | Parallel: 8") + .addInfo("Consumes 10L of " + mHotFuelName + " per second during operation") + .addInfo("Constructed exactly the same as a normal EBF") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addController("Bottom center") + .addCasingInfo(mCasingName, 9) + .addInputHatch("Any Casing", 1) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addStructureHint(mHatchName, 1) + .addEnergyHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_Adv_EBF.class) + .adder(GregtechMetaTileEntity_Adv_EBF::addPyrotheumHatch) + .hatchId(968) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + buildHatchAdder(GregtechMetaTileEntity_Adv_EBF.class) + .atLeast( + InputBus, + OutputBus, + Maintenance, + Energy, + Muffler, + InputHatch, + OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 11)))) + .addElement( + 'H', + ofCoil( + GregtechMetaTileEntity_Adv_EBF::setCoilLevel, + GregtechMetaTileEntity_Adv_EBF::getCoilLevel)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mPyrotheumHatches.clear(); + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 3, 0) && mCasing >= 9 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); + } + + @Override + public boolean checkHatch() { + return super.checkHatch() || !mPyrotheumHatches.isEmpty(); + } + + private boolean addPyrotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase + && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 968) { + return addToMachineListInternal(mPyrotheumHatches, aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void updateSlots() { + for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mPyrotheumHatches) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + super.updateSlots(); + } + + private boolean depleteFuel(int aAmount) { + for (final GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : this.mPyrotheumHatches) { + if (isValidMetaTileEntity(tHatch)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid == null || tLiquid.amount < aAmount) { + continue; + } + tLiquid = tHatch.drain(aAmount, false); + if (tLiquid != null && tLiquid.amount >= aAmount) { + tLiquid = tHatch.drain(aAmount, true); + return tLiquid != null && tLiquid.amount >= aAmount; + } + } + } + return false; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBlastRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + if (isBussesSeparate) { + FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tInputs = new ArrayList<>(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { + tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + if (tInputs.size() > 0) { + if (checkRecipeGeneric(tInputs.toArray(new ItemStack[0]), tFluids, 8, 90, 120, 10000)) { + return true; + } + } + } + return false; + } else { + return checkRecipeGeneric(8, 90, 120); + } + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvEBF; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + Logger.WARNING("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = this.getRecipeMap() + .findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + Logger.WARNING("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { + Logger.WARNING("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + int tHeatCapacityDivTiers = (int) (mHeatingCapacity.getHeat() - tRecipe.mSpecialValue) / 900; + if (tHeatCapacityDivTiers > 0) tRecipeEUt = (int) (tRecipeEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // Count recipes to do in parallel, consuming input items and fluids and + // considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + Logger.WARNING("Broke at " + parallelRecipes + "."); + break; + } + Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + int tHalfHeatCapacityDivTiers = tHeatCapacityDivTiers / 2; + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + if (tHalfHeatCapacityDivTiers > 0) { + this.mMaxProgresstime = mMaxProgresstime / 4; + tHalfHeatCapacityDivTiers--; + } else { + this.mMaxProgresstime = mMaxProgresstime / 2; + } + if (this.mMaxProgresstime <= 1) { + break; + } + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.WARNING("GOOD RETURN - 1"); + return true; + } + + private int mGraceTimer = 2; + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + // Try dry Pyrotheum after all other logic + if (this.mStartUpCheck < 0) { + if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 + || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (!this.depleteInputFromRestrictedHatches(this.mPyrotheumHatches, 5)) { + if (mGraceTimer-- == 0) { + this.causeMaintenanceIssue(); + this.stopMachine(); + mGraceTimer = 2; + } + } + } + } + } + } + + @Override + public int getMaxParallelRecipes() { + return 8; + } + + @Override + public int getEuDiscountForParallelism() { + return 90; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + isBussesSeparate = !isBussesSeparate; + aPlayer.addChatMessage(new ChatComponentTranslation( + isBussesSeparate ? "interaction.separateBusses.enabled" : "interaction.separateBusses.disabled")); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("isBussesSeparate", isBussesSeparate); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + isBussesSeparate = aNBT.getBoolean("isBussesSeparate"); + super.loadNBTData(aNBT); + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java index 8aa91fa41a..8df07d8990 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java @@ -19,16 +19,15 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import net.minecraft.block.Block; - import java.lang.reflect.Method; +import net.minecraft.block.Block; public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_FusionComputer { - public static final Method mUpdateHatchTexture; - - static { - mUpdateHatchTexture = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); + public static final Method mUpdateHatchTexture; + + static { + mUpdateHatchTexture = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); } public GregtechMetaTileEntity_Adv_Fusion_MK4(int aID, String aName, String aNameRegional) { @@ -56,7 +55,7 @@ public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_Fus .addStructureInfo("ALL Hatches must be UHV or better") .toolTipFinisher(CORE.GT_Tooltip_Builder); return tt; - } + } @Override public int tier() { @@ -69,91 +68,107 @@ public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_Fus } @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_Fusion_MK4(mName); - } - - @Override - public Block getCasing() { - return getFusionCoil(); - } - - @Override - public int getCasingMeta() { - return 12; - } - - @Override - public Block getFusionCoil() { - return ModBlocks.blockCasings3Misc; - } - - @Override - public int getFusionCoilMeta() { - return 13; - } - - @Override - public int tierOverclock() { - return 8; - } - - @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_Fusion_MK4(mName); + } + + @Override + public Block getCasing() { + return getFusionCoil(); + } + + @Override + public int getCasingMeta() { + return 12; + } + + @Override + public Block getFusionCoil() { + return ModBlocks.blockCasings3Misc; + } + + @Override + public int getFusionCoilMeta() { + return 13; + } + + @Override + public int tierOverclock() { + return 8; + } + + @Override public int overclock(int mStartEnergy) { return (mStartEnergy < 160000000) ? 16 : ((mStartEnergy < 320000000) ? 8 : (mStartEnergy < 640000000) ? 4 : 1); } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{ - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, - Dyes.getModulation(-1, Dyes._NULL.mRGBa)), - TextureFactory.builder().addIcon(this.getIconOverlay()).extFacing().build()}; - } else if (!aActive) { - return new ITexture[]{ - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, - Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; - } else { - return new ITexture[]{ - new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA, - Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; - } - } + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, Dyes.getModulation(-1, Dyes._NULL.mRGBa)), + TextureFactory.builder() + .addIcon(this.getIconOverlay()) + .extFacing() + .build() + }; + } else if (!aActive) { + return new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, Dyes.getModulation(-1, Dyes._NULL.mRGBa)) + }; + } else { + return new ITexture[] { + new GT_RenderedTexture( + TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA, Dyes.getModulation(-1, Dyes._NULL.mRGBa)) + }; + } + } @Override public ITexture getTextureOverlay() { - return new GT_RenderedTexture(this.mMaxProgresstime > 0 ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1); - } - - public IIconContainer getIconOverlay() { - return this.mMaxProgresstime > 0 ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1; - } - - public boolean turnCasingActive(final boolean status) { - try { - if (this.mEnergyHatches != null) { - for (final GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { - mUpdateHatchTexture.invoke(hatch, (status ? TAE.getIndexFromPage(2, 14) : 53)); - } - } - if (this.mOutputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Output hatch2 : this.mOutputHatches) { - mUpdateHatchTexture.invoke(hatch2, (status ? TAE.getIndexFromPage(2, 14) : 53)); - } - } - if (this.mInputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Input hatch3 : this.mInputHatches) { - mUpdateHatchTexture.invoke(hatch3, (status ? TAE.getIndexFromPage(2, 14) : 53)); - } - } - } - catch (Throwable t) { - return false; - } - return true; - } - + return new GT_RenderedTexture( + this.mMaxProgresstime > 0 + ? TexturesGtBlock.Casing_Machine_Screen_3 + : TexturesGtBlock.Casing_Machine_Screen_1); + } + + public IIconContainer getIconOverlay() { + return this.mMaxProgresstime > 0 + ? TexturesGtBlock.Casing_Machine_Screen_3 + : TexturesGtBlock.Casing_Machine_Screen_1; + } + + public boolean turnCasingActive(final boolean status) { + try { + if (this.mEnergyHatches != null) { + for (final GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { + mUpdateHatchTexture.invoke(hatch, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + if (this.mOutputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Output hatch2 : this.mOutputHatches) { + mUpdateHatchTexture.invoke(hatch2, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + if (this.mInputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Input hatch3 : this.mInputHatches) { + mUpdateHatchTexture.invoke(hatch3, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + } catch (Throwable t) { + return false; + } + return true; + } + @Override public String[] getInfoData() { String tier = "IV"; @@ -162,15 +177,15 @@ public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_Fus if (this.mLastRecipe != null) { powerRequired = this.mLastRecipe.mEUt; if (this.mLastRecipe.getFluidOutput(0) != null) { - plasmaOut = (float)this.mLastRecipe.getFluidOutput(0).amount / (float)this.mLastRecipe.mDuration; + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; } } - return new String[]{ - "Fusion Reactor MK "+tier, - "EU Required: "+powerRequired+"EU/t", - "Stored EU: "+mEUStore+" / "+maxEUStore(), - "Plasma Output: "+plasmaOut+"L/t"}; + return new String[] { + "Fusion Reactor MK " + tier, + "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + mEUStore + " / " + maxEUStore(), + "Plasma Output: " + plasmaOut + "L/t" + }; } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java index d568c298ee..002cffb816 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java @@ -6,7 +6,6 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; - import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.gui.GT_GUIContainer_MultiMachine; @@ -31,55 +30,84 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_MultiBlockBase { - - private static final int CASING_INDEX = TAE.getIndexFromPage(1, 12); +public class GregtechMetaTileEntity_Adv_HeatExchanger + extends GregtechMeta_MultiBlockBase { + + private static final int CASING_INDEX = TAE.getIndexFromPage(1, 12); private static final String STRUCTURE_PIECE_MAIN = "main"; - - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {" ccc ", "cCCCc", "cCCCc", "cCCCc", " ccc "}, - {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, - {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, - {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, - {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, - {" c~c ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, - {" hhh ", "hHHHh", "hHHHh", "hHHHh", " hhh "}, - {" f f ", "f f", " ", "f f", " f f "}, - {" f f ", "f f", " ", "f f", " f f "}, - })) - .addElement('P', ofBlock(GregTech_API.sBlockCasings2, 15)) - .addElement('f', ofBlock(getFrame(), 0)) - .addElement('C', ofChain( - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addColdFluidOutputToMachineList, CASING_INDEX, 2), - onElementPass(GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)) - )) - .addElement('H', ofChain( - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addHotFluidInputToMachineList, CASING_INDEX, 3), - onElementPass(GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)) - )) - .addElement('h', ofChain( - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addInputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addOutputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addMaintenanceToMachineList, CASING_INDEX, 1), - onElementPass(GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)) - )) - .addElement('c', ofChain( - onElementPass(GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)) - )) - .build(); - public static float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) + + private static final IStructureDefinition STRUCTURE_DEFINITION = + StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { + {" ccc ", "cCCCc", "cCCCc", "cCCCc", " ccc "}, + {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, + {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, + {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, + {" ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, + {" c~c ", "cPPPc", "cPPPc", "cPPPc", " ccc "}, + {" hhh ", "hHHHh", "hHHHh", "hHHHh", " hhh "}, + {" f f ", "f f", " ", "f f", " f f "}, + {" f f ", "f f", " ", "f f", " f f "}, + })) + .addElement('P', ofBlock(GregTech_API.sBlockCasings2, 15)) + .addElement('f', ofBlock(getFrame(), 0)) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_Adv_HeatExchanger::addColdFluidOutputToMachineList, + CASING_INDEX, + 2), + onElementPass( + GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, + ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .addElement( + 'H', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_Adv_HeatExchanger::addHotFluidInputToMachineList, + CASING_INDEX, + 3), + onElementPass( + GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, + ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .addElement( + 'h', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_Adv_HeatExchanger::addInputToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GregtechMetaTileEntity_Adv_HeatExchanger::addOutputToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GregtechMetaTileEntity_Adv_HeatExchanger::addMaintenanceToMachineList, + CASING_INDEX, + 1), + onElementPass( + GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, + ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .addElement( + 'c', + ofChain(onElementPass( + GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, + ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .build(); + public static float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) private GT_MetaTileEntity_Hatch_Input mInputHotFluidHatch; private GT_MetaTileEntity_Hatch_Output mOutputColdFluidHatch; private boolean superheated = false; - private int superheated_threshold=0; + private int superheated_threshold = 0; private float water; private int mCasingAmount; public GregtechMetaTileEntity_Adv_HeatExchanger(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } + public GregtechMetaTileEntity_Adv_HeatExchanger(String aName) { super(aName); } @@ -143,7 +171,8 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_Multi @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeHeatExchanger.png"); + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeHeatExchanger.png"); } @Override @@ -158,18 +187,17 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_Multi @Override public boolean checkRecipe(ItemStack aStack) { - if (mInputHotFluidHatch.getFluid() == null) - return true; + if (mInputHotFluidHatch.getFluid() == null) return true; int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch // The XL LHE works as fast as 32 regular LHEs. These are the comments from the original LHE, // with changes where the values needed to change for the 32x speed multiplier - superheated_threshold = 128000; // default: must have 4000L -> 128000L per second to generate superheated steam - float efficiency = 1f; // default: operate at 100% efficiency with no integrated circuitry + superheated_threshold = 128000; // default: must have 4000L -> 128000L per second to generate superheated steam + float efficiency = 1f; // default: operate at 100% efficiency with no integrated circuitry int shs_reduction_per_config = 4800; // reduce threshold 150L -> 4800L per second per circuitry level (1-25) float steam_output_multiplier = 20f; // default: multiply output by 4 * 10 (boosted x5) - float penalty = 0.0f; // penalty to apply to output based on circuitry level (1-25). + float penalty = 0.0f; // penalty to apply to output based on circuitry level (1-25). boolean do_lava = false; // Do we have an integrated circuit with a valid configuration? @@ -190,15 +218,19 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_Multi do_lava = true; } else if (mInputHotFluidHatch.getFluid().isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))) { steam_output_multiplier /= 2f; // was boosted x2 on top of x5 -> total x10 -> nerf with this code back to 5x - superheated_threshold /=5f; // 10x smaller since the Hot Things production in reactor is the same. + superheated_threshold /= 5f; // 10x smaller since the Hot Things production in reactor is the same. } else { // If we're working with neither, fail out - superheated_threshold=0; + superheated_threshold = 0; return false; } - superheated = fluidAmountToConsume >= superheated_threshold; // set the internal superheated flag if we have enough hot fluid. Used in the onRunningTick method. - fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); // Don't consume too much hot fluid per second, maximum is 2x SH threshold. + superheated = fluidAmountToConsume + >= superheated_threshold; // set the internal superheated flag if we have enough hot fluid. Used in the + // onRunningTick method. + fluidAmountToConsume = Math.min( + fluidAmountToConsume, + superheated_threshold * 2); // Don't consume too much hot fluid per second, maximum is 2x SH threshold. mInputHotFluidHatch.drain(fluidAmountToConsume, true); this.mMaxProgresstime = 20; this.mEUt = (int) (fluidAmountToConsume * steam_output_multiplier * efficiency); @@ -221,24 +253,27 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_Multi @Override public boolean onRunningTick(ItemStack aStack) { if (this.mEUt > 0) { - int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to generate. + int tGeneratedEU = + (int) (this.mEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to generate. if (tGeneratedEU > 0) { if (superheated) tGeneratedEU /= 2; // We produce half as much superheated steam if necessary int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume - //tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect 1:160 ratio with distilled water consumption + // tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect + // 1:160 ratio with distilled water consumption FluidStack distilledStack = GT_ModHandler.getDistilledWater(distilledConsumed); if (depleteInput(distilledStack)) // Consume the distilled water { if (superheated) { - addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate superheated steam + addOutput(FluidRegistry.getFluidStack( + "ic2superheatedsteam", tGeneratedEU)); // Generate superheated steam } else { addOutput(GT_ModHandler.getSteam(tGeneratedEU)); // Generate regular steam } } else { - GT_Log.exp.println(this.mName+" had no more Distilled water!"); + GT_Log.exp.println(this.mName + " had no more Distilled water!"); explodeMultiblock(); // Generate crater } } @@ -298,6 +333,7 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_Multi public int getDamageToComponent(ItemStack aStack) { return 0; } + @Override public boolean explodesOnComponentBreak(ItemStack aStack) { return false; @@ -315,20 +351,26 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_Multi @Override public String[] getExtraInfoData() { - return new String[]{ - StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", - StatCollector.translateToLocal("GT5U.multiblock.usage") + " " + StatCollector.translateToLocal("GT5U.LHE.steam") + ": " + - (superheated ? EnumChatFormatting.RED : EnumChatFormatting.YELLOW) + GT_Utility.formatNumbers(superheated ? -2 * mEUt : -mEUt) + EnumChatFormatting.RESET + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + - StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + - EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", - StatCollector.translateToLocal("GT5U.LHE.superheated") + ": " + - (superheated ? EnumChatFormatting.RED : EnumChatFormatting.BLUE) + superheated + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + StatCollector.translateToLocal("GT5U.LHE.threshold") + ": " + - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(superheated_threshold) + EnumChatFormatting.RESET + return new String[] { + StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", + StatCollector.translateToLocal("GT5U.multiblock.usage") + " " + + StatCollector.translateToLocal("GT5U.LHE.steam") + ": " + + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.YELLOW) + + GT_Utility.formatNumbers(superheated ? -2 * mEUt : -mEUt) + EnumChatFormatting.RESET + " EU/t", + StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + + ": " + EnumChatFormatting.YELLOW + + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", + StatCollector.translateToLocal("GT5U.LHE.superheated") + ": " + + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.BLUE) + superheated + + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + + StatCollector.translateToLocal("GT5U.LHE.threshold") + ": " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(superheated_threshold) + EnumChatFormatting.RESET }; } @@ -336,33 +378,38 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger extends GregtechMeta_Multi public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 2, 5, 0); } - @Override - public boolean hasSlotInGUI() { - return true; - } - @Override - public String getCustomGUIResourceName() { - return null; - } - @Override - public String getMachineType() { - return "Heat Exchanger"; - } - @Override - public int getMaxParallelRecipes() { - return 0; - } - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - private static Block sFrame; - - public static Block getFrame() { - if (sFrame == null) { - sFrame = BlockBaseModular.getMaterialBlock(ALLOY.TALONITE, BlockTypes.FRAME); - } - return sFrame; - } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Heat Exchanger"; + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + private static Block sFrame; + + public static Block getFrame() { + if (sFrame == null) { + sFrame = BlockBaseModular.getMaterialBlock(ALLOY.TALONITE, BlockTypes.FRAME); + } + return sFrame; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java index de85c3acdc..6ec4e8ddbe 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java @@ -6,7 +6,6 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; - import gregtech.api.GregTech_API; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -18,186 +17,177 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntity_Adv_Implosion extends GregtechMeta_MultiBlockBase { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Adv_Implosion(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Adv_Implosion(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_Implosion(this.mName); - } - - @Override - public String getMachineType() { - return "Implosion Compressor"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Advanced Implosion Compressor") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: ((Tier/2)+1)") - .addInfo("Constructed exactly the same as a normal Implosion Compressor") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo("Robust TungstenSteel Casing", 10) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - ofChain( - ofHatchAdder( - GregtechMetaTileEntity_Adv_Implosion::addAdvImplosionList, 48, 1 - ), - onElementPass( - x -> ++x.mCasing, - ofBlock( - sBlockCasings4, 0 - ) - ) - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - public final boolean addAdvImplosionList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return 48; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "ImplosionCompressor"; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sImplosionRecipes; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((GT_Utility.getTier(this.getMaxInputVoltage())/2+1), 100, 100); - } - - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public String getSound() { - return (String) GregTech_API.sSoundList.get(Integer.valueOf(5)); - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (GT_Utility.getTier(this.getMaxInputVoltage())/2+1); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_Adv_Implosion + extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Adv_Implosion(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_Adv_Implosion(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_Implosion(this.mName); + } + + @Override + public String getMachineType() { + return "Implosion Compressor"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Implosion Compressor") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: ((Tier/2)+1)") + .addInfo("Constructed exactly the same as a normal Implosion Compressor") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Robust TungstenSteel Casing", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder(GregtechMetaTileEntity_Adv_Implosion::addAdvImplosionList, 48, 1), + onElementPass(x -> ++x.mCasing, ofBlock(sBlockCasings4, 0)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addAdvImplosionList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return 48; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ImplosionCompressor"; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sImplosionRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((GT_Utility.getTier(this.getMaxInputVoltage()) / 2 + 1), 100, 100); + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public String getSound() { + return (String) GregTech_API.sSoundList.get(Integer.valueOf(5)); + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (GT_Utility.getTier(this.getMaxInputVoltage()) / 2 + 1); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java index 3d23523b0a..4b24df6ee7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java @@ -9,7 +9,6 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -25,139 +24,127 @@ import net.minecraft.item.ItemStack; public class GregtechMetaTileEntity_SteamCompressor extends GregtechMeta_SteamMultiBase { - private String mCasingName = "Bronze Plated Bricks"; - private IStructureDefinition STRUCTURE_DEFINITION = null; - private int mCasing; - - public GregtechMetaTileEntity_SteamCompressor(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamCompressor(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { - return new GregtechMetaTileEntity_SteamCompressor(this.mName); - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR_ACTIVE); - } - - @Override - public String getMachineType() { - return "Compressor"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Compressor") - .addInfo("Compresses " + getMaxParallelRecipes() + " things at a time") - .addSeparator() - .beginStructureBlock(3, 3, 4, true) - .addController("Front center") - .addCasingInfo(mCasingName, 28) - .addOtherStructurePart(TT_steaminputbus, "Any casing", 1) - .addOtherStructurePart(TT_steamoutputbus, "Any casing", 1) - .addOtherStructurePart(TT_steamhatch, "Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC", "CCC"}, - {"C~C", "C-C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - ofChain( - ofHatchAdder( - GregtechMetaTileEntity_SteamCompressor::addSteamMultiList, 10, 1 - ), - onElementPass( - x -> ++x.mCasing, - ofBlock( - sBlockCasings1, 10 - ) - ) - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - public final boolean addSteamMultiList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 31040){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - fixAllMaintenanceIssue(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 28; - } - - @Override - public int getMaxParallelRecipes() { - return 8; - } - - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCompressorRecipes; - } - - @Override - public ItemStack[] getOutputItems(GT_Recipe aRecipe) { - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[1]; - for (int h = 0; h < 1; h++) { - if (aRecipe.getOutput(h) != null) { - tOutputItems[h] = aRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - return tOutputItems; - } - - @Override - public int getOutputCount(ItemStack[] aOutputs) { - return 1; - } - - - + private String mCasingName = "Bronze Plated Bricks"; + private IStructureDefinition STRUCTURE_DEFINITION = null; + private int mCasing; + + public GregtechMetaTileEntity_SteamCompressor(String aName) { + super(aName); + } + + public GregtechMetaTileEntity_SteamCompressor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { + return new GregtechMetaTileEntity_SteamCompressor(this.mName); + } + + @Override + protected GT_RenderedTexture getFrontOverlay() { + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR); + } + + @Override + protected GT_RenderedTexture getFrontOverlayActive() { + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR_ACTIVE); + } + + @Override + public String getMachineType() { + return "Compressor"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Compressor") + .addInfo("Compresses " + getMaxParallelRecipes() + " things at a time") + .addSeparator() + .beginStructureBlock(3, 3, 4, true) + .addController("Front center") + .addCasingInfo(mCasingName, 28) + .addOtherStructurePart(TT_steaminputbus, "Any casing", 1) + .addOtherStructurePart(TT_steamoutputbus, "Any casing", 1) + .addOtherStructurePart(TT_steamhatch, "Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC", "CCC"}, + {"C~C", "C-C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder(GregtechMetaTileEntity_SteamCompressor::addSteamMultiList, 10, 1), + onElementPass(x -> ++x.mCasing, ofBlock(sBlockCasings1, 10)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addSteamMultiList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase + && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 31040) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + fixAllMaintenanceIssue(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 28; + } + + @Override + public int getMaxParallelRecipes() { + return 8; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCompressorRecipes; + } + + @Override + public ItemStack[] getOutputItems(GT_Recipe aRecipe) { + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[1]; + for (int h = 0; h < 1; h++) { + if (aRecipe.getOutput(h) != null) { + tOutputItems[h] = aRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + return tOutputItems; + } + + @Override + public int getOutputCount(ItemStack[] aOutputs) { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java index 85a58c5ded..5d57d68f41 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java @@ -24,142 +24,130 @@ import net.minecraft.item.ItemStack; public class GregtechMetaTileEntity_SteamMacerator extends GregtechMeta_SteamMultiBase { - private String mCasingName = "Bronze Plated Bricks"; - private IStructureDefinition STRUCTURE_DEFINITION = null; - private int mCasing; - - public GregtechMetaTileEntity_SteamMacerator(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamMacerator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { - return new GregtechMetaTileEntity_SteamMacerator(this.mName); - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR_ACTIVE); - } - - @Override - public String getMachineType() { - return "Macerator"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - if (mCasingName.contains("gt.blockcasings")) { - mCasingName = ItemList.Casing_BronzePlatedBricks.get(1).getDisplayName(); - } - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Macerator") - .addInfo("Macerates " + getMaxParallelRecipes() + " ores at a time") - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo(mCasingName, 14) - .addOtherStructurePart(TT_steaminputbus, "Any casing", 1) - .addOtherStructurePart(TT_steamoutputbus, "Any casing", 1) - .addOtherStructurePart(TT_steamhatch, "Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - ofChain( - ofHatchAdder( - GregtechMetaTileEntity_SteamMacerator::addSteamMaceratorList, 10, 1 - ), - onElementPass( - x -> ++x.mCasing, - ofBlock( - sBlockCasings1, 10 - ) - ) - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - public final boolean addSteamMaceratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 31040){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - fixAllMaintenanceIssue(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 14; - } - - @Override - public int getMaxParallelRecipes() { - return 8; - } - - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; - } - - @Override - public ItemStack[] getOutputItems(GT_Recipe aRecipe) { - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[1]; - for (int h = 0; h < 1; h++) { - if (aRecipe.getOutput(h) != null) { - tOutputItems[h] = aRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - return tOutputItems; - } - - @Override - public int getOutputCount(ItemStack[] aOutputs) { - return 1; - } - - - + private String mCasingName = "Bronze Plated Bricks"; + private IStructureDefinition STRUCTURE_DEFINITION = null; + private int mCasing; + + public GregtechMetaTileEntity_SteamMacerator(String aName) { + super(aName); + } + + public GregtechMetaTileEntity_SteamMacerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { + return new GregtechMetaTileEntity_SteamMacerator(this.mName); + } + + @Override + protected GT_RenderedTexture getFrontOverlay() { + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR); + } + + @Override + protected GT_RenderedTexture getFrontOverlayActive() { + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR_ACTIVE); + } + + @Override + public String getMachineType() { + return "Macerator"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.contains("gt.blockcasings")) { + mCasingName = ItemList.Casing_BronzePlatedBricks.get(1).getDisplayName(); + } + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Macerator") + .addInfo("Macerates " + getMaxParallelRecipes() + " ores at a time") + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo(mCasingName, 14) + .addOtherStructurePart(TT_steaminputbus, "Any casing", 1) + .addOtherStructurePart(TT_steamoutputbus, "Any casing", 1) + .addOtherStructurePart(TT_steamhatch, "Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder(GregtechMetaTileEntity_SteamMacerator::addSteamMaceratorList, 10, 1), + onElementPass(x -> ++x.mCasing, ofBlock(sBlockCasings1, 10)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addSteamMaceratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase + && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 31040) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + fixAllMaintenanceIssue(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 14; + } + + @Override + public int getMaxParallelRecipes() { + return 8; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } + + @Override + public ItemStack[] getOutputItems(GT_Recipe aRecipe) { + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[1]; + for (int h = 0; h < 1; h++) { + if (aRecipe.getOutput(h) != null) { + tOutputItems[h] = aRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + return tOutputItems; + } + + @Override + public int getOutputCount(ItemStack[] aOutputs) { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java index 19acd30668..b68880a63a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java @@ -1,7 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.lang.reflect.Field; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -26,6 +29,8 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.helpers.CraftingHelper; import gtPlusPlus.xmod.gregtech.common.helpers.autocrafter.AC_Helper_Utils; +import java.lang.reflect.Field; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -33,610 +38,612 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private MODE mMachineMode = MODE.ASSEMBLY; - private byte mTier = 1; - protected GT_Recipe mLastRecipeToBuffer; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - /** The crafting matrix inventory (3x3). */ - public CraftingHelper mInventoryCrafter; - - public static enum MODE { - CRAFTING("CIRCUIT", "ASSEMBLY"), ASSEMBLY("CRAFTING", "DISASSEMBLY"), DISASSEMBLY("ASSEMBLY", "CIRCUIT"), CIRCUIT("DISASSEMBLY", "CRAFTING"); - - private final String lastMode; - private final String nextMode; - - MODE(String previous, String next) { - this.lastMode = previous; - this.nextMode = next; - } - - public MODE nextMode() { - return MODE.valueOf(this.nextMode); - } - - public MODE lastMode() { - return MODE.valueOf(this.lastMode); - } - - } - - public void onRightclick(EntityPlayer aPlayer) { - } - - public GT4Entity_AutoCrafter(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT4Entity_AutoCrafter(String mName) { - super(mName); - } - - @Override - public String getMachineType() { - String sType = "Assembler, Disassembler, "+((CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) ? "Circuit Assembler" : ""); - return sType; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_AutoCrafter(this.mName); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - return super.onRunningTick(aStack); - //return true; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; - } - - public int getAmountOfOutputs() { - return 1; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Highly Advanced Autocrafter") - .addInfo("Right Click with a Screwdriver to change mode") - .addInfo("200% faster than using single block machines of the same voltage") - .addInfo("Processes two items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo("Autocrafter Frame", 10) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(0, 10); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GT4Entity_AutoCrafter.class) - .atLeast(InputBus, OutputBus, InputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - if (checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch()) { - setTier(); - return true; - } else return false; - } - - private static GT_Recipe_Map fCircuitMap; - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - if (this.mMachineMode == MODE.ASSEMBLY) { - return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; - } - else if (this.mMachineMode == MODE.CIRCUIT && !CORE.GTNH) { - if (fCircuitMap != null) { - return fCircuitMap; - } - GT_Recipe_Map r; - try { - Field f = ReflectionUtils.getField(GT_Recipe.GT_Recipe_Map.class, "sCircuitAssemblerRecipes"); - if (f != null) { - r = (GT_Recipe_Map) f.get(null); - if (r != null) { - fCircuitMap = r; - return r; - } - } - } catch (IllegalArgumentException | IllegalAccessException e) { - } - } - else if (this.mMachineMode == MODE.DISASSEMBLY || this.mMachineMode == MODE.CRAFTING) { - return null; - } - return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; - } - - private boolean isModernGT = true; - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (isModernGT && !CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - isModernGT = false; - } - //5.09 support - if (isModernGT && !CORE.GTNH) { - mMachineMode = mMachineMode.nextMode(); - if (mMachineMode == MODE.CRAFTING) { - PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.AQUA+"AutoCrafting"); - } else if (mMachineMode == MODE.ASSEMBLY) { - PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.GREEN+"Assembly"); - } else if (mMachineMode == MODE.DISASSEMBLY) { - PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.RED+"Disassembly"); - } else { - PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.YELLOW+"Circuit Assembly"); - } - } - //5.08 support - else { - if (mMachineMode.nextMode() == MODE.CIRCUIT) { - mMachineMode = MODE.ASSEMBLY; - } - else if (mMachineMode.nextMode() == MODE.CRAFTING) { - mMachineMode = MODE.ASSEMBLY; - } - else { - mMachineMode = mMachineMode.nextMode(); - } - - if (mMachineMode == MODE.CRAFTING) { - PlayerUtils.messagePlayer(aPlayer, "You are now running the Auto-Crafter in mode: "+EnumChatFormatting.AQUA+"AutoCrafting"); - } else if (mMachineMode == MODE.ASSEMBLY) { - PlayerUtils.messagePlayer(aPlayer, "You are now running the Auto-Crafter in mode: "+EnumChatFormatting.GREEN+"Assembly"); - } else { - PlayerUtils.messagePlayer(aPlayer, "You are now running the Auto-Crafter in mode: "+EnumChatFormatting.RED+"Disassembly"); - } - } - } - -// @Override -// public boolean checkRecipe(final ItemStack aStack) { -// -// final long tVoltage = this.getMaxInputVoltage(); -// final byte tTier = this.mTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); -// -// if (mMachineMode == MODE.DISASSEMBLY) { -// return doDisassembly(); -// } else if (mMachineMode == MODE.CRAFTING) { -// return doCrafting(aStack); -// } else { -// return super.checkRecipeGeneric(getMaxParallelRecipes(), 100, 200); -// } -// } - - private void setTier() { - long tVoltage = getMaxInputVoltage(); - this.mTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - if (mMachineMode == MODE.DISASSEMBLY) { - return doDisassembly(); - } else if (mMachineMode == MODE.CRAFTING) { - return doCrafting(aStack); - } else { - ArrayList tFluids = getStoredFluids(); - //Logger.MACHINE_INFO("1"); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tBusItems = new ArrayList(); - //Logger.MACHINE_INFO("2"); - if (isValidMetaTileEntity(tBus)) { - //Logger.MACHINE_INFO("3"); - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - - Object[] tempArray = tFluids.toArray(new FluidStack[] {}); - FluidStack[] properArray; - properArray = ((tempArray != null && tempArray.length > 0) ? (FluidStack[]) tempArray : new FluidStack[] {}); - - //Logger.MACHINE_INFO("4"); - if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), properArray, - getMaxParallelRecipes(), 100, 200, 10000)) return true; - } - return false; - } - } - - @Override - public int getMaxParallelRecipes() { - return 2 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - public boolean doDisassembly() { - - final ArrayList tInputList = this.getStoredInputs(); - for (int tInputList_sS = tInputList.size(), i = 0; i < tInputList_sS - 1; ++i) { - for (int j = i + 1; j < tInputList_sS; ++j) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize < tInputList.get(j).stackSize) { - tInputList.remove(i--); - tInputList_sS = tInputList.size(); - break; - } - tInputList.remove(j--); - tInputList_sS = tInputList.size(); - } - } - } - final ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); - - ItemStack inputItem = tInputs[0]; - if (tInputs[0].stackSize <= 0) { - tInputs[0] = null; - this.updateSlots(); - } - int outputSlots = this.mOutputBusses.get(0).getSizeInventory(); - - if (this.mOutputBusses.size() > 1) { - outputSlots = 0; - for (GT_MetaTileEntity_Hatch_OutputBus r : this.mOutputBusses) { - outputSlots += r.getSizeInventory(); - } - } - - this.mOutputItems = new ItemStack[outputSlots]; - if (inputItem != null && inputItem.stackSize > 0) { - NBTTagCompound tNBT = inputItem.getTagCompound(); - if (tNBT != null) { - tNBT = tNBT.getCompoundTag("GT.CraftingComponents"); - if (tNBT != null) { - this.mEUt = 16 * (1 << this.mTier - 1) * (1 << this.mTier - 1); - this.mMaxProgresstime = (100 - (8 * this.mTier)); - for (int i = 0; i < this.mOutputItems.length; ++i) { - if (this.getBaseMetaTileEntity().getRandomNumber(100) < 60 + 12 * this.mTier) { - this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i); - if (this.mOutputItems[i] != null) { - this.mMaxProgresstime *= (int) 1.5; - } - } - } - - if (this.mTier > 5) { - this.mMaxProgresstime >>= this.mTier - 5; - } - if (this.mEUt > 0) - this.mEUt = (-this.mEUt); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - inputItem.stackSize--; - if (inputItem.stackSize <= 0) { - tInputs[0] = null; - } - this.updateSlots(); - return true; - - } - } - } - return false; - } - - private boolean doesCrafterHave9SlotInput() { - GT_MetaTileEntity_Hatch_InputBus craftingInput = null; - if (!this.mInputBusses.isEmpty()) { - for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses) { - if (x.mInventory.length == 9) { - craftingInput = x; - } - } - } - // Return if no input hatch set. - if (craftingInput == null) { - Logger.WARNING("Cannot do Auto-Crafting without a 9-slot Input Bus [MV]."); - return false; - - } else { - return true; - } - } - - private boolean doCrafting(ItemStack aStack) { - this.mMaxProgresstime = 0; - return false; // do nothing - /* - try { - // Set Crafting input hatch - if (!doesCrafterHave9SlotInput()) { - return false; - } - - // Read stored data from encrypted data stick. - ItemStack storedData_Output[] = NBTUtils.readItemsFromNBT(aStack, "Output"); - ItemStack storedData_Input[] = NBTUtils.readItemsFromNBT(aStack); - if (storedData_Output != null && storedData_Input != null) { - ItemStack loadedData[] = new ItemStack[9]; - if (storedData_Input.length >= 1) { - int number = 0; - for (ItemStack a : storedData_Input) { - if (a.getItem() == ModItems.ZZZ_Empty) { - // Utils.LOG_WARNING("Allocating free memory into crafting manager slot - // "+number+"."); - loadedData[number] = null; - } else { - // Utils.LOG_WARNING("Downloading "+a.getDisplayName()+" into crafting manager - // slot "+number+"."); - loadedData[number] = a; - } - number++; - } - } - - // Remove inputs here - ArrayList mInputArray = new ArrayList(); - ItemStack allInputs[]; - - for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses) { - if (x.mInventory.length > 0) { - for (ItemStack r : x.mInventory) { - if (r != null) { - mInputArray.add(r); - } - } - } - } - - if (mInputArray.isEmpty()) { - return false; - } else { - List list = mInputArray; - allInputs = list.toArray(new ItemStack[list.size()]); - - if (allInputs != null && allInputs.length > 0) { - - this.mEUt = 8 * (1 << this.mTier - 1) * (1 << this.mTier - 1); - this.mMaxProgresstime = MathUtils.roundToClosestInt((50 - (5 - * MathUtils.randDouble(((this.mTier - 2) <= 0 ? 1 : (this.mTier - 2)), this.mTier)))); - - Logger.WARNING("MPT: " + mMaxProgresstime + " | " + mEUt); - this.getBaseMetaTileEntity().setActive(true); - - // Setup some vars - int counter = 0; - - ItemStack toUse[] = new ItemStack[9]; - - outerloop: for (ItemStack inputItem : loadedData) { - if (inputItem == null) { - toUse[counter] = null; - continue outerloop; - } - for (ItemStack r : allInputs) { - if (r != null) { - // Utils.LOG_WARNING("Input Bus Inventory Iteration - Found:" - // +r.getDisplayName()+" | "+allInputs.length); - if (GT_Utility.areStacksEqual(r, inputItem)) { - if (this.getBaseMetaTileEntity().isServerSide()) { - toUse[counter] = inputItem; - counter++; - continue outerloop; - } - - } - } - } - counter++; - } - - int mCorrectInputs = 0; - for (ItemStack isValid : toUse) { - if (isValid == null || this.depleteInput(isValid)) { - mCorrectInputs++; - } else { - Logger.WARNING("Input in Slot " + mCorrectInputs + " was not valid."); - } - } - - if (this.mTier > 5) { - this.mMaxProgresstime >>= this.mTier - 5; - } - if (this.mEUt > 0) - this.mEUt = (-this.mEUt); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - if (mCorrectInputs == 9) { - ItemStack mOutputItem = storedData_Output[0]; - NBTUtils.writeItemsToGtCraftingComponents(mOutputItem, loadedData, true); - this.addOutput(mOutputItem); - this.updateSlots(); - return true; - } else { - return false; - } - - } - } - } - } - // End Debug - catch (Throwable t) { - t.printStackTrace(); - this.mMaxProgresstime = 0; - } - - this.mMaxProgresstime = 0; - return false; - */ - } - - @Override - public String[] getExtraInfoData() { - final String tRunning = (this.mMaxProgresstime > 0 ? "Auto-Crafter running" : "Auto-Crafter stopped"); - final String tMaintainance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" - : "Needs Maintainance"); - String tSpecialText = "" + (60 + 12 * this.mTier) + "% chance to recover disassembled parts."; - String tMode; - if (mMachineMode == MODE.DISASSEMBLY) { - tMode = "§cDisassembly"; - tSpecialText = "" + (60 + 12 * this.mTier) + "% chance to recover disassembled parts."; - } else if (mMachineMode == MODE.ASSEMBLY || mMachineMode == MODE.CIRCUIT) { - tMode = mMachineMode == MODE.ASSEMBLY ? "§aAssembly" : "§eCircuit Assembly"; - if (mLastRecipeToBuffer != null && mLastRecipeToBuffer.mOutputs[0].getDisplayName() != null) { - tSpecialText = "Currently processing: " + mLastRecipeToBuffer.mOutputs[0].getDisplayName(); - } else { - tSpecialText = "Currently processing: Nothing"; - } - } else { - tMode = "§dAuto-Crafting"; - tSpecialText = "Does Auto-Crafter have 9-slot input bus? " + doesCrafterHave9SlotInput(); - } - - return new String[] { "Large Scale Auto-Asesembler v1.01c", tRunning, tMaintainance, "Mode: " + tMode, - tSpecialText }; - } - - private String getMode() { - return this.mMachineMode.name(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - String mMode = getMode(); - aNBT.setString("mMode", mMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - String modeString = aNBT.getString("mMode"); - MODE newMode = MODE.valueOf(modeString); - this.mMachineMode = newMode; - super.loadNBTData(aNBT); - } - - @Override - public void explodeMultiblock() { - AC_Helper_Utils.removeCrafter(this); - super.explodeMultiblock(); - } - - @Override - public void onExplosion() { - AC_Helper_Utils.removeCrafter(this); - super.onExplosion(); - } - - @Override - public void onRemoval() { - AC_Helper_Utils.removeCrafter(this); - super.onRemoval(); - } - - @Override - public void doExplosion(long aExplosionPower) { - AC_Helper_Utils.removeCrafter(this); - super.doExplosion(aExplosionPower); - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "Generic3By3"; - } - +public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private MODE mMachineMode = MODE.ASSEMBLY; + private byte mTier = 1; + protected GT_Recipe mLastRecipeToBuffer; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + /** The crafting matrix inventory (3x3). */ + public CraftingHelper mInventoryCrafter; + + public static enum MODE { + CRAFTING("CIRCUIT", "ASSEMBLY"), + ASSEMBLY("CRAFTING", "DISASSEMBLY"), + DISASSEMBLY("ASSEMBLY", "CIRCUIT"), + CIRCUIT("DISASSEMBLY", "CRAFTING"); + + private final String lastMode; + private final String nextMode; + + MODE(String previous, String next) { + this.lastMode = previous; + this.nextMode = next; + } + + public MODE nextMode() { + return MODE.valueOf(this.nextMode); + } + + public MODE lastMode() { + return MODE.valueOf(this.lastMode); + } + } + + public void onRightclick(EntityPlayer aPlayer) {} + + public GT4Entity_AutoCrafter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT4Entity_AutoCrafter(String mName) { + super(mName); + } + + @Override + public String getMachineType() { + String sType = "Assembler, Disassembler, " + + ((CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) ? "Circuit Assembler" : ""); + return sType; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_AutoCrafter(this.mName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + return super.onRunningTick(aStack); + // return true; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; + } + + public int getAmountOfOutputs() { + return 1; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Highly Advanced Autocrafter") + .addInfo("Right Click with a Screwdriver to change mode") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Processes two items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Autocrafter Frame", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(0, 10); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GT4Entity_AutoCrafter.class) + .atLeast(InputBus, OutputBus, InputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch()) { + setTier(); + return true; + } else return false; + } + + private static GT_Recipe_Map fCircuitMap; + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (this.mMachineMode == MODE.ASSEMBLY) { + return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; + } else if (this.mMachineMode == MODE.CIRCUIT && !CORE.GTNH) { + if (fCircuitMap != null) { + return fCircuitMap; + } + GT_Recipe_Map r; + try { + Field f = ReflectionUtils.getField(GT_Recipe.GT_Recipe_Map.class, "sCircuitAssemblerRecipes"); + if (f != null) { + r = (GT_Recipe_Map) f.get(null); + if (r != null) { + fCircuitMap = r; + return r; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } else if (this.mMachineMode == MODE.DISASSEMBLY || this.mMachineMode == MODE.CRAFTING) { + return null; + } + return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; + } + + private boolean isModernGT = true; + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (isModernGT && !CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + isModernGT = false; + } + // 5.09 support + if (isModernGT && !CORE.GTNH) { + mMachineMode = mMachineMode.nextMode(); + if (mMachineMode == MODE.CRAFTING) { + PlayerUtils.messagePlayer( + aPlayer, "Running the Auto-Crafter in mode: " + EnumChatFormatting.AQUA + "AutoCrafting"); + } else if (mMachineMode == MODE.ASSEMBLY) { + PlayerUtils.messagePlayer( + aPlayer, "Running the Auto-Crafter in mode: " + EnumChatFormatting.GREEN + "Assembly"); + } else if (mMachineMode == MODE.DISASSEMBLY) { + PlayerUtils.messagePlayer( + aPlayer, "Running the Auto-Crafter in mode: " + EnumChatFormatting.RED + "Disassembly"); + } else { + PlayerUtils.messagePlayer( + aPlayer, "Running the Auto-Crafter in mode: " + EnumChatFormatting.YELLOW + "Circuit Assembly"); + } + } + // 5.08 support + else { + if (mMachineMode.nextMode() == MODE.CIRCUIT) { + mMachineMode = MODE.ASSEMBLY; + } else if (mMachineMode.nextMode() == MODE.CRAFTING) { + mMachineMode = MODE.ASSEMBLY; + } else { + mMachineMode = mMachineMode.nextMode(); + } + + if (mMachineMode == MODE.CRAFTING) { + PlayerUtils.messagePlayer( + aPlayer, + "You are now running the Auto-Crafter in mode: " + EnumChatFormatting.AQUA + "AutoCrafting"); + } else if (mMachineMode == MODE.ASSEMBLY) { + PlayerUtils.messagePlayer( + aPlayer, + "You are now running the Auto-Crafter in mode: " + EnumChatFormatting.GREEN + "Assembly"); + } else { + PlayerUtils.messagePlayer( + aPlayer, + "You are now running the Auto-Crafter in mode: " + EnumChatFormatting.RED + "Disassembly"); + } + } + } + + // @Override + // public boolean checkRecipe(final ItemStack aStack) { + // + // final long tVoltage = this.getMaxInputVoltage(); + // final byte tTier = this.mTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + // + // if (mMachineMode == MODE.DISASSEMBLY) { + // return doDisassembly(); + // } else if (mMachineMode == MODE.CRAFTING) { + // return doCrafting(aStack); + // } else { + // return super.checkRecipeGeneric(getMaxParallelRecipes(), 100, 200); + // } + // } + + private void setTier() { + long tVoltage = getMaxInputVoltage(); + this.mTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + if (mMachineMode == MODE.DISASSEMBLY) { + return doDisassembly(); + } else if (mMachineMode == MODE.CRAFTING) { + return doCrafting(aStack); + } else { + ArrayList tFluids = getStoredFluids(); + // Logger.MACHINE_INFO("1"); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList tBusItems = new ArrayList(); + // Logger.MACHINE_INFO("2"); + if (isValidMetaTileEntity(tBus)) { + // Logger.MACHINE_INFO("3"); + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + + Object[] tempArray = tFluids.toArray(new FluidStack[] {}); + FluidStack[] properArray; + properArray = + ((tempArray != null && tempArray.length > 0) ? (FluidStack[]) tempArray : new FluidStack[] {}); + + // Logger.MACHINE_INFO("4"); + if (checkRecipeGeneric( + tBusItems.toArray(new ItemStack[] {}), properArray, getMaxParallelRecipes(), 100, 200, 10000)) + return true; + } + return false; + } + } + + @Override + public int getMaxParallelRecipes() { + return 2 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + public boolean doDisassembly() { + + final ArrayList tInputList = this.getStoredInputs(); + for (int tInputList_sS = tInputList.size(), i = 0; i < tInputList_sS - 1; ++i) { + for (int j = i + 1; j < tInputList_sS; ++j) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize < tInputList.get(j).stackSize) { + tInputList.remove(i--); + tInputList_sS = tInputList.size(); + break; + } + tInputList.remove(j--); + tInputList_sS = tInputList.size(); + } + } + } + final ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); + + ItemStack inputItem = tInputs[0]; + if (tInputs[0].stackSize <= 0) { + tInputs[0] = null; + this.updateSlots(); + } + int outputSlots = this.mOutputBusses.get(0).getSizeInventory(); + + if (this.mOutputBusses.size() > 1) { + outputSlots = 0; + for (GT_MetaTileEntity_Hatch_OutputBus r : this.mOutputBusses) { + outputSlots += r.getSizeInventory(); + } + } + + this.mOutputItems = new ItemStack[outputSlots]; + if (inputItem != null && inputItem.stackSize > 0) { + NBTTagCompound tNBT = inputItem.getTagCompound(); + if (tNBT != null) { + tNBT = tNBT.getCompoundTag("GT.CraftingComponents"); + if (tNBT != null) { + this.mEUt = 16 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + this.mMaxProgresstime = (100 - (8 * this.mTier)); + for (int i = 0; i < this.mOutputItems.length; ++i) { + if (this.getBaseMetaTileEntity().getRandomNumber(100) < 60 + 12 * this.mTier) { + this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i); + if (this.mOutputItems[i] != null) { + this.mMaxProgresstime *= (int) 1.5; + } + } + } + + if (this.mTier > 5) { + this.mMaxProgresstime >>= this.mTier - 5; + } + if (this.mEUt > 0) this.mEUt = (-this.mEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + inputItem.stackSize--; + if (inputItem.stackSize <= 0) { + tInputs[0] = null; + } + this.updateSlots(); + return true; + } + } + } + return false; + } + + private boolean doesCrafterHave9SlotInput() { + GT_MetaTileEntity_Hatch_InputBus craftingInput = null; + if (!this.mInputBusses.isEmpty()) { + for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses) { + if (x.mInventory.length == 9) { + craftingInput = x; + } + } + } + // Return if no input hatch set. + if (craftingInput == null) { + Logger.WARNING("Cannot do Auto-Crafting without a 9-slot Input Bus [MV]."); + return false; + + } else { + return true; + } + } + + private boolean doCrafting(ItemStack aStack) { + this.mMaxProgresstime = 0; + return false; // do nothing + /* + try { + // Set Crafting input hatch + if (!doesCrafterHave9SlotInput()) { + return false; + } + + // Read stored data from encrypted data stick. + ItemStack storedData_Output[] = NBTUtils.readItemsFromNBT(aStack, "Output"); + ItemStack storedData_Input[] = NBTUtils.readItemsFromNBT(aStack); + if (storedData_Output != null && storedData_Input != null) { + ItemStack loadedData[] = new ItemStack[9]; + if (storedData_Input.length >= 1) { + int number = 0; + for (ItemStack a : storedData_Input) { + if (a.getItem() == ModItems.ZZZ_Empty) { + // Utils.LOG_WARNING("Allocating free memory into crafting manager slot + // "+number+"."); + loadedData[number] = null; + } else { + // Utils.LOG_WARNING("Downloading "+a.getDisplayName()+" into crafting manager + // slot "+number+"."); + loadedData[number] = a; + } + number++; + } + } + + // Remove inputs here + ArrayList mInputArray = new ArrayList(); + ItemStack allInputs[]; + + for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses) { + if (x.mInventory.length > 0) { + for (ItemStack r : x.mInventory) { + if (r != null) { + mInputArray.add(r); + } + } + } + } + + if (mInputArray.isEmpty()) { + return false; + } else { + List list = mInputArray; + allInputs = list.toArray(new ItemStack[list.size()]); + + if (allInputs != null && allInputs.length > 0) { + + this.mEUt = 8 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + this.mMaxProgresstime = MathUtils.roundToClosestInt((50 - (5 + * MathUtils.randDouble(((this.mTier - 2) <= 0 ? 1 : (this.mTier - 2)), this.mTier)))); + + Logger.WARNING("MPT: " + mMaxProgresstime + " | " + mEUt); + this.getBaseMetaTileEntity().setActive(true); + + // Setup some vars + int counter = 0; + + ItemStack toUse[] = new ItemStack[9]; + + outerloop: for (ItemStack inputItem : loadedData) { + if (inputItem == null) { + toUse[counter] = null; + continue outerloop; + } + for (ItemStack r : allInputs) { + if (r != null) { + // Utils.LOG_WARNING("Input Bus Inventory Iteration - Found:" + // +r.getDisplayName()+" | "+allInputs.length); + if (GT_Utility.areStacksEqual(r, inputItem)) { + if (this.getBaseMetaTileEntity().isServerSide()) { + toUse[counter] = inputItem; + counter++; + continue outerloop; + } + + } + } + } + counter++; + } + + int mCorrectInputs = 0; + for (ItemStack isValid : toUse) { + if (isValid == null || this.depleteInput(isValid)) { + mCorrectInputs++; + } else { + Logger.WARNING("Input in Slot " + mCorrectInputs + " was not valid."); + } + } + + if (this.mTier > 5) { + this.mMaxProgresstime >>= this.mTier - 5; + } + if (this.mEUt > 0) + this.mEUt = (-this.mEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + if (mCorrectInputs == 9) { + ItemStack mOutputItem = storedData_Output[0]; + NBTUtils.writeItemsToGtCraftingComponents(mOutputItem, loadedData, true); + this.addOutput(mOutputItem); + this.updateSlots(); + return true; + } else { + return false; + } + + } + } + } + } + // End Debug + catch (Throwable t) { + t.printStackTrace(); + this.mMaxProgresstime = 0; + } + + this.mMaxProgresstime = 0; + return false; + */ + } + + @Override + public String[] getExtraInfoData() { + final String tRunning = (this.mMaxProgresstime > 0 ? "Auto-Crafter running" : "Auto-Crafter stopped"); + final String tMaintainance = + (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance"); + String tSpecialText = "" + (60 + 12 * this.mTier) + "% chance to recover disassembled parts."; + String tMode; + if (mMachineMode == MODE.DISASSEMBLY) { + tMode = "§cDisassembly"; + tSpecialText = "" + (60 + 12 * this.mTier) + "% chance to recover disassembled parts."; + } else if (mMachineMode == MODE.ASSEMBLY || mMachineMode == MODE.CIRCUIT) { + tMode = mMachineMode == MODE.ASSEMBLY ? "§aAssembly" : "§eCircuit Assembly"; + if (mLastRecipeToBuffer != null && mLastRecipeToBuffer.mOutputs[0].getDisplayName() != null) { + tSpecialText = "Currently processing: " + mLastRecipeToBuffer.mOutputs[0].getDisplayName(); + } else { + tSpecialText = "Currently processing: Nothing"; + } + } else { + tMode = "§dAuto-Crafting"; + tSpecialText = "Does Auto-Crafter have 9-slot input bus? " + doesCrafterHave9SlotInput(); + } + + return new String[] { + "Large Scale Auto-Asesembler v1.01c", tRunning, tMaintainance, "Mode: " + tMode, tSpecialText + }; + } + + private String getMode() { + return this.mMachineMode.name(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + String mMode = getMode(); + aNBT.setString("mMode", mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + String modeString = aNBT.getString("mMode"); + MODE newMode = MODE.valueOf(modeString); + this.mMachineMode = newMode; + super.loadNBTData(aNBT); + } + + @Override + public void explodeMultiblock() { + AC_Helper_Utils.removeCrafter(this); + super.explodeMultiblock(); + } + + @Override + public void onExplosion() { + AC_Helper_Utils.removeCrafter(this); + super.onExplosion(); + } + + @Override + public void onRemoval() { + AC_Helper_Utils.removeCrafter(this); + super.onRemoval(); + } + + @Override + public void doExplosion(long aExplosionPower) { + AC_Helper_Utils.removeCrafter(this); + super.doExplosion(aExplosionPower); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java index 8f16ea8f83..10f0fc5a5b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java @@ -1,5 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -27,340 +33,341 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - private int mSuperEfficencyIncrease = 0; - - public void onRightclick(EntityPlayer aPlayer) - { - getBaseMetaTileEntity().openGUI(aPlayer, 158); - } - - public GT4Entity_ThermalBoiler(int aID, String aName, String aNameRegional) - { - super(aID, aName, aNameRegional); - } - - public GT4Entity_ThermalBoiler(String mName) { - super(mName); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) - { - return new GT4Entity_ThermalBoiler(this.mName); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) - { - return true; - } - - @Override - public String getMachineType() { - return "Boiler"; - } - - @Override - public int getDamageToComponent(ItemStack aStack){ - //log("Trying to damage component."); - return ItemList.Component_LavaFilter.get(1L).getClass().isInstance(aStack) ? 1 : 0; - } - - private static Item mLavaFilter; - private static Fluid mLava = null; - private static Fluid mPahoehoe = null; - private static Fluid mSolarSaltHot = null; - - @Override - public boolean checkRecipe(ItemStack aStack) { - this.mSuperEfficencyIncrease=0; - - if (mLavaFilter == null) { - mLavaFilter = ItemList.Component_LavaFilter.getItem(); - } - if (mLava == null) { - mLava = FluidRegistry.LAVA; - } - if (mPahoehoe == null) { - mPahoehoe = FluidUtils.getPahoehoeLava(1).getFluid(); - } - if (mSolarSaltHot == null) { - mSolarSaltHot = MISC_MATERIALS.SOLAR_SALT_HOT.getFluid(); - } - - - - //Try reload new Lava Filter - if (aStack == null) { - ItemStack uStack = this.findItemInInventory(mLavaFilter); - if (uStack != null) { - this.setGUIItemStack(uStack); - aStack = this.getGUIItemStack(); - } - } - - - for (GT_Recipe tRecipe : GTPP_Recipe.GTPP_Recipe_Map.sThermalFuels.mRecipeList) { - FluidStack tFluid = tRecipe.mFluidInputs[0]; - if (tFluid != null) { - - if (tFluid.getFluid() == mLava || tFluid.getFluid() == mPahoehoe) { - if (depleteInput(tFluid)) { - this.mMaxProgresstime = Math.max(1, runtimeBoost(tRecipe.mSpecialValue * 2)); - this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); - - int loot_MAXCHANCE = 100000; - if (mLavaFilter.getClass().isInstance(aStack.getItem())) { - if ((tRecipe.getOutput(0) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(0))) { - this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(0) }) }; - } - if ((tRecipe.getOutput(1) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(1))) { - this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(1) }) }; - } - if ((tRecipe.getOutput(2) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(2))) { - this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(2) }) }; - } - if ((tRecipe.getOutput(3) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(3))) { - this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(3) }) }; - } - if ((tRecipe.getOutput(4) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(4))) { - this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(4) }) }; - } - if ((tRecipe.getOutput(5) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(5))) { - this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(5) }) }; - } - } - //Give Obsidian without Lava Filter - if (tFluid.getFluid() == mLava){ - if ((tRecipe.getOutput(6) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(6))) { - this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(6) }) }; - } - } - return true; - } - } - else if (tFluid.getFluid() == mSolarSaltHot) { - if (depleteInput(tFluid)) { - this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = 10000; - for (FluidStack aOutput : tRecipe.mFluidOutputs) { - this.addOutput(FluidUtils.getFluidStack(aOutput, aOutput.amount)); - } - return true; - } - } - } - } - this.mMaxProgresstime = 0; - this.mEUt = 0; - return false; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - if (this.mEUt > 0) { - if(this.mSuperEfficencyIncrease>0){ - this.mEfficiency = Math.min(10000, this.mEfficiency + this.mSuperEfficencyIncrease); - } - int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); - if (tGeneratedEU > 0) { - long amount = (tGeneratedEU + 160) / 160; - if (depleteInput(Materials.Water.getFluid(amount)) || depleteInput(GT_ModHandler.getDistilledWater(amount))) { - addOutput(GT_ModHandler.getSteam(tGeneratedEU)); - } else { - explodeMultiblock(); - } - } - return true; - } - return true; - } - - public int getEUt() { - return 400; - } - - public int getEfficiencyIncrease() { - return 12; - } - - int runtimeBoost(int mTime) { - return mTime * 150 / 100; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) - { - return false; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) - { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) - { - return CORE.ConfigSwitches.pollutionPerSecondMultiThermalBoiler; - } - - public int getAmountOfOutputs() - { - return 7; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Thermal Boiler Controller") - .addInfo("Converts Water & Heat into Steam") - .addInfo("Consult user manual for more information") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfo("Thermal Containment Casings", 10) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(1); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GT4Entity_ThermalBoiler.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.getIndexFromPage(0, 1)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 11))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - public void damageFilter(){ - ItemStack filter = this.mInventory[1]; - if (filter != null){ - if (filter.getItem() instanceof ItemLavaFilter){ - - long currentUse = ItemLavaFilter.getFilterDamage(filter); - - //Remove broken Filter - if (currentUse >= 100-1){ - this.mInventory[1] = null; - } - else { - //Do Damage - ItemLavaFilter.setFilterDamage(filter, currentUse+1); - } - } - } - - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()){ - // Reload Lava Filter - if (this.getGUIItemStack() == null) { - if (this.mInputBusses.size() > 0) { - for (GT_MetaTileEntity_Hatch_InputBus aBus : this.mInputBusses) { - for (ItemStack aStack : aBus.mInventory) { - if (aStack != null && aStack.getItem() instanceof ItemLavaFilter) { - this.setGUIItemStack(aStack); - } - } - } - } - } - - if (this.mEUt > 0){ - if (aTick % 600L == 0L){ - damageFilter(); - } - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "Generic3By3"; - } - +public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + private int mSuperEfficencyIncrease = 0; + + public void onRightclick(EntityPlayer aPlayer) { + getBaseMetaTileEntity().openGUI(aPlayer, 158); + } + + public GT4Entity_ThermalBoiler(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT4Entity_ThermalBoiler(String mName) { + super(mName); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_ThermalBoiler(this.mName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public String getMachineType() { + return "Boiler"; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + // log("Trying to damage component."); + return ItemList.Component_LavaFilter.get(1L).getClass().isInstance(aStack) ? 1 : 0; + } + + private static Item mLavaFilter; + private static Fluid mLava = null; + private static Fluid mPahoehoe = null; + private static Fluid mSolarSaltHot = null; + + @Override + public boolean checkRecipe(ItemStack aStack) { + this.mSuperEfficencyIncrease = 0; + + if (mLavaFilter == null) { + mLavaFilter = ItemList.Component_LavaFilter.getItem(); + } + if (mLava == null) { + mLava = FluidRegistry.LAVA; + } + if (mPahoehoe == null) { + mPahoehoe = FluidUtils.getPahoehoeLava(1).getFluid(); + } + if (mSolarSaltHot == null) { + mSolarSaltHot = MISC_MATERIALS.SOLAR_SALT_HOT.getFluid(); + } + + // Try reload new Lava Filter + if (aStack == null) { + ItemStack uStack = this.findItemInInventory(mLavaFilter); + if (uStack != null) { + this.setGUIItemStack(uStack); + aStack = this.getGUIItemStack(); + } + } + + for (GT_Recipe tRecipe : GTPP_Recipe.GTPP_Recipe_Map.sThermalFuels.mRecipeList) { + FluidStack tFluid = tRecipe.mFluidInputs[0]; + if (tFluid != null) { + + if (tFluid.getFluid() == mLava || tFluid.getFluid() == mPahoehoe) { + if (depleteInput(tFluid)) { + this.mMaxProgresstime = Math.max(1, runtimeBoost(tRecipe.mSpecialValue * 2)); + this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); + + int loot_MAXCHANCE = 100000; + if (mLavaFilter.getClass().isInstance(aStack.getItem())) { + if ((tRecipe.getOutput(0) != null) + && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) + < tRecipe.getOutputChance(0))) { + this.mOutputItems = + new ItemStack[] {GT_Utility.copy(new Object[] {tRecipe.getOutput(0)})}; + } + if ((tRecipe.getOutput(1) != null) + && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) + < tRecipe.getOutputChance(1))) { + this.mOutputItems = + new ItemStack[] {GT_Utility.copy(new Object[] {tRecipe.getOutput(1)})}; + } + if ((tRecipe.getOutput(2) != null) + && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) + < tRecipe.getOutputChance(2))) { + this.mOutputItems = + new ItemStack[] {GT_Utility.copy(new Object[] {tRecipe.getOutput(2)})}; + } + if ((tRecipe.getOutput(3) != null) + && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) + < tRecipe.getOutputChance(3))) { + this.mOutputItems = + new ItemStack[] {GT_Utility.copy(new Object[] {tRecipe.getOutput(3)})}; + } + if ((tRecipe.getOutput(4) != null) + && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) + < tRecipe.getOutputChance(4))) { + this.mOutputItems = + new ItemStack[] {GT_Utility.copy(new Object[] {tRecipe.getOutput(4)})}; + } + if ((tRecipe.getOutput(5) != null) + && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) + < tRecipe.getOutputChance(5))) { + this.mOutputItems = + new ItemStack[] {GT_Utility.copy(new Object[] {tRecipe.getOutput(5)})}; + } + } + // Give Obsidian without Lava Filter + if (tFluid.getFluid() == mLava) { + if ((tRecipe.getOutput(6) != null) + && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) + < tRecipe.getOutputChance(6))) { + this.mOutputItems = + new ItemStack[] {GT_Utility.copy(new Object[] {tRecipe.getOutput(6)})}; + } + } + return true; + } + } else if (tFluid.getFluid() == mSolarSaltHot) { + if (depleteInput(tFluid)) { + this.mMaxProgresstime = tRecipe.mDuration; + this.mEfficiency = 10000; + for (FluidStack aOutput : tRecipe.mFluidOutputs) { + this.addOutput(FluidUtils.getFluidStack(aOutput, aOutput.amount)); + } + return true; + } + } + } + } + this.mMaxProgresstime = 0; + this.mEUt = 0; + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mEUt > 0) { + if (this.mSuperEfficencyIncrease > 0) { + this.mEfficiency = Math.min(10000, this.mEfficiency + this.mSuperEfficencyIncrease); + } + int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); + if (tGeneratedEU > 0) { + long amount = (tGeneratedEU + 160) / 160; + if (depleteInput(Materials.Water.getFluid(amount)) + || depleteInput(GT_ModHandler.getDistilledWater(amount))) { + addOutput(GT_ModHandler.getSteam(tGeneratedEU)); + } else { + explodeMultiblock(); + } + } + return true; + } + return true; + } + + public int getEUt() { + return 400; + } + + public int getEfficiencyIncrease() { + return 12; + } + + int runtimeBoost(int mTime) { + return mTime * 150 / 100; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiThermalBoiler; + } + + public int getAmountOfOutputs() { + return 7; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Thermal Boiler Controller") + .addInfo("Converts Water & Heat into Steam") + .addInfo("Consult user manual for more information") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Thermal Containment Casings", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(1); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GT4Entity_ThermalBoiler.class) + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.getIndexFromPage(0, 1)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 11)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + public void damageFilter() { + ItemStack filter = this.mInventory[1]; + if (filter != null) { + if (filter.getItem() instanceof ItemLavaFilter) { + + long currentUse = ItemLavaFilter.getFilterDamage(filter); + + // Remove broken Filter + if (currentUse >= 100 - 1) { + this.mInventory[1] = null; + } else { + // Do Damage + ItemLavaFilter.setFilterDamage(filter, currentUse + 1); + } + } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + // Reload Lava Filter + if (this.getGUIItemStack() == null) { + if (this.mInputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_InputBus aBus : this.mInputBusses) { + for (ItemStack aStack : aBus.mInventory) { + if (aStack != null && aStack.getItem() instanceof ItemLavaFilter) { + this.setGUIItemStack(aStack); + } + } + } + } + } + + if (this.mEUt > 0) { + if (aTick % 600L == 0L) { + damageFilter(); + } + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java index e7dbd49621..2a7fa00352 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java @@ -1,9 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -28,648 +31,739 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ElementalDataOrbHolder; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase { - private final ArrayList mReplicatorDataOrbHatches = new ArrayList(); - private static final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 3); - private int mCasing = 0; - - public GregtechMTE_ElementalDuplicator(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_ElementalDuplicator(final String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_ElementalDuplicator(this.mName); - } - - @Override - public String getMachineType() { - return "Replicator"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Produces Elemental Material from UU Matter") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 8 * Tier") - .addInfo("Maximum 1x of each bus/hatch.") - .addInfo("Does not require both Output Hatch & Bus") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(9, 6, 9, true) - .addController("Top Center") - .addCasingInfo("Elemental Confinement Shell", 138) - .addCasingInfo("Matter Fabricator Casing", 24) - .addCasingInfo("Particle Containment Casing", 24) - .addCasingInfo("Matter Generation Coil", 24) - .addCasingInfo("High Voltage Current Capacitor", 20) - .addCasingInfo("Resonance Chamber III", 24) - .addCasingInfo("Modulator III", 16) - .addOtherStructurePart("Data Orb Repository", "1x", 1) - .addInputHatch("Any 1 dot hint", 1) - .addOutputBus("Any 1 dot hint", 1) - .addOutputHatch("Any 1 dot hint", 1) - .addEnergyHatch("Any 1 dot hint", 1) - .addMaintenanceHatch("Any 1 dot hint", 1) - .addMufflerHatch("Any 1 dot hint", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - - private static final String STRUCTURE_PIECE_MAIN = "main"; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - - // h = Hatch - // c = Casing - - // a = MF Casing 1 - // b = Matter Gen Coil - - // d = Current Capacitor - // e = Particle - - // f = Resonance III - // g = Modulator III - - .addShape(STRUCTURE_PIECE_MAIN, (new String[][]{ - {" ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccch~hccc", "ccchhhccc", " ccccccc ", " ccccc ", " ccc "}, - {" cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", " abfba ", " cac "}, - {" cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", " e e ", " cec "}, - {" cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", " e e ", " cec "}, - {" cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", " abfba ", " cac "}, - {" ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccchhhccc", "ccchhhccc", " ccccccc ", " ccccc ", " ccc "}, - })) - - - .addElement('a', ofBlock(getCasingBlock4(), getCasingMeta6())) - .addElement('b', ofBlock(getCasingBlock4(), getCasingMeta7())) - - .addElement('d', ofBlock(getCasingBlock2(), getCasingMeta2())) - .addElement('e', ofBlock(getCasingBlock2(), getCasingMeta3())) - - .addElement('f', ofBlock(getCasingBlock3(), getCasingMeta4())) - .addElement('g', ofBlock(getCasingBlock3(), getCasingMeta5())) - .addElement('c', lazy(t -> onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement('h', lazy(t -> ofChain( - buildHatchAdder(GregtechMTE_ElementalDuplicator.class) - .atLeast(InputHatch, OutputBus, OutputHatch, Maintenance, Muffler, Energy) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build() - , - buildHatchAdder(GregtechMTE_ElementalDuplicator.class) - .hatchClass(GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.class) - .adder(GregtechMTE_ElementalDuplicator::addDataOrbHatch) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build() - , - onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())) - ))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN , stackSize, hintsOnly, 4, 4, 0); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 4, 4, 0); - if (this.mInputHatches.size() != 1 || (this.mOutputBusses.size() != 1 && this.mOutputHatches.size() !=0) || this.mEnergyHatches.size() != 1 || this.mReplicatorDataOrbHatches.size() != 1) { - return false; - } - log("Casings: "+mCasing); - return aDidBuild && mCasing >= 138 && checkHatch(); - } - - protected static int getCasingTextureIndex() { - return CASING_TEXTURE_ID; - } - - protected static Block getCasingBlock() { - return ModBlocks.blockCasings5Misc; - } - - protected static Block getCasingBlock2() { - return ModBlocks.blockSpecialMultiCasings; - } - - protected static Block getCasingBlock3() { - return ModBlocks.blockSpecialMultiCasings2; - } - - protected static Block getCasingBlock4() { - return ModBlocks.blockCasingsMisc; - } - - protected static int getCasingMeta() { - return 3; - } - - protected static int getCasingMeta2() { - return 12; - } - - protected static int getCasingMeta3() { - return 13; - } - - protected static int getCasingMeta4() { - return 2; - } - - protected static int getCasingMeta5() { - return 6; - } - - protected static int getCasingMeta6() { - return 9; - } - - protected static int getCasingMeta7() { - return 8; - } - - private boolean addDataOrbHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) { - try { - ((GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) aMetaTileEntity).mRecipeMap = getRecipeMap(); - return addToMachineListInternal(mReplicatorDataOrbHatches, aMetaTileEntity, aBaseCasingIndex); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - } - return false; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public boolean requiresVanillaGtGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe_Map.sElementalDuplicatorRecipes; - } - - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), 100, 100); - } - - - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = null; - - try { - log("Checking "+aItemInputs.length+" Data Orbs"); - - for (int i=0;i 0 && nRecipe.mOutputs[0] != null ? nRecipe.mOutputs[0].getDisplayName() : nRecipe.mFluidOutputs[0].getLocalizedName())); - ItemStack aTempStack = getSpecialSlotStack(nRecipe); - if (aTempStack != null) { - for (ItemStack aItem : aItemInputs) { - if (nRecipe.mSpecialItems != null) { - if (GT_Utility.areStacksEqual(aTempStack, aItem, false)) { - Materials tMaterial = Element.get(Behaviour_DataOrb.getDataName(aTempStack)).mLinkedMaterials.get(0); - log("Found: "+aTempStack.getDisplayName()+" for "+tMaterial.name()); - aDataOrbStack = aTempStack; - break recipe; - } - } - } - } - } - if (aDataOrbStack != null) { - tRecipe = findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aDataOrbStack, aItemInputs); - if (tRecipe != null) { - Materials tMaterial = Element.get(Behaviour_DataOrb.getDataName(aDataOrbStack)).mLinkedMaterials.get(0); - log("Found recipe for "+tMaterial.name()); - } - else { - log("No Recipe Found"); - } - } - else { - log("Null DO"); - } - - } - catch (Throwable t) { - t.printStackTrace(); - } - - - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 4; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } - - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; - } - - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - // Fix GT bug - if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { - this.getBaseMetaTileEntity().setFrontFacing((byte) 1); - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mReplicatorDataOrbHatches.clear(); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public ArrayList getStoredInputs() { - ArrayList tItems = super.getStoredInputs(); - for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder tHatch : mReplicatorDataOrbHatches) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - tItems.addAll(tHatch.getInventory()); - } - } - tItems.removeAll(Collections.singleton(null)); - return tItems; - } - - /** - * finds a Recipe matching the aFluid and ItemStack Inputs. - * - * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup. - * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up. - * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs - * @param aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with the provided input - * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage - * @param aFluids the Fluid Inputs - * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. - * @param aInputs the Item Inputs - * @return the Recipe it has found or null for no matching Recipe - */ - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - - GT_Recipe_Map mRecipeMap = this.getRecipeMap(); - // No Recipes? Well, nothing to be found then. - if (mRecipeMap.mRecipeList.isEmpty()) { - return null; - } - - // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. - // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. - if (GregTech_API.sPostloadFinished) { - if (mRecipeMap.mMinimalInputFluids > 0) { - if (aFluids == null) return null; - int tAmount = 0; - for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; - if (tAmount < mRecipeMap.mMinimalInputFluids) return null; - } - if (mRecipeMap.mMinimalInputItems > 0) { - if (aInputs == null) return null; - int tAmount = 0; - for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; - if (tAmount < mRecipeMap.mMinimalInputItems) return null; - } - } - - // Unification happens here in case the Input isn't already unificated. - if (aNotUnificated) { - aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); - } - - // Check the Recipe which has been used last time in order to not have to search for it again, if possible. - if (aRecipe != null) { - ItemStack aRecipeSpecial = getSpecialSlotStack(aRecipe); - if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) && GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { - return aRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= aRecipe.mEUt ? aRecipe : null; - } - } - - // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. - if (mRecipeMap.mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) - if (tStack != null) { - Collection tRecipes = mRecipeMap.mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) { - for (GT_Recipe tRecipe : tRecipes) { - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); - if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { - return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - } - tRecipes = mRecipeMap.mRecipeItemMap.get(new GT_ItemStack(tStack, true)); - } - } - if (tRecipes != null) { - for (GT_Recipe tRecipe : tRecipes) { - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); - if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { - return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - } - } - } - } - - // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too. - if (mRecipeMap.mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) - if (aFluid != null) { - Collection - tRecipes = mRecipeMap.mRecipeFluidMap.get(aFluid.getFluid()); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) { - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); - if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { - return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - } - } - } - - // And nothing has been found. - return null; - } - - public static ItemStack getSpecialSlotStack(GT_Recipe aRecipe) { - ItemStack aStack = null; - if (aRecipe.mSpecialItems != null) { - if (aRecipe.mSpecialItems instanceof ItemStack[]) { - ItemStack[] aTempStackArray = (ItemStack[]) aRecipe.mSpecialItems; - aStack = aTempStackArray[0]; - } - } - return aStack; - } - - private static boolean areDataOrbsEqual(ItemStack aOrb1, ItemStack aOrb2) { - if (aOrb1 != null && aOrb2 != null) { - Materials tMaterial1 = Element.get(Behaviour_DataOrb.getDataName(aOrb1)).mLinkedMaterials.get(0); - Materials tMaterial2 = Element.get(Behaviour_DataOrb.getDataName(aOrb2)).mLinkedMaterials.get(0); - if (tMaterial1.equals(tMaterial2)) { - return true; - } - } - - return false; - } - + private final ArrayList mReplicatorDataOrbHatches = + new ArrayList(); + private static final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 3); + private int mCasing = 0; + + public GregtechMTE_ElementalDuplicator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ElementalDuplicator(final String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ElementalDuplicator(this.mName); + } + + @Override + public String getMachineType() { + return "Replicator"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Produces Elemental Material from UU Matter") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 8 * Tier") + .addInfo("Maximum 1x of each bus/hatch.") + .addInfo("Does not require both Output Hatch & Bus") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 6, 9, true) + .addController("Top Center") + .addCasingInfo("Elemental Confinement Shell", 138) + .addCasingInfo("Matter Fabricator Casing", 24) + .addCasingInfo("Particle Containment Casing", 24) + .addCasingInfo("Matter Generation Coil", 24) + .addCasingInfo("High Voltage Current Capacitor", 20) + .addCasingInfo("Resonance Chamber III", 24) + .addCasingInfo("Modulator III", 16) + .addOtherStructurePart("Data Orb Repository", "1x", 1) + .addInputHatch("Any 1 dot hint", 1) + .addOutputBus("Any 1 dot hint", 1) + .addOutputHatch("Any 1 dot hint", 1) + .addEnergyHatch("Any 1 dot hint", 1) + .addMaintenanceHatch("Any 1 dot hint", 1) + .addMufflerHatch("Any 1 dot hint", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + + // h = Hatch + // c = Casing + + // a = MF Casing 1 + // b = Matter Gen Coil + + // d = Current Capacitor + // e = Particle + + // f = Resonance III + // g = Modulator III + + .addShape(STRUCTURE_PIECE_MAIN, (new String[][] { + { + " ccc ", + " ccccc ", + " ccccccc ", + "ccchhhccc", + "ccch~hccc", + "ccchhhccc", + " ccccccc ", + " ccccc ", + " ccc " + }, + { + " cac ", + " abfba ", + " abfgfba ", + "cbfgdgfbc", + "afgdddgfa", + "cbfgdgfbc", + " abfgfba ", + " abfba ", + " cac " + }, + { + " cec ", + " e e ", + " e e ", + "c d c", + "e ddd e", + "c d c", + " e e ", + " e e ", + " cec " + }, + { + " cec ", + " e e ", + " e e ", + "c d c", + "e ddd e", + "c d c", + " e e ", + " e e ", + " cec " + }, + { + " cac ", + " abfba ", + " abfgfba ", + "cbfgdgfbc", + "afgdddgfa", + "cbfgdgfbc", + " abfgfba ", + " abfba ", + " cac " + }, + { + " ccc ", + " ccccc ", + " ccccccc ", + "ccchhhccc", + "ccchhhccc", + "ccchhhccc", + " ccccccc ", + " ccccc ", + " ccc " + }, + })) + .addElement('a', ofBlock(getCasingBlock4(), getCasingMeta6())) + .addElement('b', ofBlock(getCasingBlock4(), getCasingMeta7())) + .addElement('d', ofBlock(getCasingBlock2(), getCasingMeta2())) + .addElement('e', ofBlock(getCasingBlock2(), getCasingMeta3())) + .addElement('f', ofBlock(getCasingBlock3(), getCasingMeta4())) + .addElement('g', ofBlock(getCasingBlock3(), getCasingMeta5())) + .addElement( + 'c', lazy(t -> onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement( + 'h', + lazy(t -> ofChain( + buildHatchAdder(GregtechMTE_ElementalDuplicator.class) + .atLeast(InputHatch, OutputBus, OutputHatch, Maintenance, Muffler, Energy) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + buildHatchAdder(GregtechMTE_ElementalDuplicator.class) + .hatchClass(GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.class) + .adder(GregtechMTE_ElementalDuplicator::addDataOrbHatch) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 4, 4, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 4, 4, 0); + if (this.mInputHatches.size() != 1 + || (this.mOutputBusses.size() != 1 && this.mOutputHatches.size() != 0) + || this.mEnergyHatches.size() != 1 + || this.mReplicatorDataOrbHatches.size() != 1) { + return false; + } + log("Casings: " + mCasing); + return aDidBuild && mCasing >= 138 && checkHatch(); + } + + protected static int getCasingTextureIndex() { + return CASING_TEXTURE_ID; + } + + protected static Block getCasingBlock() { + return ModBlocks.blockCasings5Misc; + } + + protected static Block getCasingBlock2() { + return ModBlocks.blockSpecialMultiCasings; + } + + protected static Block getCasingBlock3() { + return ModBlocks.blockSpecialMultiCasings2; + } + + protected static Block getCasingBlock4() { + return ModBlocks.blockCasingsMisc; + } + + protected static int getCasingMeta() { + return 3; + } + + protected static int getCasingMeta2() { + return 12; + } + + protected static int getCasingMeta3() { + return 13; + } + + protected static int getCasingMeta4() { + return 2; + } + + protected static int getCasingMeta5() { + return 6; + } + + protected static int getCasingMeta6() { + return 9; + } + + protected static int getCasingMeta7() { + return 8; + } + + private boolean addDataOrbHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) { + try { + ((GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return addToMachineListInternal(mReplicatorDataOrbHatches, aMetaTileEntity, aBaseCasingIndex); + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + return false; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public boolean requiresVanillaGtGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe_Map.sElementalDuplicatorRecipes; + } + + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), 100, 100); + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = null; + + try { + log("Checking " + aItemInputs.length + " Data Orbs"); + + for (int i = 0; i < aItemInputs.length; i++) { + ItemStack aItem = aItemInputs[i]; + log("Found: " + aItem.getDisplayName()); + } + ItemStack aDataOrbStack = null; + recipe: + for (GT_Recipe nRecipe : this.getRecipeMap().mRecipeList) { + // log("Checking Recipe for: "+(nRecipe.mOutputs.length > 0 && nRecipe.mOutputs[0] != null ? + // nRecipe.mOutputs[0].getDisplayName() : nRecipe.mFluidOutputs[0].getLocalizedName())); + ItemStack aTempStack = getSpecialSlotStack(nRecipe); + if (aTempStack != null) { + for (ItemStack aItem : aItemInputs) { + if (nRecipe.mSpecialItems != null) { + if (GT_Utility.areStacksEqual(aTempStack, aItem, false)) { + Materials tMaterial = Element.get(Behaviour_DataOrb.getDataName(aTempStack)) + .mLinkedMaterials + .get(0); + log("Found: " + aTempStack.getDisplayName() + " for " + tMaterial.name()); + aDataOrbStack = aTempStack; + break recipe; + } + } + } + } + } + if (aDataOrbStack != null) { + tRecipe = findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aDataOrbStack, + aItemInputs); + if (tRecipe != null) { + Materials tMaterial = Element.get(Behaviour_DataOrb.getDataName(aDataOrbStack)) + .mLinkedMaterials + .get(0); + log("Found recipe for " + tMaterial.name()); + } else { + log("No Recipe Found"); + } + } else { + log("Null DO"); + } + + } catch (Throwable t) { + t.printStackTrace(); + } + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 4; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; + } + + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Fix GT bug + if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { + this.getBaseMetaTileEntity().setFrontFacing((byte) 1); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mReplicatorDataOrbHatches.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public ArrayList getStoredInputs() { + ArrayList tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder tHatch : mReplicatorDataOrbHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getInventory()); + } + } + tItems.removeAll(Collections.singleton(null)); + return tItems; + } + + /** + * finds a Recipe matching the aFluid and ItemStack Inputs. + * + * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup. + * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up. + * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs + * @param aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with the provided input + * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage + * @param aFluids the Fluid Inputs + * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. + * @param aInputs the Item Inputs + * @return the Recipe it has found or null for no matching Recipe + */ + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + boolean aDontCheckStackSizes, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { + + GT_Recipe_Map mRecipeMap = this.getRecipeMap(); + // No Recipes? Well, nothing to be found then. + if (mRecipeMap.mRecipeList.isEmpty()) { + return null; + } + + // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or + // "at least 2 Stacks" before they start searching for Recipes. + // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in + // their Machines to select Sub Recipes. + if (GregTech_API.sPostloadFinished) { + if (mRecipeMap.mMinimalInputFluids > 0) { + if (aFluids == null) return null; + int tAmount = 0; + for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; + if (tAmount < mRecipeMap.mMinimalInputFluids) return null; + } + if (mRecipeMap.mMinimalInputItems > 0) { + if (aInputs == null) return null; + int tAmount = 0; + for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; + if (tAmount < mRecipeMap.mMinimalInputItems) return null; + } + } + + // Unification happens here in case the Input isn't already unificated. + if (aNotUnificated) { + aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); + } + + // Check the Recipe which has been used last time in order to not have to search for it again, if possible. + if (aRecipe != null) { + ItemStack aRecipeSpecial = getSpecialSlotStack(aRecipe); + if (!aRecipe.mFakeRecipe + && aRecipe.mCanBeBuffered + && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) + && GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) + && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return aRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= aRecipe.mEUt ? aRecipe : null; + } + } + + // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. + if (mRecipeMap.mUsualInputCount > 0 && aInputs != null) + for (ItemStack tStack : aInputs) + if (tStack != null) { + Collection tRecipes = mRecipeMap.mRecipeItemMap.get(new GT_ItemStack(tStack)); + if (tRecipes != null) { + for (GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); + if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) + && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt + ? tRecipe + : null; + } + } + tRecipes = mRecipeMap.mRecipeItemMap.get(new GT_ItemStack(tStack, true)); + } + } + if (tRecipes != null) { + for (GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); + if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) + && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt + ? tRecipe + : null; + } + } + } + } + } + + // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map + // too. + if (mRecipeMap.mMinimalInputItems == 0 && aFluids != null) + for (FluidStack aFluid : aFluids) + if (aFluid != null) { + Collection tRecipes = mRecipeMap.mRecipeFluidMap.get(aFluid.getFluid()); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + ItemStack aRecipeSpecial = getSpecialSlotStack(tRecipe); + if (GT_Utility.areStacksEqual(aRecipeSpecial, aSpecialSlot, false) + && areDataOrbsEqual(aRecipeSpecial, aSpecialSlot)) { + return tRecipe.mEnabled && aVoltage * mRecipeMap.mAmperage >= tRecipe.mEUt + ? tRecipe + : null; + } + } + } + } + + // And nothing has been found. + return null; + } + + public static ItemStack getSpecialSlotStack(GT_Recipe aRecipe) { + ItemStack aStack = null; + if (aRecipe.mSpecialItems != null) { + if (aRecipe.mSpecialItems instanceof ItemStack[]) { + ItemStack[] aTempStackArray = (ItemStack[]) aRecipe.mSpecialItems; + aStack = aTempStackArray[0]; + } + } + return aStack; + } + + private static boolean areDataOrbsEqual(ItemStack aOrb1, ItemStack aOrb2) { + if (aOrb1 != null && aOrb2 != null) { + Materials tMaterial1 = Element.get(Behaviour_DataOrb.getDataName(aOrb1)) + .mLinkedMaterials + .get(0); + Materials tMaterial2 = Element.get(Behaviour_DataOrb.getDataName(aOrb2)) + .mLinkedMaterials + .get(0); + if (tMaterial1.equals(tMaterial2)) { + return true; + } + } + + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FastNeutronReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FastNeutronReactor.java index 3941d59edb..0d065f6e4b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FastNeutronReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FastNeutronReactor.java @@ -1,19 +1,6 @@ /* package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; public class GregtechMTE_FastNeutronReactor extends GregtechMeta_MultiBlockBase @@ -39,7 +26,7 @@ extends GregtechMeta_MultiBlockBase @Override public String getCustomGUIResourceName() { return null; - } + } @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) @@ -70,7 +57,7 @@ extends GregtechMeta_MultiBlockBase if (processing_Stage_2()) { if (processing_Stage_3()) { if (processing_Stage_4()) { - + } else { //Stage 4 @@ -88,8 +75,8 @@ extends GregtechMeta_MultiBlockBase //Stage 1 } return false; - } - + } + @Override public int getMaxParallelRecipes() { return 1; @@ -104,7 +91,7 @@ extends GregtechMeta_MultiBlockBase for (GT_MetaTileEntity_Hatch_Input tRecipe : this.mInputHatches) { if (tRecipe.getFluid() != null){ FluidStack tFluid = FluidUtils.getFluidStack(tRecipe.getFluid(), 200); - if (tFluid != null) { + if (tFluid != null) { if (tFluid == GT_ModHandler.getDistilledWater(1)) { if (depleteInput(tFluid)) { this.mMaxProgresstime = Math.max(1, runtimeBoost(8 * 2)); @@ -112,10 +99,10 @@ extends GregtechMeta_MultiBlockBase this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); return true; } - } - + } + } - } + } } this.mMaxProgresstime = 0; this.mEUt = 0; @@ -150,11 +137,11 @@ extends GregtechMeta_MultiBlockBase } return true; } - + public int getEUt() { return 0; //Default 400 } - + public int getEfficiencyIncrease() { return 0; //Default 12 } @@ -213,7 +200,7 @@ extends GregtechMeta_MultiBlockBase return true; } - public boolean damageFilter(){ + public boolean damageFilter(){ return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java index d378622b00..61468ce100 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java @@ -1,8 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -23,6 +25,9 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -30,430 +35,419 @@ import net.minecraftforge.common.util.Constants; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMTE_FrothFlotationCell(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_FrothFlotationCell(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_FrothFlotationCell(this.mName); - } - - @Override - public String getMachineType() { - return "Flotation Cell"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Process that milled ore!") - .addInfo("You can only ever process one type of material per controller") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 9, 3, true) - .addController("Front Center") - .addCasingInfo("Inconel Reinforced Casing", 68) - .addCasingInfo("Flotation Casing", 52) - .addInputBus("Bottom Casing", 1) - .addInputHatch("Bottom Casing", 1) - .addOutputHatch("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(207)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(2, 1); - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sFlotationCellRecipes; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, new String[][]{ - {" ", " ", " X ", " X~X ", " X ", " ", " "}, - {" ", " F ", " FFF ", " FF FF ", " FFF ", " F ", " "}, - {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, - {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, - {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, - {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, - {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, - {" CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC "}, - {" CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC "}, - }) - .addElement( - 'C', - buildHatchAdder(GregtechMTE_FrothFlotationCell.class) - .atLeast(InputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(1)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1))) - ) - .addElement( - 'F', - ofBlock( - ModBlocks.blockSpecialMultiCasings, 9 - ) - ) - .addElement( - 'X', - ofBlock( - ModBlocks.blockCasings3Misc, 1 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 3, 3, 0) && mCasing >= 68 - 4 && checkHatch(); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiFrothFlotationCell; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - // Fix GT bug - if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { - log("Fixing Bad Facing. (GT Bug)"); - this.getBaseMetaTileEntity().setFrontFacing((byte) 1); - } - } - - @Override - public boolean checkRecipe(ItemStack arg0) { - return super.checkRecipeGeneric(); - } - - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - /* - * - * Material checks - * Makes sure we can only ever use one type of material in this flotation cell. - * We used to depend on Alk's hash, but it's unreliable and user-hostile - * So we're using unlocalized name of material now. - * - */ - Material foundMaterial = FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(tRecipe)); - String foundMaterialName = null; - if (foundMaterial != null) { - foundMaterialName = foundMaterial.getUnlocalizedName(); - } - - if (foundMaterialName == null) { - log("Did not find material from Milled Ore."); - ItemStack milledStack = FlotationRecipeHandler.findMilledStack(tRecipe); - if (milledStack != null) { - log("Found stack: " + milledStack.getDisplayName()); - } - return false; - } - - // Set material locked for this controller - if (lockedMaterialName == null) { - lockedMaterialName = foundMaterialName; - } - - // Check material match - if (!Objects.equals(lockedMaterialName, foundMaterialName)) { - log("Did not find the correct milled type."); - log("Found: "+foundMaterialName); - log("Expected: "+lockedMaterialName); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 4; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } - - /* - * Handle NBT - */ - - private String lockedMaterialName = null; - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - if (lockedMaterialName != null) { - aNBT.setString("lockedMaterialName", lockedMaterialName); - } - super.setItemNBT(aNBT); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - if (lockedMaterialName != null) { - aNBT.setString("lockedMaterialName", lockedMaterialName); - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (aNBT.hasKey("lockedMaterialName", Constants.NBT.TAG_STRING)) { - lockedMaterialName = aNBT.getString("lockedMaterialName"); - } - } - - @Override - public String[] getExtraInfoData() { - return new String[] { - "Locked material: " + lockedMaterialName - }; - } +public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMTE_FrothFlotationCell(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_FrothFlotationCell(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_FrothFlotationCell(this.mName); + } + + @Override + public String getMachineType() { + return "Flotation Cell"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Process that milled ore!") + .addInfo("You can only ever process one type of material per controller") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 9, 3, true) + .addController("Front Center") + .addCasingInfo("Inconel Reinforced Casing", 68) + .addCasingInfo("Flotation Casing", 52) + .addInputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addOutputHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(2, 1); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sFlotationCellRecipes; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, new String[][] { + {" ", " ", " X ", " X~X ", " X ", " ", " "}, + {" ", " F ", " FFF ", " FF FF ", " FFF ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC "}, + {" CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC "}, + }) + .addElement( + 'C', + buildHatchAdder(GregtechMTE_FrothFlotationCell.class) + .atLeast(InputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(1)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1)))) + .addElement('F', ofBlock(ModBlocks.blockSpecialMultiCasings, 9)) + .addElement('X', ofBlock(ModBlocks.blockCasings3Misc, 1)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 3, 3, 0) && mCasing >= 68 - 4 && checkHatch(); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiFrothFlotationCell; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Fix GT bug + if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { + log("Fixing Bad Facing. (GT Bug)"); + this.getBaseMetaTileEntity().setFrontFacing((byte) 1); + } + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + return super.checkRecipeGeneric(); + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + /* + * + * Material checks + * Makes sure we can only ever use one type of material in this flotation cell. + * We used to depend on Alk's hash, but it's unreliable and user-hostile + * So we're using unlocalized name of material now. + * + */ + Material foundMaterial = + FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(tRecipe)); + String foundMaterialName = null; + if (foundMaterial != null) { + foundMaterialName = foundMaterial.getUnlocalizedName(); + } + + if (foundMaterialName == null) { + log("Did not find material from Milled Ore."); + ItemStack milledStack = FlotationRecipeHandler.findMilledStack(tRecipe); + if (milledStack != null) { + log("Found stack: " + milledStack.getDisplayName()); + } + return false; + } + + // Set material locked for this controller + if (lockedMaterialName == null) { + lockedMaterialName = foundMaterialName; + } + + // Check material match + if (!Objects.equals(lockedMaterialName, foundMaterialName)) { + log("Did not find the correct milled type."); + log("Found: " + foundMaterialName); + log("Expected: " + lockedMaterialName); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 4; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + /* + * Handle NBT + */ + + private String lockedMaterialName = null; + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (lockedMaterialName != null) { + aNBT.setString("lockedMaterialName", lockedMaterialName); + } + super.setItemNBT(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (lockedMaterialName != null) { + aNBT.setString("lockedMaterialName", lockedMaterialName); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("lockedMaterialName", Constants.NBT.TAG_STRING)) { + lockedMaterialName = aNBT.getString("lockedMaterialName"); + } + } + + @Override + public String[] getExtraInfoData() { + return new String[] {"Locked material: " + lockedMaterialName}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java index 1ead7edad5..57529d1900 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java @@ -1,37 +1,12 @@ /* package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.TAE; -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.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.util.minecraft.LangUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { public ArrayList mNaqHatches = new ArrayList(); public static String[] mCasingName = new String[5]; - public static String mHatchName = "Naquadah Fuel Hatch"; + public static String mHatchName = "Naquadah Fuel Hatch"; private final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 13); private final int META_BaseCasing = 0; //4 @@ -47,7 +22,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); - mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); mHatchName = LangUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); } @@ -74,14 +49,14 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { } if (mCasingName[4].toLowerCase().contains(".name")) { mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); - } + } if (mHatchName.toLowerCase().contains(".name")) { mHatchName = LangUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); } return new String[]{ "Naquadah reacts violently with potassium, ", "resulting in massive explosions with radioactive potential.", - "Size: 3x4x12, WxHxL", + "Size: 3x4x12, WxHxL", "Bottom Layer: "+mCasingName[0]+"s, (30x min)", "Middle Layer: "+mCasingName[2]+"s (10x), with", " "+mCasingName[3]+"s on either side", @@ -92,7 +67,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { "", "1x " + mHatchName + " (Any bottom layer casing)", "1x " + "Maintenance Hatch" + " (Any bottom layer side casing)", - "1x " + "Energy Hatch" + " (Any top layer casing)", + "1x " + "Energy Hatch" + " (Any top layer casing)", }; } @@ -126,7 +101,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { public boolean checkRecipe(ItemStack aStack) { return false; - } + } @Override public int getMaxParallelRecipes() { @@ -148,7 +123,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { @Override public String getSound() { - return (String) GregTech_API.sSoundList.get(Integer.valueOf(212)); + return (String) GregTech_API.sSoundList.get(Integer.valueOf(212)); } private Block getCasing(int casingID) { @@ -187,7 +162,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { int aShieldingCount = 0; int aPipeCount = 0; int aIntegralCasingCount = 0; - int aContainmentChamberCount = 0; + int aContainmentChamberCount = 0; // Bottom Layer aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, -7, xDir, zDir); @@ -241,7 +216,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { if (aOwnerName != null && aOwnerName.length() > 0) { aOwner = PlayerUtils.getPlayer(aOwnerName); } - + if (aShieldingCount != 128) { log("Not enough "+mCasingName[4]+"s, require 128."); if (aOwner != null) { @@ -283,7 +258,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { PlayerUtils.messagePlayer(aOwner, "Not enough "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s, require 48."); } return false; - } + } log("LNR Formed."); if (aOwner != null) { PlayerUtils.messagePlayer(aOwner, "Large Naquadah Reactor has formed successfully."); @@ -305,7 +280,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { return false; } } - } + } public int checkEntireLayer(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { int aCasingCount = 0; @@ -313,48 +288,48 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { for (int z = -4; z < 5; z++) { int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; //Skip the corners if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { continue; - } + } // Skip controller if (aY == 0 && x == 0 && z == 0) { continue; } - + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { log("Layer has error. Height: "+aY); //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); return 0; } - } - } + } + } return aCasingCount; } - public int checkOuterRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + public int checkOuterRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { int aCasingCount = 0; for (int x = -4; x < 5; x++) { for (int z = -4; z < 5; z++) { int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; //Skip the corners if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { continue; - } + } // If we are on the 5x5 ring, proceed - if ((x > -4 && x < 4 ) && (z > -4 && z < 4)) { + if ((x > -4 && x < 4 ) && (z > -4 && z < 4)) { if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); } else { continue; @@ -365,14 +340,14 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { log("Layer has error. Height: "+aY); //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); return 0; } - } + } } return aCasingCount; } @@ -382,16 +357,16 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { for (int z = -3; z < 4; z++) { int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; //Skip the corners if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { continue; - } + } // If we are on the 5x5 ring, proceed - if ((x > -3 && x < 3 ) && (z > -3 && z < 3)) { + if ((x > -3 && x < 3 ) && (z > -3 && z < 3)) { if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { - //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); } else { continue; @@ -402,51 +377,51 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { log("Layer has error. Height: "+aY); //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); return 0; } - } + } } return aCasingCount; } - + public int checkPipes(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { int aCasingCount = 0; for (int x = -1; x < 2; x++) { for (int z = -1; z < 2; z++) { int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; //Skip the corners if ((x == 1 && z == 1) || (x == -1 && z == -1) || (x == 1 && z == -1) || (x == -1 && z == 1) || (x == 0 && z == 0)) { Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { log("Pipe has error. Height: "+aY); //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); return 0; }; } - } + } } return aCasingCount; } - + public int checkContainmentRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { int aCasingCount = 0; for (int x = -2; x < 3; x++) { for (int z = -2; z < 3; z++) { int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; - int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; //Skip the corners if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { continue; @@ -456,14 +431,14 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { aCasingCount++; - } - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { log("Layer has error. Height: "+aY); //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); return 0; } - } + } } return aCasingCount; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java index 9c2e3289c3..8f0a2802d4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java @@ -1,37 +1,12 @@ /* package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Plasma; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { public long currentVoltage = GT_Values.V[7]; public byte currentTier = 8; - + public void upvolt() { byte f = currentTier; if ((f+1) > 10) { @@ -40,10 +15,10 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { else { f++; } - this.currentTier = f; + this.currentTier = f; updateVoltage(); } - + public void downvolt() { byte f = currentTier; if ((f-1) < 8) { @@ -52,19 +27,19 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { else { f--; } - this.currentTier = f; + this.currentTier = f; updateVoltage(); } - + private long updateVoltage() { this.currentVoltage = GT_Values.V[this.currentTier-1]; return currentVoltage; } - + public GregtechMTE_MiniFusionPlant(String aName) { super(aName); } - + public GregtechMTE_MiniFusionPlant(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -101,10 +76,10 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { } return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(10))}; } - + @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { + public GT_Recipe.GT_Recipe_Map getRecipeMap() { return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; } @@ -125,10 +100,10 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { @Override public String[] getTooltip() { - return new String[] { - "Small scale fusion", + return new String[] { + "Small scale fusion", "16x slower than using Multiblock of the same voltage", - //"Input voltage can be changed within the GUI", + //"Input voltage can be changed within the GUI", "Place Input/Output Hatches on sides and bottom", "Power can only be inserted into the back", //e"Power can only be extracted from the top", @@ -155,7 +130,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { int tAmount = 0; ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); - + //Require air in front, I think if (!aBaseMetaTileEntity.getAirOffset(xDir2, 0, zDir2)) { Logger.INFO("Did not find air in front"); @@ -168,9 +143,9 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); if (this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(10))) { - tAmount++; + tAmount++; } - } + } } } } @@ -181,7 +156,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(ItemStack arg0) { - + ArrayList tFluidList = this.getStoredFluids(); int tFluidList_sS = tFluidList.size(); @@ -232,10 +207,10 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { //Logger.INFO("Step "+aStep++); return false; - - - - + + + + //return this.checkRecipeGeneric(this.getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); } @@ -268,15 +243,15 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { @Override public String[] getExtraInfoData() { - String mode = EnumChatFormatting.BLUE + "" + currentVoltage + EnumChatFormatting.RESET; - String aOutput = EnumChatFormatting.BLUE + "" + mEUt + EnumChatFormatting.RESET; + String mode = EnumChatFormatting.BLUE + "" + currentVoltage + EnumChatFormatting.RESET; + String aOutput = EnumChatFormatting.BLUE + "" + mEUt + EnumChatFormatting.RESET; String storedEnergyText; if (this.getEUVar() > maxEUStore()) { storedEnergyText = EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; } else { storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; } - + return new String[]{ "Stored EU: " + storedEnergyText, "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, @@ -304,7 +279,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { public long getInputTier() { return (long) GT_Utility.getTier(maxEUInput()); } - + @Override public boolean isElectric() { return true; @@ -374,11 +349,11 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { @Override public int getPollutionPerTick(ItemStack arg0) { return 0; - } + } @Override public GT_MetaTileEntity_Hatch_ControlCore getControlCoreBus() { - GT_MetaTileEntity_Hatch_ControlCore x = new GT_MetaTileEntity_Hatch_ControlCore("", 0, "", null); + GT_MetaTileEntity_Hatch_ControlCore x = new GT_MetaTileEntity_Hatch_ControlCore("", 0, "", null); return (GT_MetaTileEntity_Hatch_ControlCore) x; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java index de86a097cf..fa8b27dec9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java @@ -1,6 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.Collection; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.filterByMTETier; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -26,525 +32,531 @@ import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.util.Collection; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.filterByMTETier; - -public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected int mFuelRemaining = 0; - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - - public GregtechMTE_NuclearReactor(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_NuclearReactor(final String aName) { - super(aName); - } - - @Override - public long maxEUStore() { - return (640000000L * (Math.min(16, this.mEnergyHatches.size()))) / 16L; - } - - @Override - public String getMachineType() { - return "Reactor"; - } - - @Override - public GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Liquid Fluoride Thorium Reactor.") - .addInfo("Produces Heat & Energy from Radioactive Beta Decay.") - .addInfo("Outputs U233 every 10 seconds, on average") - .addInfo("Input Fluorine and Helium for bonus byproducts") - .addInfo("Input Li2BeF4 and a molten salt as fuel.") - .addInfo("LiFBeF2ThF4UF4, LiFBeF2ZrF4UF4 or LiFBeF2ZrF4U235") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(7, 4, 7, true) - .addController("Bottom Center") - .addCasingInfo("Hastelloy-N Reactor Casing", 27) - .addCasingInfo("Zeron-100 Reactor Shielding", 26) - .addInputHatch("Top or bottom layer edges", 1) - .addOutputHatch("Top or bottom layer edges", 1) - .addDynamoHatch("Top or bottom layer edges", 1) - .addMaintenanceHatch("Top or bottom layer edges", 1) - .addMufflerHatch("Top 3x3", 2) - .addStructureInfo("All dynamos must be IV or LuV tier.") - .addStructureInfo("All other hatches must be IV+ tier.") - .addStructureInfo("3x Output Hatches, 2x Input Hatches, 4x Dynamo Hatches") - .addStructureInfo("2x Maintenance Hatches, 4x Mufflers") - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public String[] getExtraInfoData() { - final String tRunning = (this.mMaxProgresstime>0 ? "Reactor running":"Reactor stopped"); - final String tMaintainance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance"); - - return new String[]{ - "Liquid Fluoride Thorium Reactor", - tRunning, - tMaintainance, - "Current Output: "+this.mEUt+" EU/t", - "Fuel Remaining: "+this.mFuelRemaining+" Litres", - "Current Efficiency: "+(this.mEfficiency/5)+"%", - "Current Efficiency (Raw): "+(this.mEfficiency), - "It requires you to have 100% Efficiency."}; - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aStack) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - boolean aWarmedUp = this.mEfficiency == this.getMaxEfficiency(null); - if (!aBaseMetaTileEntity.isActive() || !aWarmedUp){ - if (aSide == aFacing) { - if (aActive) - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE).extFacing().build()}; - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR).extFacing().build()}; - } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; - } - else if(aBaseMetaTileEntity.isActive() && aWarmedUp){ - if (aSide == aFacing) { - if (aActive) - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), - TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE).extFacing().build()}; - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), - TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR).extFacing().build()}; - } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13))}; - } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; - - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "MatterFabricator"; - } - - public final boolean addNuclearReactorEdgeList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo && (((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mTier >= 5 && ((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mTier <= 6)){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input && ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier >= 5) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output && ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier >= 5) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - public final boolean addNuclearReactorTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 5) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCCCCCC", "COOOOOC", "COXXXOC", "COXXXOC", "COXXXOC", "COOOOOC", "CCCCCCC"}, - {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, - {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, - {"CCC~CCC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "CCCCCCC"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMTE_NuclearReactor.class) - .atLeast(Maintenance) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_NuclearReactor.class) - .atLeast(InputHatch, OutputHatch) - .adder(GregtechMTE_NuclearReactor::addNuclearReactorEdgeList) - .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_NuclearReactor.class) - .atLeast(Dynamo) - .adder(GregtechMTE_NuclearReactor::addNuclearReactorEdgeList) - .hatchItemFilterAnd(t -> filterByMTETier(5, 6)) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasingsMisc, 12 - ) - ) - ) - ) - .addElement( - 'X', - buildHatchAdder(GregtechMTE_NuclearReactor.class) - .atLeast(Muffler) - .adder(GregtechMTE_NuclearReactor::addNuclearReactorTopList) - .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 12))) - ) - .addElement( - 'O', - ofBlock( - ModBlocks.blockCasingsMisc, 12 - ) - ) - .addElement( - 'G', - ofBlock( - ModBlocks.blockCasingsMisc, 13 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) { - if (mOutputHatches.size() >= 3 && mInputHatches.size() >= 2 && mDynamoHatches.size() == 4 && - mMufflerHatches.size() == 4 && mMaintenanceHatches.size() == 2) { - this.mWrench = true; - this.mScrewdriver = true; - this.mSoftHammer = true; - this.mHardHammer = true; - this.mSolderingTool = true; - this.mCrowbar = true; - this.turnCasingActive(false); - return true; - } - } - return false; - } - - // Alk's Life Lessons from Greg. - /* - [23:41:15] xdir and zdir are x2 and not x3 - [23:41:26] thats you issue - [23:44:33] mmm? - [23:44:49] Should they be x3? - [23:44:50] you just do a x2, what is for a 5x5 multiblock - [23:45:01] x3 is for a 7x7 one - [23:45:06] I have no idea what that value does, tbh.. - [23:45:15] its the offset - [23:45:23] Debugging checkMachine has been a pain and I usually trash designs that don't work straight up.. - [23:45:28] it determines the horizontal middle of the multiblock - [23:45:47] which is in your case THREE blocks away from the controller - [23:45:51] Ahh - [23:45:57] and not 2 - [23:46:06] Noted, thanks :D - */ - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return true; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_NuclearReactor(this.mName); - } - - public boolean turnCasingActive(final boolean status) { - //TODO - if (this.mDynamoHatches != null) { - for (final GT_MetaTileEntity_Hatch_Dynamo hatch : this.mDynamoHatches) { - hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); - } - } - if (this.mMufflerHatches != null) { - for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { - hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); - } - } - if (this.mOutputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { - hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); - } - } - if (this.mInputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { - hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); - } - } - if (this.mMaintenanceHatches != null) { - for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { - hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); - } - } - return true; - } - - public FluidStack[] getStoredFluidsAsArray() { - return getStoredFluids().toArray(new FluidStack[0]); - } - - public int getStoredFuel(GT_Recipe aRecipe) { - int aFuelStored = 0; - FluidStack aFuelFluid = null; - for (FluidStack aFluidInput : aRecipe.mFluidInputs) { - if (!aFluidInput.getFluid().equals(NUCLIDE.Li2BeF4.getFluid())) { - aFuelFluid = aFluidInput; - break; - } - } - if (aFuelFluid != null) { - for (GT_MetaTileEntity_Hatch_Input aInputHatch : this.mInputHatches) { - if (aInputHatch.getFluid() != null && aInputHatch.getFluidAmount() > 0) { - if (aInputHatch.getFluid().isFluidEqual(aFuelFluid)) { - aFuelStored += aInputHatch.getFluidAmount(); - } - } - } - } - return aFuelStored; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - // Warm up for 4~ minutes - Logger.WARNING("Checking LFTR recipes."); - if (mEfficiency < this.getMaxEfficiency(null)) { - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - this.mProgresstime = 0; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 2; - Logger.WARNING("Warming Up! "+this.mEfficiency+"/"+this.getMaxEfficiency(null)); - return true; - } - Logger.WARNING("Warmed up, checking LFTR recipes."); - - final FluidStack[] tFluids = getStoredFluidsAsArray(); - final Collection tRecipeList = getRecipeMap().mRecipeList; - if(tFluids.length > 0 && tRecipeList != null && tRecipeList.size() > 0) { //Does input hatch have a LFTR fuel? - Logger.WARNING("Found more than one input fluid and a list of valid recipes."); - // Find a valid recipe - GT_Recipe aFuelProcessing = this.findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, 0, tFluids, new ItemStack[] {}); - if (aFuelProcessing == null) { - Logger.WARNING("Did not find valid recipe for given inputs."); - return false; - } - else { - Logger.WARNING("Found recipe? "+(aFuelProcessing != null ? "true" : "false")); - for (FluidStack aFluidInput : aFuelProcessing.mFluidInputs) { - Logger.WARNING("Using "+aFluidInput.getLocalizedName()); - } - } - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - this.mLastRecipe = aFuelProcessing; - // Deplete Inputs - if (aFuelProcessing.mFluidInputs.length > 0) { - for (FluidStack aInputToConsume : aFuelProcessing.mFluidInputs) { - Logger.WARNING("Depleting "+aInputToConsume.getLocalizedName()+" - "+aInputToConsume.amount+"L"); - this.depleteInput(aInputToConsume); - } - } - // -- Try not to fail after this point - inputs have already been consumed! -- - this.mMaxProgresstime = (int)(aFuelProcessing.mDuration); - this.mEUt = aFuelProcessing.mSpecialValue * 4; - Logger.WARNING("Outputting "+this.mEUt+"eu/t"); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - Logger.WARNING("Recipe time: "+this.mMaxProgresstime); - mFuelRemaining = getStoredFuel(aFuelProcessing); //Record available fuel - - this.mOutputFluids = aFuelProcessing.mFluidOutputs.clone(); - updateSlots(); - Logger.WARNING("Recipe Good!"); - return true; - } - this.mEUt = 0; - this.mEfficiency = 0; - Logger.WARNING("Recipe Bad!"); - return false; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void explodeMultiblock() { - this.mInventory[1] = null; - long explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - for (final MetaTileEntity tTileEntity : this.mInputBusses) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mOutputBusses) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mInputHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mOutputHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); - } - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - this.getBaseMetaTileEntity().doExplosion(explodevalue); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.getWorld().isRemote) { - if (aBaseMetaTileEntity.isActive()){ - // Set casings active if we're warmed up. - if (this.mEfficiency == this.getMaxEfficiency(null)){ - this.turnCasingActive(true); - } - else { - this.turnCasingActive(false); - } - } - else { - this.turnCasingActive(false); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - // See if we're warmed up. - if (this.mEfficiency == this.getMaxEfficiency(null)){ - // Try output some Uranium-233 - if (MathUtils.randInt(1, 300) == 1){ - this.addOutput(ELEMENT.getInstance().URANIUM233.getFluidStack(MathUtils.randInt(1, 10))); - } - - } - return super.onRunningTick(aStack); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mFuelRemaining", this.mFuelRemaining); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mFuelRemaining = aNBT.getInteger("mFuelRemaining"); - super.loadNBTData(aNBT); - } - +public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + protected int mFuelRemaining = 0; + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMTE_NuclearReactor(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_NuclearReactor(final String aName) { + super(aName); + } + + @Override + public long maxEUStore() { + return (640000000L * (Math.min(16, this.mEnergyHatches.size()))) / 16L; + } + + @Override + public String getMachineType() { + return "Reactor"; + } + + @Override + public GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Liquid Fluoride Thorium Reactor.") + .addInfo("Produces Heat & Energy from Radioactive Beta Decay.") + .addInfo("Outputs U233 every 10 seconds, on average") + .addInfo("Input Fluorine and Helium for bonus byproducts") + .addInfo("Input Li2BeF4 and a molten salt as fuel.") + .addInfo("LiFBeF2ThF4UF4, LiFBeF2ZrF4UF4 or LiFBeF2ZrF4U235") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(7, 4, 7, true) + .addController("Bottom Center") + .addCasingInfo("Hastelloy-N Reactor Casing", 27) + .addCasingInfo("Zeron-100 Reactor Shielding", 26) + .addInputHatch("Top or bottom layer edges", 1) + .addOutputHatch("Top or bottom layer edges", 1) + .addDynamoHatch("Top or bottom layer edges", 1) + .addMaintenanceHatch("Top or bottom layer edges", 1) + .addMufflerHatch("Top 3x3", 2) + .addStructureInfo("All dynamos must be IV or LuV tier.") + .addStructureInfo("All other hatches must be IV+ tier.") + .addStructureInfo("3x Output Hatches, 2x Input Hatches, 4x Dynamo Hatches") + .addStructureInfo("2x Maintenance Hatches, 4x Mufflers") + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public String[] getExtraInfoData() { + final String tRunning = (this.mMaxProgresstime > 0 ? "Reactor running" : "Reactor stopped"); + final String tMaintainance = + (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance"); + + return new String[] { + "Liquid Fluoride Thorium Reactor", + tRunning, + tMaintainance, + "Current Output: " + this.mEUt + " EU/t", + "Fuel Remaining: " + this.mFuelRemaining + " Litres", + "Current Efficiency: " + (this.mEfficiency / 5) + "%", + "Current Efficiency (Raw): " + (this.mEfficiency), + "It requires you to have 100% Efficiency." + }; + } + + @Override + public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aStack) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + boolean aWarmedUp = this.mEfficiency == this.getMaxEfficiency(null); + if (!aBaseMetaTileEntity.isActive() || !aWarmedUp) { + if (aSide == aFacing) { + if (aActive) + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE) + .extFacing() + .build() + }; + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR) + .extFacing() + .build() + }; + } + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; + } else if (aBaseMetaTileEntity.isActive() && aWarmedUp) { + if (aSide == aFacing) { + if (aActive) + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE) + .extFacing() + .build() + }; + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR) + .extFacing() + .build() + }; + } + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13))}; + } + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MatterFabricator"; + } + + public final boolean addNuclearReactorEdgeList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo + && (((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mTier >= 5 + && ((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mTier <= 6)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input + && ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output + && ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addNuclearReactorTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler + && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCCCCCC", "COOOOOC", "COXXXOC", "COXXXOC", "COXXXOC", "COOOOOC", "CCCCCCC"}, + {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, + {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, + {"CCC~CCC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "CCCCCCC"}, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMTE_NuclearReactor.class) + .atLeast(Maintenance) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .build(), + buildHatchAdder(GregtechMTE_NuclearReactor.class) + .atLeast(InputHatch, OutputHatch) + .adder(GregtechMTE_NuclearReactor::addNuclearReactorEdgeList) + .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .build(), + buildHatchAdder(GregtechMTE_NuclearReactor.class) + .atLeast(Dynamo) + .adder(GregtechMTE_NuclearReactor::addNuclearReactorEdgeList) + .hatchItemFilterAnd(t -> filterByMTETier(5, 6)) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 12)))) + .addElement( + 'X', + buildHatchAdder(GregtechMTE_NuclearReactor.class) + .atLeast(Muffler) + .adder(GregtechMTE_NuclearReactor::addNuclearReactorTopList) + .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 12)))) + .addElement('O', ofBlock(ModBlocks.blockCasingsMisc, 12)) + .addElement('G', ofBlock(ModBlocks.blockCasingsMisc, 13)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) { + if (mOutputHatches.size() >= 3 + && mInputHatches.size() >= 2 + && mDynamoHatches.size() == 4 + && mMufflerHatches.size() == 4 + && mMaintenanceHatches.size() == 2) { + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + this.turnCasingActive(false); + return true; + } + } + return false; + } + + // Alk's Life Lessons from Greg. + /* + [23:41:15] xdir and zdir are x2 and not x3 + [23:41:26] thats you issue + [23:44:33] mmm? + [23:44:49] Should they be x3? + [23:44:50] you just do a x2, what is for a 5x5 multiblock + [23:45:01] x3 is for a 7x7 one + [23:45:06] I have no idea what that value does, tbh.. + [23:45:15] its the offset + [23:45:23] Debugging checkMachine has been a pain and I usually trash designs that don't work straight up.. + [23:45:28] it determines the horizontal middle of the multiblock + [23:45:47] which is in your case THREE blocks away from the controller + [23:45:51] Ahh + [23:45:57] and not 2 + [23:46:06] Noted, thanks :D + */ + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return true; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_NuclearReactor(this.mName); + } + + public boolean turnCasingActive(final boolean status) { + // TODO + if (this.mDynamoHatches != null) { + for (final GT_MetaTileEntity_Hatch_Dynamo hatch : this.mDynamoHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mMufflerHatches != null) { + for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mOutputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mInputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mMaintenanceHatches != null) { + for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + return true; + } + + public FluidStack[] getStoredFluidsAsArray() { + return getStoredFluids().toArray(new FluidStack[0]); + } + + public int getStoredFuel(GT_Recipe aRecipe) { + int aFuelStored = 0; + FluidStack aFuelFluid = null; + for (FluidStack aFluidInput : aRecipe.mFluidInputs) { + if (!aFluidInput.getFluid().equals(NUCLIDE.Li2BeF4.getFluid())) { + aFuelFluid = aFluidInput; + break; + } + } + if (aFuelFluid != null) { + for (GT_MetaTileEntity_Hatch_Input aInputHatch : this.mInputHatches) { + if (aInputHatch.getFluid() != null && aInputHatch.getFluidAmount() > 0) { + if (aInputHatch.getFluid().isFluidEqual(aFuelFluid)) { + aFuelStored += aInputHatch.getFluidAmount(); + } + } + } + } + return aFuelStored; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + // Warm up for 4~ minutes + Logger.WARNING("Checking LFTR recipes."); + if (mEfficiency < this.getMaxEfficiency(null)) { + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 2; + Logger.WARNING("Warming Up! " + this.mEfficiency + "/" + this.getMaxEfficiency(null)); + return true; + } + Logger.WARNING("Warmed up, checking LFTR recipes."); + + final FluidStack[] tFluids = getStoredFluidsAsArray(); + final Collection tRecipeList = getRecipeMap().mRecipeList; + if (tFluids.length > 0 && tRecipeList != null && tRecipeList.size() > 0) { // Does input hatch have a LFTR fuel? + Logger.WARNING("Found more than one input fluid and a list of valid recipes."); + // Find a valid recipe + GT_Recipe aFuelProcessing = + this.findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, 0, tFluids, new ItemStack[] {}); + if (aFuelProcessing == null) { + Logger.WARNING("Did not find valid recipe for given inputs."); + return false; + } else { + Logger.WARNING("Found recipe? " + (aFuelProcessing != null ? "true" : "false")); + for (FluidStack aFluidInput : aFuelProcessing.mFluidInputs) { + Logger.WARNING("Using " + aFluidInput.getLocalizedName()); + } + } + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + this.mLastRecipe = aFuelProcessing; + // Deplete Inputs + if (aFuelProcessing.mFluidInputs.length > 0) { + for (FluidStack aInputToConsume : aFuelProcessing.mFluidInputs) { + Logger.WARNING( + "Depleting " + aInputToConsume.getLocalizedName() + " - " + aInputToConsume.amount + "L"); + this.depleteInput(aInputToConsume); + } + } + // -- Try not to fail after this point - inputs have already been consumed! -- + this.mMaxProgresstime = (int) (aFuelProcessing.mDuration); + this.mEUt = aFuelProcessing.mSpecialValue * 4; + Logger.WARNING("Outputting " + this.mEUt + "eu/t"); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + Logger.WARNING("Recipe time: " + this.mMaxProgresstime); + mFuelRemaining = getStoredFuel(aFuelProcessing); // Record available fuel + + this.mOutputFluids = aFuelProcessing.mFluidOutputs.clone(); + updateSlots(); + Logger.WARNING("Recipe Good!"); + return true; + } + this.mEUt = 0; + this.mEfficiency = 0; + Logger.WARNING("Recipe Bad!"); + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void explodeMultiblock() { + this.mInventory[1] = null; + long explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + for (final MetaTileEntity tTileEntity : this.mInputBusses) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mOutputBusses) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mInputHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mOutputHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + this.getBaseMetaTileEntity().doExplosion(explodevalue); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.getWorld().isRemote) { + if (aBaseMetaTileEntity.isActive()) { + // Set casings active if we're warmed up. + if (this.mEfficiency == this.getMaxEfficiency(null)) { + this.turnCasingActive(true); + } else { + this.turnCasingActive(false); + } + } else { + this.turnCasingActive(false); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + // See if we're warmed up. + if (this.mEfficiency == this.getMaxEfficiency(null)) { + // Try output some Uranium-233 + if (MathUtils.randInt(1, 300) == 1) { + this.addOutput(ELEMENT.getInstance().URANIUM233.getFluidStack(MathUtils.randInt(1, 10))); + } + } + return super.onRunningTick(aStack); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mFuelRemaining", this.mFuelRemaining); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mFuelRemaining = aNBT.getInteger("mFuelRemaining"); + super.loadNBTData(aNBT); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java index 715ef31871..281885bfd0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java @@ -1,6 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -18,487 +23,486 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.*; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; - -public class GregtechMetaTileEntityGeneratorArray extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntityGeneratorArray(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityGeneratorArray(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityGeneratorArray(this.mName); - } - - @Override - public String getMachineType() { - return "Processing Array"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Generator Array") - .addInfo("Runs supplied generators as if placed in the world") - .addInfo("Place up to 16 Single Block GT Generators into the Controller") - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo("Robust Tungstensteel Machine Casings", 10) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addDynamoHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return 48; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "ProcessingArray"; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - this.mMode = getModeFromInventorySlot(this.getGUIItemStack()); - if (this.mMode == MODE_NONE) { - return null; - } - else if (this.mMode == MODE_STEAM) { - return GTPP_Recipe.GTPP_Recipe_Map.sSteamTurbineFuels; - } - else if (this.mMode == MODE_DIESEL) { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } - else if (this.mMode == MODE_GAS) { - return GT_Recipe.GT_Recipe_Map.sTurbineFuels; - } - else if (this.mMode == MODE_SEMIFLUID) { - return GTPP_Recipe.GTPP_Recipe_Map.sSemiFluidLiquidFuels; - } - else if (this.mMode == MODE_GEOTHERMAL) { - return GTPP_Recipe.GTPP_Recipe_Map.sThermalFuels; - } - else if (this.mMode == MODE_ROCKETFUEL) { - return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; - } - else if (this.mMode == MODE_MAGIC_A) { - return GT_Recipe.GT_Recipe_Map.sMagicFuels; - } - else if (this.mMode == MODE_PLASMA) { - return GT_Recipe.GT_Recipe_Map.sPlasmaFuels; - } - else if (this.mMode == MODE_NAQUADAH) { - return GT_Recipe.GT_Recipe_Map.sFluidNaquadahReactorFuels; - } - return null; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - if (aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.")) { - return true; - } - return false; - } - - protected int fuelConsumption = 0; - protected int fuelValue = 0; - protected int fuelRemaining = 0; - protected boolean boostEu = false; - - int mMode = 0; - - private final static int MODE_STEAM = 0; - private final static int MODE_DIESEL = 1; - private final static int MODE_GAS = 2; - private final static int MODE_SEMIFLUID = 3; - private final static int MODE_GEOTHERMAL = 4; - private final static int MODE_ROCKETFUEL = 5; - private final static int MODE_MAGIC_A = 6; - private final static int MODE_MAGIC_B_DISABLED = 7; - private final static int MODE_PLASMA = 8; - private final static int MODE_NAQUADAH = 9; - private final static int MODE_NONE = 100; - - private final static int[] ID_STEAM = new int[] {962, 1120, 1121, 1122}; - private final static int[] ID_GAS = new int[] {961, 1115, 1116, 1117}; - private final static int[] ID_DIESEL = new int[] {960, 1110, 1111, 1112}; - private final static int[] ID_SEMIFLUID = new int[] {837, 838, 839}; - private final static int[] ID_GEOTHERMAL = new int[] {830, 831, 832}; - private final static int[] ID_ROCKETFUEL = new int[] {793, 794, 795}; - private final static int[] ID_MAGIC_A = new int[] {1123, 1124, 1125}; - private final static int[] ID_MAGIC_B_DISABLED = new int[] {1127, 1128, 1129, 1130}; - private final static int[] ID_PLASMA = new int[] {1196, 1197, 1198}; - private final static int[] ID_NAQUADAH = new int[] {1190, 1191, 1192}; - - private static final int getModeFromInventorySlot(ItemStack aStack) { - - if (aStack == null) { - return MODE_NONE; - } - - String aItemStackName = aStack == null ? "" : aStack.getUnlocalizedName(); - //Logger.INFO("Item Name: "+aItemStackName+" ("+aStack.getItemDamage()+")"); - if (aItemStackName.toLowerCase().contains("gt.blockmachines")) { - for (int g : ID_STEAM) { - if (aStack.getItemDamage() == g) { - return MODE_STEAM; - } - } - for (int g : ID_GAS) { - if (aStack.getItemDamage() == g) { - return MODE_GAS; - } - } - for (int g : ID_DIESEL) { - if (aStack.getItemDamage() == g) { - return MODE_DIESEL; - } - } - for (int g : ID_SEMIFLUID) { - if (aStack.getItemDamage() == g) { - return MODE_SEMIFLUID; - } - } - for (int g : ID_GEOTHERMAL) { - if (aStack.getItemDamage() == g) { - return MODE_GEOTHERMAL; - } - } - for (int g : ID_ROCKETFUEL) { - if (aStack.getItemDamage() == g) { - return MODE_ROCKETFUEL; - } - } - for (int g : ID_MAGIC_A) { - if (aStack.getItemDamage() == g) { - return MODE_MAGIC_A; - } - } - for (int g : ID_PLASMA) { - if (aStack.getItemDamage() == g) { - return MODE_PLASMA; - } - } - for (int g : ID_NAQUADAH) { - if (aStack.getItemDamage() == g) { - return MODE_NAQUADAH; - } - } - } - return MODE_NONE; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - return false; - -/** this.resetRecipeMapForAllInputHatches(); - this.mMode = getModeFromInventorySlot(aStack); - if (mMode == MODE_NONE) { - Logger.INFO("Did not find valid generator."); - return false; - } - else { - Logger.INFO("Changed Mode to "+mMode); - } - int aMulti = this.getGUIItemStack() != null ? this.getGUIItemStack().stackSize : 0; - if (aMulti > 16 || aMulti == 0) { - return false; - } - - - - ArrayList tFluids = this.getStoredFluids(); - - Collection tRecipeList = this.getRecipeMap().mRecipeList; - Logger.INFO("Got Recipe Map"); - if (tFluids.size() > 0 && tRecipeList != null) { - Logger.INFO("Found Fuels for Map."); - Iterator arg3 = tFluids.iterator(); - int aCount = 0; - while (arg3.hasNext()) { - FluidStack hatchFluid1 = (FluidStack) arg3.next(); - Logger.INFO("Iterating Fluid Found "+(aCount++)+" | "+hatchFluid1.getLocalizedName()); - Iterator arg5 = tRecipeList.iterator(); - - int Hatch = 0; - int totalFuelValue = 0; - while (arg5.hasNext()) { - Logger.INFO("Iterating Recipe "+(Hatch++)); - GT_Recipe aFuel = (GT_Recipe) arg5.next(); - FluidStack tLiquid; - boolean addedFuelOnce = false; - for (int a = 0; a < aMulti; a++) { - if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null - && hatchFluid1.isFluidEqual(tLiquid)) { - this.fuelConsumption = tLiquid.amount = this.boostEu - ? 4096 / aFuel.mSpecialValue - : 2048 / aFuel.mSpecialValue; - if (this.depleteInput(tLiquid)) { - Logger.INFO("Depleted Fuel"); - this.boostEu = this.depleteInput(Materials.Oxygen.getGas(2L)); - -/*if (!tFluids.contains(Materials.Lubricant.getFluid(1L))) { - Logger.INFO("No Lube."); - return false; - }*/ -/** - if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { - this.depleteInput(Materials.Lubricant.getFluid(this.boostEu ? 2L : 1L)); - } - Logger.INFO("ADDING POWER"); - this.fuelRemaining = hatchFluid1.amount; - totalFuelValue++; - } - } - } - //Do things after consuming Fuel - if (totalFuelValue == aMulti) { - this.fuelValue = aFuel.mSpecialValue*aMulti; - this.mEUt = this.mEfficiency < 2000 ? 0 : aFuel.mSpecialValue*aMulti; - this.mProgresstime = aMulti; - this.mMaxProgresstime = aMulti; - this.mEfficiencyIncrease = 15*aMulti; - return true; - } - } - } - } - - this.mEUt = 0; - this.mEfficiency = 0; - return false; - **/ - } - - public static ItemStack[] clean(final ItemStack[] v) { - List list = new ArrayList(Arrays.asList(v)); - list.removeAll(Collections.singleton(null)); - return list.toArray(new ItemStack[list.size()]); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntityGeneratorArray.class) - .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Dynamo.or(TTDynamo), Muffler) - .casingIndex(48) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings4, 0))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - /** - * Code from single blocks - */ - - public void tryProcessFuelItems(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a) { - if (a != null - && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + this.getMinimumStoredEU() - && GT_Utility.getFluidForFilledItem(a, true) == null) { - int tFuelValue; - tFuelValue = this.getFuelValue(a); - if (tFuelValue > 0) { - ItemStack tEmptyContainer1 = this.getEmptyContainer(a); - if (this.addOutput(tEmptyContainer1)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); - this.depleteInput(a); - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); - } - } - } - } - - public void tryProcessFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick, FluidStack mFluid) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { - int tFuelValue; - if (mFluid != null) { - tFuelValue = this.getFuelValue(mFluid); - int tEmptyContainer = this.consumedFluidPerOperation(mFluid); - if (tFuelValue > 0 && tEmptyContainer > 0 && mFluid.amount > tEmptyContainer) { - long tFluidAmountToUse = Math.min((long) (mFluid.amount / tEmptyContainer), - (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); - if (tFluidAmountToUse > 0L && aBaseMetaTileEntity - .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); - mFluid.amount = (int) ((long) mFluid.amount - - tFluidAmountToUse * (long) tEmptyContainer); - } - } - } - - //Check items - } - - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity - .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); - } - - } - - public boolean isFluidInputAllowed(FluidStack aFluid) { - return this.getFuelValue(aFluid) > 0; - } - - - public int consumedFluidPerOperation(FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid != null && this.getRecipeMap() != null) { - Collection tRecipeList = this.getRecipeMap().mRecipeList; - if (tRecipeList != null) { - Iterator arg3 = tRecipeList.iterator(); - - while (arg3.hasNext()) { - GT_Recipe tFuel = (GT_Recipe) arg3.next(); - FluidStack tLiquid; - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null - && aLiquid.isFluidEqual(tLiquid)) { - return (int) ((long) tFuel.mSpecialValue * (long) this.mEfficiency - * (long) this.consumedFluidPerOperation(tLiquid) / 100L); - } - } - } - - return 0; - } else { - return 0; - } - } - - public int getFuelValue(ItemStack aStack) { - if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { - GT_Recipe tFuel = this.getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, - (FluidStack[]) null, new ItemStack[]{aStack}); - return tFuel != null ? (int) ((long) tFuel.mSpecialValue * 1000L * (long) this.mEfficiency / 100L) : 0; - } else { - return 0; - } - } - - public ItemStack getEmptyContainer(ItemStack aStack) { - if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { - GT_Recipe tFuel = this.getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, - (FluidStack[]) null, new ItemStack[]{aStack}); - return tFuel != null - ? GT_Utility.copy(new Object[]{tFuel.getOutput(0)}) - : GT_Utility.getContainerItem(aStack, true); - } else { - return null; - } - } -} \ No newline at end of file +public class GregtechMetaTileEntityGeneratorArray + extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntityGeneratorArray(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityGeneratorArray(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeneratorArray(this.mName); + } + + @Override + public String getMachineType() { + return "Processing Array"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Generator Array") + .addInfo("Runs supplied generators as if placed in the world") + .addInfo("Place up to 16 Single Block GT Generators into the Controller") + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Robust Tungstensteel Machine Casings", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addDynamoHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return 48; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ProcessingArray"; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + this.mMode = getModeFromInventorySlot(this.getGUIItemStack()); + if (this.mMode == MODE_NONE) { + return null; + } else if (this.mMode == MODE_STEAM) { + return GTPP_Recipe.GTPP_Recipe_Map.sSteamTurbineFuels; + } else if (this.mMode == MODE_DIESEL) { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } else if (this.mMode == MODE_GAS) { + return GT_Recipe.GT_Recipe_Map.sTurbineFuels; + } else if (this.mMode == MODE_SEMIFLUID) { + return GTPP_Recipe.GTPP_Recipe_Map.sSemiFluidLiquidFuels; + } else if (this.mMode == MODE_GEOTHERMAL) { + return GTPP_Recipe.GTPP_Recipe_Map.sThermalFuels; + } else if (this.mMode == MODE_ROCKETFUEL) { + return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; + } else if (this.mMode == MODE_MAGIC_A) { + return GT_Recipe.GT_Recipe_Map.sMagicFuels; + } else if (this.mMode == MODE_PLASMA) { + return GT_Recipe.GT_Recipe_Map.sPlasmaFuels; + } else if (this.mMode == MODE_NAQUADAH) { + return GT_Recipe.GT_Recipe_Map.sFluidNaquadahReactorFuels; + } + return null; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + if (aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.")) { + return true; + } + return false; + } + + protected int fuelConsumption = 0; + protected int fuelValue = 0; + protected int fuelRemaining = 0; + protected boolean boostEu = false; + + int mMode = 0; + + private static final int MODE_STEAM = 0; + private static final int MODE_DIESEL = 1; + private static final int MODE_GAS = 2; + private static final int MODE_SEMIFLUID = 3; + private static final int MODE_GEOTHERMAL = 4; + private static final int MODE_ROCKETFUEL = 5; + private static final int MODE_MAGIC_A = 6; + private static final int MODE_MAGIC_B_DISABLED = 7; + private static final int MODE_PLASMA = 8; + private static final int MODE_NAQUADAH = 9; + private static final int MODE_NONE = 100; + + private static final int[] ID_STEAM = new int[] {962, 1120, 1121, 1122}; + private static final int[] ID_GAS = new int[] {961, 1115, 1116, 1117}; + private static final int[] ID_DIESEL = new int[] {960, 1110, 1111, 1112}; + private static final int[] ID_SEMIFLUID = new int[] {837, 838, 839}; + private static final int[] ID_GEOTHERMAL = new int[] {830, 831, 832}; + private static final int[] ID_ROCKETFUEL = new int[] {793, 794, 795}; + private static final int[] ID_MAGIC_A = new int[] {1123, 1124, 1125}; + private static final int[] ID_MAGIC_B_DISABLED = new int[] {1127, 1128, 1129, 1130}; + private static final int[] ID_PLASMA = new int[] {1196, 1197, 1198}; + private static final int[] ID_NAQUADAH = new int[] {1190, 1191, 1192}; + + private static final int getModeFromInventorySlot(ItemStack aStack) { + + if (aStack == null) { + return MODE_NONE; + } + + String aItemStackName = aStack == null ? "" : aStack.getUnlocalizedName(); + // Logger.INFO("Item Name: "+aItemStackName+" ("+aStack.getItemDamage()+")"); + if (aItemStackName.toLowerCase().contains("gt.blockmachines")) { + for (int g : ID_STEAM) { + if (aStack.getItemDamage() == g) { + return MODE_STEAM; + } + } + for (int g : ID_GAS) { + if (aStack.getItemDamage() == g) { + return MODE_GAS; + } + } + for (int g : ID_DIESEL) { + if (aStack.getItemDamage() == g) { + return MODE_DIESEL; + } + } + for (int g : ID_SEMIFLUID) { + if (aStack.getItemDamage() == g) { + return MODE_SEMIFLUID; + } + } + for (int g : ID_GEOTHERMAL) { + if (aStack.getItemDamage() == g) { + return MODE_GEOTHERMAL; + } + } + for (int g : ID_ROCKETFUEL) { + if (aStack.getItemDamage() == g) { + return MODE_ROCKETFUEL; + } + } + for (int g : ID_MAGIC_A) { + if (aStack.getItemDamage() == g) { + return MODE_MAGIC_A; + } + } + for (int g : ID_PLASMA) { + if (aStack.getItemDamage() == g) { + return MODE_PLASMA; + } + } + for (int g : ID_NAQUADAH) { + if (aStack.getItemDamage() == g) { + return MODE_NAQUADAH; + } + } + } + return MODE_NONE; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + return false; + + /** this.resetRecipeMapForAllInputHatches(); + * this.mMode = getModeFromInventorySlot(aStack); + * if (mMode == MODE_NONE) { + * Logger.INFO("Did not find valid generator."); + * return false; + * } + * else { + * Logger.INFO("Changed Mode to "+mMode); + * } + * int aMulti = this.getGUIItemStack() != null ? this.getGUIItemStack().stackSize : 0; + * if (aMulti > 16 || aMulti == 0) { + * return false; + * } + * + * + * + * ArrayList tFluids = this.getStoredFluids(); + * + * Collection tRecipeList = this.getRecipeMap().mRecipeList; + * Logger.INFO("Got Recipe Map"); + * if (tFluids.size() > 0 && tRecipeList != null) { + * Logger.INFO("Found Fuels for Map."); + * Iterator arg3 = tFluids.iterator(); + * int aCount = 0; + * while (arg3.hasNext()) { + * FluidStack hatchFluid1 = (FluidStack) arg3.next(); + * Logger.INFO("Iterating Fluid Found "+(aCount++)+" | "+hatchFluid1.getLocalizedName()); + * Iterator arg5 = tRecipeList.iterator(); + * + * int Hatch = 0; + * int totalFuelValue = 0; + * while (arg5.hasNext()) { + * Logger.INFO("Iterating Recipe "+(Hatch++)); + * GT_Recipe aFuel = (GT_Recipe) arg5.next(); + * FluidStack tLiquid; + * boolean addedFuelOnce = false; + * for (int a = 0; a < aMulti; a++) { + * if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null + * && hatchFluid1.isFluidEqual(tLiquid)) { + * this.fuelConsumption = tLiquid.amount = this.boostEu + * ? 4096 / aFuel.mSpecialValue + * : 2048 / aFuel.mSpecialValue; + * if (this.depleteInput(tLiquid)) { + * Logger.INFO("Depleted Fuel"); + * this.boostEu = this.depleteInput(Materials.Oxygen.getGas(2L)); + * + * /*if (!tFluids.contains(Materials.Lubricant.getFluid(1L))) { + * Logger.INFO("No Lube."); + * return false; + * }*/ + /** + * if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { + * this.depleteInput(Materials.Lubricant.getFluid(this.boostEu ? 2L : 1L)); + * } + * Logger.INFO("ADDING POWER"); + * this.fuelRemaining = hatchFluid1.amount; + * totalFuelValue++; + * } + * } + * } + * //Do things after consuming Fuel + * if (totalFuelValue == aMulti) { + * this.fuelValue = aFuel.mSpecialValue*aMulti; + * this.mEUt = this.mEfficiency < 2000 ? 0 : aFuel.mSpecialValue*aMulti; + * this.mProgresstime = aMulti; + * this.mMaxProgresstime = aMulti; + * this.mEfficiencyIncrease = 15*aMulti; + * return true; + * } + * } + * } + * } + * + * this.mEUt = 0; + * this.mEfficiency = 0; + * return false; + **/ + } + + public static ItemStack[] clean(final ItemStack[] v) { + List list = new ArrayList(Arrays.asList(v)); + list.removeAll(Collections.singleton(null)); + return list.toArray(new ItemStack[list.size()]); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntityGeneratorArray.class) + .atLeast( + InputHatch, + OutputHatch, + InputBus, + OutputBus, + Maintenance, + Dynamo.or(TTDynamo), + Muffler) + .casingIndex(48) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings4, 0)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + /** + * Code from single blocks + */ + public void tryProcessFuelItems(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a) { + if (a != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(a, true) == null) { + int tFuelValue; + tFuelValue = this.getFuelValue(a); + if (tFuelValue > 0) { + ItemStack tEmptyContainer1 = this.getEmptyContainer(a); + if (this.addOutput(tEmptyContainer1)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + this.depleteInput(a); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + } + } + } + } + + public void tryProcessFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick, FluidStack mFluid) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (mFluid != null) { + tFuelValue = this.getFuelValue(mFluid); + int tEmptyContainer = this.consumedFluidPerOperation(mFluid); + if (tFuelValue > 0 && tEmptyContainer > 0 && mFluid.amount > tEmptyContainer) { + long tFluidAmountToUse = Math.min( + (long) (mFluid.amount / tEmptyContainer), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L + && aBaseMetaTileEntity.increaseStoredEnergyUnits( + tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + mFluid.amount = (int) ((long) mFluid.amount - tFluidAmountToUse * (long) tEmptyContainer); + } + } + } + + // Check items + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() + && aBaseMetaTileEntity.getUniversalEnergyStored() + >= this.maxEUOutput() + this.getMinimumStoredEU()); + } + } + + public boolean isFluidInputAllowed(FluidStack aFluid) { + return this.getFuelValue(aFluid) > 0; + } + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid != null && this.getRecipeMap() != null) { + Collection tRecipeList = this.getRecipeMap().mRecipeList; + if (tRecipeList != null) { + Iterator arg3 = tRecipeList.iterator(); + + while (arg3.hasNext()) { + GT_Recipe tFuel = (GT_Recipe) arg3.next(); + FluidStack tLiquid; + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null + && aLiquid.isFluidEqual(tLiquid)) { + return (int) ((long) tFuel.mSpecialValue + * (long) this.mEfficiency + * (long) this.consumedFluidPerOperation(tLiquid) + / 100L); + } + } + } + + return 0; + } else { + return 0; + } + } + + public int getFuelValue(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { + GT_Recipe tFuel = this.getRecipeMap() + .findRecipe( + this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, (FluidStack[]) null, new ItemStack[] { + aStack + }); + return tFuel != null ? (int) ((long) tFuel.mSpecialValue * 1000L * (long) this.mEfficiency / 100L) : 0; + } else { + return 0; + } + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { + GT_Recipe tFuel = this.getRecipeMap() + .findRecipe( + this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, (FluidStack[]) null, new ItemStack[] { + aStack + }); + return tFuel != null + ? GT_Utility.copy(new Object[] {tFuel.getOutput(0)}) + : GT_Utility.getContainerItem(aStack, true); + } else { + return null; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 5c4278a198..2be790ac16 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -1,9 +1,11 @@ - package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; -import java.util.HashMap; -import javax.annotation.Nonnull; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTEnergy; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -34,502 +36,578 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; +import java.util.ArrayList; +import java.util.HashMap; +import javax.annotation.Nonnull; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTEnergy; - -public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - public static String mCasingName = "Sterile Farm Casing"; -// public static TreeGenerator mTreeData; - public static HashMap sLogCache = new HashMap<>(); - private static final int TICKS_PER_OPERATION = 100; - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - private SAWTOOL mToolType; - private ItemStack mSapling; - private ItemStack mWood; - private float heightModifier = 1.0f; - private float saplingsModifier = 1.0f; - private int girthModifier = 1; - - public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); - } - - public GregtechMetaTileEntityTreeFarm(final String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); - } - - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityTreeFarm(this.mName); - } - - @Override - public String getMachineType() { - return "Tree Farm"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Converts EU to Logs") - .addInfo("Eu Usage: 100% | Parallel: 1") - .addInfo("Requires a Saw or Chainsaw in GUI slot") - .addInfo("Output multiplier:") - .addInfo("Saw = 1x") - .addInfo("Buzzsaw = 2x") - .addInfo("Chainsaw = 4x") - .addInfo("Add a sapling in the input bus to select wood type output") - .addInfo("Tools can also be fed to the controller via input bus") - .addInfo("The working speed is fixed for 5s") - .addInfo("Production Formula: (2 * tier^2 - 2 * tier + 5) * 5 * saw boost") - .addInfo("When fertilizer is insufficient, sapling production reduced to one-tenth") - .addInfo("Forestry saplings can get increased production") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo("Sterile Farm Casing", 8) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "VacuumFreezer"; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - // is correct part && either not powered tool or have enough power - if (TreeFarmHelper.isValidForGUI(aStack) && GT_MetaGenerated_Tool.getToolDamage(aStack) < GT_MetaGenerated_Tool.getToolMaxDamage(aStack)) { - return GT_ModHandler.isElectricItem(aStack) ? GT_ModHandler.canUseElectricItem(aStack, 32) : true; - } - return false; - } - - /** - * Method used to get the boost based on the ordinal of the saw - * @param sawType type of the saw - * @return an int corresponding to the boost - */ - public int getSawBoost(SAWTOOL sawType){ - switch(sawType){ - case SAW: - return 1; - case BUZZSAW: - return 2; - case CHAINSAW: - return 4; - default: - return 1; - } - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - if (!isCorrectMachinePart(aStack) && !replaceTool()) return false; - if (!checkSapling()) return false; - - this.mToolType = TreeFarmHelper.isCorrectMachinePart(aStack); - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - int aOutputAmount = ((2 * (tTier * tTier)) - (2 * tTier) + 5) * (TICKS_PER_OPERATION / 20) * getSawBoost(mToolType); - int aFert = hasLiquidFert(); - ItemStack[] toOutput; - - if (aFert > 0) { //Sapling - if (aFert < aOutputAmount) { - aOutputAmount /= 10; - } - int amplifiedOutputAmount = (int) (aOutputAmount * saplingsModifier); - toOutput = new ItemStack[]{ItemUtils.getSimpleStack(mSapling, amplifiedOutputAmount)}; - } else { //Log - int amplifiedOutputAmount = (int) (aOutputAmount * heightModifier * girthModifier); - toOutput = new ItemStack[]{ItemUtils.getSimpleStack(mWood, amplifiedOutputAmount)}; - } - - if (canBufferOutputs(toOutput, new FluidStack[]{}, 1) == 0) { - return false; - } - - if (aFert > 0 && aFert >= aOutputAmount) { - tryConsumeLiquidFert(aOutputAmount); - } - - this.mOutputItems = toOutput; - - this.mMaxProgresstime = TICKS_PER_OPERATION; - this.mEUt = MaterialUtils.getVoltageForTier(tTier); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.tryDamageTool(); - this.updateSlots(); - return true; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 8 && checkHatch(); - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"C~C", "C-C", "CCC"}, - {"CCC", "CCC", "CCC"}, - })) - .addElement('C', buildHatchAdder(GregtechMetaTileEntityTreeFarm.class) - .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Energy.or(TTEnergy), Muffler) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 15))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiTreeFarm; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return MathUtils.balance((int) (75 - ((GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).getMass()))), 5, 120); - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - private boolean tryDamageTool() { - GT_ModHandler.damageOrDechargeItem(this.mInventory[1], 1, 32, null); - return replaceTool(); - } - - public boolean replaceTool() { - ItemStack invItem = this.mInventory[1]; - if (isCorrectMachinePart(invItem)) return true; - else { - if (invItem != null) { - this.mInventory[1] = null; - this.addOutput(invItem); - } - - for (ItemStack aStack : getStoredInputs()) { - if (isCorrectMachinePart(aStack)) { - this.mInventory[1] = aStack.copy(); - this.depleteInput(aStack); - return true; - } - } - } - return false; - } - - public boolean checkSapling() { - for (ItemStack uStack : this.getStoredInputs()) { - - if (uStack != null) { - String registryName = Item.itemRegistry.getNameForObject(uStack.getItem()); - ItemStack aWood = sLogCache.get(registryName + ":" + uStack.getItemDamage()); - - if (aWood != null) { - this.heightModifier = 1.0f; - this.saplingsModifier = 1.0f; - this.girthModifier = 1; - - this.mSapling = uStack; - this.mWood = aWood; - return true; - } else { - if (registryName.equals("Forestry:sapling")) { - - ITree tree = TreeManager.treeRoot.getMember(uStack); - - this.heightModifier = Math.max(3 * (tree.getGenome().getHeight() - 1), 0) + 1; - this.saplingsModifier = Math.max(tree.getGenome().getFertility() * 20, 1); - this.girthModifier = tree.getGenome().getGirth(); - boolean fireproof = ((IAlleleBoolean) tree.getGenome().getChromosomes()[EnumTreeChromosome.FIREPROOF.ordinal()].getActiveAllele()).getValue(); - - aWood = sLogCache.get(tree.getIdent() + (fireproof ? "fireproof" : "")); - - this.mSapling = uStack; - this.mWood = aWood; - return true; - } - } - } - } - return false; - } - - public static void loadMapWoodFromSapling() { - - // galaxySpace - mapSaplingToLog("GalaxySpace:barnardaCsapling:1", GT_ModHandler.getModItem("GalaxySpace", "barnardaClog", 1)); // barnarda c - - // minecraft - mapSaplingToLog("minecraft:sapling:0", new ItemStack(Blocks.log, 1, 0)); // oak - mapSaplingToLog("minecraft:sapling:1", new ItemStack(Blocks.log, 1, 1)); // spruce - mapSaplingToLog("minecraft:sapling:2", new ItemStack(Blocks.log, 1, 2)); // birch - mapSaplingToLog("minecraft:sapling:3", new ItemStack(Blocks.log, 1, 3)); // jungle - mapSaplingToLog("minecraft:sapling:4", new ItemStack(Blocks.log2, 1, 0)); // acacia - mapSaplingToLog("minecraft:sapling:5", new ItemStack(Blocks.log2, 1, 1)); // dark oak - - - // ic2 - mapSaplingToLog("IC2:blockRubSapling:0", GT_ModHandler.getModItem("IC2", "blockRubWood", 1)); // rubber - - // natura - mapSaplingToLog("Natura:florasapling:0", GT_ModHandler.getModItem("Natura", "redwood", 1, 1)); // redwood - mapSaplingToLog("Natura:florasapling:1", GT_ModHandler.getModItem("Natura", "tree", 1, 0)); // eucalyptus - mapSaplingToLog("Natura:florasapling:2", GT_ModHandler.getModItem("Natura", "tree", 1, 3)); // hopseed - mapSaplingToLog("Natura:florasapling:3", GT_ModHandler.getModItem("Natura", "tree", 1, 1)); // sakura - mapSaplingToLog("Natura:florasapling:4", GT_ModHandler.getModItem("Natura", "tree", 1, 2)); // ghostwood - mapSaplingToLog("Natura:florasapling:5", GT_ModHandler.getModItem("Natura", "bloodwood", 1, 0)); // bloodwood - mapSaplingToLog("Natura:florasapling:6", GT_ModHandler.getModItem("Natura", "Dark Tree", 1, 0)); // darkwood - mapSaplingToLog("Natura:florasapling:7", GT_ModHandler.getModItem("Natura", "Dark Tree", 1, 1)); // fusewood - - mapSaplingToLog("Natura:Rare Sapling:0", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 0)); // maple - mapSaplingToLog("Natura:Rare Sapling:1", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 1)); // silverbell - mapSaplingToLog("Natura:Rare Sapling:2", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 2)); // amaranth - mapSaplingToLog("Natura:Rare Sapling:3", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 3)); // tigerwood - mapSaplingToLog("Natura:Rare Sapling:4", GT_ModHandler.getModItem("Natura", "willow", 1, 0)); // willow - - // BOP - mapSaplingToLog("BiomesOPlenty:colorizedSaplings:0", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 0)); // Sacred Oak - mapSaplingToLog("BiomesOPlenty:colorizedSaplings:1", GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 2)); // Mangrove - mapSaplingToLog("BiomesOPlenty:colorizedSaplings:2", GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 3)); // Palm - mapSaplingToLog("BiomesOPlenty:colorizedSaplings:3", GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 0)); // Redwood - mapSaplingToLog("BiomesOPlenty:colorizedSaplings:4", GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 1)); // Willow - mapSaplingToLog("BiomesOPlenty:colorizedSaplings:5", GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 0)); // Pine - mapSaplingToLog("BiomesOPlenty:colorizedSaplings:6", GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 3)); // Mahogany - mapSaplingToLog("BiomesOPlenty:saplings:2", GT_ModHandler.getModItem("BiomesOPlenty", "bamboo", 1, 0)); // Bamboo - mapSaplingToLog("BiomesOPlenty:saplings:3", GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 1)); // Magic - mapSaplingToLog("BiomesOPlenty:saplings:4", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 2)); // Dark - mapSaplingToLog("BiomesOPlenty:saplings:5", GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 2)); // Dying/Dead - mapSaplingToLog("BiomesOPlenty:saplings:6", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 3)); // Fir - mapSaplingToLog("BiomesOPlenty:saplings:7", GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 0)); // Ethereal - mapSaplingToLog("BiomesOPlenty:saplings:10", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 1)); // Pink Cherry - mapSaplingToLog("BiomesOPlenty:saplings:12", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 1)); // White Cherry - mapSaplingToLog("BiomesOPlenty:saplings:13", GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 1)); // Hellbark - mapSaplingToLog("BiomesOPlenty:saplings:14", GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 2)); // Jacaranda - mapSaplingToLog("minecraft:yellow_flower:0", GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 3)); // Giant Flower Stem - mapSaplingToLog("minecraft:red_flower:0", GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 3)); // Giant Flower Stem - - // Witchery - mapSaplingToLog("witchery:witchsapling:0", GT_ModHandler.getModItem("witchery", "witchlog", 1, 0)); // Rowan - mapSaplingToLog("witchery:witchsapling:1", GT_ModHandler.getModItem("witchery", "witchlog", 1, 1)); // Alder - mapSaplingToLog("witchery:witchsapling:2", GT_ModHandler.getModItem("witchery", "witchlog", 1, 2)); // Hawthorn - - - // TConstruct - mapSaplingToLog("TConstruct:slime.sapling:0", GT_ModHandler.getModItem("TConstruct", "slime.gel", 1)); // green slime blocks - - // TaintedMagic - mapSaplingToLog("TaintedMagic:BlockWarpwoodSapling:0", GT_ModHandler.getModItem("TaintedMagic", "BlockWarpwoodLog", 1)); // warpwood - - // Thaumcraft - mapSaplingToLog("Thaumcraft:blockCustomPlant:0", GT_ModHandler.getModItem("Thaumcraft", "blockMagicalLog", 1, 0)); // greatwood - mapSaplingToLog("Thaumcraft:blockCustomPlant:1", GT_ModHandler.getModItem("Thaumcraft", "blockMagicalLog", 1, 1)); // silverwood - - // gt++ - mapSaplingToLog("miscutils:blockRainforestOakSapling:0", GT_ModHandler.getModItem("miscutils", "blockRainforestOakLog", 1)); // rainforest - mapSaplingToLog("miscutils:blockPineSapling:0", GT_ModHandler.getModItem("miscutils", "blockPineLogLog", 1)); // pine - - // Harvestcraft - mapSaplingToLog("harvestcraft:pampistachioSapling:0", new ItemStack(Blocks.log, 1, 3)); // Pistachio - mapSaplingToLog("harvestcraft:pampapayaSapling:0", new ItemStack(Blocks.log, 1, 3)); // Papaya - mapSaplingToLog("harvestcraft:pammapleSapling:0", GT_ModHandler.getModItem("harvestcraft", "pamMaple", 1)); // Maple - mapSaplingToLog("harvestcraft:pamappleSapling:0", new ItemStack(Blocks.log, 1, 0)); // Apple - mapSaplingToLog("harvestcraft:pamdateSapling:0", new ItemStack(Blocks.log, 1, 3)); // Date - mapSaplingToLog("harvestcraft:pamorangeSapling:0", new ItemStack(Blocks.log, 1, 3)); // Orange - mapSaplingToLog("harvestcraft:pamdragonfruitSapling:0", new ItemStack(Blocks.log, 1, 3)); // Dragon fruit - mapSaplingToLog("harvestcraft:pamnutmegSapling:0", new ItemStack(Blocks.log, 1, 0)); // NutMeg - mapSaplingToLog("harvestcraft:pampaperbarkSapling:0", GT_ModHandler.getModItem("harvestcraft", "pamPaperbark", 1)); // Paperbark - mapSaplingToLog("harvestcraft:pammangoSapling:0", new ItemStack(Blocks.log, 1, 3)); // Mango - mapSaplingToLog("harvestcraft:pamavocadoSapling:0", new ItemStack(Blocks.log, 1, 0)); // Avocado - mapSaplingToLog("harvestcraft:pamchestnutSapling:0", new ItemStack(Blocks.log, 1, 0)); // Chestnut - mapSaplingToLog("harvestcraft:pampeppercornSapling:0", new ItemStack(Blocks.log, 1, 3)); // Peppercorn - mapSaplingToLog("harvestcraft:pampecanSapling:0", new ItemStack(Blocks.log, 1, 3)); // Pecan - mapSaplingToLog("harvestcraft:pamcashewSapling:0", new ItemStack(Blocks.log, 1, 3)); // Cashew - mapSaplingToLog("harvestcraft:pamfigSapling:0", new ItemStack(Blocks.log, 1, 3)); // Fig - mapSaplingToLog("harvestcraft:pamoliveSapling:0", new ItemStack(Blocks.log, 1, 3)); // Olive - mapSaplingToLog("harvestcraft:pamcinnamonSapling:0", GT_ModHandler.getModItem("harvestcraft", "pamCinnamon", 1)); // Cinnamon - mapSaplingToLog("harvestcraft:pampeachSapling:0", new ItemStack(Blocks.log, 1, 3)); // Peach - mapSaplingToLog("harvestcraft:pamlemonSapling:0", new ItemStack(Blocks.log, 1, 3)); // Lemon - mapSaplingToLog("harvestcraft:pamvanillabeanSapling:0", new ItemStack(Blocks.log, 1, 3)); // Vanilla - mapSaplingToLog("harvestcraft:pamalmondSapling:0", new ItemStack(Blocks.log, 1, 3)); // Almond - mapSaplingToLog("harvestcraft:pambananaSapling:0", new ItemStack(Blocks.log, 1, 3)); // Banana - mapSaplingToLog("harvestcraft:pamdurianSapling:0", new ItemStack(Blocks.log, 1, 3)); // Durian - mapSaplingToLog("harvestcraft:pamplumSapling:0", new ItemStack(Blocks.log, 1, 0)); // Plum - mapSaplingToLog("harvestcraft:pamlimeSapling:0", new ItemStack(Blocks.log, 1, 3)); // Lime - mapSaplingToLog("harvestcraft:pampearSapling:0", new ItemStack(Blocks.log, 1, 0)); // Pear - mapSaplingToLog("harvestcraft:pamgooseberrySapling:0", new ItemStack(Blocks.log, 1, 0)); // Gooseberry - mapSaplingToLog("harvestcraft:pamcherrySapling:0", new ItemStack(Blocks.log, 1, 0)); // Cherry - mapSaplingToLog("harvestcraft:pampomegranateSapling:0", new ItemStack(Blocks.log, 1, 3)); // Pomegranate - mapSaplingToLog("harvestcraft:pamwalnutSapling:0", new ItemStack(Blocks.log, 1, 0)); // Walnut - mapSaplingToLog("harvestcraft:pampersimmonSapling:0", new ItemStack(Blocks.log, 1, 3)); // Persimmon - mapSaplingToLog("harvestcraft:pamapricotSapling:0", new ItemStack(Blocks.log, 1, 3)); // Apricot - mapSaplingToLog("harvestcraft:pamcoconutSapling:0", new ItemStack(Blocks.log, 1, 3)); // Coconut - mapSaplingToLog("harvestcraft:pamgrapefruitSapling:0", new ItemStack(Blocks.log, 1, 3)); // Grapefruit - mapSaplingToLog("harvestcraft:pamstarfruitSapling:0", new ItemStack(Blocks.log, 1, 3)); // Starfruit - - // Harvest The Nether - mapSaplingToLog("harvestthenether:netherSapling:0", GT_ModHandler.getModItem("harvestthenether", "netherLog", 1)); // Nether - - // The Twilight Forest - mapSaplingToLog("TwilightForest:tile.TFSapling:0", GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 0)); // Sickly Twilight Oak - mapSaplingToLog("TwilightForest:tile.TFSapling:1", GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 1)); // Canopy Tree - mapSaplingToLog("TwilightForest:tile.TFSapling:2", GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 2)); // Twilight Mangrove - mapSaplingToLog("TwilightForest:tile.TFSapling:3", GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 3)); // Darkwood - mapSaplingToLog("TwilightForest:tile.TFSapling:4", GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 0)); // Robust Twilight Oad - mapSaplingToLog("TwilightForest:tile.TFSapling:5", GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 0)); // Tree of Time - mapSaplingToLog("TwilightForest:tile.TFSapling:6", GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 1)); // Tree of Trasformation - mapSaplingToLog("TwilightForest:tile.TFSapling:7", GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 2)); // Miner's Tree - mapSaplingToLog("TwilightForest:tile.TFSapling:8", GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 3)); // Sorting Tree - mapSaplingToLog("TwilightForest:tile.TFSapling:9", GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 0)); // Rainbow Oak - - // Thaumic Bases - mapSaplingToLog("thaumicbases:goldenOakSapling:0", new ItemStack(Blocks.log, 1, 0)); // Golden Oak - mapSaplingToLog("thaumicbases:goldenOakSapling:1", GT_ModHandler.getModItem("thaumicbases", "genLogs", 1, 0)); // Peaceful - mapSaplingToLog("thaumicbases:goldenOakSapling:2", GT_ModHandler.getModItem("thaumicbases", "genLogs", 1, 1)); // Nether - mapSaplingToLog("thaumicbases:goldenOakSapling:3", GT_ModHandler.getModItem("thaumicbases", "genLogs", 1, 2)); // Ender - - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - public static void mapSaplingToLog(String aSapling, ItemStack aLog) { - ItemStack aSaplingStack = ItemUtils.getItemStackFromFQRN(aSapling, 1); - if (aSaplingStack != null && aLog != null) { - sLogCache.put(aSapling, aLog); - addFakeRecipeToNEI(aSaplingStack, aLog); - } else { - Logger.INFO("Unable to add Tree Growth Simulation for " + aSapling); - } - } - - private static int sRecipeID = 0; - - public static boolean addFakeRecipeToNEI(@Nonnull ItemStack aSapling, ItemStack aLog) { - int aRecipes = GTPP_Recipe_Map.sTreeSimFakeRecipes.mRecipeList.size(); - Logger.INFO("Adding Tree Growth Simulation for " + aSapling.getDisplayName() + " -> " + (aLog == null ? "NULL" : aLog.getDisplayName())); - ItemStack[] aOutput = new ItemStack[]{aLog, aSapling}; - String aOutputs = ItemUtils.getArrayStackNames(aOutput); - Logger.INFO("" + aOutputs); - GTPP_Recipe_Map.sTreeSimFakeRecipes.addFakeRecipe( - false, - new ItemStack[]{aSapling.copy()}, - aOutput, - null, - new int[]{10000, 1000}, - new FluidStack[]{FluidUtils.getFluidStack(ModItems.fluidFertBasic, 1)}, - new FluidStack[]{}, - 1, - sRecipeID++, - 0); - return GTPP_Recipe_Map.sTreeSimFakeRecipes.mRecipeList.size() > aRecipes; - } - - public int hasLiquidFert() { - ArrayList aFluids = this.getStoredFluids(); - for (FluidStack aFluid : aFluids) { - if (aFluid.getFluid().equals(ModItems.fluidFertBasic)) { - return aFluid.amount; - } - } - return 0; - } - - public boolean tryConsumeLiquidFert(int aFluidAmount) { - return this.depleteInput(FluidUtils.getFluidStack(ModItems.fluidFertBasic, aFluidAmount)); - } +public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + public static String mCasingName = "Sterile Farm Casing"; + // public static TreeGenerator mTreeData; + public static HashMap sLogCache = new HashMap<>(); + private static final int TICKS_PER_OPERATION = 100; + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + private SAWTOOL mToolType; + private ItemStack mSapling; + private ItemStack mWood; + private float heightModifier = 1.0f; + private float saplingsModifier = 1.0f; + private int girthModifier = 1; + + public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + } + + public GregtechMetaTileEntityTreeFarm(final String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityTreeFarm(this.mName); + } + + @Override + public String getMachineType() { + return "Tree Farm"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Converts EU to Logs") + .addInfo("Eu Usage: 100% | Parallel: 1") + .addInfo("Requires a Saw or Chainsaw in GUI slot") + .addInfo("Output multiplier:") + .addInfo("Saw = 1x") + .addInfo("Buzzsaw = 2x") + .addInfo("Chainsaw = 4x") + .addInfo("Add a sapling in the input bus to select wood type output") + .addInfo("Tools can also be fed to the controller via input bus") + .addInfo("The working speed is fixed for 5s") + .addInfo("Production Formula: (2 * tier^2 - 2 * tier + 5) * 5 * saw boost") + .addInfo("When fertilizer is insufficient, sapling production reduced to one-tenth") + .addInfo("Forestry saplings can get increased production") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Sterile Farm Casing", 8) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "VacuumFreezer"; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + // is correct part && either not powered tool or have enough power + if (TreeFarmHelper.isValidForGUI(aStack) + && GT_MetaGenerated_Tool.getToolDamage(aStack) < GT_MetaGenerated_Tool.getToolMaxDamage(aStack)) { + return GT_ModHandler.isElectricItem(aStack) ? GT_ModHandler.canUseElectricItem(aStack, 32) : true; + } + return false; + } + + /** + * Method used to get the boost based on the ordinal of the saw + * @param sawType type of the saw + * @return an int corresponding to the boost + */ + public int getSawBoost(SAWTOOL sawType) { + switch (sawType) { + case SAW: + return 1; + case BUZZSAW: + return 2; + case CHAINSAW: + return 4; + default: + return 1; + } + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + if (!isCorrectMachinePart(aStack) && !replaceTool()) return false; + if (!checkSapling()) return false; + + this.mToolType = TreeFarmHelper.isCorrectMachinePart(aStack); + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + int aOutputAmount = + ((2 * (tTier * tTier)) - (2 * tTier) + 5) * (TICKS_PER_OPERATION / 20) * getSawBoost(mToolType); + int aFert = hasLiquidFert(); + ItemStack[] toOutput; + + if (aFert > 0) { // Sapling + if (aFert < aOutputAmount) { + aOutputAmount /= 10; + } + int amplifiedOutputAmount = (int) (aOutputAmount * saplingsModifier); + toOutput = new ItemStack[] {ItemUtils.getSimpleStack(mSapling, amplifiedOutputAmount)}; + } else { // Log + int amplifiedOutputAmount = (int) (aOutputAmount * heightModifier * girthModifier); + toOutput = new ItemStack[] {ItemUtils.getSimpleStack(mWood, amplifiedOutputAmount)}; + } + + if (canBufferOutputs(toOutput, new FluidStack[] {}, 1) == 0) { + return false; + } + + if (aFert > 0 && aFert >= aOutputAmount) { + tryConsumeLiquidFert(aOutputAmount); + } + + this.mOutputItems = toOutput; + + this.mMaxProgresstime = TICKS_PER_OPERATION; + this.mEUt = MaterialUtils.getVoltageForTier(tTier); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.tryDamageTool(); + this.updateSlots(); + return true; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 8 && checkHatch(); + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntityTreeFarm.class) + .atLeast( + InputHatch, + OutputHatch, + InputBus, + OutputBus, + Maintenance, + Energy.or(TTEnergy), + Muffler) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 15)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiTreeFarm; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return MathUtils.balance( + (int) (75 - ((GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).getMass()))), 5, 120); + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private boolean tryDamageTool() { + GT_ModHandler.damageOrDechargeItem(this.mInventory[1], 1, 32, null); + return replaceTool(); + } + + public boolean replaceTool() { + ItemStack invItem = this.mInventory[1]; + if (isCorrectMachinePart(invItem)) return true; + else { + if (invItem != null) { + this.mInventory[1] = null; + this.addOutput(invItem); + } + + for (ItemStack aStack : getStoredInputs()) { + if (isCorrectMachinePart(aStack)) { + this.mInventory[1] = aStack.copy(); + this.depleteInput(aStack); + return true; + } + } + } + return false; + } + + public boolean checkSapling() { + for (ItemStack uStack : this.getStoredInputs()) { + + if (uStack != null) { + String registryName = Item.itemRegistry.getNameForObject(uStack.getItem()); + ItemStack aWood = sLogCache.get(registryName + ":" + uStack.getItemDamage()); + + if (aWood != null) { + this.heightModifier = 1.0f; + this.saplingsModifier = 1.0f; + this.girthModifier = 1; + + this.mSapling = uStack; + this.mWood = aWood; + return true; + } else { + if (registryName.equals("Forestry:sapling")) { + + ITree tree = TreeManager.treeRoot.getMember(uStack); + + this.heightModifier = Math.max(3 * (tree.getGenome().getHeight() - 1), 0) + 1; + this.saplingsModifier = Math.max(tree.getGenome().getFertility() * 20, 1); + this.girthModifier = tree.getGenome().getGirth(); + boolean fireproof = ((IAlleleBoolean) tree.getGenome() + .getChromosomes()[EnumTreeChromosome.FIREPROOF.ordinal()] + .getActiveAllele()) + .getValue(); + + aWood = sLogCache.get(tree.getIdent() + (fireproof ? "fireproof" : "")); + + this.mSapling = uStack; + this.mWood = aWood; + return true; + } + } + } + } + return false; + } + + public static void loadMapWoodFromSapling() { + + // galaxySpace + mapSaplingToLog( + "GalaxySpace:barnardaCsapling:1", + GT_ModHandler.getModItem("GalaxySpace", "barnardaClog", 1)); // barnarda c + + // minecraft + mapSaplingToLog("minecraft:sapling:0", new ItemStack(Blocks.log, 1, 0)); // oak + mapSaplingToLog("minecraft:sapling:1", new ItemStack(Blocks.log, 1, 1)); // spruce + mapSaplingToLog("minecraft:sapling:2", new ItemStack(Blocks.log, 1, 2)); // birch + mapSaplingToLog("minecraft:sapling:3", new ItemStack(Blocks.log, 1, 3)); // jungle + mapSaplingToLog("minecraft:sapling:4", new ItemStack(Blocks.log2, 1, 0)); // acacia + mapSaplingToLog("minecraft:sapling:5", new ItemStack(Blocks.log2, 1, 1)); // dark oak + + // ic2 + mapSaplingToLog("IC2:blockRubSapling:0", GT_ModHandler.getModItem("IC2", "blockRubWood", 1)); // rubber + + // natura + mapSaplingToLog("Natura:florasapling:0", GT_ModHandler.getModItem("Natura", "redwood", 1, 1)); // redwood + mapSaplingToLog("Natura:florasapling:1", GT_ModHandler.getModItem("Natura", "tree", 1, 0)); // eucalyptus + mapSaplingToLog("Natura:florasapling:2", GT_ModHandler.getModItem("Natura", "tree", 1, 3)); // hopseed + mapSaplingToLog("Natura:florasapling:3", GT_ModHandler.getModItem("Natura", "tree", 1, 1)); // sakura + mapSaplingToLog("Natura:florasapling:4", GT_ModHandler.getModItem("Natura", "tree", 1, 2)); // ghostwood + mapSaplingToLog("Natura:florasapling:5", GT_ModHandler.getModItem("Natura", "bloodwood", 1, 0)); // bloodwood + mapSaplingToLog("Natura:florasapling:6", GT_ModHandler.getModItem("Natura", "Dark Tree", 1, 0)); // darkwood + mapSaplingToLog("Natura:florasapling:7", GT_ModHandler.getModItem("Natura", "Dark Tree", 1, 1)); // fusewood + + mapSaplingToLog("Natura:Rare Sapling:0", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 0)); // maple + mapSaplingToLog("Natura:Rare Sapling:1", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 1)); // silverbell + mapSaplingToLog("Natura:Rare Sapling:2", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 2)); // amaranth + mapSaplingToLog("Natura:Rare Sapling:3", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 3)); // tigerwood + mapSaplingToLog("Natura:Rare Sapling:4", GT_ModHandler.getModItem("Natura", "willow", 1, 0)); // willow + + // BOP + mapSaplingToLog( + "BiomesOPlenty:colorizedSaplings:0", + GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 0)); // Sacred Oak + mapSaplingToLog( + "BiomesOPlenty:colorizedSaplings:1", + GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 2)); // Mangrove + mapSaplingToLog( + "BiomesOPlenty:colorizedSaplings:2", GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 3)); // Palm + mapSaplingToLog( + "BiomesOPlenty:colorizedSaplings:3", + GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 0)); // Redwood + mapSaplingToLog( + "BiomesOPlenty:colorizedSaplings:4", + GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 1)); // Willow + mapSaplingToLog( + "BiomesOPlenty:colorizedSaplings:5", GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 0)); // Pine + mapSaplingToLog( + "BiomesOPlenty:colorizedSaplings:6", + GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 3)); // Mahogany + mapSaplingToLog( + "BiomesOPlenty:saplings:2", GT_ModHandler.getModItem("BiomesOPlenty", "bamboo", 1, 0)); // Bamboo + mapSaplingToLog("BiomesOPlenty:saplings:3", GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 1)); // Magic + mapSaplingToLog("BiomesOPlenty:saplings:4", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 2)); // Dark + mapSaplingToLog( + "BiomesOPlenty:saplings:5", GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 2)); // Dying/Dead + mapSaplingToLog("BiomesOPlenty:saplings:6", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 3)); // Fir + mapSaplingToLog( + "BiomesOPlenty:saplings:7", GT_ModHandler.getModItem("BiomesOPlenty", "logs2", 1, 0)); // Ethereal + mapSaplingToLog( + "BiomesOPlenty:saplings:10", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 1)); // Pink Cherry + mapSaplingToLog( + "BiomesOPlenty:saplings:12", GT_ModHandler.getModItem("BiomesOPlenty", "logs1", 1, 1)); // White Cherry + mapSaplingToLog( + "BiomesOPlenty:saplings:13", GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 1)); // Hellbark + mapSaplingToLog( + "BiomesOPlenty:saplings:14", GT_ModHandler.getModItem("BiomesOPlenty", "logs4", 1, 2)); // Jacaranda + mapSaplingToLog( + "minecraft:yellow_flower:0", + GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 3)); // Giant Flower Stem + mapSaplingToLog( + "minecraft:red_flower:0", + GT_ModHandler.getModItem("BiomesOPlenty", "logs3", 1, 3)); // Giant Flower Stem + + // Witchery + mapSaplingToLog("witchery:witchsapling:0", GT_ModHandler.getModItem("witchery", "witchlog", 1, 0)); // Rowan + mapSaplingToLog("witchery:witchsapling:1", GT_ModHandler.getModItem("witchery", "witchlog", 1, 1)); // Alder + mapSaplingToLog("witchery:witchsapling:2", GT_ModHandler.getModItem("witchery", "witchlog", 1, 2)); // Hawthorn + + // TConstruct + mapSaplingToLog( + "TConstruct:slime.sapling:0", + GT_ModHandler.getModItem("TConstruct", "slime.gel", 1)); // green slime blocks + + // TaintedMagic + mapSaplingToLog( + "TaintedMagic:BlockWarpwoodSapling:0", + GT_ModHandler.getModItem("TaintedMagic", "BlockWarpwoodLog", 1)); // warpwood + + // Thaumcraft + mapSaplingToLog( + "Thaumcraft:blockCustomPlant:0", + GT_ModHandler.getModItem("Thaumcraft", "blockMagicalLog", 1, 0)); // greatwood + mapSaplingToLog( + "Thaumcraft:blockCustomPlant:1", + GT_ModHandler.getModItem("Thaumcraft", "blockMagicalLog", 1, 1)); // silverwood + + // gt++ + mapSaplingToLog( + "miscutils:blockRainforestOakSapling:0", + GT_ModHandler.getModItem("miscutils", "blockRainforestOakLog", 1)); // rainforest + mapSaplingToLog( + "miscutils:blockPineSapling:0", GT_ModHandler.getModItem("miscutils", "blockPineLogLog", 1)); // pine + + // Harvestcraft + mapSaplingToLog("harvestcraft:pampistachioSapling:0", new ItemStack(Blocks.log, 1, 3)); // Pistachio + mapSaplingToLog("harvestcraft:pampapayaSapling:0", new ItemStack(Blocks.log, 1, 3)); // Papaya + mapSaplingToLog( + "harvestcraft:pammapleSapling:0", GT_ModHandler.getModItem("harvestcraft", "pamMaple", 1)); // Maple + mapSaplingToLog("harvestcraft:pamappleSapling:0", new ItemStack(Blocks.log, 1, 0)); // Apple + mapSaplingToLog("harvestcraft:pamdateSapling:0", new ItemStack(Blocks.log, 1, 3)); // Date + mapSaplingToLog("harvestcraft:pamorangeSapling:0", new ItemStack(Blocks.log, 1, 3)); // Orange + mapSaplingToLog("harvestcraft:pamdragonfruitSapling:0", new ItemStack(Blocks.log, 1, 3)); // Dragon fruit + mapSaplingToLog("harvestcraft:pamnutmegSapling:0", new ItemStack(Blocks.log, 1, 0)); // NutMeg + mapSaplingToLog( + "harvestcraft:pampaperbarkSapling:0", + GT_ModHandler.getModItem("harvestcraft", "pamPaperbark", 1)); // Paperbark + mapSaplingToLog("harvestcraft:pammangoSapling:0", new ItemStack(Blocks.log, 1, 3)); // Mango + mapSaplingToLog("harvestcraft:pamavocadoSapling:0", new ItemStack(Blocks.log, 1, 0)); // Avocado + mapSaplingToLog("harvestcraft:pamchestnutSapling:0", new ItemStack(Blocks.log, 1, 0)); // Chestnut + mapSaplingToLog("harvestcraft:pampeppercornSapling:0", new ItemStack(Blocks.log, 1, 3)); // Peppercorn + mapSaplingToLog("harvestcraft:pampecanSapling:0", new ItemStack(Blocks.log, 1, 3)); // Pecan + mapSaplingToLog("harvestcraft:pamcashewSapling:0", new ItemStack(Blocks.log, 1, 3)); // Cashew + mapSaplingToLog("harvestcraft:pamfigSapling:0", new ItemStack(Blocks.log, 1, 3)); // Fig + mapSaplingToLog("harvestcraft:pamoliveSapling:0", new ItemStack(Blocks.log, 1, 3)); // Olive + mapSaplingToLog( + "harvestcraft:pamcinnamonSapling:0", + GT_ModHandler.getModItem("harvestcraft", "pamCinnamon", 1)); // Cinnamon + mapSaplingToLog("harvestcraft:pampeachSapling:0", new ItemStack(Blocks.log, 1, 3)); // Peach + mapSaplingToLog("harvestcraft:pamlemonSapling:0", new ItemStack(Blocks.log, 1, 3)); // Lemon + mapSaplingToLog("harvestcraft:pamvanillabeanSapling:0", new ItemStack(Blocks.log, 1, 3)); // Vanilla + mapSaplingToLog("harvestcraft:pamalmondSapling:0", new ItemStack(Blocks.log, 1, 3)); // Almond + mapSaplingToLog("harvestcraft:pambananaSapling:0", new ItemStack(Blocks.log, 1, 3)); // Banana + mapSaplingToLog("harvestcraft:pamdurianSapling:0", new ItemStack(Blocks.log, 1, 3)); // Durian + mapSaplingToLog("harvestcraft:pamplumSapling:0", new ItemStack(Blocks.log, 1, 0)); // Plum + mapSaplingToLog("harvestcraft:pamlimeSapling:0", new ItemStack(Blocks.log, 1, 3)); // Lime + mapSaplingToLog("harvestcraft:pampearSapling:0", new ItemStack(Blocks.log, 1, 0)); // Pear + mapSaplingToLog("harvestcraft:pamgooseberrySapling:0", new ItemStack(Blocks.log, 1, 0)); // Gooseberry + mapSaplingToLog("harvestcraft:pamcherrySapling:0", new ItemStack(Blocks.log, 1, 0)); // Cherry + mapSaplingToLog("harvestcraft:pampomegranateSapling:0", new ItemStack(Blocks.log, 1, 3)); // Pomegranate + mapSaplingToLog("harvestcraft:pamwalnutSapling:0", new ItemStack(Blocks.log, 1, 0)); // Walnut + mapSaplingToLog("harvestcraft:pampersimmonSapling:0", new ItemStack(Blocks.log, 1, 3)); // Persimmon + mapSaplingToLog("harvestcraft:pamapricotSapling:0", new ItemStack(Blocks.log, 1, 3)); // Apricot + mapSaplingToLog("harvestcraft:pamcoconutSapling:0", new ItemStack(Blocks.log, 1, 3)); // Coconut + mapSaplingToLog("harvestcraft:pamgrapefruitSapling:0", new ItemStack(Blocks.log, 1, 3)); // Grapefruit + mapSaplingToLog("harvestcraft:pamstarfruitSapling:0", new ItemStack(Blocks.log, 1, 3)); // Starfruit + + // Harvest The Nether + mapSaplingToLog( + "harvestthenether:netherSapling:0", + GT_ModHandler.getModItem("harvestthenether", "netherLog", 1)); // Nether + + // The Twilight Forest + mapSaplingToLog( + "TwilightForest:tile.TFSapling:0", + GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 0)); // Sickly Twilight Oak + mapSaplingToLog( + "TwilightForest:tile.TFSapling:1", + GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 1)); // Canopy Tree + mapSaplingToLog( + "TwilightForest:tile.TFSapling:2", + GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 2)); // Twilight Mangrove + mapSaplingToLog( + "TwilightForest:tile.TFSapling:3", + GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 3)); // Darkwood + mapSaplingToLog( + "TwilightForest:tile.TFSapling:4", + GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 0)); // Robust Twilight Oad + mapSaplingToLog( + "TwilightForest:tile.TFSapling:5", + GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 0)); // Tree of Time + mapSaplingToLog( + "TwilightForest:tile.TFSapling:6", + GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 1)); // Tree of Trasformation + mapSaplingToLog( + "TwilightForest:tile.TFSapling:7", + GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 2)); // Miner's Tree + mapSaplingToLog( + "TwilightForest:tile.TFSapling:8", + GT_ModHandler.getModItem("TwilightForest", "tile.TFMagicLog", 1, 3)); // Sorting Tree + mapSaplingToLog( + "TwilightForest:tile.TFSapling:9", + GT_ModHandler.getModItem("TwilightForest", "tile.TFLog", 1, 0)); // Rainbow Oak + + // Thaumic Bases + mapSaplingToLog("thaumicbases:goldenOakSapling:0", new ItemStack(Blocks.log, 1, 0)); // Golden Oak + mapSaplingToLog( + "thaumicbases:goldenOakSapling:1", + GT_ModHandler.getModItem("thaumicbases", "genLogs", 1, 0)); // Peaceful + mapSaplingToLog( + "thaumicbases:goldenOakSapling:2", GT_ModHandler.getModItem("thaumicbases", "genLogs", 1, 1)); // Nether + mapSaplingToLog( + "thaumicbases:goldenOakSapling:3", GT_ModHandler.getModItem("thaumicbases", "genLogs", 1, 2)); // Ender + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + public static void mapSaplingToLog(String aSapling, ItemStack aLog) { + ItemStack aSaplingStack = ItemUtils.getItemStackFromFQRN(aSapling, 1); + if (aSaplingStack != null && aLog != null) { + sLogCache.put(aSapling, aLog); + addFakeRecipeToNEI(aSaplingStack, aLog); + } else { + Logger.INFO("Unable to add Tree Growth Simulation for " + aSapling); + } + } + + private static int sRecipeID = 0; + + public static boolean addFakeRecipeToNEI(@Nonnull ItemStack aSapling, ItemStack aLog) { + int aRecipes = GTPP_Recipe_Map.sTreeSimFakeRecipes.mRecipeList.size(); + Logger.INFO("Adding Tree Growth Simulation for " + aSapling.getDisplayName() + " -> " + + (aLog == null ? "NULL" : aLog.getDisplayName())); + ItemStack[] aOutput = new ItemStack[] {aLog, aSapling}; + String aOutputs = ItemUtils.getArrayStackNames(aOutput); + Logger.INFO("" + aOutputs); + GTPP_Recipe_Map.sTreeSimFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {aSapling.copy()}, + aOutput, + null, + new int[] {10000, 1000}, + new FluidStack[] {FluidUtils.getFluidStack(ModItems.fluidFertBasic, 1)}, + new FluidStack[] {}, + 1, + sRecipeID++, + 0); + return GTPP_Recipe_Map.sTreeSimFakeRecipes.mRecipeList.size() > aRecipes; + } + + public int hasLiquidFert() { + ArrayList aFluids = this.getStoredFluids(); + for (FluidStack aFluid : aFluids) { + if (aFluid.getFluid().equals(ModItems.fluidFertBasic)) { + return aFluid.amount; + } + } + return 0; + } + + public boolean tryConsumeLiquidFert(int aFluidAmount) { + return this.depleteInput(FluidUtils.getFluidStack(ModItems.fluidFertBasic, aFluidAmount)); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java index 8c986db704..6781f130b2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -1,7 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -24,6 +27,8 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -32,42 +37,36 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; +public class GregtechMetaTileEntity_AlloyBlastSmelter + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_AlloyBlastSmelter extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mMode = 0; - private boolean isUsingControllerCircuit = false; - private boolean isBussesSeparate = false; - private static Item circuit; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - + private int mMode = 0; + private boolean isUsingControllerCircuit = false; + private boolean isBussesSeparate = false; + private static Item circuit; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; - public GregtechMetaTileEntity_AlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } + public GregtechMetaTileEntity_AlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } - public GregtechMetaTileEntity_AlloyBlastSmelter(final String aName) { - super(aName); - } + public GregtechMetaTileEntity_AlloyBlastSmelter(final String aName) { + super(aName); + } - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); - } + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); + } - @Override - public String getMachineType() { - return "Fluid Alloy Cooker"; - } + @Override + public String getMachineType() { + return "Fluid Alloy Cooker"; + } - @Override + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setBoolean("isBussesSeparate", isBussesSeparate); @@ -79,278 +78,280 @@ public class GregtechMetaTileEntity_AlloyBlastSmelter extends GregtechMeta_Multi isBussesSeparate = aNBT.getBoolean("isBussesSeparate"); } - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Alloy Blast Smelter") - .addInfo("20% Faster than the Electric Blast Furnace") - .addInfo("Allows Complex GT++ alloys to be created") - .addInfo("Accepts only one Energy Hatch") - .addInfo("Circuit for recipe goes in the Input Bus or GUI slot") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 4, 3, true) - .addController("Bottom Center") - .addCasingInfo("Blast Smelter Casings", 10) - .addCasingInfo("Blast Smelter Heat Containment Coils", 16) - .addInputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"HHH", "H-H", "HHH"}, - {"HHH", "H-H", "HHH"}, - {"C~C", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_AlloyBlastSmelter.class) - .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(15)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 15))) - ) - .addElement( - 'H', - ofBlock( - ModBlocks.blockCasingsMisc, 14 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 3, 0) && mCasing >= 10 && mEnergyHatches.size() == 1 && checkHatch(); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(208)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(15); - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "ElectricBlastFurnace"; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - if (this.getBaseMetaTileEntity().isServerSide()) { - //Get Controller Circuit - if (circuit == null) { - circuit = CI.getNumberedCircuit(0).getItem(); - } - if (aStack != null && aStack.getItem() == circuit) { - this.mMode = aStack.getItemDamage(); - return this.isUsingControllerCircuit = true; - } - else { - if (aStack == null) { - this.isUsingControllerCircuit = false; - return true; //Allowed empty - } - Logger.WARNING("Not circuit in GUI inputs."); - return this.isUsingControllerCircuit = false; - } - } - Logger.WARNING("No Circuit, clientside."); - return this.isUsingControllerCircuit = false; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - - if (this.getBaseMetaTileEntity().isServerSide()) { - - ArrayList tInputList = null; - //Get Controller Circuit - this.isUsingControllerCircuit = isCorrectMachinePart(aStack); - - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - ItemStack[] tInputs = null; - final FluidStack[] tFluids = getCompactedFluids(); - GT_Recipe tRecipe = null; - - if (isBussesSeparate) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - tInputList = new ArrayList<>(); - tBus.mRecipeMap = getRecipeMap(); - - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tInputList.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - tInputs = tInputList.toArray(new ItemStack[0]); - tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if ((tRecipe != null)) { - break; - } - } - } else { - tInputList = this.getStoredInputs(); - for (int i = 0; i < (tInputList.size() - 1); i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - tInputs = tInputList.toArray(new ItemStack[0]); - tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - } - - //Validity check - if ((isUsingControllerCircuit && tInputList.size() < 1) || (!isUsingControllerCircuit && tInputList.size() < 2)) { - Logger.WARNING("Not enough inputs."); - return false; - } - else if (isUsingControllerCircuit && tInputList.size() >= 1) { - tInputList.add(CI.getNumberedCircuit(this.mMode)); - } - - if (tInputList.size() > 1) { - if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - Logger.WARNING("Found some Valid Inputs."); - this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; - List tOutPutItems = new ArrayList(); - for (ItemStack tOut : tRecipe.mOutputs) { - if (ItemUtils.checkForInvalidItems(tOut)) { - tOutPutItems.add(tOut); - } - } - if (tOutPutItems.size() > 0) - this.mOutputItems = tOutPutItems.toArray(new ItemStack[tOutPutItems.size()]); - this.updateSlots(); - return true; - } - } - } - Logger.WARNING("Failed to find some Valid Inputs or Clientside."); - return false; - } - - @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - isBussesSeparate = !isBussesSeparate; - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + isBussesSeparate); + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Alloy Blast Smelter") + .addInfo("20% Faster than the Electric Blast Furnace") + .addInfo("Allows Complex GT++ alloys to be created") + .addInfo("Accepts only one Energy Hatch") + .addInfo("Circuit for recipe goes in the Input Bus or GUI slot") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Bottom Center") + .addCasingInfo("Blast Smelter Casings", 10) + .addCasingInfo("Blast Smelter Heat Containment Coils", 16) + .addInputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_AlloyBlastSmelter.class) + .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(15)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 15)))) + .addElement('H', ofBlock(ModBlocks.blockCasingsMisc, 14)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 3, 0) && mCasing >= 10 && mEnergyHatches.size() == 1 && checkHatch(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(208)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(15); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + if (this.getBaseMetaTileEntity().isServerSide()) { + // Get Controller Circuit + if (circuit == null) { + circuit = CI.getNumberedCircuit(0).getItem(); + } + if (aStack != null && aStack.getItem() == circuit) { + this.mMode = aStack.getItemDamage(); + return this.isUsingControllerCircuit = true; + } else { + if (aStack == null) { + this.isUsingControllerCircuit = false; + return true; // Allowed empty + } + Logger.WARNING("Not circuit in GUI inputs."); + return this.isUsingControllerCircuit = false; + } + } + Logger.WARNING("No Circuit, clientside."); + return this.isUsingControllerCircuit = false; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + + if (this.getBaseMetaTileEntity().isServerSide()) { + + ArrayList tInputList = null; + // Get Controller Circuit + this.isUsingControllerCircuit = isCorrectMachinePart(aStack); + + final long tVoltage = this.getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + ItemStack[] tInputs = null; + final FluidStack[] tFluids = getCompactedFluids(); + GT_Recipe tRecipe = null; + + if (isBussesSeparate) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + tInputList = new ArrayList<>(); + tBus.mRecipeMap = getRecipeMap(); + + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { + tInputList.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + tInputs = tInputList.toArray(new ItemStack[0]); + tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe( + this.getBaseMetaTileEntity(), + false, + gregtech.api.enums.GT_Values.V[tTier], + tFluids, + tInputs); + if ((tRecipe != null)) { + break; + } + } + } else { + tInputList = this.getStoredInputs(); + for (int i = 0; i < (tInputList.size() - 1); i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + tInputs = tInputList.toArray(new ItemStack[0]); + tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe( + this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + } + + // Validity check + if ((isUsingControllerCircuit && tInputList.size() < 1) + || (!isUsingControllerCircuit && tInputList.size() < 2)) { + Logger.WARNING("Not enough inputs."); + return false; + } else if (isUsingControllerCircuit && tInputList.size() >= 1) { + tInputList.add(CI.getNumberedCircuit(this.mMode)); + } + + if (tInputList.size() > 1) { + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + Logger.WARNING("Found some Valid Inputs."); + this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)}; + List tOutPutItems = new ArrayList(); + for (ItemStack tOut : tRecipe.mOutputs) { + if (ItemUtils.checkForInvalidItems(tOut)) { + tOutPutItems.add(tOut); + } + } + if (tOutPutItems.size() > 0) + this.mOutputItems = tOutPutItems.toArray(new ItemStack[tOutPutItems.size()]); + this.updateSlots(); + return true; + } + } + } + Logger.WARNING("Failed to find some Valid Inputs or Clientside."); + return false; + } + + @Override + public boolean onWireCutterRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + isBussesSeparate = !isBussesSeparate; + GT_Utility.sendChatToPlayer( + aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + isBussesSeparate); return true; } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiABS; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiABS; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java index 84553fb02c..ec90d8d71d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -1,6 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -22,6 +26,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -29,435 +34,411 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Cyclotron(int aID, String aName, String aNameRegional, int tier) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Cyclotron(String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Particle Accelerator"; - } - - public int tier(){ - return 5; - } - - @Override - public long maxEUStore() { - return 1800000000L; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); - //return new CONTAINER_Cyclotron(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return super.getClientGUI(aID, aPlayerInventory, aBaseMetaTileEntity); - //return new GUI_Cyclotron(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), Recipe_GT.Gregtech_Recipe_Map.sCyclotronRecipes.mNEIName); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Cyclotron(this.mName); - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return aSide != getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - { - " ", - " hhh ", - " hh hh ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " hh hh ", - " hhh ", - " ", - }, - { - " hhh ", - " hhccchh ", - " hcchhhcch ", - " hchh hhch ", - " hch hch ", - " hch hch ", - "hch hch", - "hch hch", - "hch hch", - " hch hch ", - " hch hch ", - " hchh hhch ", - " hcch~hcch ", - " hhccchh ", - " hhh ", - }, - { - " ", - " hhh ", - " hh hh ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " h h ", - " hh hh ", - " hhh ", - " ", - } - })) - .addElement( - 'h', - buildHatchAdder(GregtechMetaTileEntity_Cyclotron.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(44) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))) - ) - .addElement( - 'c', - ofBlock( - getCyclotronCoil(), getCyclotronCoilMeta() - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 7, 1, 12); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 7, 1, 12, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 7, 1, 12) && mCasing >= 40 && checkHatch(); - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - public int getCasingMeta() { - return 10; - } - - public Block getCyclotronCoil() { - return ModBlocks.blockCasings2Misc; - } - - public int getCyclotronCoilMeta() { - return 9; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Super Magnetic Speed Shooter") - .addSeparator() - .addInfo("Particles are accelerated over 186 revolutions to 80% light speed") - .addInfo("Can produce a continuous beam current of 2.2 mA at 590 MeV") - .addInfo("Which will be extracted from the Isochronous Cyclotron") - .addSeparator() - .addInfo("Consists of the same layout as a Fusion Reactor") - .addInfo("Any external casing can be a hatch/bus, unlike Fusion") - .addInfo("Cyclotron Machine Casings around Cyclotron Coil Blocks") - .addInfo("All Hatches must be IV or better") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addCasingInfo("Cyclotron Machine Casings", 40) - .addCasingInfo("Cyclotron Coil", 32) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return getIconOverlay(); - } - - @Override - protected IIconContainer getInactiveOverlay() { - return getIconOverlay(); - } - - @Override - protected int getCasingTextureId() { - return 44; - } - - public IIconContainer getIconOverlay() { - if (this.getBaseMetaTileEntity().isActive()){ - return TexturesGtBlock.Overlay_MatterFab_Active_Animated; - } - return TexturesGtBlock.Overlay_MatterFab_Animated; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - - /*if (CORE.DEVENV) { - return this.checkRecipeGeneric(); - }*/ - this.fixAllMaintenanceIssue(); - - //log("Recipe Check."); - ArrayList tItemList = getStoredInputs(); - ItemStack[] tItemInputs = tItemList.toArray(new ItemStack[tItemList.size()]); - ArrayList tInputList = getStoredFluids(); - FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[tInputList.size()]); - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.findRecipe(getBaseMetaTileEntity(), false, - gregtech.api.enums.GT_Values.V[tTier], tFluidInputs, tItemInputs); - if (tRecipe != null){ - if (tRecipe.isRecipeInputEqual(true, tFluidInputs, tItemInputs)) { - - this.mEfficiency = (10000 - ((getIdealStatus() - getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - final ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; - for (int i = 0; i < tRecipe.mOutputs.length; i++){ - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)){ - Logger.WARNING("Adding a bonus output"); - outputs[i] = tRecipe.getOutput(i); - } - else { - Logger.WARNING("Adding null output"); - outputs[i] = null; - } - } - - for (ItemStack s : outputs) { - if (s != null) { - if (s.getItem() instanceof IonParticles) { - long aCharge = IonParticles.getChargeState(s); - if (aCharge == 0) { - IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] { - -5, -5, - -4, -4, -4, - -3, -3, -3, -3, -3, - -2, -2, -2, -2, -2, -2, -2, - -1, -1, -1, -1, -1, -1, -1, -1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, - 5, 5, 5, - 6, 6})); - } - } - } - } - - this.mOutputItems = outputs; - this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)}; - this.updateSlots(); - return true; - } - } - return false; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - if (this.mOutputBusses.size() > 0) { - for (GT_MetaTileEntity_Hatch_OutputBus g : this.mOutputBusses) { - if (g != null) { - for (ItemStack s : g.mInventory) { - if (s != null) { - if (s.getItem() instanceof IonParticles) { - long aCharge = IonParticles.getChargeState(s); - if (aCharge == 0) { - IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] { - -5, -5, - -4, -4, -4, - -3, -3, -3, -3, -3, - -2, -2, -2, -2, -2, -2, -2, - -1, -1, -1, -1, -1, -1, -1, -1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, - 5, 5, 5, - 6, 6})); - } - } - } - } - } - } - } - this.fixAllMaintenanceIssue(); - return super.onRunningTick(aStack); - } - - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiCyclotron; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public String[] getExtraInfoData() { - String tier = tier() == 5 ? "I" : "II"; - float plasmaOut = 0; - int powerRequired = 0; - if (this.mLastRecipe != null) { - powerRequired = this.mLastRecipe.mEUt; - if (this.mLastRecipe.getFluidOutput(0) != null) { - plasmaOut = (float)this.mLastRecipe.getFluidOutput(0).amount / (float)this.mLastRecipe.mDuration; - } - } - - return new String[]{ - "COMET - Compact Cyclotron MK "+tier, - "EU Required: "+powerRequired+"EU/t", - "Stored EU: "+this.getEUVar()+" / "+maxEUStore()}; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @SuppressWarnings("deprecation") - public boolean turnCasingActive(final boolean status) { - if (this.mEnergyHatches != null) { - for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { - hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; - } - } - if (this.mOutputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { - hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; - } - } - if (this.mInputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { - hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; - } - } - if (this.mMaintenanceHatches != null) { - for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { - hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; - } - } - return true; - } -} \ No newline at end of file +public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Cyclotron(int aID, String aName, String aNameRegional, int tier) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_Cyclotron(String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Particle Accelerator"; + } + + public int tier() { + return 5; + } + + @Override + public long maxEUStore() { + return 1800000000L; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + // return new CONTAINER_Cyclotron(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return super.getClientGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + // return new GUI_Cyclotron(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), + // Recipe_GT.Gregtech_Recipe_Map.sCyclotronRecipes.mNEIName); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Cyclotron(this.mName); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + { + " ", + " hhh ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " hhh ", + " ", + }, + { + " hhh ", + " hhccchh ", + " hcchhhcch ", + " hchh hhch ", + " hch hch ", + " hch hch ", + "hch hch", + "hch hch", + "hch hch", + " hch hch ", + " hch hch ", + " hchh hhch ", + " hcch~hcch ", + " hhccchh ", + " hhh ", + }, + { + " ", + " hhh ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " hhh ", + " ", + } + })) + .addElement( + 'h', + buildHatchAdder(GregtechMetaTileEntity_Cyclotron.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(44) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('c', ofBlock(getCyclotronCoil(), getCyclotronCoilMeta())) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 7, 1, 12); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 7, 1, 12, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 7, 1, 12) && mCasing >= 40 && checkHatch(); + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public int getCasingMeta() { + return 10; + } + + public Block getCyclotronCoil() { + return ModBlocks.blockCasings2Misc; + } + + public int getCyclotronCoilMeta() { + return 9; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Super Magnetic Speed Shooter") + .addSeparator() + .addInfo("Particles are accelerated over 186 revolutions to 80% light speed") + .addInfo("Can produce a continuous beam current of 2.2 mA at 590 MeV") + .addInfo("Which will be extracted from the Isochronous Cyclotron") + .addSeparator() + .addInfo("Consists of the same layout as a Fusion Reactor") + .addInfo("Any external casing can be a hatch/bus, unlike Fusion") + .addInfo("Cyclotron Machine Casings around Cyclotron Coil Blocks") + .addInfo("All Hatches must be IV or better") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addCasingInfo("Cyclotron Machine Casings", 40) + .addCasingInfo("Cyclotron Coil", 32) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return getIconOverlay(); + } + + @Override + protected IIconContainer getInactiveOverlay() { + return getIconOverlay(); + } + + @Override + protected int getCasingTextureId() { + return 44; + } + + public IIconContainer getIconOverlay() { + if (this.getBaseMetaTileEntity().isActive()) { + return TexturesGtBlock.Overlay_MatterFab_Active_Animated; + } + return TexturesGtBlock.Overlay_MatterFab_Animated; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + + /*if (CORE.DEVENV) { + return this.checkRecipeGeneric(); + }*/ + this.fixAllMaintenanceIssue(); + + // log("Recipe Check."); + ArrayList tItemList = getStoredInputs(); + ItemStack[] tItemInputs = tItemList.toArray(new ItemStack[tItemList.size()]); + ArrayList tInputList = getStoredFluids(); + FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[tInputList.size()]); + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.findRecipe( + getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluidInputs, tItemInputs); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, tFluidInputs, tItemInputs)) { + + this.mEfficiency = (10000 - ((getIdealStatus() - getRepairStatus()) * 1000)); + this.mEfficiencyIncrease = 10000; + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + final ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; + for (int i = 0; i < tRecipe.mOutputs.length; i++) { + if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) { + Logger.WARNING("Adding a bonus output"); + outputs[i] = tRecipe.getOutput(i); + } else { + Logger.WARNING("Adding null output"); + outputs[i] = null; + } + } + + for (ItemStack s : outputs) { + if (s != null) { + if (s.getItem() instanceof IonParticles) { + long aCharge = IonParticles.getChargeState(s); + if (aCharge == 0) { + IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] { + -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, + -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6 + })); + } + } + } + } + + this.mOutputItems = outputs; + this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)}; + this.updateSlots(); + return true; + } + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mOutputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_OutputBus g : this.mOutputBusses) { + if (g != null) { + for (ItemStack s : g.mInventory) { + if (s != null) { + if (s.getItem() instanceof IonParticles) { + long aCharge = IonParticles.getChargeState(s); + if (aCharge == 0) { + IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] { + -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, + -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6 + })); + } + } + } + } + } + } + } + this.fixAllMaintenanceIssue(); + return super.onRunningTick(aStack); + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiCyclotron; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String[] getExtraInfoData() { + String tier = tier() == 5 ? "I" : "II"; + float plasmaOut = 0; + int powerRequired = 0; + if (this.mLastRecipe != null) { + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { + "COMET - Compact Cyclotron MK " + tier, + "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore() + }; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @SuppressWarnings("deprecation") + public boolean turnCasingActive(final boolean status) { + if (this.mEnergyHatches != null) { + for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + if (this.mOutputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + if (this.mInputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + if (this.mMaintenanceHatches != null) { + for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java index d8ccaf13ef..5d817d587e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -1,8 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -26,6 +29,9 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import ic2.core.init.BlocksItems; import ic2.core.init.InternalName; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; @@ -35,578 +41,601 @@ import net.minecraft.util.WeightedRandomFishable; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_IndustrialFishingPond extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private boolean isUsingControllerCircuit = false; - private static final Item circuit = CI.getNumberedCircuit(0).getItem(); - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - private static final Class cofhWater; - - static { - cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); - } - - public GregtechMetaTileEntity_IndustrialFishingPond(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialFishingPond(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialFishingPond(this.mName); - } - - @Override - public String getMachineType() { - return "Fish Trap"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Fishing Pond") - .addInfo("Can process (Tier + 1) * 2 recipes") - .addInfo("Put a numbered circuit into the input bus.") - .addInfo("Circuit 14 for Fish") - .addInfo("Circuit 15 for Junk") - .addInfo("Circuit 16 for Treasure") - .addInfo("Need to be filled with water.") - .addInfo("Will automatically fill water from input hatch.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(9, 3, 9, true) - .addController("Front Center") - .addCasingInfo("Aquatic Casings", 64) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // fuck - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, - {"XXXX~XXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, - {"XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX"}, - })) - .addElement( - 'X', - buildHatchAdder(GregtechMetaTileEntity_IndustrialFishingPond.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 4, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 4, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 4, 1, 0) && mCasing >= 64 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - if (aStack != null) { - log("Found " + aStack.getDisplayName()); - if (aStack.getItem() == circuit) { - this.isUsingControllerCircuit = true; - this.mMode = aStack.getItemDamage(); - log("Found Circuit!"); - } else { - this.isUsingControllerCircuit = false; - } - } else { - this.isUsingControllerCircuit = false; - } - if (!hasGenerateRecipes) { - log("Generating Recipes."); - generateRecipes(); - } - if (hasGenerateRecipes) { - if (!checkForWater()) { - return false; - } - - log("Trying to run recipe."); - ArrayList tItems = getStoredInputs(); - ArrayList tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - - if (!isUsingControllerCircuit && tItems.size() == 0) { - return false; - } - - return checkRecipeGeneric(tItemInputs, tFluidInputs, getMaxParallelRecipes(), 100, 80, 100); - } - return true; - } - - @Override - public int getMaxParallelRecipes() { - return (2 * (GT_Utility.getTier(this.getMaxInputVoltage())+1)); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialFishingPond; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta() { - return 0; - } - - public int getCasingTextureIndex() { - return TAE.GTPP_INDEX(32); - } - - public boolean checkForWater() { - - // Get Facing direction - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - mCurrentDirectionX = 4; - mCurrentDirectionZ = 4; - - mOffsetX_Lower = -4; - mOffsetX_Upper = 4; - mOffsetZ_Lower = -4; - mOffsetZ_Upper = 4; - - // if (aBaseMetaTileEntity.fac) - - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX - * mCurrentDirectionX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ - * mCurrentDirectionZ; - - int tAmount = 0; - for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { - for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { - for (int h = 0; h < 2; h++) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (isNotStaticWater(tBlock, tMeta)) { - if (this.getStoredFluids() != null) { - for (FluidStack stored : this.getStoredFluids()) { - if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { - if (stored.amount >= 1000) { - // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); - stored.amount -= 1000; - Block fluidUsed = Blocks.water; - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getXCoord() + xDir + i, - aBaseMetaTileEntity.getYCoord() + h, - aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); - - } - } - } - } - } - tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { - ++tAmount; - // log("Found Water"); - } - } - } - } - - boolean isValidWater = tAmount >= 60; - if (isValidWater) { - log("Filled structure."); - } - else { - log("Did not fill structure."); - } - return isValidWater; - } - - private boolean isNotStaticWater(Block block, byte meta) { - return block == Blocks.air - || block == Blocks.flowing_water - || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) - || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); - } - - private static AutoMap> categories = new AutoMap>(); - private static AutoMap categoryFish = new AutoMap(); - private static AutoMap categoryJunk = new AutoMap(); - private static AutoMap categoryLoot = new AutoMap(); - private static boolean hasGenerateRecipes = false; - private int mMode = 14; - private int mMax = 8; - - private boolean generateRecipes() { - if (!hasGenerateRecipes) { - categories.put(categoryFish); - categories.put(categoryJunk); - categories.put(categoryLoot); - for (WeightedRandomFishable h : FishPondFakeRecipe.fish) { - categoryFish.put(h); - } - for (WeightedRandomFishable h : FishPondFakeRecipe.junk) { - categoryJunk.put(h); - } - for (WeightedRandomFishable h : FishPondFakeRecipe.treasure) { - categoryLoot.put(h); - } - hasGenerateRecipes = true; - return true; - } else { - return true; - } - } - - private int getCircuit(ItemStack[] t) { - if (!this.isUsingControllerCircuit) { - for (ItemStack j : t) { - if (j.getItem() == CI.getNumberedCircuit(0).getItem()) { - // Fish - if (j.getItemDamage() == 14) { - mMax = 8 + (this.getMaxParallelRecipes() - 2); - this.mMode = 14; - break; - } - // Junk - else if (j.getItemDamage() == 15) { - this.mMode = 15; - mMax = 4; - break; - } - // Loot - else if (j.getItemDamage() == 16) { - this.mMode = 16; - mMax = 4; - break; - } else { - this.mMode = 0; - mMax = 0; - break; - } - } else { - this.mMode = 0; - mMax = 0; - break; - } - } - } - return this.mMode; - } - - // reflection map - private static Map reflectiveFishMap = new HashMap(); - - private ItemStack reflectiveFish(WeightedRandomFishable y) { - if (reflectiveFishMap.containsKey(y)) { - return reflectiveFishMap.get(y); - } - ItemStack t; - try { - t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(y); - ItemStack k = ItemUtils.getSimpleStack(t, 1); - reflectiveFishMap.put(y, k); - return t; - } catch (IllegalArgumentException | IllegalAccessException e) { - } - return null; - } - - private ItemStack[] generateLoot(int mode) { - ItemStack[] mFishOutput = new ItemStack[this.mMax]; - if (this.mMode == 14) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) - for (WeightedRandomFishable g : categoryFish.values()) { - if (MathUtils.randInt(0, (65 - getMaxParallelRecipes())) <= 2) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else if (this.mMode == 15) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) - for (WeightedRandomFishable g : categoryJunk.values()) { - if (MathUtils.randInt(0, 100) <= 1) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else if (this.mMode == 16) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) - for (WeightedRandomFishable g : categoryLoot.values()) { - if (MathUtils.randInt(0, 1000) <= 2) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else { - mFishOutput = null; - } - return mFishOutput; - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - - - - //Control Core to control the Multiblocks behaviour. - int aControlCoreTier = getControlCoreTier(); - - //If no core, return false; - if (aControlCoreTier == 0 && CORE.ConfigSwitches.requireControlCores) { - log("Invalid/No Control Core"); - return false; - } - - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - //Check to see if Voltage Tier > Control Core Tier - if (tTier > aControlCoreTier && CORE.ConfigSwitches.requireControlCores) { - return false; - } - - // Based on the Processing Array. A bit overkill, but very flexible. - getCircuit(aItemInputs); - - /* - * GT_Recipe tRecipe = this.getRecipeMap().findRecipe( getBaseMetaTileEntity(), - * mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, - * aItemInputs); - */ - - ItemStack[] mFishOutput = generateLoot(this.mMode); - mFishOutput = removeNulls(mFishOutput); - GT_Recipe g = new GTPP_Recipe(true, new ItemStack[] {}, mFishOutput, null, new int[] {}, aFluidInputs, mOutputFluids, 200, 16, 0); - aMaxParallelRecipes = this.canBufferOutputs(g, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("No Space"); - return false; - } - - log("Mode: " + this.mMode + " | Is loot valid? " + (mFishOutput != null)); - - int jslot = 0; - for (ItemStack x : mFishOutput) { - if (x != null) { - log( - "Slot " + jslot + " in mFishOutput contains " + x.stackSize + "x " + x.getDisplayName() + "."); - } else { - log("Slot " + jslot + " in mFishOutput was null."); - } - jslot++; - } - - // EU discount - float tRecipeEUt = (8 * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(20 * tTimeFactor * 4); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - - //Only Overclock as high as the control circuit. - byte tTierOld = tTier; - tTier = CORE.ConfigSwitches.requireControlCores ? (byte) aControlCoreTier : tTierOld; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - - log("Recipe Step. [3]"); - // Collect output item types - ItemStack[] tOutputItems = mFishOutput; - - int rslot = 0; - tOutputItems = removeNulls(mFishOutput); - - for (ItemStack x : tOutputItems) { - if (x != null) { - log( - "rSlot " + rslot + " in mFishOutput contains " + x.stackSize + "x " + x.getDisplayName() + "."); - } else { - log("rSlot " + rslot + " in mFishOutput was null."); - } - rslot++; - } - - // Commit outputs - this.mOutputItems = tOutputItems; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - return true; - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_IndustrialFishingPond + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private boolean isUsingControllerCircuit = false; + private static final Item circuit = CI.getNumberedCircuit(0).getItem(); + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + private static final Class cofhWater; + + static { + cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); + } + + public GregtechMetaTileEntity_IndustrialFishingPond(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialFishingPond(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialFishingPond(this.mName); + } + + @Override + public String getMachineType() { + return "Fish Trap"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Fishing Pond") + .addInfo("Can process (Tier + 1) * 2 recipes") + .addInfo("Put a numbered circuit into the input bus.") + .addInfo("Circuit 14 for Fish") + .addInfo("Circuit 15 for Junk") + .addInfo("Circuit 16 for Treasure") + .addInfo("Need to be filled with water.") + .addInfo("Will automatically fill water from input hatch.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 3, 9, true) + .addController("Front Center") + .addCasingInfo("Aquatic Casings", 64) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // fuck + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + { + "XXXXXXXXX", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "XXXXXXXXX" + }, + { + "XXXX~XXXX", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "XXXXXXXXX" + }, + { + "XXXXXXXXX", + "XXXXXXXXX", + "XXXXXXXXX", + "XXXXXXXXX", + "XXXXXXXXX", + "XXXXXXXXX", + "XXXXXXXXX", + "XXXXXXXXX", + "XXXXXXXXX" + }, + })) + .addElement( + 'X', + buildHatchAdder(GregtechMetaTileEntity_IndustrialFishingPond.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 4, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 4, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 4, 1, 0) && mCasing >= 64 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureIndex(); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + if (aStack != null) { + log("Found " + aStack.getDisplayName()); + if (aStack.getItem() == circuit) { + this.isUsingControllerCircuit = true; + this.mMode = aStack.getItemDamage(); + log("Found Circuit!"); + } else { + this.isUsingControllerCircuit = false; + } + } else { + this.isUsingControllerCircuit = false; + } + if (!hasGenerateRecipes) { + log("Generating Recipes."); + generateRecipes(); + } + if (hasGenerateRecipes) { + if (!checkForWater()) { + return false; + } + + log("Trying to run recipe."); + ArrayList tItems = getStoredInputs(); + ArrayList tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + + if (!isUsingControllerCircuit && tItems.size() == 0) { + return false; + } + + return checkRecipeGeneric(tItemInputs, tFluidInputs, getMaxParallelRecipes(), 100, 80, 100); + } + return true; + } + + @Override + public int getMaxParallelRecipes() { + return (2 * (GT_Utility.getTier(this.getMaxInputVoltage()) + 1)); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialFishingPond; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public int getCasingTextureIndex() { + return TAE.GTPP_INDEX(32); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * mCurrentDirectionX; + final int zDir = + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (isNotStaticWater(tBlock, tMeta)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + fluidUsed); + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // log("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 60; + if (isValidWater) { + log("Filled structure."); + } else { + log("Did not fill structure."); + } + return isValidWater; + } + + private boolean isNotStaticWater(Block block, byte meta) { + return block == Blocks.air + || block == Blocks.flowing_water + || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) + || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); + } + + private static AutoMap> categories = new AutoMap>(); + private static AutoMap categoryFish = new AutoMap(); + private static AutoMap categoryJunk = new AutoMap(); + private static AutoMap categoryLoot = new AutoMap(); + private static boolean hasGenerateRecipes = false; + private int mMode = 14; + private int mMax = 8; + + private boolean generateRecipes() { + if (!hasGenerateRecipes) { + categories.put(categoryFish); + categories.put(categoryJunk); + categories.put(categoryLoot); + for (WeightedRandomFishable h : FishPondFakeRecipe.fish) { + categoryFish.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.junk) { + categoryJunk.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.treasure) { + categoryLoot.put(h); + } + hasGenerateRecipes = true; + return true; + } else { + return true; + } + } + + private int getCircuit(ItemStack[] t) { + if (!this.isUsingControllerCircuit) { + for (ItemStack j : t) { + if (j.getItem() == CI.getNumberedCircuit(0).getItem()) { + // Fish + if (j.getItemDamage() == 14) { + mMax = 8 + (this.getMaxParallelRecipes() - 2); + this.mMode = 14; + break; + } + // Junk + else if (j.getItemDamage() == 15) { + this.mMode = 15; + mMax = 4; + break; + } + // Loot + else if (j.getItemDamage() == 16) { + this.mMode = 16; + mMax = 4; + break; + } else { + this.mMode = 0; + mMax = 0; + break; + } + } else { + this.mMode = 0; + mMax = 0; + break; + } + } + } + return this.mMode; + } + + // reflection map + private static Map reflectiveFishMap = + new HashMap(); + + private ItemStack reflectiveFish(WeightedRandomFishable y) { + if (reflectiveFishMap.containsKey(y)) { + return reflectiveFishMap.get(y); + } + ItemStack t; + try { + t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b") + .get(y); + ItemStack k = ItemUtils.getSimpleStack(t, 1); + reflectiveFishMap.put(y, k); + return t; + } catch (IllegalArgumentException | IllegalAccessException e) { + } + return null; + } + + private ItemStack[] generateLoot(int mode) { + ItemStack[] mFishOutput = new ItemStack[this.mMax]; + if (this.mMode == 14) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryFish.values()) { + if (MathUtils.randInt(0, (65 - getMaxParallelRecipes())) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else if (this.mMode == 15) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryJunk.values()) { + if (MathUtils.randInt(0, 100) <= 1) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else if (this.mMode == 16) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryLoot.values()) { + if (MathUtils.randInt(0, 1000) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else { + mFishOutput = null; + } + return mFishOutput; + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + + // Control Core to control the Multiblocks behaviour. + int aControlCoreTier = getControlCoreTier(); + + // If no core, return false; + if (aControlCoreTier == 0 && CORE.ConfigSwitches.requireControlCores) { + log("Invalid/No Control Core"); + return false; + } + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + // Check to see if Voltage Tier > Control Core Tier + if (tTier > aControlCoreTier && CORE.ConfigSwitches.requireControlCores) { + return false; + } + + // Based on the Processing Array. A bit overkill, but very flexible. + getCircuit(aItemInputs); + + /* + * GT_Recipe tRecipe = this.getRecipeMap().findRecipe( getBaseMetaTileEntity(), + * mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, + * aItemInputs); + */ + + ItemStack[] mFishOutput = generateLoot(this.mMode); + mFishOutput = removeNulls(mFishOutput); + GT_Recipe g = new GTPP_Recipe( + true, new ItemStack[] {}, mFishOutput, null, new int[] {}, aFluidInputs, mOutputFluids, 200, 16, 0); + aMaxParallelRecipes = this.canBufferOutputs(g, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("No Space"); + return false; + } + + log("Mode: " + this.mMode + " | Is loot valid? " + (mFishOutput != null)); + + int jslot = 0; + for (ItemStack x : mFishOutput) { + if (x != null) { + log("Slot " + jslot + " in mFishOutput contains " + x.stackSize + "x " + x.getDisplayName() + "."); + } else { + log("Slot " + jslot + " in mFishOutput was null."); + } + jslot++; + } + + // EU discount + float tRecipeEUt = (8 * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (20 * tTimeFactor * 4); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Only Overclock as high as the control circuit. + byte tTierOld = tTier; + tTier = CORE.ConfigSwitches.requireControlCores ? (byte) aControlCoreTier : tTierOld; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + log("Recipe Step. [3]"); + // Collect output item types + ItemStack[] tOutputItems = mFishOutput; + + int rslot = 0; + tOutputItems = removeNulls(mFishOutput); + + for (ItemStack x : tOutputItems) { + if (x != null) { + log("rSlot " + rslot + " in mFishOutput contains " + x.stackSize + "x " + x.getDisplayName() + "."); + } else { + log("rSlot " + rslot + " in mFishOutput was null."); + } + rslot++; + } + + // Commit outputs + this.mOutputItems = tOutputItems; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java index ef30eacc5b..4ea9075ee5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java @@ -1,8 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -24,6 +29,9 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -31,501 +39,489 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.enums.GT_Values.E; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - - public GregtechMetaTileEntity_IndustrialRockBreaker(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialRockBreaker(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialRockBreaker(this.mName); - } - - @Override - public String getMachineType() { - return "Rock Breaker"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Rock Breaker") - .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 8") - .addInfo("Circuit goes in the GUI slot") - .addInfo("1 = cobble, 2 = stone, 3 = obsidian") - .addInfo("Supply Water/Lava") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 4, 3, true) - .addController("Bottom Center") - .addCasingInfo("Thermal Processing Casing", 9) - .addCasingInfo("Thermal Containment Casing", 16) - .addInputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCC", "CCC", "CCC"}, - {"HHH", "H-H", "HHH"}, - {"HHH", "H-H", "HHH"}, - {"C~C", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialRockBreaker.class) - .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(16)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0))) - ) - .addElement( - 'H', - ofBlock( - ModBlocks.blockCasings2Misc, 11 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - boolean aCheckPiece = checkPiece(mName, 1, 3, 0); - boolean aCasingCount = mCasing >= 9; - boolean aCheckHatch = checkHatch(); - log(""+aCheckPiece+", "+aCasingCount+", "+aCheckHatch); - return aCheckPiece && aCasingCount && aCheckHatch; - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(208); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(16); - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public boolean requiresVanillaGtGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return "ElectricBlastFurnace"; - } - - private static final GT_Recipe_Map sFakeRecipeMap = new GT_Recipe_Map(new HashSet<>(0), "gt.recipe.fakerockbreaker", "Rock Breaker", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 0, 0, 1, E, 1, E, true, false); - - private static void generateRecipeMap() { - if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { - generateRecipes(); - } - FluidStack[] aInputFluids = new FluidStack[] {FluidUtils.getWater(1000), FluidUtils.getLava(1000)}; - GT_Recipe aTemp = sRecipe_Cobblestone.copy(); - aTemp.mFluidInputs = aInputFluids; - sFakeRecipeMap.add(aTemp); - aTemp = sRecipe_SmoothStone.copy(); - aTemp.mFluidInputs = aInputFluids; - sFakeRecipeMap.add(aTemp); - aTemp = sRecipe_Redstone.copy(); - aTemp.mFluidInputs = aInputFluids; - sFakeRecipeMap.add(aTemp); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - if (sFakeRecipeMap.mRecipeList.isEmpty()) { - generateRecipeMap(); - } - return sFakeRecipeMap; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - private static GT_Recipe sRecipe_Cobblestone; - private static GT_Recipe sRecipe_SmoothStone; - private static GT_Recipe sRecipe_Redstone; - - private static final void generateRecipes() { - sRecipe_Cobblestone = new GTPP_Recipe( - false, - new ItemStack[] { - CI.getNumberedCircuit(1) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(Blocks.cobblestone) - }, - null, - new int[] {10000}, - null, - null, - 16, - 32, - 0); - sRecipe_SmoothStone = new GTPP_Recipe( - false, - new ItemStack[] { - CI.getNumberedCircuit(2) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(Blocks.stone) - }, - null, - new int[] {10000}, - null, - null, - 16, - 32, - 0); - sRecipe_Redstone = new GTPP_Recipe( - false, - new ItemStack[] { - CI.getNumberedCircuit(3), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(Blocks.obsidian) - }, - null, - new int[] {10000}, - null, - null, - 128, - 32, - 0); - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - ArrayList aFluids = this.getStoredFluids(); - if (!aFluids.isEmpty()) { - boolean aHasWater = false; - boolean aHasLava = false; - for (FluidStack aFluid : aFluids) { - if (aFluid.getFluid() == FluidRegistry.WATER) { - aHasWater = true; - } - else if (aFluid.getFluid() == FluidRegistry.LAVA) { - aHasLava = true; - } - } - ArrayList aItems = this.getStoredInputs(); - boolean aHasRedstone = false; - if (!aItems.isEmpty()) { - for (ItemStack aItem : aItems) { - if (GT_Utility.areStacksEqual(aItem, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))) { - aHasRedstone = true; - break; - } - } - } - - if (!aHasWater || !aHasLava) { - log("BAD RETURN - 0-1"); - return false; - } - ItemStack aGuiCircuit = this.getGUIItemStack(); - if (aGuiCircuit == null || !ItemUtils.isControlCircuit(aGuiCircuit)) { - log("BAD RETURN - 0-2"); - return false; - } - - if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { - generateRecipes(); - } - - int aCircuit = aGuiCircuit.getItemDamage(); - - GT_Recipe tRecipe = null; - switch (aCircuit) { - case 1: - tRecipe = sRecipe_Cobblestone; - break; - case 2: - tRecipe = sRecipe_SmoothStone; - break; - case 3: - if (aHasRedstone) { - tRecipe = sRecipe_Redstone; - } - break; - } - - if (tRecipe == null) { - log("BAD RETURN - 0-3"); - return false; - } - - // Based on the Processing Array. A bit overkill, but very flexible. - ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); - FluidStack[] aFluidInputs = new FluidStack[] {}; - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - int aMaxParallelRecipes = getMaxParallelRecipes(); - int aEUPercent = getEuDiscountForParallelism(); - int aSpeedBonusPercent = 200; - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - - if (aItems.size() > 0 && aCircuit == 3) { - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!this.depleteInput(tRecipe.mInputs[1])) { - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - } - else if (aCircuit >= 1 && aCircuit <= 2) { - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - } - - log("Broke at "+parallelRecipes+"."); - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } - - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialRockBreaker; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public ArrayList getStoredInputs() { - ArrayList aInputs = super.getStoredInputs(); - if (this.hasSlotInGUI() && this.getGUIItemStack() != null) { - aInputs.add(this.getGUIItemStack()); - } - return aInputs; - } +public class GregtechMetaTileEntity_IndustrialRockBreaker + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialRockBreaker(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialRockBreaker(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialRockBreaker(this.mName); + } + + @Override + public String getMachineType() { + return "Rock Breaker"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Rock Breaker") + .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 8") + .addInfo("Circuit goes in the GUI slot") + .addInfo("1 = cobble, 2 = stone, 3 = obsidian") + .addInfo("Supply Water/Lava") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Bottom Center") + .addCasingInfo("Thermal Processing Casing", 9) + .addCasingInfo("Thermal Containment Casing", 16) + .addInputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_IndustrialRockBreaker.class) + .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(16)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)))) + .addElement('H', ofBlock(ModBlocks.blockCasings2Misc, 11)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + boolean aCheckPiece = checkPiece(mName, 1, 3, 0); + boolean aCasingCount = mCasing >= 9; + boolean aCheckHatch = checkHatch(); + log("" + aCheckPiece + ", " + aCasingCount + ", " + aCheckHatch); + return aCheckPiece && aCasingCount && aCheckHatch; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(208); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(16); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + private static final GT_Recipe_Map sFakeRecipeMap = new GT_Recipe_Map( + new HashSet<>(0), + "gt.recipe.fakerockbreaker", + "Rock Breaker", + "smelting", + RES_PATH_GUI + "basicmachines/E_Furnace", + 1, + 1, + 0, + 0, + 1, + E, + 1, + E, + true, + false); + + private static void generateRecipeMap() { + if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { + generateRecipes(); + } + FluidStack[] aInputFluids = new FluidStack[] {FluidUtils.getWater(1000), FluidUtils.getLava(1000)}; + GT_Recipe aTemp = sRecipe_Cobblestone.copy(); + aTemp.mFluidInputs = aInputFluids; + sFakeRecipeMap.add(aTemp); + aTemp = sRecipe_SmoothStone.copy(); + aTemp.mFluidInputs = aInputFluids; + sFakeRecipeMap.add(aTemp); + aTemp = sRecipe_Redstone.copy(); + aTemp.mFluidInputs = aInputFluids; + sFakeRecipeMap.add(aTemp); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (sFakeRecipeMap.mRecipeList.isEmpty()) { + generateRecipeMap(); + } + return sFakeRecipeMap; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + private static GT_Recipe sRecipe_Cobblestone; + private static GT_Recipe sRecipe_SmoothStone; + private static GT_Recipe sRecipe_Redstone; + + private static final void generateRecipes() { + sRecipe_Cobblestone = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(1)}, + new ItemStack[] {ItemUtils.getSimpleStack(Blocks.cobblestone)}, + null, + new int[] {10000}, + null, + null, + 16, + 32, + 0); + sRecipe_SmoothStone = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(2)}, + new ItemStack[] {ItemUtils.getSimpleStack(Blocks.stone)}, + null, + new int[] {10000}, + null, + null, + 16, + 32, + 0); + sRecipe_Redstone = new GTPP_Recipe( + false, + new ItemStack[] { + CI.getNumberedCircuit(3), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) + }, + new ItemStack[] {ItemUtils.getSimpleStack(Blocks.obsidian)}, + null, + new int[] {10000}, + null, + null, + 128, + 32, + 0); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + ArrayList aFluids = this.getStoredFluids(); + if (!aFluids.isEmpty()) { + boolean aHasWater = false; + boolean aHasLava = false; + for (FluidStack aFluid : aFluids) { + if (aFluid.getFluid() == FluidRegistry.WATER) { + aHasWater = true; + } else if (aFluid.getFluid() == FluidRegistry.LAVA) { + aHasLava = true; + } + } + ArrayList aItems = this.getStoredInputs(); + boolean aHasRedstone = false; + if (!aItems.isEmpty()) { + for (ItemStack aItem : aItems) { + if (GT_Utility.areStacksEqual( + aItem, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))) { + aHasRedstone = true; + break; + } + } + } + + if (!aHasWater || !aHasLava) { + log("BAD RETURN - 0-1"); + return false; + } + ItemStack aGuiCircuit = this.getGUIItemStack(); + if (aGuiCircuit == null || !ItemUtils.isControlCircuit(aGuiCircuit)) { + log("BAD RETURN - 0-2"); + return false; + } + + if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { + generateRecipes(); + } + + int aCircuit = aGuiCircuit.getItemDamage(); + + GT_Recipe tRecipe = null; + switch (aCircuit) { + case 1: + tRecipe = sRecipe_Cobblestone; + break; + case 2: + tRecipe = sRecipe_SmoothStone; + break; + case 3: + if (aHasRedstone) { + tRecipe = sRecipe_Redstone; + } + break; + } + + if (tRecipe == null) { + log("BAD RETURN - 0-3"); + return false; + } + + // Based on the Processing Array. A bit overkill, but very flexible. + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); + FluidStack[] aFluidInputs = new FluidStack[] {}; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + int aMaxParallelRecipes = getMaxParallelRecipes(); + int aEUPercent = getEuDiscountForParallelism(); + int aSpeedBonusPercent = 200; + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + + if (aItems.size() > 0 && aCircuit == 3) { + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage + // limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!this.depleteInput(tRecipe.mInputs[1])) { + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + } else if (aCircuit >= 1 && aCircuit <= 2) { + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + } + + log("Broke at " + parallelRecipes + "."); + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialRockBreaker; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public ArrayList getStoredInputs() { + ArrayList aInputs = super.getStoredInputs(); + if (this.hasSlotInGUI() && this.getGUIItemStack() != null) { + aInputs.add(this.getGUIItemStack()); + } + return aInputs; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java index 9a6a416357..a37b4301a2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java @@ -1,6 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.AirIntake; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; import com.google.common.collect.ImmutableMap; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -26,6 +32,7 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -34,570 +41,564 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.AirIntake; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; - -public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - protected int fuelConsumption; - protected int fuelValue; - protected int fuelRemaining; - protected int freeFuelTicks = 0; - protected int euProduction = 0; - protected boolean boostEu; - - public static String mLubricantName = "Carbon Dioxide"; - public static String mCoolantName = "Liquid Hydrogen"; - - public static String mCasingName = "Turbodyne Casing"; - public static String mIntakeHatchName = "Tungstensteel Turbine Casing"; - public static String mGearboxName = "Inconel Reinforced Casing"; - - private static Fluid sAirFluid = null; - private static FluidStack sAirFluidStack = null; - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - private final static int CASING_ID = TAE.getIndexFromPage(3, 11); - - public GregtechMetaTileEntity_LargeRocketEngine(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - this.fuelConsumption = 0; - this.fuelValue = 0; - this.fuelRemaining = 0; - this.boostEu = false; - setAir(); - } - - public GregtechMetaTileEntity_LargeRocketEngine(final String aName) { - super(aName); - this.fuelConsumption = 0; - this.fuelValue = 0; - this.fuelRemaining = 0; - this.boostEu = false; - setAir(); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Large Rocket Engine") - .addInfo("Supply Rocket Fuels and 1000L of " + mLubricantName + " per hour") - .addInfo("Produces as much energy as you put fuel in, with optional boosting") - .addInfo("Supply 4L of " + mCoolantName + " per second, per 2100 EU/t to boost") - .addInfo("Takes 3x the amount of fuel and " + mLubricantName + "to run 3x faster") - .addInfo("Consumes 2000L/s of air and pollutes 1500 gibbl/s per 16384 eu/t produced") - .addInfo("If producing more than 18.4k EU/t, fuel will be consumed less efficiently:") - .addInfo("- 75% of max fuel efficiency at 44k EU/t output energy") - .addInfo("- 50% of max fuel efficiency at 105k EU/t output energy") - .addInfo("- 25% of max fuel efficiency at 294k EU/t output energy") - .addInfo("(These thresholds are 3x higher when boosted)") - .addInfo("formula: x = input of energy (10K^(1/3)/ x^(1/3)) * (40K^(1/3)/ x^(1/3))") - .addSeparator() - .beginStructureBlock(3, 3, 10, false) - .addController("Front Center") - .addCasingInfo(mCasingName, 64) - .addCasingInfo(mGearboxName, 8) - .addStructureHint("Air Intake Hatch", 1) - .addInputBus("Side center line", 1) - .addInputHatch("Side center line", 1) - .addMaintenanceHatch("Any Block Touching Inconel Reinforced Casing", 1) - .addDynamoHatch("Top center line", 2) - .addMufflerHatch("Back Center", 3) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (this.STRUCTURE_DEFINITION == null) { - this.STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(this.mName, transpose(new String[][]{ - {"CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC"}, - {"C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC"}, - {"CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC"}, - })) - .addElement('C', ofBlock(getCasingBlock(), getCasingMeta())) - .addElement('I', ofBlock(getGearboxBlock(), getGearboxMeta())) - // side - .addElement('S', buildHatchAdder(GregtechMetaTileEntity_LargeRocketEngine.class) - .atLeast(ImmutableMap.of(InputBus, 1, InputHatch, 3, Maintenance, 1, AirIntake, 8)) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - // top - .addElement('T', buildHatchAdder(GregtechMetaTileEntity_LargeRocketEngine.class) - .atLeast(ImmutableMap.of(Dynamo.or(TTDynamo), 1, Maintenance, 1, AirIntake, 8)) - .casingIndex(getCasingTextureIndex()) - .dot(2) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement('M', Muffler.newAny(getCasingTextureIndex(), 3)) - .build(); - } - return this.STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(this.mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - this.mCasing = 0; - this.mTecTechDynamoHatches.clear(); - this.mAllDynamoHatches.clear(); - this.mAirIntakes.clear(); - return checkPiece(this.mName, 1, 1, 0) && this.mCasing >= 64 - 48 && this.mAirIntakes.size() >= 8 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return CASING_ID; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return this.getMaxEfficiency(aStack) > 0; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return super.getClientGUI(aID, aPlayerInventory, aBaseMetaTileEntity); - } - - public static void setAir() { - if (sAirFluidStack == null) { - sAirFluidStack = FluidUtils.getFluidStack("air", 1); - } - if (sAirFluid == null && sAirFluidStack != null) { - sAirFluid = sAirFluidStack.getFluid(); - } - } - - public int getAir() { - setAir(); - if (this.mAirIntakes.isEmpty() || this.mAirIntakes.size() <= 0) { - return 0; - } - else { - int totalAir = 0; - for (GT_MetaTileEntity_Hatch_AirIntake u : this.mAirIntakes) { - if (u != null && u.mFluid != null) { - FluidStack f = u.mFluid; - if (f.isFluidEqual(sAirFluidStack)) { - totalAir += f.amount; - } - } - } - return totalAir; - } - } - - @Override - public GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList tFluids = this.getStoredFluids(); - this.clearRecipeMapForAllInputHatches(); - int aircount = getAir() ; - int aAirToConsume = this.euProduction/100; - if (aircount < aAirToConsume) { - log("Not Enough Air to Run "+aircount); - return false; - } - else { - int aTotalAir = 0; - for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : this.mAirIntakes) { - if (aAirHatch.mFluid != null) { - aTotalAir += aAirHatch.getFluidAmount(); - } - } - log("Total Air: "+aTotalAir); - if (aTotalAir >= aAirToConsume) { - int aSplitAmount = (aAirToConsume / this.mAirIntakes.size()); - if (aSplitAmount > 0) { - for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : mAirIntakes) { - boolean hasIntakeAir = aAirHatch.drain(aSplitAmount, true) != null; - if (!hasIntakeAir) { - log("Could not consume Air to run "+aSplitAmount); - this.freeFuelTicks = 0; - return false; - } - log("Consumed Air to run "+aSplitAmount); - } - } - } - } - // reset fuel ticks in case it does not reset when it stops - if (this.freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) - this.freeFuelTicks = 0; - - log("Running "+aircount); - log("looking at hatch"); - - - if (tFluids.size() > 0 && getRecipeMap() != null) { - FluidStack aCO2 = MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1); - FluidStack aCO2Fallback = FluidUtils.getWildcardFluidStack("carbondioxide", (this.boostEu ? 3 : 1)); - - - boolean aHasCO2 = false; - for (FluidStack aFluid : tFluids) { - if (aCO2 != null && aFluid.isFluidEqual(aCO2)) { - log("Found CO2 (1)"); - aHasCO2 = true; - break; - } - if (aCO2Fallback != null && aFluid.isFluidEqual(aCO2Fallback)) { - log("Found CO2 (2)"); - aHasCO2 = true; - break; - } - log("Found: "+aFluid.getUnlocalizedName()); - } - if (aHasCO2) { - if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { - if (!consumeCO2()) { - this.freeFuelTicks = 0; - log("Bad Return 1"); - return false; - } - } - } - else { - this.freeFuelTicks = 0; - log("Bad Return 2 | "+aHasCO2+" | "+(aCO2 != null)+" | "+(aCO2Fallback != null)); - return false; - } - if (this.freeFuelTicks == 0) { - this.boostEu = consumeLOH(); - } - for (final FluidStack hatchFluid1 : tFluids) { - if (hatchFluid1.isFluidEqual(sAirFluidStack)) { - continue; - } - if (this.freeFuelTicks == 0) { - for (final GT_Recipe aFuel : getRecipeMap().mRecipeList) { - final FluidStack tLiquid; - tLiquid = aFuel.mFluidInputs[0]; - if (hatchFluid1.isFluidEqual(tLiquid)) { - if (!consumeFuel(aFuel,hatchFluid1.amount)) { - continue; - } - this.fuelValue = aFuel.mSpecialValue * 3; - this.fuelRemaining = hatchFluid1.amount; - this.mEUt = (int) ((this.mEfficiency < 2000) ? 0 : GT_Values.V[5]<<1); - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = this.euProduction/2000; - return true; - } - } - } - else { - this.mEfficiencyIncrease = this.euProduction/2000; - this.freeFuelTicks--; - this.mEUt = (int) ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5]<<1); - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - return true; - } - } - } - this.mEUt = 0; - this.mEfficiency = 0; - this.freeFuelTicks = 0; - log("Bad Return 3"); - return false; - } - - /** - * Consumes Fuel if required. Free Fuel Ticks are handled here. - * @param aFuel - * @return - */ - public boolean consumeFuel(GT_Recipe aFuel,int amount) { - amount *= this.boostEu ? 0.3 : 0.9; - this.freeFuelTicks = 0; - int value = aFuel.mSpecialValue * 3; - int energy = value * amount; - if (amount < 5) - return false; - FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount)); - if (!this.depleteInput(tLiquid)) { - return false; - } - else { - this.fuelConsumption = this.boostEu ? amount * 3 : amount; - this.freeFuelTicks = 20; - setEUProduction(energy); - return true; - } - } - - public void setEUProduction(int energy){ - energy /= 20; - double energyEfficiency; - double tDivideEnergy = Math.cbrt(energy); - if (energy > 10000) { - //cbrt(10 000) / - energyEfficiency = (21.5443469/tDivideEnergy); - if (energy >= 40000) - //cbrt(40 000) / - energyEfficiency *= (34.19951893/tDivideEnergy); - energyEfficiency *= energy; - } - else { - energyEfficiency = energy; - } - this.euProduction = (int) (energyEfficiency * 1.84); - if (this.boostEu) - this.euProduction *= 3; - } - - public boolean consumeCO2() { - if (this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) { - return true; - } - else { - return false; - } - } - - public boolean consumeLOH() { - int LOHamount = (3 * this.euProduction)/1000; - return this.depleteInput(FluidUtils.getFluidStack(RocketFuels.Liquid_Hydrogen, LOHamount)); //(40 * ((long) euProduction / 10000)) - } - - @Override - public boolean addEnergyOutput(long aEU) { - if (aEU <= 0) { - return true; - } - if (this.mAllDynamoHatches.size() > 0) { - return addEnergyOutputMultipleDynamos(aEU, true); - } - return false; - } - - - @Override - public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { - int injected = 0; - long totalOutput = 0; - long aFirstVoltageFound = -1; - boolean aFoundMixedDynamos = false; - for (GT_MetaTileEntity_Hatch aDynamo : this.mAllDynamoHatches) { - if( aDynamo == null ) { - return false; - } - if (isValidMetaTileEntity(aDynamo)) { - long aVoltage = aDynamo.maxEUOutput(); - long aTotal = aDynamo.maxAmperesOut() * aVoltage; - // Check against voltage to check when hatch mixing - if (aFirstVoltageFound == -1) { - aFirstVoltageFound = aVoltage; - } - else { - /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? - */ - //Long time calculation - if (aFirstVoltageFound != aVoltage) { - aFoundMixedDynamos = true; - } - } - totalOutput += aTotal; - } - } - - if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { - explodeMultiblock(); - return false; - } - - long leftToInject; - //Long EUt calculation - long aVoltage; - //Isnt too low EUt check? - int aAmpsToInject; - int aRemainder; - - //xEUt *= 4;//this is effect of everclocking - for (GT_MetaTileEntity_Hatch aDynamo : this.mAllDynamoHatches) { - if (isValidMetaTileEntity(aDynamo)) { - leftToInject = aEU - injected; - aVoltage = aDynamo.maxEUOutput(); - aAmpsToInject = (int) (leftToInject / aVoltage); - aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); - long powerGain; - for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject + 1); i++) { - if (i == Math.min(aDynamo.maxAmperesOut(), aAmpsToInject)){ - powerGain = aRemainder; - }else{ - powerGain = aVoltage; - } - aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(powerGain, false); - injected += powerGain; - } - } - } - return injected > 0; - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - if (this.mRuntime%20 == 0) { - if (this.mMufflerHatches.size() == 1 && this.mMufflerHatches.get(0) instanceof GT_MetaTileEntity_Hatch_Muffler_Adv) { - GT_MetaTileEntity_Hatch_Muffler_Adv tMuffler = (GT_MetaTileEntity_Hatch_Muffler_Adv) this.mMufflerHatches.get(0); - if (!tMuffler.hasValidFilter()) { - ArrayList tInputs = getStoredInputs(); - for (ItemStack tItem : tInputs) { - if (tMuffler.isAirFilter(tItem)) { - tMuffler.mInventory[0] = tItem.copy(); - depleteInput(tItem); - updateSlots(); - break; - } - } - } - } - } - super.onRunningTick(aStack); - return true; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings4Misc; - } - - public byte getCasingMeta() { - return 11; - } - - public Block getGearboxBlock() { - return ModBlocks.blockCasings3Misc; - } - - public byte getGearboxMeta() { - return 1; - } - - public byte getCasingTextureIndex() { - return (byte) CASING_ID; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_LargeRocketEngine(this.mName); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("freeFuelTicks", this.freeFuelTicks); - aNBT.setInteger("euProduction", this.euProduction); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.freeFuelTicks = aNBT.getInteger("freeFuelTicks"); - this.euProduction = aNBT.getInteger("euProduction"); - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 1; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return this.euProduction; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 75 * ( this.euProduction / 10000); - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return true; - } - - @Override - public String[] getExtraInfoData() { - return new String[] { - "Rocket Engine", - "Current Air: "+getAir(), - "Current Pollution: " + getPollutionPerTick(null), - "Time until next fuel consumption: "+this.freeFuelTicks, - "Current Output: " + this.mEUt * this.mEfficiency / 10000 + " EU/t", - "Fuel Consumption: " + (this.fuelConsumption) + "L/s", - "Fuel Value: " + this.fuelValue + " EU/L", - "Fuel Remaining: " + this.fuelRemaining + " Litres", - "Current Efficiency: " + this.mEfficiency / 100 + "%", - (this.getIdealStatus() == this.getRepairStatus()) ? "No Maintainance issues" : "Needs Maintainance" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Rocket Engine"; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } +public class GregtechMetaTileEntity_LargeRocketEngine + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + protected int fuelConsumption; + protected int fuelValue; + protected int fuelRemaining; + protected int freeFuelTicks = 0; + protected int euProduction = 0; + protected boolean boostEu; + + public static String mLubricantName = "Carbon Dioxide"; + public static String mCoolantName = "Liquid Hydrogen"; + + public static String mCasingName = "Turbodyne Casing"; + public static String mIntakeHatchName = "Tungstensteel Turbine Casing"; + public static String mGearboxName = "Inconel Reinforced Casing"; + + private static Fluid sAirFluid = null; + private static FluidStack sAirFluidStack = null; + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + private static final int CASING_ID = TAE.getIndexFromPage(3, 11); + + public GregtechMetaTileEntity_LargeRocketEngine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + this.fuelConsumption = 0; + this.fuelValue = 0; + this.fuelRemaining = 0; + this.boostEu = false; + setAir(); + } + + public GregtechMetaTileEntity_LargeRocketEngine(final String aName) { + super(aName); + this.fuelConsumption = 0; + this.fuelValue = 0; + this.fuelRemaining = 0; + this.boostEu = false; + setAir(); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Rocket Engine") + .addInfo("Supply Rocket Fuels and 1000L of " + mLubricantName + " per hour") + .addInfo("Produces as much energy as you put fuel in, with optional boosting") + .addInfo("Supply 4L of " + mCoolantName + " per second, per 2100 EU/t to boost") + .addInfo("Takes 3x the amount of fuel and " + mLubricantName + "to run 3x faster") + .addInfo("Consumes 2000L/s of air and pollutes 1500 gibbl/s per 16384 eu/t produced") + .addInfo("If producing more than 18.4k EU/t, fuel will be consumed less efficiently:") + .addInfo("- 75% of max fuel efficiency at 44k EU/t output energy") + .addInfo("- 50% of max fuel efficiency at 105k EU/t output energy") + .addInfo("- 25% of max fuel efficiency at 294k EU/t output energy") + .addInfo("(These thresholds are 3x higher when boosted)") + .addInfo("formula: x = input of energy (10K^(1/3)/ x^(1/3)) * (40K^(1/3)/ x^(1/3))") + .addSeparator() + .beginStructureBlock(3, 3, 10, false) + .addController("Front Center") + .addCasingInfo(mCasingName, 64) + .addCasingInfo(mGearboxName, 8) + .addStructureHint("Air Intake Hatch", 1) + .addInputBus("Side center line", 1) + .addInputHatch("Side center line", 1) + .addMaintenanceHatch("Any Block Touching Inconel Reinforced Casing", 1) + .addDynamoHatch("Top center line", 2) + .addMufflerHatch("Back Center", 3) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (this.STRUCTURE_DEFINITION == null) { + this.STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(this.mName, transpose(new String[][] { + {"CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC"}, + {"C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC"}, + {"CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC"}, + })) + .addElement('C', ofBlock(getCasingBlock(), getCasingMeta())) + .addElement('I', ofBlock(getGearboxBlock(), getGearboxMeta())) + // side + .addElement( + 'S', + buildHatchAdder(GregtechMetaTileEntity_LargeRocketEngine.class) + .atLeast(ImmutableMap.of(InputBus, 1, InputHatch, 3, Maintenance, 1, AirIntake, 8)) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + // top + .addElement( + 'T', + buildHatchAdder(GregtechMetaTileEntity_LargeRocketEngine.class) + .atLeast(ImmutableMap.of(Dynamo.or(TTDynamo), 1, Maintenance, 1, AirIntake, 8)) + .casingIndex(getCasingTextureIndex()) + .dot(2) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('M', Muffler.newAny(getCasingTextureIndex(), 3)) + .build(); + } + return this.STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(this.mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.mCasing = 0; + this.mTecTechDynamoHatches.clear(); + this.mAllDynamoHatches.clear(); + this.mAirIntakes.clear(); + return checkPiece(this.mName, 1, 1, 0) + && this.mCasing >= 64 - 48 + && this.mAirIntakes.size() >= 8 + && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return CASING_ID; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return this.getMaxEfficiency(aStack) > 0; + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return super.getClientGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + } + + public static void setAir() { + if (sAirFluidStack == null) { + sAirFluidStack = FluidUtils.getFluidStack("air", 1); + } + if (sAirFluid == null && sAirFluidStack != null) { + sAirFluid = sAirFluidStack.getFluid(); + } + } + + public int getAir() { + setAir(); + if (this.mAirIntakes.isEmpty() || this.mAirIntakes.size() <= 0) { + return 0; + } else { + int totalAir = 0; + for (GT_MetaTileEntity_Hatch_AirIntake u : this.mAirIntakes) { + if (u != null && u.mFluid != null) { + FluidStack f = u.mFluid; + if (f.isFluidEqual(sAirFluidStack)) { + totalAir += f.amount; + } + } + } + return totalAir; + } + } + + @Override + public GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + final ArrayList tFluids = this.getStoredFluids(); + this.clearRecipeMapForAllInputHatches(); + int aircount = getAir(); + int aAirToConsume = this.euProduction / 100; + if (aircount < aAirToConsume) { + log("Not Enough Air to Run " + aircount); + return false; + } else { + int aTotalAir = 0; + for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : this.mAirIntakes) { + if (aAirHatch.mFluid != null) { + aTotalAir += aAirHatch.getFluidAmount(); + } + } + log("Total Air: " + aTotalAir); + if (aTotalAir >= aAirToConsume) { + int aSplitAmount = (aAirToConsume / this.mAirIntakes.size()); + if (aSplitAmount > 0) { + for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : mAirIntakes) { + boolean hasIntakeAir = aAirHatch.drain(aSplitAmount, true) != null; + if (!hasIntakeAir) { + log("Could not consume Air to run " + aSplitAmount); + this.freeFuelTicks = 0; + return false; + } + log("Consumed Air to run " + aSplitAmount); + } + } + } + } + // reset fuel ticks in case it does not reset when it stops + if (this.freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) this.freeFuelTicks = 0; + + log("Running " + aircount); + log("looking at hatch"); + + if (tFluids.size() > 0 && getRecipeMap() != null) { + FluidStack aCO2 = MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1); + FluidStack aCO2Fallback = FluidUtils.getWildcardFluidStack("carbondioxide", (this.boostEu ? 3 : 1)); + + boolean aHasCO2 = false; + for (FluidStack aFluid : tFluids) { + if (aCO2 != null && aFluid.isFluidEqual(aCO2)) { + log("Found CO2 (1)"); + aHasCO2 = true; + break; + } + if (aCO2Fallback != null && aFluid.isFluidEqual(aCO2Fallback)) { + log("Found CO2 (2)"); + aHasCO2 = true; + break; + } + log("Found: " + aFluid.getUnlocalizedName()); + } + if (aHasCO2) { + if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { + if (!consumeCO2()) { + this.freeFuelTicks = 0; + log("Bad Return 1"); + return false; + } + } + } else { + this.freeFuelTicks = 0; + log("Bad Return 2 | " + aHasCO2 + " | " + (aCO2 != null) + " | " + (aCO2Fallback != null)); + return false; + } + if (this.freeFuelTicks == 0) { + this.boostEu = consumeLOH(); + } + for (final FluidStack hatchFluid1 : tFluids) { + if (hatchFluid1.isFluidEqual(sAirFluidStack)) { + continue; + } + if (this.freeFuelTicks == 0) { + for (final GT_Recipe aFuel : getRecipeMap().mRecipeList) { + final FluidStack tLiquid; + tLiquid = aFuel.mFluidInputs[0]; + if (hatchFluid1.isFluidEqual(tLiquid)) { + if (!consumeFuel(aFuel, hatchFluid1.amount)) { + continue; + } + this.fuelValue = aFuel.mSpecialValue * 3; + this.fuelRemaining = hatchFluid1.amount; + this.mEUt = (int) ((this.mEfficiency < 2000) ? 0 : GT_Values.V[5] << 1); + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = this.euProduction / 2000; + return true; + } + } + } else { + this.mEfficiencyIncrease = this.euProduction / 2000; + this.freeFuelTicks--; + this.mEUt = (int) ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5] << 1); + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + return true; + } + } + } + this.mEUt = 0; + this.mEfficiency = 0; + this.freeFuelTicks = 0; + log("Bad Return 3"); + return false; + } + + /** + * Consumes Fuel if required. Free Fuel Ticks are handled here. + * @param aFuel + * @return + */ + public boolean consumeFuel(GT_Recipe aFuel, int amount) { + amount *= this.boostEu ? 0.3 : 0.9; + this.freeFuelTicks = 0; + int value = aFuel.mSpecialValue * 3; + int energy = value * amount; + if (amount < 5) return false; + FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount)); + if (!this.depleteInput(tLiquid)) { + return false; + } else { + this.fuelConsumption = this.boostEu ? amount * 3 : amount; + this.freeFuelTicks = 20; + setEUProduction(energy); + return true; + } + } + + public void setEUProduction(int energy) { + energy /= 20; + double energyEfficiency; + double tDivideEnergy = Math.cbrt(energy); + if (energy > 10000) { + // cbrt(10 000) / + energyEfficiency = (21.5443469 / tDivideEnergy); + if (energy >= 40000) + // cbrt(40 000) / + energyEfficiency *= (34.19951893 / tDivideEnergy); + energyEfficiency *= energy; + } else { + energyEfficiency = energy; + } + this.euProduction = (int) (energyEfficiency * 1.84); + if (this.boostEu) this.euProduction *= 3; + } + + public boolean consumeCO2() { + if (this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) + || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) { + return true; + } else { + return false; + } + } + + public boolean consumeLOH() { + int LOHamount = (3 * this.euProduction) / 1000; + return this.depleteInput(FluidUtils.getFluidStack( + RocketFuels.Liquid_Hydrogen, LOHamount)); // (40 * ((long) euProduction / 10000)) + } + + @Override + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) { + return true; + } + if (this.mAllDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + + @Override + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { + int injected = 0; + long totalOutput = 0; + long aFirstVoltageFound = -1; + boolean aFoundMixedDynamos = false; + for (GT_MetaTileEntity_Hatch aDynamo : this.mAllDynamoHatches) { + if (aDynamo == null) { + return false; + } + if (isValidMetaTileEntity(aDynamo)) { + long aVoltage = aDynamo.maxEUOutput(); + long aTotal = aDynamo.maxAmperesOut() * aVoltage; + // Check against voltage to check when hatch mixing + if (aFirstVoltageFound == -1) { + aFirstVoltageFound = aVoltage; + } else { + /** + * Calcualtes overclocked ness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + */ + // Long time calculation + if (aFirstVoltageFound != aVoltage) { + aFoundMixedDynamos = true; + } + } + totalOutput += aTotal; + } + } + + if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { + explodeMultiblock(); + return false; + } + + long leftToInject; + // Long EUt calculation + long aVoltage; + // Isnt too low EUt check? + int aAmpsToInject; + int aRemainder; + + // xEUt *= 4;//this is effect of everclocking + for (GT_MetaTileEntity_Hatch aDynamo : this.mAllDynamoHatches) { + if (isValidMetaTileEntity(aDynamo)) { + leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + aAmpsToInject = (int) (leftToInject / aVoltage); + aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); + long powerGain; + for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject + 1); i++) { + if (i == Math.min(aDynamo.maxAmperesOut(), aAmpsToInject)) { + powerGain = aRemainder; + } else { + powerGain = aVoltage; + } + aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(powerGain, false); + injected += powerGain; + } + } + } + return injected > 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mRuntime % 20 == 0) { + if (this.mMufflerHatches.size() == 1 + && this.mMufflerHatches.get(0) instanceof GT_MetaTileEntity_Hatch_Muffler_Adv) { + GT_MetaTileEntity_Hatch_Muffler_Adv tMuffler = + (GT_MetaTileEntity_Hatch_Muffler_Adv) this.mMufflerHatches.get(0); + if (!tMuffler.hasValidFilter()) { + ArrayList tInputs = getStoredInputs(); + for (ItemStack tItem : tInputs) { + if (tMuffler.isAirFilter(tItem)) { + tMuffler.mInventory[0] = tItem.copy(); + depleteInput(tItem); + updateSlots(); + break; + } + } + } + } + } + super.onRunningTick(aStack); + return true; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + public byte getCasingMeta() { + return 11; + } + + public Block getGearboxBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getGearboxMeta() { + return 1; + } + + public byte getCasingTextureIndex() { + return (byte) CASING_ID; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_LargeRocketEngine(this.mName); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("freeFuelTicks", this.freeFuelTicks); + aNBT.setInteger("euProduction", this.euProduction); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.freeFuelTicks = aNBT.getInteger("freeFuelTicks"); + this.euProduction = aNBT.getInteger("euProduction"); + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 1; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return this.euProduction; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 75 * (this.euProduction / 10000); + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return true; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { + "Rocket Engine", + "Current Air: " + getAir(), + "Current Pollution: " + getPollutionPerTick(null), + "Time until next fuel consumption: " + this.freeFuelTicks, + "Current Output: " + this.mEUt * this.mEfficiency / 10000 + " EU/t", + "Fuel Consumption: " + (this.fuelConsumption) + "L/s", + "Fuel Value: " + this.fuelValue + " EU/L", + "Fuel Remaining: " + this.fuelRemaining + " Litres", + "Current Efficiency: " + this.mEfficiency / 100 + "%", + (this.getIdealStatus() == this.getRepairStatus()) ? "No Maintainance issues" : "Needs Maintainance" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Rocket Engine"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java index 37d5cb422c..ec3f85014e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java @@ -1,6 +1,14 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.Dynamo; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_HatchElement.Muffler; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -22,6 +30,7 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -29,337 +38,311 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.enums.GT_HatchElement.Muffler; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; - -public class GregtechMetaTileEntity_LargeSemifluidGenerator extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - protected int fuelConsumption = 0; - protected int fuelValue = 0; - protected int fuelRemaining = 0; - protected boolean boostEu = false; - - public GregtechMetaTileEntity_LargeSemifluidGenerator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_LargeSemifluidGenerator(String aName) { - super(aName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Large Semifluid Generator") - .addInfo("Engine Intake Casings must not be obstructed in front (only air blocks)") - .addInfo("Supply Semifluid Fuels and 2000L of Lubricant per hour to run.") - .addInfo("Supply 80L of Oxygen per second to boost output (optional).") - .addInfo("Default: Produces 2048EU/t at 100% efficiency") - .addInfo("Boosted: Produces 6144EU/t at 150% efficiency") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 4, false) - .addController("Front Center") - .addCasingInfo("Stable Titanium Machine Casing", 16) - .addCasingInfo("Steel Gear Box Machine Casing", 2) - .addCasingInfo("Engine Intake Machine Casing", 8) - .addInputHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .addDynamoHatch("Back Center", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE; - } - - @Override - protected int getCasingTextureId() { - return 50; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return getMaxEfficiency(aStack) > 0; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluids = getStoredFluids(); - - // Check for lubricant and oxygen first, so we can compute costs ahead of time. - // This will allow us to check costs without needing to actually try to deplete fluids - // (wasting earlier fluids in the check if later fluids turn out to be insufficient). - FluidStack lubricant = Materials.Lubricant.getFluid(0L); - FluidStack oxygen = Materials.Oxygen.getGas(0L); - for (FluidStack hatchFluid : tFluids) { - if (hatchFluid.isFluidEqual(lubricant)) { - lubricant.amount = Math.max(lubricant.amount, hatchFluid.amount); - } else if (hatchFluid.isFluidEqual(oxygen)) { - oxygen.amount = Math.max(oxygen.amount, hatchFluid.amount); - } - } - boostEu = oxygen.amount >= 4L; - long lubricantCost = boostEu ? 2L : 1L; - if (lubricant.amount < lubricantCost) { - return false; - } - - for (FluidStack hatchFluid : tFluids) { //Loops through hatches - GT_Recipe aFuel = GTPP_Recipe_Map.sSemiFluidLiquidFuels.findFuel(hatchFluid); - if (aFuel == null) { - // Not a valid semi-fluid fuel. - continue; - } - - int newEUt = boostEu ? 4096 : 2048; - fuelConsumption = newEUt / aFuel.mSpecialValue; //Calc fuel consumption - FluidStack tLiquid = new FluidStack(hatchFluid.getFluid(), fuelConsumption); - if(depleteInput(tLiquid)) { //Deplete that amount - // We checked beforehand, so both of these depletions should succeed. - // But check the return values anyway just to be safe. - if (boostEu) { - if (!depleteInput(Materials.Oxygen.getGas(4L))) { - return false; - } - } - //Deplete Lubricant. 2000L should = 1 hour of runtime (if baseEU = 2048) - if(mRuntime % 72 == 0 || mRuntime == 0) { - if(!depleteInput(Materials.Lubricant.getFluid(lubricantCost))) { - return false; - } - } - - fuelValue = aFuel.mSpecialValue; - fuelRemaining = hatchFluid.amount; //Record available fuel - this.mEUt = mEfficiency < 2000 ? 0 : newEUt; //Output 0 if startup is less than 20% - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 15; - return true; - } - } - - this.mEUt = 0; - this.mEfficiency = 0; - return false; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"III", "CCC", "CCC", "CCC"}, - {"I~I", "CGC", "CGC", "CMC"}, - {"III", "CCC", "CCC", "CCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_LargeSemifluidGenerator.class) - .atLeast(Muffler, InputHatch, Maintenance) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass( - x -> ++x.mCasing, - ofBlock( - getCasingBlock(), getCasingMeta() - ) - ) - ) - ) - .addElement( - 'G', - ofBlock( - getGearboxBlock(), getGearboxMeta() - ) - ) - .addElement( - 'I', - ofBlock( - getIntakeBlock(), getIntakeMeta() - ) - ) - .addElement( - 'M', - Dynamo.or(TTDynamo).newAny(getCasingTextureIndex(), 2) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mDynamoHatches.clear(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 16 && checkHatch(); - } - - public final boolean addLargeSemifluidGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - public final boolean addLargeSemifluidGeneratorBackList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo || this.isThisHatchMultiDynamo(aTileEntity)){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - public Block getCasingBlock() { - return GregTech_API.sBlockCasings4; - } - - public byte getCasingMeta() { - return 2; - } - - public Block getIntakeBlock() { - return GregTech_API.sBlockCasings4; - } - - public byte getIntakeMeta() { - return 13; - } - - public Block getGearboxBlock() { - return GregTech_API.sBlockCasings2; - } - - public byte getGearboxMeta() { - return 3; - } - - public byte getCasingTextureIndex() { - return 50; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_LargeSemifluidGenerator(this.mName); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - - public int getMaxEfficiency(ItemStack aStack) { - return boostEu ? 15000 : 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiLargeSemiFluidGenerator; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return true; - } - - @Override - public String[] getExtraInfoData() { - return new String[]{ - "Large Semifluid Generator", - "Current Output: " + mEUt * mEfficiency / 10000 + " EU/t", - "Fuel Consumption: " + fuelConsumption + "L/t", - "Fuel Value: " + fuelValue + " EU/L", - "Fuel Remaining: " + fuelRemaining + " Litres", - "Current Efficiency: " + (mEfficiency / 100) + "%", - getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Semifluid Generator"; - } - - @Override - public int getMaxParallelRecipes() { - return 0; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } +public class GregtechMetaTileEntity_LargeSemifluidGenerator + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + protected int fuelConsumption = 0; + protected int fuelValue = 0; + protected int fuelRemaining = 0; + protected boolean boostEu = false; + + public GregtechMetaTileEntity_LargeSemifluidGenerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_LargeSemifluidGenerator(String aName) { + super(aName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Semifluid Generator") + .addInfo("Engine Intake Casings must not be obstructed in front (only air blocks)") + .addInfo("Supply Semifluid Fuels and 2000L of Lubricant per hour to run.") + .addInfo("Supply 80L of Oxygen per second to boost output (optional).") + .addInfo("Default: Produces 2048EU/t at 100% efficiency") + .addInfo("Boosted: Produces 6144EU/t at 150% efficiency") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 4, false) + .addController("Front Center") + .addCasingInfo("Stable Titanium Machine Casing", 16) + .addCasingInfo("Steel Gear Box Machine Casing", 2) + .addCasingInfo("Engine Intake Machine Casing", 8) + .addInputHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addDynamoHatch("Back Center", 2) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE; + } + + @Override + protected int getCasingTextureId() { + return 50; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tFluids = getStoredFluids(); + + // Check for lubricant and oxygen first, so we can compute costs ahead of time. + // This will allow us to check costs without needing to actually try to deplete fluids + // (wasting earlier fluids in the check if later fluids turn out to be insufficient). + FluidStack lubricant = Materials.Lubricant.getFluid(0L); + FluidStack oxygen = Materials.Oxygen.getGas(0L); + for (FluidStack hatchFluid : tFluids) { + if (hatchFluid.isFluidEqual(lubricant)) { + lubricant.amount = Math.max(lubricant.amount, hatchFluid.amount); + } else if (hatchFluid.isFluidEqual(oxygen)) { + oxygen.amount = Math.max(oxygen.amount, hatchFluid.amount); + } + } + boostEu = oxygen.amount >= 4L; + long lubricantCost = boostEu ? 2L : 1L; + if (lubricant.amount < lubricantCost) { + return false; + } + + for (FluidStack hatchFluid : tFluids) { // Loops through hatches + GT_Recipe aFuel = GTPP_Recipe_Map.sSemiFluidLiquidFuels.findFuel(hatchFluid); + if (aFuel == null) { + // Not a valid semi-fluid fuel. + continue; + } + + int newEUt = boostEu ? 4096 : 2048; + fuelConsumption = newEUt / aFuel.mSpecialValue; // Calc fuel consumption + FluidStack tLiquid = new FluidStack(hatchFluid.getFluid(), fuelConsumption); + if (depleteInput(tLiquid)) { // Deplete that amount + // We checked beforehand, so both of these depletions should succeed. + // But check the return values anyway just to be safe. + if (boostEu) { + if (!depleteInput(Materials.Oxygen.getGas(4L))) { + return false; + } + } + // Deplete Lubricant. 2000L should = 1 hour of runtime (if baseEU = 2048) + if (mRuntime % 72 == 0 || mRuntime == 0) { + if (!depleteInput(Materials.Lubricant.getFluid(lubricantCost))) { + return false; + } + } + + fuelValue = aFuel.mSpecialValue; + fuelRemaining = hatchFluid.amount; // Record available fuel + this.mEUt = mEfficiency < 2000 ? 0 : newEUt; // Output 0 if startup is less than 20% + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 15; + return true; + } + } + + this.mEUt = 0; + this.mEfficiency = 0; + return false; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"III", "CCC", "CCC", "CCC"}, + {"I~I", "CGC", "CGC", "CMC"}, + {"III", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_LargeSemifluidGenerator.class) + .atLeast(Muffler, InputHatch, Maintenance) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass( + x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('G', ofBlock(getGearboxBlock(), getGearboxMeta())) + .addElement('I', ofBlock(getIntakeBlock(), getIntakeMeta())) + .addElement('M', Dynamo.or(TTDynamo).newAny(getCasingTextureIndex(), 2)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mDynamoHatches.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 16 && checkHatch(); + } + + public final boolean addLargeSemifluidGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addLargeSemifluidGeneratorBackList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo || this.isThisHatchMultiDynamo(aTileEntity)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getCasingMeta() { + return 2; + } + + public Block getIntakeBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getIntakeMeta() { + return 13; + } + + public Block getGearboxBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getGearboxMeta() { + return 3; + } + + public byte getCasingTextureIndex() { + return 50; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_LargeSemifluidGenerator(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + return boostEu ? 15000 : 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiLargeSemiFluidGenerator; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return true; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { + "Large Semifluid Generator", + "Current Output: " + mEUt * mEfficiency / 10000 + " EU/t", + "Fuel Consumption: " + fuelConsumption + "L/t", + "Fuel Value: " + fuelValue + " EU/L", + "Fuel Remaining: " + fuelRemaining + " Litres", + "Current Efficiency: " + (mEfficiency / 100) + "%", + getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Semifluid Generator"; + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java index f629c27b24..39f2958dfb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java @@ -1,8 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -26,6 +29,9 @@ import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MatterFab; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -34,648 +40,660 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3200; - - public int mMatterProduced = 0; - public int mScrapProduced = 0; - public int mAmplifierProduced = 0; - public int mScrapUsed = 0; - public int mAmplifierUsed = 0; - - public static String mCasingName1 = "Matter Fabricator Casing"; - public static String mCasingName2 = "Containment Casing"; - public static String mCasingName3 = "Matter Generation Coil"; - - private int mMode = 0; - - private final static int MODE_SCRAP = 1; - private final static int MODE_UU = 0; - - public static boolean sRequiresUUA = false; - private static FluidStack[] mUU = new FluidStack[2]; - private static ItemStack mScrap[] = new ItemStack[2]; - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public int getAmplifierUsed(){ - return this.mAmplifierUsed; - } - - public int getMatterProduced(){ - return this.mMatterProduced; - } - - public int getScrapProduced(){ - return this.mScrapProduced; - } - - public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_MassFabricator(final String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Mass Fabricator / Recycler"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Matter Fabricator") - .addInfo("Speed: +0% | EU Usage: 80%") - .addInfo("Parallel: Scrap = 64 | UU = 8 * Tier") - .addInfo("Produces UU-A, UU-M & Scrap") - .addInfo("Change mode with screwdriver") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 4, 5, true) - .addController("Front Center") - .addCasingInfo(mCasingName3, 9) - .addCasingInfo(mCasingName2, 24) - .addCasingInfo(mCasingName1, 40) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab_Active_Animated; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab_Animated; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(9); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "MatterFabricator"; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_MatterFab(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public void onConfigLoad(final GT_Config aConfig) { - super.onConfigLoad(aConfig); - sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); - sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); - sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); - sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); - //Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - ArrayList tItems = getStoredInputs(); - ArrayList tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - init(); - return checkRecipeGeneric(tItemInputs, tFluidInputs, 4, 80, 00, 10000); - } - - public static boolean sInit = false; - - public static void init() { - if (!sInit) { - if (mScrap[0] == null) { - mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); - } - if (mScrap[1] == null) { - mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); - } - if (mUU[0] == null) { - mUU[0] = Materials.UUAmplifier.getFluid(100); - } - if (mUU[1] == null) { - mUU[1] = Materials.UUMatter.getFluid(100); - } - sInit = true; - } - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, - {"CGGGC", "G---G", "G---G", "G---G", "CGGGC"}, - {"CGGGC", "G---G", "G---G", "G---G", "CGGGC"}, - {"CC~CC", "CHHHC", "CHHHC", "CHHHC", "CCCCC"}, - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_MassFabricator.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(9)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 9))) - ) - .addElement( - 'H', - ofBlock( - ModBlocks.blockCasingsMisc, 8 - ) - ) - .addElement( - 'G', - ofBlock( - ModBlocks.blockCasings3Misc, 15 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 2, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 3, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 2, 3, 0) && mCasing >= 40 && checkHatch(); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiMassFabricator; - } - - @Override - public int getAmountOfOutputs() { - return 10; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MassFabricator(this.mName); - } - - /** - * Special Recipe Handling - */ - - - @Override - public GT_Recipe_Map getRecipeMap() { - return this.mMode == MODE_SCRAP ? GT_Recipe_Map.sRecyclerRecipes : GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes; - //return Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes; - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - if (this.mMode == MODE_SCRAP) { - return checkRecipeScrap(aItemInputs, aFluidInputs, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll); - } - else { - return checkRecipeUU(aItemInputs, aFluidInputs, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll); - } - } - - public boolean checkRecipeScrap( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - - if (aItemInputs == null || aItemInputs.length <= 0) { - return false; - } - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - ItemStack aPotentialOutput = GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(1, aItemInputs[0]), 0); - GT_Recipe tRecipe = new GTPP_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aItemInputs[0])}, aPotentialOutput == null ? null : new ItemStack[]{aPotentialOutput}, null, new int[]{2000}, null, null, 40, MaterialUtils.getVoltageForTier(1), 0); - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - int parallelRecipes = 0; - // Count recipes to do in parallel, consuming input items and fluids and - // considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - break; - } - log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + ". "); - tTotalEUt += tRecipeEUt; - } - log("Broke at " + parallelRecipes + "."); - if (parallelRecipes > 0) { - // -- Try not to fail after this point - inputs have already been - // consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe - // duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); - this.mEUt = (int) Math.ceil(tTotalEUt); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } - else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 4; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - tOutputItems = removeNulls(tOutputItems); - for (ItemStack aOutputStack : tOutputItems) { - if (aOutputStack != null) { - mScrapProduced += aOutputStack.stackSize; - } - } - // Sanitize item stack size, splitting any stacks greater than max - // stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) - tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - // Commit outputs - this.mOutputItems = tOutputItems; - updateSlots(); - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; - } - return false; - } - - public boolean checkRecipeUU( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - - - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, false, aFluidInputs, aItemInputs)) { - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - log("Broke at "+parallelRecipes+"."); - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 4; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - - int aMatterProduced = 0; - int aAmplifierProduced = 0; - int aScrapUsed = 0; - int aAmplifierUsed = 0; - - for (int i=0; i splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - - } - - @Override - public int getMaxParallelRecipes() { - return this.mMode == MODE_SCRAP ? 64 : 8 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); - } - - @Override - public int getEuDiscountForParallelism() { - return 80; - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - int aMode = this.mMode + 1; - if (aMode > 1) { - this.mMode = MODE_UU; - PlayerUtils.messagePlayer(aPlayer, "Mode ["+this.mMode+"]: Matter/AmpliFabricator"); - } - else if (aMode == 1) { - this.mMode = MODE_SCRAP; - PlayerUtils.messagePlayer(aPlayer, "Mode ["+this.mMode+"]: Recycler"); - } - else { - this.mMode = MODE_SCRAP; - PlayerUtils.messagePlayer(aPlayer, "Mode ["+this.mMode+"]: Recycler"); - } - GT_Recipe_Map r = this.getRecipeMap(); - final Collection x = r.mRecipeList; - Logger.INFO("Dumping " + r.mUnlocalizedName + " Recipes for Debug. size: "+x.size()); - for (final GT_Recipe newBo : x) { - Logger.INFO("========================"); - Logger.INFO("Dumping Input: " + ItemUtils.getArrayStackNames(newBo.mInputs)); - Logger.INFO("Dumping Inputs " + ItemUtils.getFluidArrayStackNames(newBo.mFluidInputs)); - Logger.INFO("Dumping Duration: " + newBo.mDuration); - Logger.INFO("Dumping EU/t: " + newBo.mEUt); - Logger.INFO("Dumping Output: " + ItemUtils.getArrayStackNames(newBo.mOutputs)); - Logger.INFO("Dumping Output: " + ItemUtils.getFluidArrayStackNames(newBo.mFluidOutputs)); - Logger.INFO("========================"); - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mScrapProduced", mScrapProduced); - aNBT.setInteger("mAmplifierProduced", mAmplifierProduced); - aNBT.setInteger("mMatterProduced", mMatterProduced); - aNBT.setInteger("mScrapUsed", mScrapUsed); - aNBT.setInteger("mAmplifierUsed", mAmplifierUsed); - aNBT.setInteger("mMode", mMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mScrapProduced = aNBT.getInteger("mScrapProduced"); - mAmplifierProduced = aNBT.getInteger("mAmplifierProduced"); - mMatterProduced = aNBT.getInteger("mMatterProduced"); - mScrapUsed = aNBT.getInteger("mScrapUsed"); - mAmplifierUsed = aNBT.getInteger("mAmplifierUsed"); - mMode = aNBT.getInteger("mMode"); - super.loadNBTData(aNBT); - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_MassFabricator + extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { + + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3200; + + public int mMatterProduced = 0; + public int mScrapProduced = 0; + public int mAmplifierProduced = 0; + public int mScrapUsed = 0; + public int mAmplifierUsed = 0; + + public static String mCasingName1 = "Matter Fabricator Casing"; + public static String mCasingName2 = "Containment Casing"; + public static String mCasingName3 = "Matter Generation Coil"; + + private int mMode = 0; + + private static final int MODE_SCRAP = 1; + private static final int MODE_UU = 0; + + public static boolean sRequiresUUA = false; + private static FluidStack[] mUU = new FluidStack[2]; + private static ItemStack mScrap[] = new ItemStack[2]; + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public int getAmplifierUsed() { + return this.mAmplifierUsed; + } + + public int getMatterProduced() { + return this.mMatterProduced; + } + + public int getScrapProduced() { + return this.mScrapProduced; + } + + public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_MassFabricator(final String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Mass Fabricator / Recycler"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Matter Fabricator") + .addInfo("Speed: +0% | EU Usage: 80%") + .addInfo("Parallel: Scrap = 64 | UU = 8 * Tier") + .addInfo("Produces UU-A, UU-M & Scrap") + .addInfo("Change mode with screwdriver") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 4, 5, true) + .addController("Front Center") + .addCasingInfo(mCasingName3, 9) + .addCasingInfo(mCasingName2, 24) + .addCasingInfo(mCasingName1, 40) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab_Active_Animated; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab_Animated; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(9); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MatterFabricator"; + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_MatterFab(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public void onConfigLoad(final GT_Config aConfig) { + super.onConfigLoad(aConfig); + sDurationMultiplier = aConfig.get( + ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); + sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); + sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); + sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); + // Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + ArrayList tItems = getStoredInputs(); + ArrayList tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + init(); + return checkRecipeGeneric(tItemInputs, tFluidInputs, 4, 80, 00, 10000); + } + + public static boolean sInit = false; + + public static void init() { + if (!sInit) { + if (mScrap[0] == null) { + mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); + } + if (mScrap[1] == null) { + mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); + } + if (mUU[0] == null) { + mUU[0] = Materials.UUAmplifier.getFluid(100); + } + if (mUU[1] == null) { + mUU[1] = Materials.UUMatter.getFluid(100); + } + sInit = true; + } + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + {"CGGGC", "G---G", "G---G", "G---G", "CGGGC"}, + {"CGGGC", "G---G", "G---G", "G---G", "CGGGC"}, + {"CC~CC", "CHHHC", "CHHHC", "CHHHC", "CCCCC"}, + })) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_MassFabricator.class) + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(9)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 9)))) + .addElement('H', ofBlock(ModBlocks.blockCasingsMisc, 8)) + .addElement('G', ofBlock(ModBlocks.blockCasings3Misc, 15)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 3, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 3, 0) && mCasing >= 40 && checkHatch(); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiMassFabricator; + } + + @Override + public int getAmountOfOutputs() { + return 10; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MassFabricator(this.mName); + } + + /** + * Special Recipe Handling + */ + @Override + public GT_Recipe_Map getRecipeMap() { + return this.mMode == MODE_SCRAP + ? GT_Recipe_Map.sRecyclerRecipes + : GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes; + // return Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes; + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + if (this.mMode == MODE_SCRAP) { + return checkRecipeScrap( + aItemInputs, + aFluidInputs, + getMaxParallelRecipes(), + getEuDiscountForParallelism(), + aSpeedBonusPercent, + aOutputChanceRoll); + } else { + return checkRecipeUU( + aItemInputs, + aFluidInputs, + getMaxParallelRecipes(), + getEuDiscountForParallelism(), + aSpeedBonusPercent, + aOutputChanceRoll); + } + } + + public boolean checkRecipeScrap( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + int aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + + if (aItemInputs == null || aItemInputs.length <= 0) { + return false; + } + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + ItemStack aPotentialOutput = GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(1, aItemInputs[0]), 0); + GT_Recipe tRecipe = new GTPP_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aItemInputs[0])}, + aPotentialOutput == null ? null : new ItemStack[] {aPotentialOutput}, + null, + new int[] {2000}, + null, + null, + 40, + MaterialUtils.getVoltageForTier(1), + 0); + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + int parallelRecipes = 0; + // Count recipes to do in parallel, consuming input items and fluids and + // considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + ". "); + tTotalEUt += tRecipeEUt; + } + log("Broke at " + parallelRecipes + "."); + if (parallelRecipes > 0) { + // -- Try not to fail after this point - inputs have already been + // consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe + // duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + this.mEUt = (int) Math.ceil(tTotalEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 4; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + tOutputItems = removeNulls(tOutputItems); + for (ItemStack aOutputStack : tOutputItems) { + if (aOutputStack != null) { + mScrapProduced += aOutputStack.stackSize; + } + } + // Sanitize item stack size, splitting any stacks greater than max + // stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + // Commit outputs + this.mOutputItems = tOutputItems; + updateSlots(); + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + return true; + } + return false; + } + + public boolean checkRecipeUU( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + int aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, false, aFluidInputs, aItemInputs)) { + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + log("Broke at " + parallelRecipes + "."); + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 4; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + int aMatterProduced = 0; + int aAmplifierProduced = 0; + int aScrapUsed = 0; + int aAmplifierUsed = 0; + + for (int i = 0; i < parallelRecipes; i++) { + // Logger.INFO("Trying to bump stats "+i); + for (ItemStack aInput : tRecipe.mInputs) { + if (aInput != null && GT_Utility.areStacksEqual(aInput, mScrap[0], true)) { + aScrapUsed += aInput.stackSize; + // Logger.INFO("Found Scrap to use."); + } + } + for (FluidStack aInput : tRecipe.mFluidInputs) { + if (aInput != null && GT_Utility.areFluidsEqual(aInput, mUU[0], true)) { + aAmplifierUsed += aInput.amount; + // Logger.INFO("Found UU-A to use."); + } + } + for (FluidStack aOutput : tRecipe.mFluidOutputs) { + if (aOutput != null && GT_Utility.areFluidsEqual(aOutput, mUU[0], true)) { + aAmplifierProduced += aOutput.amount; + // Logger.INFO("Found UU-A as Output."); + } + if (aOutput != null && GT_Utility.areFluidsEqual(aOutput, mUU[1], true)) { + aMatterProduced += aOutput.amount; + // Logger.INFO("Found UU-M as Output."); + } + } + } + + this.mMatterProduced += aMatterProduced; + this.mAmplifierProduced += aAmplifierProduced; + this.mScrapUsed += aScrapUsed; + this.mAmplifierUsed += aAmplifierUsed; + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + @Override + public int getMaxParallelRecipes() { + return this.mMode == MODE_SCRAP ? 64 : 8 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); + } + + @Override + public int getEuDiscountForParallelism() { + return 80; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + int aMode = this.mMode + 1; + if (aMode > 1) { + this.mMode = MODE_UU; + PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Matter/AmpliFabricator"); + } else if (aMode == 1) { + this.mMode = MODE_SCRAP; + PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Recycler"); + } else { + this.mMode = MODE_SCRAP; + PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Recycler"); + } + GT_Recipe_Map r = this.getRecipeMap(); + final Collection x = r.mRecipeList; + Logger.INFO("Dumping " + r.mUnlocalizedName + " Recipes for Debug. size: " + x.size()); + for (final GT_Recipe newBo : x) { + Logger.INFO("========================"); + Logger.INFO("Dumping Input: " + ItemUtils.getArrayStackNames(newBo.mInputs)); + Logger.INFO("Dumping Inputs " + ItemUtils.getFluidArrayStackNames(newBo.mFluidInputs)); + Logger.INFO("Dumping Duration: " + newBo.mDuration); + Logger.INFO("Dumping EU/t: " + newBo.mEUt); + Logger.INFO("Dumping Output: " + ItemUtils.getArrayStackNames(newBo.mOutputs)); + Logger.INFO("Dumping Output: " + ItemUtils.getFluidArrayStackNames(newBo.mFluidOutputs)); + Logger.INFO("========================"); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mScrapProduced", mScrapProduced); + aNBT.setInteger("mAmplifierProduced", mAmplifierProduced); + aNBT.setInteger("mMatterProduced", mMatterProduced); + aNBT.setInteger("mScrapUsed", mScrapUsed); + aNBT.setInteger("mAmplifierUsed", mAmplifierUsed); + aNBT.setInteger("mMode", mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mScrapProduced = aNBT.getInteger("mScrapProduced"); + mAmplifierProduced = aNBT.getInteger("mAmplifierProduced"); + mMatterProduced = aNBT.getInteger("mMatterProduced"); + mScrapUsed = aNBT.getInteger("mScrapUsed"); + mAmplifierUsed = aNBT.getInteger("mAmplifierUsed"); + mMode = aNBT.getInteger("mMode"); + super.loadNBTData(aNBT); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index c404efd1cb..a83f19fa74 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -1,5 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.filterByMTETier; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -20,240 +28,213 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.filterByMTETier; - -public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Refinery(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Refinery(final String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Fuel Refinery"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Fission Fuel Processing Unit") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 9, 3, false) - .addController("Bottom Center") - .addCasingInfo("Hastelloy-X Structural Casing", 7) - .addCasingInfo("Incoloy-DS Fluid Containment Block", 5) - .addCasingInfo("Zeron-100 Reactor Shielding", 4) - .addCasingInfo("Hastelloy-N Sealant Blocks", 17) - .addInputHatch("Base platform", 1) - .addOutputHatch("Base platform", 1) - .addOutputBus("Base platform", 1) - .addMufflerHatch("Base platform", 1) - .addMaintenanceHatch("Base platform", 1) - .addEnergyHatch("Base platform", 1) - .addStructureInfo("Muffler's Tier must be LuV+") - .addStructureInfo("4x Input Hatches, 2x Output Hatches, 1x Output Bus") - .addStructureInfo("1x Muffler, 1x Maintenance Hatch, 1x Energy Hatch") - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(18); - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return "MatterFabricator"; - } - - @Override - public GT_Recipe_Map getRecipeMap() { - return GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - //this.resetRecipeMapForAllInputHatches(); - for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { - g.mRecipeMap = null; - } - boolean ab = super.checkRecipeGeneric(); - //Logger.INFO("Did Recipe? "+ab); - return ab; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 6) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {" ", " N ", " "}, - {" N ", "NIN", " N "}, - {" N ", "NIN", " N "}, - {" N ", "NIN", " N "}, - {" Z ", "ZIZ", " Z "}, - {" N ", "NIN", " N "}, - {"XXX", "XXX", "XXX"}, - {"X~X", "XXX", "XXX"}, - })) - .addElement( - 'X', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_Refinery.class) - .atLeast(Energy, Maintenance, OutputHatch, OutputBus, InputHatch) - .casingIndex(TAE.GTPP_INDEX(18)) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_Refinery.class) - .atLeast(Muffler) - .adder(GregtechMetaTileEntity_Refinery::addMufflerToMachineList) - .hatchItemFilterAnd(t -> filterByMTETier(6, Integer.MAX_VALUE)) - .casingIndex(TAE.GTPP_INDEX(18)) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasings2Misc, 2 - ) - ) - ) - ) - .addElement( - 'I', - ofBlock( - ModBlocks.blockCasings2Misc, 3 - ) - ) - .addElement( - 'N', - ofBlock( - ModBlocks.blockCasings2Misc, 1 - ) - ) - .addElement( - 'Z', - ofBlock( - ModBlocks.blockCasingsMisc, 13 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 7, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 7, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - if (checkPiece(mName, 1, 7, 0) && mCasing >= 7) { - if (this.mInputHatches.size() == 4 && this.mOutputHatches.size() == 2 && - this.mOutputBusses.size() == 1 && this.mMufflerHatches.size() == 1 && - this.mMaintenanceHatches.size() == 1 && this.mEnergyHatches.size() == 1) { - this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); - return true; - } - } - return false; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiRefinery; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - public int getAmountOfOutputs() { - return 5; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Refinery(this.mName); - } - +public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Refinery(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_Refinery(final String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Fuel Refinery"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Fission Fuel Processing Unit") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 9, 3, false) + .addController("Bottom Center") + .addCasingInfo("Hastelloy-X Structural Casing", 7) + .addCasingInfo("Incoloy-DS Fluid Containment Block", 5) + .addCasingInfo("Zeron-100 Reactor Shielding", 4) + .addCasingInfo("Hastelloy-N Sealant Blocks", 17) + .addInputHatch("Base platform", 1) + .addOutputHatch("Base platform", 1) + .addOutputBus("Base platform", 1) + .addMufflerHatch("Base platform", 1) + .addMaintenanceHatch("Base platform", 1) + .addEnergyHatch("Base platform", 1) + .addStructureInfo("Muffler's Tier must be LuV+") + .addStructureInfo("4x Input Hatches, 2x Output Hatches, 1x Output Bus") + .addStructureInfo("1x Muffler, 1x Maintenance Hatch, 1x Energy Hatch") + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(18); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MatterFabricator"; + } + + @Override + public GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + // this.resetRecipeMapForAllInputHatches(); + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + g.mRecipeMap = null; + } + boolean ab = super.checkRecipeGeneric(); + // Logger.INFO("Did Recipe? "+ab); + return ab; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler + && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 6) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {" ", " N ", " "}, + {" N ", "NIN", " N "}, + {" N ", "NIN", " N "}, + {" N ", "NIN", " N "}, + {" Z ", "ZIZ", " Z "}, + {" N ", "NIN", " N "}, + {"XXX", "XXX", "XXX"}, + {"X~X", "XXX", "XXX"}, + })) + .addElement( + 'X', + ofChain( + buildHatchAdder(GregtechMetaTileEntity_Refinery.class) + .atLeast(Energy, Maintenance, OutputHatch, OutputBus, InputHatch) + .casingIndex(TAE.GTPP_INDEX(18)) + .dot(1) + .build(), + buildHatchAdder(GregtechMetaTileEntity_Refinery.class) + .atLeast(Muffler) + .adder(GregtechMetaTileEntity_Refinery::addMufflerToMachineList) + .hatchItemFilterAnd(t -> filterByMTETier(6, Integer.MAX_VALUE)) + .casingIndex(TAE.GTPP_INDEX(18)) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 2)))) + .addElement('I', ofBlock(ModBlocks.blockCasings2Misc, 3)) + .addElement('N', ofBlock(ModBlocks.blockCasings2Misc, 1)) + .addElement('Z', ofBlock(ModBlocks.blockCasingsMisc, 13)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 7, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 7, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 1, 7, 0) && mCasing >= 7) { + if (this.mInputHatches.size() == 4 + && this.mOutputHatches.size() == 2 + && this.mOutputBusses.size() == 1 + && this.mMufflerHatches.size() == 1 + && this.mMaintenanceHatches.size() == 1 + && this.mEnergyHatches.size() == 1) { + this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); + return true; + } + } + return false; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiRefinery; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 5; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Refinery(this.mName); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java index 7d7789b0b6..1a98737700 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java @@ -1,6 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_HatchElement.OutputHatch; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -23,6 +29,7 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.tileentities.misc.TileEntitySolarHeater; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -32,703 +39,787 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - //862 - private static final int mCasingTextureID = TAE.getIndexFromPage(3, 9); - private int mHeatLevel = 0; - private int mCasing1; - private int mCasing2; - private int mCasing3; - private int mCasing4; - - - public ArrayList mSolarHeaters = new ArrayList(); - - - public GregtechMetaTileEntity_SolarTower(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_SolarTower(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SolarTower(this.mName); - } - - @Override - public String getMachineType() { - return "Solar Tower"; - } - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Contributing Green Energy towards the future") - .addInfo("Input: "+MISC_MATERIALS.SOLAR_SALT_COLD.getLocalizedName()) - .addInfo("Output: "+MISC_MATERIALS.SOLAR_SALT_HOT.getLocalizedName()) - .addInfo("Surround with rings of Solar Heaters") - .addInfo("Each ring increases tier") - .addInfo("1 = 1, 2 = 2, 3 = 4, 4 = 8, 5 = 16") - .addInfo("Tier decreases heating time and allows more salt to be processed") - .addSeparator() - .beginStructureBlock(6, 27, 6, false) - .addController("Top Middle") - .addCasingInfo("Structural Solar Casing", 229) - .addCasingInfo("Thermally Insulated Casing", 60) - .addCasingInfo("Salt Containment Casing", 66) - .addCasingInfo("Thermal Containment Casing", 60) - .addInputHatch("Any 2 dot hint(min 1)", 2) - .addOutputHatch("Any 2 dot hint(min 1)", 2) - .addMaintenanceHatch("Any 2 dot hint", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - private static final String STRUCTURE_PIECE_BASE = "base"; - private static final String STRUCTURE_PIECE_TOWER = "tower"; - private static final String STRUCTURE_PIECE_TOP = "top"; - - private static final String[] STRUCTURE_PIECE_SOLAR_HEATER_RING = {"ring1", "ring2", "ring3", "ring4", "ring5"}; - private static final String SOLAR_HEATER_RING_1 = STRUCTURE_PIECE_SOLAR_HEATER_RING[0]; - private static final String SOLAR_HEATER_RING_2 = STRUCTURE_PIECE_SOLAR_HEATER_RING[1]; - private static final String SOLAR_HEATER_RING_3 = STRUCTURE_PIECE_SOLAR_HEATER_RING[2]; - private static final String SOLAR_HEATER_RING_4 = STRUCTURE_PIECE_SOLAR_HEATER_RING[3]; - private static final String SOLAR_HEATER_RING_5 = STRUCTURE_PIECE_SOLAR_HEATER_RING[4]; - - private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { - @Override - protected IStructureDefinition computeValue(Class type) { - return StructureDefinition.builder() - - // s = salt - // c = thermal containment - // i = thermal insulated - // t = solar structural - // h = hatch - // g = solar heater - - .addShape(STRUCTURE_PIECE_TOP, (new String[][]{ - {" ", " ", " ~ ", " ", " "}, - {" ", " s ", " sss ", " s ", " "}, - {" c ", " ccc ", "ccscc", " ccc ", " c "}, - {" c ", " ccc ", "ccscc", " ccc ", " c "}, - {" c ", " ccc ", "ccscc", " ccc ", " c "}, - {" c ", " ccc ", "ccscc", " ccc ", " c "}, - {" c ", " ccc ", "ccscc", " ccc ", " c "}, - })) - .addShape(STRUCTURE_PIECE_TOWER, (new String[][]{ - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - {" i ", "isi", " i "}, - })) - .addShape(STRUCTURE_PIECE_BASE, (new String[][]{ - {" ", " ", " t ", " ttt ", " ttstt ", " ttssstt ", " ttstt ", " ttt ", " t ", " ", " "}, - {" ", " ", " t ", " ttt ", " tssst ", " ttssstt ", " tssst ", " ttt ", " t ", " ", " "}, - {" ", " t ", " ttt ", " ttttt ", " ttssstt ", " tttsssttt ", " ttssstt ", " ttttt ", " ttt ", " t ", " "}, - {" ", " t ", " ttt ", " ttttt ", " ttssstt ", " tttsssttt ", " ttssstt ", " ttttt ", " ttt ", " t ", " "}, - {" hhh ", " ttttt ", " ttttttt ", " ttttttttt ", "htttsssttth", "htttsssttth", "htttsssttth", " ttttttttt ", " ttttttt ", " ttttt ", " hhh "}, - {" hhh ", " ttttt ", " ttttttt ", " ttttttttt ", "httttttttth", "httttttttth", "httttttttth", " ttttttttt ", " ttttttt ", " ttttt ", " hhh "}, - })) - - - .addShape(SOLAR_HEATER_RING_1, (new String[][]{ - { - " ggggg ", - " g g ", - " g g ", - " g g ", - " g g ", - "g g", - "g g", - "g g", - "g g", - "g g", - " g g ", - " g g ", - " g g ", - " g g ", - " ggggg ", - }})) - .addShape(SOLAR_HEATER_RING_2, (new String[][]{ - { - " ggggggggg ", - " g g ", - " g g ", - " g g ", - " g g ", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - " g g ", - " g g ", - " g g ", - " g g ", - " ggggggggg ", - }})) - .addShape(SOLAR_HEATER_RING_3, (new String[][]{ - { - " ggggggggggggg ", - " g g ", - " g g ", - " g g ", - " g g ", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - " g g ", - " g g ", - " g g ", - " g g ", - " ggggggggggggg ", - }})) - .addShape(SOLAR_HEATER_RING_4, (new String[][]{ - { - " ggggggggggggggggg ", - " g g ", - " g g ", - " g g ", - " g g ", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - " g g ", - " g g ", - " g g ", - " g g ", - " ggggggggggggggggg ", - }})) - .addShape(SOLAR_HEATER_RING_5, (new String[][]{ - { - " ggggggggggggggggggggg ", - " g g ", - " g g ", - " g g ", - " g g ", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - "g g", - " g g ", - " g g ", - " g g ", - " g g ", - " ggggggggggggggggggggg ", - }})) - - .addElement('g', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_SolarTower.class) - .hatchClass(TileEntitySolarHeater.class) - .adder(GregtechMetaTileEntity_SolarTower::addSolarHeater) - // use a positive casing index to make adder builder happy - .casingIndex(1) - .dot(1) - .continueIfSuccess() - .build())) - .addElement('t', lazy(t -> onElementPass(x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta())))) - .addElement('i', lazy(t -> onElementPass(x -> ++x.mCasing2, ofBlock(t.getCasingBlock(), t.getCasingMeta2())))) - .addElement('s', lazy(t -> onElementPass(x -> ++x.mCasing3, ofBlock(t.getCasingBlock(), t.getCasingMeta3())))) - .addElement('c', lazy(t -> onElementPass(x -> ++x.mCasing4, ofBlock(t.getCasingBlock2(), t.getCasingMeta4())))) - .addElement('h', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_SolarTower.class) - .atLeast(InputHatch, OutputHatch, Maintenance) - .casingIndex(t.getCasingTextureIndex()) - .dot(2) - .buildAndChain(onElementPass(x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta())))) - ) - .build(); - } - }; - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - resetSolarHeaters(); - this.mMaintenanceHatches.clear(); - this.mInputHatches.clear(); - this.mOutputHatches.clear(); - mCasing1 = 0; - mCasing2 = 0; - mCasing3 = 0; - mCasing4 = 0; - - boolean aStructureTop = checkPiece(STRUCTURE_PIECE_TOP, 2, 2, 0); - log("Top Check: "+aStructureTop); - boolean aStructureTower = checkPiece(STRUCTURE_PIECE_TOWER, 1, 1, -7); - log("Tower Check: "+aStructureTower); - boolean aStructureBase = checkPiece(STRUCTURE_PIECE_BASE, 5, 5, -22); - log("Base Check: "+aStructureBase); - boolean aCasingCount1 = mCasing1 >= 229; - boolean aCasingCount2 = mCasing2 == 60; - boolean aCasingCount3 = mCasing3 == 66; - boolean aCasingCount4 = mCasing4 == 60; - boolean aAllStructure = aStructureTop && aStructureTower && aStructureBase; - boolean aAllCasings = aCasingCount1 && aCasingCount2 && aCasingCount3 && aCasingCount4; - if (!aAllCasings || !aAllStructure || - mMaintenanceHatches.size() != 1 || - mInputHatches.size() < 1 || - mOutputHatches.size() < 1 - ) { - log("Bad Hatches - Solar Heaters: "+mSolarHeaters.size()+ - ", Maint: "+mMaintenanceHatches.size()+ - ", Input Hatches: "+mInputHatches.size()+ - ", Output Hatches: "+mOutputHatches.size()+ - ", Top: "+aStructureTop+ - ", Tower: "+aStructureTower+ - ", Base: "+aStructureBase+ - ", Casing Count: "+aCasingCount1+" | Found: "+mCasing1+ - ", Casing Count: "+aCasingCount2+" | Found: "+mCasing2+ - ", Casing Count: "+aCasingCount3+" | Found: "+mCasing3+ - ", Casing Count: "+aCasingCount4+" | Found: "+mCasing4); - return false; - } - log("Built "+this.getLocalName()+" with "+mCasing1+" Structural Solar casings, "+mCasing2+" Thermally Insulated casings, "+mCasing3+" Salt Containment casings, "+mCasing4+" Thermal Containment casings."); - return aAllCasings && aAllStructure; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - // Tower - buildPiece(STRUCTURE_PIECE_TOP, stackSize, hintsOnly, 2, 2, 0); - buildPiece(STRUCTURE_PIECE_TOWER, stackSize, hintsOnly, 1, 1, -7); - buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 5, 5, -22); - - //Solar Heaters - if (stackSize.stackSize >= 1) { - buildPiece(SOLAR_HEATER_RING_1, stackSize, hintsOnly, 7, 7, -27); - if (stackSize.stackSize >= 2) { - buildPiece(SOLAR_HEATER_RING_2, stackSize, hintsOnly, 9, 9, -27); - if (stackSize.stackSize >= 3) { - buildPiece(SOLAR_HEATER_RING_3, stackSize, hintsOnly, 11, 11, -27); - if (stackSize.stackSize >= 4) { - buildPiece(SOLAR_HEATER_RING_4, stackSize, hintsOnly, 13, 13, -27); - if (stackSize.stackSize >= 5) { - buildPiece(SOLAR_HEATER_RING_5, stackSize, hintsOnly, 15, 15, -27); - } - } - } - } - } - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - int built; - int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); - // Tower - built = survivialBuildPiece(STRUCTURE_PIECE_TOP, stackSize, 2, 2, 0, realBudget, source, actor, false, true); - if (built >= 0) return built; - built = survivialBuildPiece(STRUCTURE_PIECE_TOWER, stackSize, 1, 1, -7, realBudget, source, actor, false, true); - if (built >= 0) return built; - built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 5, 5, -22, realBudget, source, actor, false, true); - if (built >= 0) return built; - - //Solar Heaters - if (stackSize.stackSize < 1) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_1, stackSize, 7, 7, -27, realBudget, source, actor, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 2) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_2, stackSize, 9, 9, -27, realBudget, source, actor, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 3) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_3, stackSize, 11, 11, -27, realBudget, source, actor, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 4) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_4, stackSize, 13, 13, -27, realBudget, source, actor, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 5) return -1; - return survivialBuildPiece(SOLAR_HEATER_RING_5, stackSize, 15, 15, -27, realBudget, source, actor, false, true); - } - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION.get(getClass()); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(212)); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == 0 || aSide == 1) { - if (aActive) - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder().addIcon(TexturesGtBlock.Overlay_Machine_Controller_Default_Active).extFacing().build()}; - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder().addIcon(TexturesGtBlock.Overlay_Machine_Controller_Default).extFacing().build()}; - } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; - } - - @Override - public boolean hasSlotInGUI() { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - private int getHeaterTier() { - int aSolarHeaterCounter = this.mSolarHeaters.size(); - if (aSolarHeaterCounter > 0) { - if (aSolarHeaterCounter == 36) { - return 1; - } - else if (aSolarHeaterCounter == 88) { - return 2; - } - else if (aSolarHeaterCounter == 156) { - return 4; - } - else if (aSolarHeaterCounter == 240) { - return 8; - } - else if (aSolarHeaterCounter == 340) { - return 16; - } - } - return 0; - } - - private int getHeaterCountForTier(int aTier) { - switch (aTier) { - case 1: - return 36; - case 2: - return 88; - case 4: - return 156; - case 8: - return 240; - case 16: - return 340; - default: - return 0; - } - } - - public boolean getConnectedSolarReflectors(){ - - this.mSolarHeaters.clear(); - int aRing = 1; - - if (this.mSolarHeaters.size() < 36) { - // 15x15 - boolean aRing1 = checkPiece(SOLAR_HEATER_RING_1, 7, 7, -27); - if (aRing1) { - //log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 88) { - // 17x17 - boolean aRing2 = checkPiece(SOLAR_HEATER_RING_2, 9, 9, -27); - if (aRing2) { - //log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 156) { - // 19x19 - boolean aRing3 = checkPiece(SOLAR_HEATER_RING_3, 11, 11, -27); - if (aRing3) { - //log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 240) { - // 21x21 - boolean aRing4 = checkPiece(SOLAR_HEATER_RING_4, 13, 13, -27); - if (aRing4) { - //log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 340) { - // 23x23 - boolean aRing5 = checkPiece(SOLAR_HEATER_RING_5, 15, 15, -27); - if (aRing5) { - //log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - return mSolarHeaters.size() > 0; - } - - private boolean addSolarHeater(IGregTechTileEntity aTileEntity, int a) { - if (aTileEntity == null) { - return false; - } - else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof TileEntitySolarHeater) { - TileEntitySolarHeater mTile = (TileEntitySolarHeater) aMetaTileEntity; - if (!mTile.hasSolarTower() && mTile.canSeeSky()) { - //Logger.INFO("Found Solar Reflector, Injecting Data."); - mTile.setSolarTower(this); - return this.mSolarHeaters.add(mTile); - } - } - } - return false; - } - - private Fluid mColdSalt = null; - private Fluid mHotSalt = null; - - @Override - public boolean checkRecipe(final ItemStack aStack) { - this.mEfficiencyIncrease = 10; - this.mMaxProgresstime = 100; - - if (this.mSolarHeaters.isEmpty() || this.mSolarHeaters.size() < 340 || this.getTotalRuntimeInTicks() % 200 == 0) { - getConnectedSolarReflectors(); - } - - int aTier = getHeaterTier(); - int aHeaters = getHeaterCountForTier(aTier); - - //Manage Heat every 5s - //Add Heat First, if sources available - if (aHeaters > 0) { - for (int i = 0; i < aHeaters; i++) { - Math.min((this.mHeatLevel += aTier), 20000); - } - } - - //Remove Heat, based on time of day - if (mHeatLevel > 0) { - if (mHeatLevel > 20000) { - this.mHeatLevel = 20000; - } - } - World w = this.getBaseMetaTileEntity().getWorld(); - if (w != null) { - int aRemovalFactor = 0; - if (w.isDaytime()) { - aRemovalFactor = 1; - } - else { - aRemovalFactor = 8; - } - for (int i = 0; i= 10000) { - if (mColdSalt == null) { - mColdSalt = MISC_MATERIALS.SOLAR_SALT_COLD.getFluid(); - } - if (mHotSalt == null) { - mHotSalt = MISC_MATERIALS.SOLAR_SALT_HOT.getFluid(); - } - ArrayList aFluids = this.getStoredFluids(); - for (FluidStack aFluid : aFluids) { - if (aFluid.getFluid().equals(mColdSalt)) { - if (aFluid.amount >= (aTier * 1000)) { - this.depleteInput(FluidUtils.getFluidStack(mColdSalt, (aTier * 1000))); - this.addOutput(FluidUtils.getFluidStack(mHotSalt, (aTier * 1000))); - break; - } - } - } - } - - - return true; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockSpecialMultiCasings; - } - - public Block getCasingBlock2() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta() { - return 6; - } - - - public byte getCasingMeta2() { - return 8; - } - - - public byte getCasingMeta3() { - return 7; - } - - public byte getCasingMeta4() { - return 11; - } - - public byte getCasingTextureIndex() { - return (byte) mCasingTextureID; - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - - - - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mHeatLevel", mHeatLevel); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mHeatLevel = aNBT.getInteger("mHeatLevel"); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - // Fix GT bug - if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { - this.getBaseMetaTileEntity().setFrontFacing((byte) 1); - } - } - - @Override - public void onRemoval() { - resetSolarHeaters(); - super.onRemoval(); - } - - private void resetSolarHeaters() { - for (TileEntitySolarHeater aTile : this.mSolarHeaters) { - aTile.clearSolarTower(); - } - this.mSolarHeaters.clear(); - } - - @Override - public String[] getExtraInfoData() { - return new String[] { - "Internal Heat Level: "+this.mHeatLevel, - "Connected Solar Reflectors: "+this.mSolarHeaters.size() - }; - } - +public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + // 862 + private static final int mCasingTextureID = TAE.getIndexFromPage(3, 9); + private int mHeatLevel = 0; + private int mCasing1; + private int mCasing2; + private int mCasing3; + private int mCasing4; + + public ArrayList mSolarHeaters = new ArrayList(); + + public GregtechMetaTileEntity_SolarTower(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_SolarTower(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_SolarTower(this.mName); + } + + @Override + public String getMachineType() { + return "Solar Tower"; + } + + @Override + protected final GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Contributing Green Energy towards the future") + .addInfo("Input: " + MISC_MATERIALS.SOLAR_SALT_COLD.getLocalizedName()) + .addInfo("Output: " + MISC_MATERIALS.SOLAR_SALT_HOT.getLocalizedName()) + .addInfo("Surround with rings of Solar Heaters") + .addInfo("Each ring increases tier") + .addInfo("1 = 1, 2 = 2, 3 = 4, 4 = 8, 5 = 16") + .addInfo("Tier decreases heating time and allows more salt to be processed") + .addSeparator() + .beginStructureBlock(6, 27, 6, false) + .addController("Top Middle") + .addCasingInfo("Structural Solar Casing", 229) + .addCasingInfo("Thermally Insulated Casing", 60) + .addCasingInfo("Salt Containment Casing", 66) + .addCasingInfo("Thermal Containment Casing", 60) + .addInputHatch("Any 2 dot hint(min 1)", 2) + .addOutputHatch("Any 2 dot hint(min 1)", 2) + .addMaintenanceHatch("Any 2 dot hint", 2) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + private static final String STRUCTURE_PIECE_BASE = "base"; + private static final String STRUCTURE_PIECE_TOWER = "tower"; + private static final String STRUCTURE_PIECE_TOP = "top"; + + private static final String[] STRUCTURE_PIECE_SOLAR_HEATER_RING = {"ring1", "ring2", "ring3", "ring4", "ring5"}; + private static final String SOLAR_HEATER_RING_1 = STRUCTURE_PIECE_SOLAR_HEATER_RING[0]; + private static final String SOLAR_HEATER_RING_2 = STRUCTURE_PIECE_SOLAR_HEATER_RING[1]; + private static final String SOLAR_HEATER_RING_3 = STRUCTURE_PIECE_SOLAR_HEATER_RING[2]; + private static final String SOLAR_HEATER_RING_4 = STRUCTURE_PIECE_SOLAR_HEATER_RING[3]; + private static final String SOLAR_HEATER_RING_5 = STRUCTURE_PIECE_SOLAR_HEATER_RING[4]; + + private static final ClassValue> STRUCTURE_DEFINITION = + new ClassValue>() { + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + + // s = salt + // c = thermal containment + // i = thermal insulated + // t = solar structural + // h = hatch + // g = solar heater + + .addShape(STRUCTURE_PIECE_TOP, (new String[][] { + {" ", " ", " ~ ", " ", " "}, + {" ", " s ", " sss ", " s ", " "}, + {" c ", " ccc ", "ccscc", " ccc ", " c "}, + {" c ", " ccc ", "ccscc", " ccc ", " c "}, + {" c ", " ccc ", "ccscc", " ccc ", " c "}, + {" c ", " ccc ", "ccscc", " ccc ", " c "}, + {" c ", " ccc ", "ccscc", " ccc ", " c "}, + })) + .addShape(STRUCTURE_PIECE_TOWER, (new String[][] { + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + {" i ", "isi", " i "}, + })) + .addShape(STRUCTURE_PIECE_BASE, (new String[][] { + { + " ", + " ", + " t ", + " ttt ", + " ttstt ", + " ttssstt ", + " ttstt ", + " ttt ", + " t ", + " ", + " " + }, + { + " ", + " ", + " t ", + " ttt ", + " tssst ", + " ttssstt ", + " tssst ", + " ttt ", + " t ", + " ", + " " + }, + { + " ", + " t ", + " ttt ", + " ttttt ", + " ttssstt ", + " tttsssttt ", + " ttssstt ", + " ttttt ", + " ttt ", + " t ", + " " + }, + { + " ", + " t ", + " ttt ", + " ttttt ", + " ttssstt ", + " tttsssttt ", + " ttssstt ", + " ttttt ", + " ttt ", + " t ", + " " + }, + { + " hhh ", + " ttttt ", + " ttttttt ", + " ttttttttt ", + "htttsssttth", + "htttsssttth", + "htttsssttth", + " ttttttttt ", + " ttttttt ", + " ttttt ", + " hhh " + }, + { + " hhh ", + " ttttt ", + " ttttttt ", + " ttttttttt ", + "httttttttth", + "httttttttth", + "httttttttth", + " ttttttttt ", + " ttttttt ", + " ttttt ", + " hhh " + }, + })) + .addShape(SOLAR_HEATER_RING_1, (new String[][] { + { + " ggggg ", + " g g ", + " g g ", + " g g ", + " g g ", + "g g", + "g g", + "g g", + "g g", + "g g", + " g g ", + " g g ", + " g g ", + " g g ", + " ggggg ", + } + })) + .addShape(SOLAR_HEATER_RING_2, (new String[][] { + { + " ggggggggg ", + " g g ", + " g g ", + " g g ", + " g g ", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + " g g ", + " g g ", + " g g ", + " g g ", + " ggggggggg ", + } + })) + .addShape(SOLAR_HEATER_RING_3, (new String[][] { + { + " ggggggggggggg ", + " g g ", + " g g ", + " g g ", + " g g ", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + " g g ", + " g g ", + " g g ", + " g g ", + " ggggggggggggg ", + } + })) + .addShape(SOLAR_HEATER_RING_4, (new String[][] { + { + " ggggggggggggggggg ", + " g g ", + " g g ", + " g g ", + " g g ", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + " g g ", + " g g ", + " g g ", + " g g ", + " ggggggggggggggggg ", + } + })) + .addShape(SOLAR_HEATER_RING_5, (new String[][] { + { + " ggggggggggggggggggggg ", + " g g ", + " g g ", + " g g ", + " g g ", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + "g g", + " g g ", + " g g ", + " g g ", + " g g ", + " ggggggggggggggggggggg ", + } + })) + .addElement('g', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_SolarTower.class) + .hatchClass(TileEntitySolarHeater.class) + .adder(GregtechMetaTileEntity_SolarTower::addSolarHeater) + // use a positive casing index to make adder builder happy + .casingIndex(1) + .dot(1) + .continueIfSuccess() + .build())) + .addElement( + 't', + lazy(t -> onElementPass( + x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta())))) + .addElement( + 'i', + lazy(t -> onElementPass( + x -> ++x.mCasing2, ofBlock(t.getCasingBlock(), t.getCasingMeta2())))) + .addElement( + 's', + lazy(t -> onElementPass( + x -> ++x.mCasing3, ofBlock(t.getCasingBlock(), t.getCasingMeta3())))) + .addElement( + 'c', + lazy(t -> onElementPass( + x -> ++x.mCasing4, ofBlock(t.getCasingBlock2(), t.getCasingMeta4())))) + .addElement('h', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_SolarTower.class) + .atLeast(InputHatch, OutputHatch, Maintenance) + .casingIndex(t.getCasingTextureIndex()) + .dot(2) + .buildAndChain(onElementPass( + x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta()))))) + .build(); + } + }; + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + resetSolarHeaters(); + this.mMaintenanceHatches.clear(); + this.mInputHatches.clear(); + this.mOutputHatches.clear(); + mCasing1 = 0; + mCasing2 = 0; + mCasing3 = 0; + mCasing4 = 0; + + boolean aStructureTop = checkPiece(STRUCTURE_PIECE_TOP, 2, 2, 0); + log("Top Check: " + aStructureTop); + boolean aStructureTower = checkPiece(STRUCTURE_PIECE_TOWER, 1, 1, -7); + log("Tower Check: " + aStructureTower); + boolean aStructureBase = checkPiece(STRUCTURE_PIECE_BASE, 5, 5, -22); + log("Base Check: " + aStructureBase); + boolean aCasingCount1 = mCasing1 >= 229; + boolean aCasingCount2 = mCasing2 == 60; + boolean aCasingCount3 = mCasing3 == 66; + boolean aCasingCount4 = mCasing4 == 60; + boolean aAllStructure = aStructureTop && aStructureTower && aStructureBase; + boolean aAllCasings = aCasingCount1 && aCasingCount2 && aCasingCount3 && aCasingCount4; + if (!aAllCasings + || !aAllStructure + || mMaintenanceHatches.size() != 1 + || mInputHatches.size() < 1 + || mOutputHatches.size() < 1) { + log("Bad Hatches - Solar Heaters: " + mSolarHeaters.size() + ", Maint: " + + mMaintenanceHatches.size() + ", Input Hatches: " + + mInputHatches.size() + ", Output Hatches: " + + mOutputHatches.size() + ", Top: " + + aStructureTop + ", Tower: " + + aStructureTower + ", Base: " + + aStructureBase + ", Casing Count: " + + aCasingCount1 + " | Found: " + mCasing1 + ", Casing Count: " + + aCasingCount2 + " | Found: " + mCasing2 + ", Casing Count: " + + aCasingCount3 + " | Found: " + mCasing3 + ", Casing Count: " + + aCasingCount4 + " | Found: " + mCasing4); + return false; + } + log("Built " + this.getLocalName() + " with " + mCasing1 + " Structural Solar casings, " + mCasing2 + + " Thermally Insulated casings, " + mCasing3 + " Salt Containment casings, " + mCasing4 + + " Thermal Containment casings."); + return aAllCasings && aAllStructure; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + // Tower + buildPiece(STRUCTURE_PIECE_TOP, stackSize, hintsOnly, 2, 2, 0); + buildPiece(STRUCTURE_PIECE_TOWER, stackSize, hintsOnly, 1, 1, -7); + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 5, 5, -22); + + // Solar Heaters + if (stackSize.stackSize >= 1) { + buildPiece(SOLAR_HEATER_RING_1, stackSize, hintsOnly, 7, 7, -27); + if (stackSize.stackSize >= 2) { + buildPiece(SOLAR_HEATER_RING_2, stackSize, hintsOnly, 9, 9, -27); + if (stackSize.stackSize >= 3) { + buildPiece(SOLAR_HEATER_RING_3, stackSize, hintsOnly, 11, 11, -27); + if (stackSize.stackSize >= 4) { + buildPiece(SOLAR_HEATER_RING_4, stackSize, hintsOnly, 13, 13, -27); + if (stackSize.stackSize >= 5) { + buildPiece(SOLAR_HEATER_RING_5, stackSize, hintsOnly, 15, 15, -27); + } + } + } + } + } + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + int built; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); + // Tower + built = survivialBuildPiece(STRUCTURE_PIECE_TOP, stackSize, 2, 2, 0, realBudget, source, actor, false, true); + if (built >= 0) return built; + built = survivialBuildPiece(STRUCTURE_PIECE_TOWER, stackSize, 1, 1, -7, realBudget, source, actor, false, true); + if (built >= 0) return built; + built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 5, 5, -22, realBudget, source, actor, false, true); + if (built >= 0) return built; + + // Solar Heaters + if (stackSize.stackSize < 1) return -1; + built = survivialBuildPiece(SOLAR_HEATER_RING_1, stackSize, 7, 7, -27, realBudget, source, actor, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 2) return -1; + built = survivialBuildPiece(SOLAR_HEATER_RING_2, stackSize, 9, 9, -27, realBudget, source, actor, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 3) return -1; + built = survivialBuildPiece( + SOLAR_HEATER_RING_3, stackSize, 11, 11, -27, realBudget, source, actor, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 4) return -1; + built = survivialBuildPiece( + SOLAR_HEATER_RING_4, stackSize, 13, 13, -27, realBudget, source, actor, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 5) return -1; + return survivialBuildPiece(SOLAR_HEATER_RING_5, stackSize, 15, 15, -27, realBudget, source, actor, false, true); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION.get(getClass()); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(212)); + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == 0 || aSide == 1) { + if (aActive) + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Machine_Controller_Default_Active) + .extFacing() + .build() + }; + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Machine_Controller_Default) + .extFacing() + .build() + }; + } + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + private int getHeaterTier() { + int aSolarHeaterCounter = this.mSolarHeaters.size(); + if (aSolarHeaterCounter > 0) { + if (aSolarHeaterCounter == 36) { + return 1; + } else if (aSolarHeaterCounter == 88) { + return 2; + } else if (aSolarHeaterCounter == 156) { + return 4; + } else if (aSolarHeaterCounter == 240) { + return 8; + } else if (aSolarHeaterCounter == 340) { + return 16; + } + } + return 0; + } + + private int getHeaterCountForTier(int aTier) { + switch (aTier) { + case 1: + return 36; + case 2: + return 88; + case 4: + return 156; + case 8: + return 240; + case 16: + return 340; + default: + return 0; + } + } + + public boolean getConnectedSolarReflectors() { + + this.mSolarHeaters.clear(); + int aRing = 1; + + if (this.mSolarHeaters.size() < 36) { + // 15x15 + boolean aRing1 = checkPiece(SOLAR_HEATER_RING_1, 7, 7, -27); + if (aRing1) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 88) { + // 17x17 + boolean aRing2 = checkPiece(SOLAR_HEATER_RING_2, 9, 9, -27); + if (aRing2) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 156) { + // 19x19 + boolean aRing3 = checkPiece(SOLAR_HEATER_RING_3, 11, 11, -27); + if (aRing3) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 240) { + // 21x21 + boolean aRing4 = checkPiece(SOLAR_HEATER_RING_4, 13, 13, -27); + if (aRing4) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 340) { + // 23x23 + boolean aRing5 = checkPiece(SOLAR_HEATER_RING_5, 15, 15, -27); + if (aRing5) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + return mSolarHeaters.size() > 0; + } + + private boolean addSolarHeater(IGregTechTileEntity aTileEntity, int a) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof TileEntitySolarHeater) { + TileEntitySolarHeater mTile = (TileEntitySolarHeater) aMetaTileEntity; + if (!mTile.hasSolarTower() && mTile.canSeeSky()) { + // Logger.INFO("Found Solar Reflector, Injecting Data."); + mTile.setSolarTower(this); + return this.mSolarHeaters.add(mTile); + } + } + } + return false; + } + + private Fluid mColdSalt = null; + private Fluid mHotSalt = null; + + @Override + public boolean checkRecipe(final ItemStack aStack) { + this.mEfficiencyIncrease = 10; + this.mMaxProgresstime = 100; + + if (this.mSolarHeaters.isEmpty() + || this.mSolarHeaters.size() < 340 + || this.getTotalRuntimeInTicks() % 200 == 0) { + getConnectedSolarReflectors(); + } + + int aTier = getHeaterTier(); + int aHeaters = getHeaterCountForTier(aTier); + + // Manage Heat every 5s + // Add Heat First, if sources available + if (aHeaters > 0) { + for (int i = 0; i < aHeaters; i++) { + Math.min((this.mHeatLevel += aTier), 20000); + } + } + + // Remove Heat, based on time of day + if (mHeatLevel > 0) { + if (mHeatLevel > 20000) { + this.mHeatLevel = 20000; + } + } + World w = this.getBaseMetaTileEntity().getWorld(); + if (w != null) { + int aRemovalFactor = 0; + if (w.isDaytime()) { + aRemovalFactor = 1; + } else { + aRemovalFactor = 8; + } + for (int i = 0; i < MathUtils.randInt((aHeaters / 10), aHeaters); i++) { + this.mHeatLevel -= aRemovalFactor; + } + } + + if (this.mEfficiency == this.getMaxEfficiency(null) && this.mHeatLevel >= 10000) { + if (mColdSalt == null) { + mColdSalt = MISC_MATERIALS.SOLAR_SALT_COLD.getFluid(); + } + if (mHotSalt == null) { + mHotSalt = MISC_MATERIALS.SOLAR_SALT_HOT.getFluid(); + } + ArrayList aFluids = this.getStoredFluids(); + for (FluidStack aFluid : aFluids) { + if (aFluid.getFluid().equals(mColdSalt)) { + if (aFluid.amount >= (aTier * 1000)) { + this.depleteInput(FluidUtils.getFluidStack(mColdSalt, (aTier * 1000))); + this.addOutput(FluidUtils.getFluidStack(mHotSalt, (aTier * 1000))); + break; + } + } + } + } + + return true; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockSpecialMultiCasings; + } + + public Block getCasingBlock2() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 6; + } + + public byte getCasingMeta2() { + return 8; + } + + public byte getCasingMeta3() { + return 7; + } + + public byte getCasingMeta4() { + return 11; + } + + public byte getCasingTextureIndex() { + return (byte) mCasingTextureID; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {} + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mHeatLevel", mHeatLevel); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mHeatLevel = aNBT.getInteger("mHeatLevel"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Fix GT bug + if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { + this.getBaseMetaTileEntity().setFrontFacing((byte) 1); + } + } + + @Override + public void onRemoval() { + resetSolarHeaters(); + super.onRemoval(); + } + + private void resetSolarHeaters() { + for (TileEntitySolarHeater aTile : this.mSolarHeaters) { + aTile.clearSolarTower(); + } + this.mSolarHeaters.clear(); + } + + @Override + public String[] getExtraInfoData() { + return new String[] { + "Internal Heat Level: " + this.mHeatLevel, "Connected Solar Reflectors: " + this.mSolarHeaters.size() + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java index 312c58722e..f7e60432c8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -1,7 +1,14 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae; -import java.util.ArrayList; -import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.InputBus; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.OutputBus; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -28,6 +35,8 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; import ic2.core.init.BlocksItems; import ic2.core.init.InternalName; +import java.util.ArrayList; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; @@ -36,469 +45,479 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.InputBus; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mLevel = -1; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - private int checkMeta; - private int minTierOfHatch; - private static final Class cofhWater; - - static { - cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); - } - - public GregtechMTE_AlgaePondBase(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_AlgaePondBase(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_AlgaePondBase(this.mName); - } - - @Override - public String getMachineType() { - return "Algae Pond"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Grows Algae!") - .addInfo("Controller Block for the Algae Farm") - .addInfo("Provide compost to boost production by one tier") - .addInfo("Does not require power or maintenance") - .addInfo("All Machine Casings must be the same tier, this dictates machine speed.") - .addInfo("All Buses/Hatches must, at least, match the tier of the Casings") - .addInfo("Fill Input Hatch with Water to fill the inside of the multiblock.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(9, 3, 9, true) - .addController("Front Center") - .addCasingInfo("Machine Casings", 64) - .addCasingInfo("Sterile Farm Casings", 34) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - public void setMeta(int meta) { - checkMeta = meta; - } - - public int getMeta() { - return checkMeta; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, - {"XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, - {"CCCC~CCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMTE_AlgaePondBase.class) - .atLeast(InputHatch, InputBus, OutputBus) - .casingIndex(TAE.getIndexFromPage(1, 15)) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - addTieredBlock( - GregTech_API.sBlockCasings1, GregtechMTE_AlgaePondBase::setMeta, GregtechMTE_AlgaePondBase::getMeta, 10 - ) - ) - ) - ) - .addElement( - 'X', - ofBlock( - ModBlocks.blockCasings2Misc, 15 - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 4, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 4, 2, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mLevel = 0; - checkMeta = 0; - minTierOfHatch = 100; - if (checkPiece(mName, 4, 2, 0) && mCasing >= 64 && checkMeta > 0) { - mLevel = checkMeta - 1; - return mLevel <= minTierOfHatch; - } - return false; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // fuck - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(207)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Default; - } - - @Override - protected int getCasingTextureId() { - int aID = TAE.getIndexFromPage(1, 15); - if (mLevel > -1) { - aID = mLevel; - } - return aID; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - @Override - public int getMaxParallelRecipes() { - return 2; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - public boolean checkForWater() { - - // Get Facing direction - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - mCurrentDirectionX = 4; - mCurrentDirectionZ = 4; - - mOffsetX_Lower = -4; - mOffsetX_Upper = 4; - mOffsetZ_Lower = -4; - mOffsetZ_Upper = 4; - - // if (aBaseMetaTileEntity.fac) - - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX - * mCurrentDirectionX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ - * mCurrentDirectionZ; - - int tAmount = 0; - for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { - for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { - for (int h = 0; h < 2; h++) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (isNotStaticWater(tBlock, tMeta)) { - if (this.getStoredFluids() != null) { - for (FluidStack stored : this.getStoredFluids()) { - if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { - if (stored.amount >= 1000) { - // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); - stored.amount -= 1000; - Block fluidUsed = Blocks.water; - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getXCoord() + xDir + i, - aBaseMetaTileEntity.getYCoord() + h, - aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); - - } - } - } - } - } - tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { - ++tAmount; - // Logger.INFO("Found Water"); - } - } - } - } - - boolean isValidWater = tAmount >= 49; - - if (isValidWater) { - Logger.INFO("Filled structure."); - return true; - } - else { - return false; - } - } - - private boolean isNotStaticWater(Block block, byte meta) { - return block == Blocks.air - || block == Blocks.flowing_water - || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) - || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAlgaePond; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - this.fixAllMaintenanceIssue(); - // Silly Client Syncing - if (aBaseMetaTileEntity.isClientSide()) { - this.mLevel = getCasingTier(); - } - - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); - } - - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - if (this.mLevel < 0) { - Logger.INFO("Bad Tier."); - return false; - } - - if (!checkForWater()) { - Logger.INFO("Not enough Water."); - return false; - } - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - Logger.INFO("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); - - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - return false; - } - if (tRecipe.mInputs.length > 0) { - for (ItemStack aInputToConsume : tRecipe.mInputs) { - this.depleteInput(aInputToConsume); - } - } - - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - this.mMaxProgresstime = (int)(tRecipe.mDuration); - this.mEUt = 0; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - Logger.INFO("Recipe time: "+this.mMaxProgresstime); - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= aMaxParallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < aMaxParallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - Logger.INFO("GOOD RETURN - 1"); - return true; - - } - - private boolean isUsingCompost(ItemStack[] aItemInputs) { - ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); - for (ItemStack i : aItemInputs) { - if (GT_Utility.areStacksEqual(aCompost, i)) { - if (i.stackSize >= 8) { - return true; - } - } - } - return false; - } - - - private int getCasingTier() { - if (this.getBaseMetaTileEntity().getWorld() == null) { - return 0; - } - try { - Block aInitStructureCheck; - int aInitStructureCheckMeta; - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); - aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); - if (aInitStructureCheck == GregTech_API.sBlockCasings1) { - return aInitStructureCheckMeta; - } - return 0; - } - catch (Throwable t) { - t.printStackTrace(); - return 0; - } - } - - - +public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mLevel = -1; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + private int checkMeta; + private int minTierOfHatch; + private static final Class cofhWater; + + static { + cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); + } + + public GregtechMTE_AlgaePondBase(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_AlgaePondBase(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_AlgaePondBase(this.mName); + } + + @Override + public String getMachineType() { + return "Algae Pond"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Grows Algae!") + .addInfo("Controller Block for the Algae Farm") + .addInfo("Provide compost to boost production by one tier") + .addInfo("Does not require power or maintenance") + .addInfo("All Machine Casings must be the same tier, this dictates machine speed.") + .addInfo("All Buses/Hatches must, at least, match the tier of the Casings") + .addInfo("Fill Input Hatch with Water to fill the inside of the multiblock.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 3, 9, true) + .addController("Front Center") + .addCasingInfo("Machine Casings", 64) + .addCasingInfo("Sterile Farm Casings", 34) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + public void setMeta(int meta) { + checkMeta = meta; + } + + public int getMeta() { + return checkMeta; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + { + "XXXXXXXXX", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "XXXXXXXXX" + }, + { + "XXXXXXXXX", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "X X", + "XXXXXXXXX" + }, + { + "CCCC~CCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC" + }, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMTE_AlgaePondBase.class) + .atLeast(InputHatch, InputBus, OutputBus) + .casingIndex(TAE.getIndexFromPage(1, 15)) + .dot(1) + .build(), + onElementPass( + x -> ++x.mCasing, + addTieredBlock( + GregTech_API.sBlockCasings1, + GregtechMTE_AlgaePondBase::setMeta, + GregtechMTE_AlgaePondBase::getMeta, + 10)))) + .addElement('X', ofBlock(ModBlocks.blockCasings2Misc, 15)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 4, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 4, 2, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mLevel = 0; + checkMeta = 0; + minTierOfHatch = 100; + if (checkPiece(mName, 4, 2, 0) && mCasing >= 64 && checkMeta > 0) { + mLevel = checkMeta - 1; + return mLevel <= minTierOfHatch; + } + return false; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // fuck + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Default; + } + + @Override + protected int getCasingTextureId() { + int aID = TAE.getIndexFromPage(1, 15); + if (mLevel > -1) { + aID = mLevel; + } + return aID; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public int getMaxParallelRecipes() { + return 2; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * mCurrentDirectionX; + final int zDir = + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (isNotStaticWater(tBlock, tMeta)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity + .getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + fluidUsed); + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // Logger.INFO("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 49; + + if (isValidWater) { + Logger.INFO("Filled structure."); + return true; + } else { + return false; + } + } + + private boolean isNotStaticWater(Block block, byte meta) { + return block == Blocks.air + || block == Blocks.flowing_water + || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) + || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAlgaePond; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + this.fixAllMaintenanceIssue(); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mLevel = getCasingTier(); + } + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + + if (this.mLevel < 0) { + Logger.INFO("Bad Tier."); + return false; + } + + if (!checkForWater()) { + Logger.INFO("Not enough Water."); + return false; + } + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + Logger.INFO("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); + + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + return false; + } + if (tRecipe.mInputs.length > 0) { + for (ItemStack aInputToConsume : tRecipe.mInputs) { + this.depleteInput(aInputToConsume); + } + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + this.mMaxProgresstime = (int) (tRecipe.mDuration); + this.mEUt = 0; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + Logger.INFO("Recipe time: " + this.mMaxProgresstime); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= aMaxParallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < aMaxParallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.INFO("GOOD RETURN - 1"); + return true; + } + + private boolean isUsingCompost(ItemStack[] aItemInputs) { + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); + for (ItemStack i : aItemInputs) { + if (GT_Utility.areStacksEqual(aCompost, i)) { + if (i.stackSize >= 8) { + return true; + } + } + } + return false; + } + + private int getCasingTier() { + if (this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); + if (aInitStructureCheck == GregTech_API.sBlockCasings1) { + return aInitStructureCheckMeta; + } + return 0; + } catch (Throwable t) { + t.printStackTrace(); + return 0; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java index 018120d614..875c449f2d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java @@ -1,11 +1,6 @@ /* package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.bedrock; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.core.material.ALLOY; -import gtPlusPlus.core.material.Material; public class GregtechMetaTileEntity_BedrockMiningPlatform1 extends GregtechMetaTileEntity_BedrockMiningPlatformBase { public GregtechMetaTileEntity_BedrockMiningPlatform1(final int aID, final String aName, final String aNameRegional) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java index 6b97cb7ee2..f67ecfe87f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java @@ -1,11 +1,6 @@ /* package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.bedrock; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.Material; public class GregtechMetaTileEntity_BedrockMiningPlatform2 extends GregtechMetaTileEntity_BedrockMiningPlatformBase { public GregtechMetaTileEntity_BedrockMiningPlatform2(final int aID, final String aName, final String aNameRegional) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java index b74f2459a3..50c10bab0d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java @@ -32,653 +32,608 @@ import net.minecraftforge.common.util.ForgeDirection; public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends GregtechMeta_MultiBlockBase { - protected double mProductionModifier = 0; - - - private static final ItemStack miningPipe; - private static final ItemStack miningPipeTip; - - private Block casingBlock; - private int casingMeta; - // private int frameMeta; - private int casingTextureIndex; - - private ForgeDirection back; - - private int xDrill; - private int yDrill; - private int zDrill; - - private int[] xCenter = new int[5]; - private int[] zCenter = new int[5]; - - public GregtechMetaTileEntity_BedrockMiningPlatformBase(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - this.initFields(); - } - - public GregtechMetaTileEntity_BedrockMiningPlatformBase(final String aName) { - super(aName); - this.initFields(); - } - - private void initFields() { - this.casingBlock = this.getCasingBlockItem().getBlock(); - this.casingMeta = this.getCasingBlockItem().get(0L, new Object[0]).getItemDamage(); - this.casingTextureIndex = this.getCasingTextureIndex(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT; - } - - @Override - protected int getCasingTextureId() { - return this.casingTextureIndex; - } - - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "OreDrillingPlant.png"); - } - - - public int getAmountOfOutputs() { - return 1; - } - - public void saveNBTData(final NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setDouble("mProductionModifier", mProductionModifier); - } - - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mProductionModifier = aNBT.getDouble("mProductionModifier"); - } - - public boolean checkRecipe(final ItemStack aStack) { - //this.setElectricityStats(); - - - if (true) { - return false; - } - - boolean[] didWork = new boolean[5]; - - if (!this.tryConsumeDrillingFluid()) { - Logger.INFO("No drilling Fluid."); - return false; - } - - if (MathUtils.isNumberEven((int) this.mProductionModifier)) { - if (!this.tryConsumePyrotheum()) { - Logger.INFO("No tryConsumePyrotheum Fluid."); - return false; - } - else { - mProductionModifier++; - } - } - else { - if (!this.tryConsumeCryotheum()) { - Logger.INFO("No tryConsumeCryotheum Fluid."); - return false; - } - else { - mProductionModifier++; - } - } - - for (int i = 0; i < 5; i++) { - process(); - didWork[i] = true; - } - - // Fail recipe handling if one pipe didn't handle properly, to try again - // next run. - for (boolean y : didWork) { - if (!y) { - Logger.INFO("[Bedrock Miner] Fail [x]"); - return false; - } - } - - this.mEUt = -8000; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 10000; - - return true; - } - - private boolean isEnergyEnough() { - long requiredEnergy = 512L + this.getMaxInputVoltage() * 4L; - for (final GT_MetaTileEntity_Hatch_Energy energyHatch : this.mEnergyHatches) { - requiredEnergy -= energyHatch.getEUVar(); - if (requiredEnergy <= 0L) { - return true; - } - } - return false; - } - - private void setElectricityStats() { - //this.mEfficiency = this.getCurrentEfficiency((ItemStack) null); - this.mEfficiencyIncrease = 10000; - final int overclock = 8 << GT_Utility.getTier(this.getMaxInputVoltage()); - //this.mEUt = -12 * overclock * overclock; - Logger.INFO("Trying to set EU to "+(12 * overclock * overclock)); - int mCombinedAvgTime = 0; - for (int g = 0; g < 5; g++) { - mCombinedAvgTime += this.getBaseProgressTime() / overclock; - } - Logger.INFO("Trying to set Max Time to "+(mCombinedAvgTime)); - //this.mMaxProgresstime = (mCombinedAvgTime / 5); - } - - private boolean tryConsumeDrillingFluid() { - boolean consumed = false; - boolean g = (this.getBaseMetaTileEntity().getWorld().getTotalWorldTime() % 2 == 0); - consumed = (g ? tryConsumePyrotheum() : tryConsumeCryotheum()); - if (consumed) { - //increaseProduction(g ? 2 : 1); - } - else { - //lowerProduction(g ? 5 : 3); - } - return consumed; - } - - private boolean tryConsumePyrotheum() { - return this.depleteInput(FluidUtils.getFluidStack("pyrotheum", 4)); - } - - private boolean tryConsumeCryotheum() { - return this.depleteInput(FluidUtils.getFluidStack("cryotheum", 4)); - } - - private void putMiningPipesFromInputsInController() { - final int maxPipes = 64; - if (this.isHasMiningPipes(maxPipes)) { - return; - } - ItemStack pipes = this.getStackInSlot(1); - for (final ItemStack storedItem : this.getStoredInputs()) { - if (!storedItem.isItemEqual(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe)) { - continue; - } - if (pipes == null) { - this.setInventorySlotContents(1, - GT_Utility.copy(new Object[] { GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe })); - pipes = this.getStackInSlot(1); - } - if (pipes.stackSize == maxPipes) { - break; - } - final int needPipes = maxPipes - pipes.stackSize; - final int transferPipes = (storedItem.stackSize < needPipes) ? storedItem.stackSize : needPipes; - final ItemStack itemStack = pipes; - itemStack.stackSize += transferPipes; - final ItemStack itemStack2 = storedItem; - itemStack2.stackSize -= transferPipes; - } - this.updateSlots(); - } - - - - private boolean isHasMiningPipes(final int minCount) { - final ItemStack pipe = this.getStackInSlot(1); - return pipe != null && pipe.stackSize > minCount - 1 - && pipe.isItemEqual(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe); - } - - public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - this.updateCoordinates(); - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int tAmount = 0; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } else { - - Block aCasing = Block.getBlockFromItem(getCasingBlockItem().getItem()); - - for (int i = -1; i < 2; ++i) { - for (int j = -1; j < 2; ++j) { - for (int h = -1; h < 2; ++h) { - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); - Block aBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - int aMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - - if (!this.addToMachineList(tTileEntity, 48)) { - if (aBlock != aCasing) { - Logger.INFO("Found Bad Casing"); - return false; - } - if (aMeta != 3) { - Logger.INFO("Found Bad Meta"); - return false; - } - } - ++tAmount; - - - - /*if (!isValidBlockForStructure(tTileEntity, 48, true, aBlock, aMeta, sBlockCasings4, 0)) { - Logger.INFO("Bad centrifuge casing"); - return false; - }*/ - - } - } - } - } - return tAmount >= 10; - } - - } - - private void updateCoordinates() { - this.xDrill = this.getBaseMetaTileEntity().getXCoord(); - this.yDrill = this.getBaseMetaTileEntity().getYCoord()-1; - this.zDrill = this.getBaseMetaTileEntity().getZCoord(); - this.back = ForgeDirection.getOrientation((int) this.getBaseMetaTileEntity().getBackFacing()); - - // Middle - this.xCenter[0] = this.xDrill + this.back.offsetX; - this.zCenter[0] = this.zDrill + this.back.offsetZ; - - this.xCenter[1] = xCenter[0] + 1; - this.zCenter[1] = zCenter[0]; - - this.xCenter[2] = xCenter[0] - 1; - this.zCenter[2] = zCenter[0]; - - this.xCenter[3] = xCenter[0]; - this.zCenter[3] = zCenter[0] + 1; - - this.xCenter[4] = xCenter[0]; - this.zCenter[4] = zCenter[0] - 1; - - } - - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - protected GregtechItemList getCasingBlockItem() { - return GregtechItemList.Casing_BedrockMiner; - } - - protected abstract Material getFrameMaterial(); - - protected abstract int getCasingTextureIndex(); - - protected abstract int getRadiusInChunks(); - - protected abstract int getMinTier(); - - protected abstract int getBaseProgressTime(); - - protected String[] getDescriptionInternal(final String tierSuffix) { - final String casings = this.getCasingBlockItem().get(0L, new Object[0]).getDisplayName(); - return new String[] { - "Controller Block for the Experimental Deep Earth Drilling Platform - MK " - + ((tierSuffix != null) ? tierSuffix : ""), - "Size(WxHxD): 3x7x3, Controller (Front middle bottom)", "3x1x3 Base of " + casings, - "1x3x1 " + casings + " pillar (Center of base)", - "1x3x1 " + this.getFrameMaterial().getLocalizedName() + " Frame Boxes (Each pillar side and on top)", - "2x Input Hatch (Any bottom layer casing)", - "1x Input Bus for mining pipes (Any bottom layer casing; not necessary)", - "1x Output Bus (Any bottom layer casing)", "1x Maintenance Hatch (Any bottom layer casing)", - "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", - "Radius is " + (this.getRadiusInChunks() << 4) + " blocks", - "Every tick, this machine altenates betweem consumption of Pyrotheum & Cryotheum", - "Pyrotheum is used to bore through the Mantle of the world", - "Cryotheum is used to keep the internal components cool",}; - } - - static { - miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0L); - miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0L); - } - - - - - - - - - - - - - - - - - - - - - - - - - - private AutoMap mOutputs; - - public void process() { - ItemStack aOutput = generateOutputWithchance(); - if (aOutput != null) { - this.addOutput(aOutput); - Logger.INFO("Mined some "+aOutput.getDisplayName()); - } - this.updateSlots(); - } - - public ItemStack generateOutputWithchance() { - int aChance = MathUtils.randInt(0, 7500); - if (aChance < 100) { - return generateOutput(); - } - else { - return null; - } - } - - public ItemStack generateOutput() { - AutoMap aData = generateOreForOutput(); - int aMax = aData.size()-1; - return aData.get(MathUtils.randInt(0, aMax)); - } - - /** - * Here we generate valid ores and also a basic loot set - */ - - public AutoMap generateOreForOutput() { - - if (mOutputs != null) { - return mOutputs; - } - - AutoMap aOverWorldOres = MiningUtils.getOresForDim(0); - AutoMap aNetherOres = MiningUtils.getOresForDim(-1); - AutoMap aEndOres = MiningUtils.getOresForDim(1); - - AutoMap aTempMap = new AutoMap(); - Block tOreBlock = GregTech_API.sBlockOres1; - Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Initial]"); - - for (GT_Worldgen_GT_Ore_Layer layer : aOverWorldOres) { - if (layer.mEnabled) { - ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); - ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); - ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); - ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); - aTempMap.put(aTempOreStack1); - aTempMap.put(aTempOreStack2); - aTempMap.put(aTempOreStack3); - aTempMap.put(aTempOreStack4); - aTempMap.put(aTempOreStack1); - aTempMap.put(aTempOreStack2); - aTempMap.put(aTempOreStack3); - aTempMap.put(aTempOreStack4); - aTempMap.put(aTempOreStack1); - aTempMap.put(aTempOreStack2); - aTempMap.put(aTempOreStack3); - aTempMap.put(aTempOreStack4); - } - } - Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Overworld]"); - for (GT_Worldgen_GT_Ore_Layer layer : aNetherOres) { - if (layer.mEnabled) { - ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); - ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); - ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); - ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); - aTempMap.put(aTempOreStack1); - aTempMap.put(aTempOreStack2); - aTempMap.put(aTempOreStack3); - aTempMap.put(aTempOreStack4); - aTempMap.put(aTempOreStack1); - aTempMap.put(aTempOreStack2); - aTempMap.put(aTempOreStack3); - aTempMap.put(aTempOreStack4); - } - } - Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Nether]"); - for (GT_Worldgen_GT_Ore_Layer layer : aEndOres) { - if (layer.mEnabled) { - ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); - ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); - ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); - ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); - aTempMap.put(aTempOreStack1); - aTempMap.put(aTempOreStack2); - aTempMap.put(aTempOreStack3); - aTempMap.put(aTempOreStack4); - } - } - Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [End]"); - - addOreTypeToMap(ELEMENT.getInstance().IRON, 200, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().COPPER, 175, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().TIN, 150, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().GOLD, 150, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().SILVER, 110, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().NICKEL, 40, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().ZINC, 40, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().LEAD, 40, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().ALUMINIUM, 30, aTempMap); - addOreTypeToMap(ELEMENT.getInstance().THORIUM, 20, aTempMap); - Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Extra Common Ores]"); - - AutoMap> mMixedOreData = new AutoMap>(); - mMixedOreData.put(new Pair("oreRuby", 30)); - mMixedOreData.put(new Pair("oreSapphire", 25)); - mMixedOreData.put(new Pair("oreEmerald", 25)); - mMixedOreData.put(new Pair("oreLapis", 40)); - mMixedOreData.put(new Pair("oreRedstone", 40)); - - if (LoadedMods.Thaumcraft || (OreDictUtils.containsValidEntries("oreAmber") && OreDictUtils.containsValidEntries("oreCinnabar"))) { - mMixedOreData.put(new Pair("oreAmber", 20)); - mMixedOreData.put(new Pair("oreCinnabar", 20)); - } - if (LoadedMods.Railcraft || OreDictUtils.containsValidEntries("oreSaltpeter")) { - mMixedOreData.put(new Pair("oreSaltpeter", 10)); - } - if (LoadedMods.IndustrialCraft2 || OreDictUtils.containsValidEntries("oreUranium")) { - mMixedOreData.put(new Pair("oreUranium", 10)); - } - if (OreDictUtils.containsValidEntries("oreSulfur")) { - mMixedOreData.put(new Pair("oreSulfur", 15)); - } - if (OreDictUtils.containsValidEntries("oreSilicon")) { - mMixedOreData.put(new Pair("oreSilicon", 15)); - } - if (OreDictUtils.containsValidEntries("oreApatite")) { - mMixedOreData.put(new Pair("oreApatite", 25)); - } - - mMixedOreData.put(new Pair("oreFirestone", 2)); - mMixedOreData.put(new Pair("oreBismuth", 20)); - mMixedOreData.put(new Pair("oreLithium", 20)); - mMixedOreData.put(new Pair("oreManganese", 20)); - mMixedOreData.put(new Pair("oreBeryllium", 20)); - mMixedOreData.put(new Pair("oreCoal", 75)); - mMixedOreData.put(new Pair("oreLignite", 75)); - mMixedOreData.put(new Pair("oreSalt", 15)); - mMixedOreData.put(new Pair("oreCalcite", 15)); - mMixedOreData.put(new Pair("oreBauxite", 20)); - mMixedOreData.put(new Pair("oreAlmandine", 15)); - mMixedOreData.put(new Pair("oreGraphite", 25)); - mMixedOreData.put(new Pair("oreGlauconite", 15)); - mMixedOreData.put(new Pair("orePyrolusite", 15)); - mMixedOreData.put(new Pair("oreGrossular", 15)); - mMixedOreData.put(new Pair("oreTantalite", 15)); - - for (Pair g : mMixedOreData) { - for (int i=0; i aMyOreMaterials = new AutoMap(); - aMyOreMaterials.add(ORES.CROCROITE); - aMyOreMaterials.add(ORES.GEIKIELITE); - aMyOreMaterials.add(ORES.NICHROMITE); - aMyOreMaterials.add(ORES.TITANITE); - aMyOreMaterials.add(ORES.ZIMBABWEITE); - aMyOreMaterials.add(ORES.ZIRCONILITE); - aMyOreMaterials.add(ORES.GADOLINITE_CE); - aMyOreMaterials.add(ORES.GADOLINITE_Y); - aMyOreMaterials.add(ORES.LEPERSONNITE); - aMyOreMaterials.add(ORES.SAMARSKITE_Y); - aMyOreMaterials.add(ORES.SAMARSKITE_YB); - aMyOreMaterials.add(ORES.XENOTIME); - aMyOreMaterials.add(ORES.YTTRIAITE); - aMyOreMaterials.add(ORES.YTTRIALITE); - aMyOreMaterials.add(ORES.YTTROCERITE); - aMyOreMaterials.add(ORES.ZIRCON); - aMyOreMaterials.add(ORES.POLYCRASE); - aMyOreMaterials.add(ORES.ZIRCOPHYLLITE); - aMyOreMaterials.add(ORES.ZIRKELITE); - aMyOreMaterials.add(ORES.LANTHANITE_LA); - aMyOreMaterials.add(ORES.LANTHANITE_CE); - aMyOreMaterials.add(ORES.LANTHANITE_ND); - aMyOreMaterials.add(ORES.AGARDITE_Y); - aMyOreMaterials.add(ORES.AGARDITE_CD); - aMyOreMaterials.add(ORES.AGARDITE_LA); - aMyOreMaterials.add(ORES.AGARDITE_ND); - aMyOreMaterials.add(ORES.HIBONITE); - aMyOreMaterials.add(ORES.CERITE); - aMyOreMaterials.add(ORES.FLUORCAPHITE); - aMyOreMaterials.add(ORES.FLORENCITE); - aMyOreMaterials.add(ORES.CRYOLITE); - aMyOreMaterials.add(ORES.LAUTARITE); - aMyOreMaterials.add(ORES.LAFOSSAITE); - aMyOreMaterials.add(ORES.DEMICHELEITE_BR); - aMyOreMaterials.add(ORES.COMANCHEITE); - aMyOreMaterials.add(ORES.PERROUDITE); - aMyOreMaterials.add(ORES.HONEAITE); - aMyOreMaterials.add(ORES.ALBURNITE); - aMyOreMaterials.add(ORES.MIESSIITE); - aMyOreMaterials.add(ORES.KASHINITE); - aMyOreMaterials.add(ORES.IRARSITE); - aMyOreMaterials.add(ORES.RADIOBARITE); - aMyOreMaterials.add(ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT); - - for (Material aOreType : aMyOreMaterials) { - if (aOreType == ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT || aOreType == ORES.RADIOBARITE) { - addOreTypeToMap(aOreType, 4, aTempMap); - } - else { - addOreTypeToMap(aOreType, 7, aTempMap); - } - } - - //Cleanup Map - Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [GT++]"); - AutoMap aCleanUp = new AutoMap(); - for (ItemStack verify : aTempMap) { - if (!ItemUtils.checkForInvalidItems(verify)) { - aCleanUp.put(verify); - } - } - Logger.INFO("Cleanup Map contains "+aCleanUp.size()+" values."); - for (ItemStack remove : aCleanUp) { - aTempMap.remove(remove); - } - - //Generate Massive Map - AutoMap aFinalMap = new AutoMap(); - for (ItemStack aTempItem : aTempMap) { - int aTempMulti = MathUtils.randInt(20, 50); - for (int i=0;i aMap) { - for (int i=0; i minCount - 1 + && pipe.isItemEqual(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe); + } + + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + this.updateCoordinates(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int tAmount = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } else { + + Block aCasing = Block.getBlockFromItem(getCasingBlockItem().getItem()); + + for (int i = -1; i < 2; ++i) { + for (int j = -1; j < 2; ++j) { + for (int h = -1; h < 2; ++h) { + if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { + IGregTechTileEntity tTileEntity = + aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + Block aBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + + if (!this.addToMachineList(tTileEntity, 48)) { + if (aBlock != aCasing) { + Logger.INFO("Found Bad Casing"); + return false; + } + if (aMeta != 3) { + Logger.INFO("Found Bad Meta"); + return false; + } + } + ++tAmount; + + /*if (!isValidBlockForStructure(tTileEntity, 48, true, aBlock, aMeta, sBlockCasings4, 0)) { + Logger.INFO("Bad centrifuge casing"); + return false; + }*/ + + } + } + } + } + return tAmount >= 10; + } + } + + private void updateCoordinates() { + this.xDrill = this.getBaseMetaTileEntity().getXCoord(); + this.yDrill = this.getBaseMetaTileEntity().getYCoord() - 1; + this.zDrill = this.getBaseMetaTileEntity().getZCoord(); + this.back = + ForgeDirection.getOrientation((int) this.getBaseMetaTileEntity().getBackFacing()); + + // Middle + this.xCenter[0] = this.xDrill + this.back.offsetX; + this.zCenter[0] = this.zDrill + this.back.offsetZ; + + this.xCenter[1] = xCenter[0] + 1; + this.zCenter[1] = zCenter[0]; + + this.xCenter[2] = xCenter[0] - 1; + this.zCenter[2] = zCenter[0]; + + this.xCenter[3] = xCenter[0]; + this.zCenter[3] = zCenter[0] + 1; + + this.xCenter[4] = xCenter[0]; + this.zCenter[4] = zCenter[0] - 1; + } + + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + protected GregtechItemList getCasingBlockItem() { + return GregtechItemList.Casing_BedrockMiner; + } + + protected abstract Material getFrameMaterial(); + + protected abstract int getCasingTextureIndex(); + + protected abstract int getRadiusInChunks(); + + protected abstract int getMinTier(); + + protected abstract int getBaseProgressTime(); + + protected String[] getDescriptionInternal(final String tierSuffix) { + final String casings = this.getCasingBlockItem().get(0L, new Object[0]).getDisplayName(); + return new String[] { + "Controller Block for the Experimental Deep Earth Drilling Platform - MK " + + ((tierSuffix != null) ? tierSuffix : ""), + "Size(WxHxD): 3x7x3, Controller (Front middle bottom)", + "3x1x3 Base of " + casings, + "1x3x1 " + casings + " pillar (Center of base)", + "1x3x1 " + this.getFrameMaterial().getLocalizedName() + " Frame Boxes (Each pillar side and on top)", + "2x Input Hatch (Any bottom layer casing)", + "1x Input Bus for mining pipes (Any bottom layer casing; not necessary)", + "1x Output Bus (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", + "Radius is " + (this.getRadiusInChunks() << 4) + " blocks", + "Every tick, this machine altenates betweem consumption of Pyrotheum & Cryotheum", + "Pyrotheum is used to bore through the Mantle of the world", + "Cryotheum is used to keep the internal components cool", + }; + } + + static { + miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0L); + miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0L); + } + + private AutoMap mOutputs; + + public void process() { + ItemStack aOutput = generateOutputWithchance(); + if (aOutput != null) { + this.addOutput(aOutput); + Logger.INFO("Mined some " + aOutput.getDisplayName()); + } + this.updateSlots(); + } + + public ItemStack generateOutputWithchance() { + int aChance = MathUtils.randInt(0, 7500); + if (aChance < 100) { + return generateOutput(); + } else { + return null; + } + } + + public ItemStack generateOutput() { + AutoMap aData = generateOreForOutput(); + int aMax = aData.size() - 1; + return aData.get(MathUtils.randInt(0, aMax)); + } + + /** + * Here we generate valid ores and also a basic loot set + */ + public AutoMap generateOreForOutput() { + + if (mOutputs != null) { + return mOutputs; + } + + AutoMap aOverWorldOres = MiningUtils.getOresForDim(0); + AutoMap aNetherOres = MiningUtils.getOresForDim(-1); + AutoMap aEndOres = MiningUtils.getOresForDim(1); + + AutoMap aTempMap = new AutoMap(); + Block tOreBlock = GregTech_API.sBlockOres1; + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [Initial]"); + + for (GT_Worldgen_GT_Ore_Layer layer : aOverWorldOres) { + if (layer.mEnabled) { + ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); + ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); + ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); + ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + } + } + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [Overworld]"); + for (GT_Worldgen_GT_Ore_Layer layer : aNetherOres) { + if (layer.mEnabled) { + ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); + ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); + ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); + ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + } + } + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [Nether]"); + for (GT_Worldgen_GT_Ore_Layer layer : aEndOres) { + if (layer.mEnabled) { + ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); + ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); + ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); + ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + } + } + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [End]"); + + addOreTypeToMap(ELEMENT.getInstance().IRON, 200, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().COPPER, 175, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().TIN, 150, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().GOLD, 150, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().SILVER, 110, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().NICKEL, 40, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().ZINC, 40, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().LEAD, 40, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().ALUMINIUM, 30, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().THORIUM, 20, aTempMap); + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [Extra Common Ores]"); + + AutoMap> mMixedOreData = new AutoMap>(); + mMixedOreData.put(new Pair("oreRuby", 30)); + mMixedOreData.put(new Pair("oreSapphire", 25)); + mMixedOreData.put(new Pair("oreEmerald", 25)); + mMixedOreData.put(new Pair("oreLapis", 40)); + mMixedOreData.put(new Pair("oreRedstone", 40)); + + if (LoadedMods.Thaumcraft + || (OreDictUtils.containsValidEntries("oreAmber") + && OreDictUtils.containsValidEntries("oreCinnabar"))) { + mMixedOreData.put(new Pair("oreAmber", 20)); + mMixedOreData.put(new Pair("oreCinnabar", 20)); + } + if (LoadedMods.Railcraft || OreDictUtils.containsValidEntries("oreSaltpeter")) { + mMixedOreData.put(new Pair("oreSaltpeter", 10)); + } + if (LoadedMods.IndustrialCraft2 || OreDictUtils.containsValidEntries("oreUranium")) { + mMixedOreData.put(new Pair("oreUranium", 10)); + } + if (OreDictUtils.containsValidEntries("oreSulfur")) { + mMixedOreData.put(new Pair("oreSulfur", 15)); + } + if (OreDictUtils.containsValidEntries("oreSilicon")) { + mMixedOreData.put(new Pair("oreSilicon", 15)); + } + if (OreDictUtils.containsValidEntries("oreApatite")) { + mMixedOreData.put(new Pair("oreApatite", 25)); + } + + mMixedOreData.put(new Pair("oreFirestone", 2)); + mMixedOreData.put(new Pair("oreBismuth", 20)); + mMixedOreData.put(new Pair("oreLithium", 20)); + mMixedOreData.put(new Pair("oreManganese", 20)); + mMixedOreData.put(new Pair("oreBeryllium", 20)); + mMixedOreData.put(new Pair("oreCoal", 75)); + mMixedOreData.put(new Pair("oreLignite", 75)); + mMixedOreData.put(new Pair("oreSalt", 15)); + mMixedOreData.put(new Pair("oreCalcite", 15)); + mMixedOreData.put(new Pair("oreBauxite", 20)); + mMixedOreData.put(new Pair("oreAlmandine", 15)); + mMixedOreData.put(new Pair("oreGraphite", 25)); + mMixedOreData.put(new Pair("oreGlauconite", 15)); + mMixedOreData.put(new Pair("orePyrolusite", 15)); + mMixedOreData.put(new Pair("oreGrossular", 15)); + mMixedOreData.put(new Pair("oreTantalite", 15)); + + for (Pair g : mMixedOreData) { + for (int i = 0; i < g.getValue(); i++) { + aTempMap.put(ItemUtils.getItemStackOfAmountFromOreDict(g.getKey(), 1)); + } + } + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [Extra Mixed Ores]"); + + addOreTypeToMap(ELEMENT.STANDALONE.RUNITE, 2, aTempMap); + addOreTypeToMap(ELEMENT.STANDALONE.GRANITE, 8, aTempMap); + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [OSRS Ores]"); + + AutoMap aMyOreMaterials = new AutoMap(); + aMyOreMaterials.add(ORES.CROCROITE); + aMyOreMaterials.add(ORES.GEIKIELITE); + aMyOreMaterials.add(ORES.NICHROMITE); + aMyOreMaterials.add(ORES.TITANITE); + aMyOreMaterials.add(ORES.ZIMBABWEITE); + aMyOreMaterials.add(ORES.ZIRCONILITE); + aMyOreMaterials.add(ORES.GADOLINITE_CE); + aMyOreMaterials.add(ORES.GADOLINITE_Y); + aMyOreMaterials.add(ORES.LEPERSONNITE); + aMyOreMaterials.add(ORES.SAMARSKITE_Y); + aMyOreMaterials.add(ORES.SAMARSKITE_YB); + aMyOreMaterials.add(ORES.XENOTIME); + aMyOreMaterials.add(ORES.YTTRIAITE); + aMyOreMaterials.add(ORES.YTTRIALITE); + aMyOreMaterials.add(ORES.YTTROCERITE); + aMyOreMaterials.add(ORES.ZIRCON); + aMyOreMaterials.add(ORES.POLYCRASE); + aMyOreMaterials.add(ORES.ZIRCOPHYLLITE); + aMyOreMaterials.add(ORES.ZIRKELITE); + aMyOreMaterials.add(ORES.LANTHANITE_LA); + aMyOreMaterials.add(ORES.LANTHANITE_CE); + aMyOreMaterials.add(ORES.LANTHANITE_ND); + aMyOreMaterials.add(ORES.AGARDITE_Y); + aMyOreMaterials.add(ORES.AGARDITE_CD); + aMyOreMaterials.add(ORES.AGARDITE_LA); + aMyOreMaterials.add(ORES.AGARDITE_ND); + aMyOreMaterials.add(ORES.HIBONITE); + aMyOreMaterials.add(ORES.CERITE); + aMyOreMaterials.add(ORES.FLUORCAPHITE); + aMyOreMaterials.add(ORES.FLORENCITE); + aMyOreMaterials.add(ORES.CRYOLITE); + aMyOreMaterials.add(ORES.LAUTARITE); + aMyOreMaterials.add(ORES.LAFOSSAITE); + aMyOreMaterials.add(ORES.DEMICHELEITE_BR); + aMyOreMaterials.add(ORES.COMANCHEITE); + aMyOreMaterials.add(ORES.PERROUDITE); + aMyOreMaterials.add(ORES.HONEAITE); + aMyOreMaterials.add(ORES.ALBURNITE); + aMyOreMaterials.add(ORES.MIESSIITE); + aMyOreMaterials.add(ORES.KASHINITE); + aMyOreMaterials.add(ORES.IRARSITE); + aMyOreMaterials.add(ORES.RADIOBARITE); + aMyOreMaterials.add(ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT); + + for (Material aOreType : aMyOreMaterials) { + if (aOreType == ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT || aOreType == ORES.RADIOBARITE) { + addOreTypeToMap(aOreType, 4, aTempMap); + } else { + addOreTypeToMap(aOreType, 7, aTempMap); + } + } + + // Cleanup Map + Logger.INFO("Ore Map contains " + aTempMap.size() + " values. [GT++]"); + AutoMap aCleanUp = new AutoMap(); + for (ItemStack verify : aTempMap) { + if (!ItemUtils.checkForInvalidItems(verify)) { + aCleanUp.put(verify); + } + } + Logger.INFO("Cleanup Map contains " + aCleanUp.size() + " values."); + for (ItemStack remove : aCleanUp) { + aTempMap.remove(remove); + } + + // Generate Massive Map + AutoMap aFinalMap = new AutoMap(); + for (ItemStack aTempItem : aTempMap) { + int aTempMulti = MathUtils.randInt(20, 50); + for (int i = 0; i < aTempMulti; i++) { + aFinalMap.put(aTempItem.copy()); + } + } + Logger.INFO("Final Ore Map contains " + aFinalMap.size() + " values."); + mOutputs = aFinalMap; + return mOutputs; + } + + private static void addOreTypeToMap(Material aMaterial, int aAmount, AutoMap aMap) { + for (int i = 0; i < aAmount; i++) { + aMap.add(aMaterial.getOre(1)); + } + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Miner"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 77916eb9f4..87442949a5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -1,11 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.IntStream; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.filterByMTETier; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -32,953 +34,995 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.tuple.Pair; - - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.filterByMTETier; -import static gregtech.api.util.GT_StructureUtility.ofCoil; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; -public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mSolidCasingTier = 0; - private int mMachineCasingTier = 0; - private int mPipeCasingTier = 0; - private int mCoilTier = 0; - private HeatingCoilLevel checkCoil; - private int[] checkCasing = new int[8]; - private int checkMachine; - private int checkPipe; - private int maxTierOfHatch; - private int mCasing; - private IStructureDefinition STRUCTURE_DEFINITION = null; - - private final ArrayList mCatalystBuses = new ArrayList(); - - private static final HashMap> mTieredBlockRegistry = new HashMap<>(); - - public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_ChemicalPlant(final String aName) { - super(aName); - } - - public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { - Triplet aCasingData = new Triplet(aBlock, aMeta, aCasingTextureID); - if (mTieredBlockRegistry.containsKey(aTier)) { - CORE.crash("Tried to register a Machine casing for tier "+aTier+" to the Chemical Plant, however this tier already contains one."); - } - mTieredBlockRegistry.put(aTier, aCasingData); - return true; - } - - private static int getCasingTextureIdForTier(int aTier) { - if (!mTieredBlockRegistry.containsKey(aTier)) { - return 10; - } - int aCasingID = mTieredBlockRegistry.get(aTier).getValue_3(); - //Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); - return aCasingID; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_ChemicalPlant(this.mName); - } - - @Override - public String getMachineType() { - return "Chemical Plant"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Chemical Plant") - .addInfo("Heavy Industry, now right at your doorstep!") - .addInfo("Please read the user manual for more information on construction and usage") - .addSeparator() - .addController("Bottom Center") - .addStructureHint("Catalyst Housing", 1) - .addInputBus("Bottom Casing", 1) - .addOutputBus("Bottom Casing", 1) - .addInputHatch("Bottom Casing", 1) - .addOutputHatch("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .addSubChannelUsage("casing", "metal machine casing") - .addSubChannelUsage("machine", "tier machine casing") - .addSubChannelUsage("coil", "heating coil blocks") - .addSubChannelUsage("pipe", "pipe casing blocks") - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - public void setMachineMeta(int meta) { - checkMachine = meta; - } - - public int getMachineMeta() { - return checkMachine; - } - - public void setPipeMeta(int meta) { - checkPipe = meta; - } - - public int getPipeMeta() { - return checkPipe; - } - - public void setCoilMeta(HeatingCoilLevel meta) { - checkCoil = meta; - } - - public HeatingCoilLevel getCoilMeta() { - return checkCoil; - } - - public int coilTier(int meta) { - switch (meta) { - case 0: return 1; - case 1: return 2; - case 2: return 3; - case 3: return 4; - case 4: return 5; - case 5: return 7; - case 6: return 8; - case 7: return 10; - case 8: return 11; - case 9: return 6; - case 10: return 9; - case 11: return 12; - case 12: return 13; - case 13: return 14; - default: return 0; - } - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - IStructureElement allCasingsElement = withChannel( - "casing", - ofChain( - IntStream.range(0, 8) - .mapToObj(GregtechMTE_ChemicalPlant::ofSolidCasing) - .collect(Collectors.toList()) - ) - ); - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][]{ - {"XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX"}, - {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, - {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, - {"X X", " ", " HHH ", " HHH ", " HHH ", " ", "X X"}, - {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, - {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, - {"CCC~CCC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CCCCCCC"}, - })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMTE_ChemicalPlant.class) - .atLeast(Maintenance) - .casingIndex(getCasingTextureID()) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_ChemicalPlant.class) - .atLeast(InputHatch, OutputHatch, InputBus, OutputBus) - .adder(GregtechMTE_ChemicalPlant::addChemicalPlantList) - .hatchItemFilterAnd((t, s) -> filterByMTETier(Integer.MIN_VALUE, s.stackSize >= 10 ? Integer.MAX_VALUE : s.stackSize)) - .casingIndex(getCasingTextureID()) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_ChemicalPlant.class) - .hatchClass(GT_MetaTileEntity_Hatch_Catalysts.class) - .adder(GregtechMTE_ChemicalPlant::addChemicalPlantList) - .casingIndex(getCasingTextureID()) - .dot(1) - .build(), - allCasingsElement - ) - ) - .addElement( - 'X', - allCasingsElement - ) - .addElement( - 'M', - withChannel( - "machine", - addTieredBlock( - GregTech_API.sBlockCasings1, GregtechMTE_ChemicalPlant::setMachineMeta, GregtechMTE_ChemicalPlant::getMachineMeta, 10 - ) - ) - ) - .addElement( - 'H', - withChannel( - "coil", - ofCoil(GregtechMTE_ChemicalPlant::setCoilMeta, GregtechMTE_ChemicalPlant::getCoilMeta) - ) - ) - .addElement( - 'P', - withChannel( - "pipe", - addTieredBlock( - GregTech_API.sBlockCasings2, GregtechMTE_ChemicalPlant::setPipeMeta, GregtechMTE_ChemicalPlant::getPipeMeta, 12, 16 - ) - ) - ) - .build(); - } - return STRUCTURE_DEFINITION; - } - - private static IStructureElement ofSolidCasing(int aIndex) { - return new IStructureElement() { - @Override - public boolean check(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z) { - if (check(aIndex, world, x, y, z)) { - t.checkCasing[aIndex]++; - t.mCasing++; - return true; - } - else return false; - } - - private boolean check(int aIndex, World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - Block target = mTieredBlockRegistry.get(aIndex).getValue_1(); - int targetMeta = mTieredBlockRegistry.get(aIndex).getValue_2(); - return target.equals(block) && meta == targetMeta; - } - - int getIndex(int size) { - if (size > 8) size = 8; - return size - 1; - } - - @Override - public boolean spawnHint(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2()); - return true; - } - - @Override - public boolean placeBlock(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, ItemStack trigger) { - return world.setBlock(x, y, z, mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2(), 3); - } - - @Override - public PlaceResult survivalPlaceBlock(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer chatter) { - if (check(getIndex(trigger.stackSize), world, x, y, z)) return PlaceResult.SKIP; - return StructureUtility.survivalPlaceBlock(mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2(), world, x, y, z, s, actor, chatter); - } - }; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 3, 6, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 3, 6, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - for (int i = 0; i < 8; i++) { - checkCasing[i] = 0; - } - checkPipe = 0; - checkMachine = 0; - mSolidCasingTier = 0; - mMachineCasingTier = 0; - mPipeCasingTier = 0; - mCoilTier = 0; - mCatalystBuses.clear(); - if (checkPiece(mName, 3, 6, 0) && mCasing >= 70) { - for (int i = 0; i < 8; i++) { - if (checkCasing[i] == mCasing) { - mSolidCasingTier = i; - } - else if (checkCasing[i] > 0) - return false; - } - mMachineCasingTier = checkMachine - 1; - mPipeCasingTier = checkPipe - 12; - mCoilTier = checkCoil.getTier(); - getBaseMetaTileEntity().sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, getUpdateData()); - updateHatchTexture(); - return mMachineCasingTier >= 9 || mMachineCasingTier >= maxTierOfHatch; - } - return false; - } - - public void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mCatalystBuses) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mInputBusses) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mMaintenanceHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mEnergyHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mOutputBusses) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mInputHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); - } - - public final boolean addChemicalPlantList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(207)); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureID(); - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - if (GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList.size() == 0) { - generateRecipes(); - } - return GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT; - } - - public static void generateRecipes() { - for (GT_Recipe i : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { - GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.add(i); - } - } - - @Override - public int getMaxParallelRecipes() { - return 2 * getPipeCasingTier(); - } - - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - private int getSolidCasingTier() { - return this.mSolidCasingTier; - } - - private int getMachineCasingTier() { - return mMachineCasingTier; - } - - private int getPipeCasingTier() { - return mPipeCasingTier; - } - - private int getCasingTextureID() { - // Check the Tier Client Side - int aTier = mSolidCasingTier; - return getCasingTextureIdForTier(aTier); - } - - public boolean addToMachineList(IGregTechTileEntity aTileEntity) { - int aMaxTier = getMachineCasingTier(); - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { - GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; - int aTileTier = aMachineBlock.mTier; - if (aTileTier > aMaxTier) { - log("Hatch tier too high."); - return false; - } - else { - return addToMachineList(aTileEntity, getCasingTextureID()); - } - } - else { - log("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. - return false; - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); - aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); - aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); - aNBT.setInteger("mCoilTier", this.mCoilTier); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); - mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); - mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); - mCoilTier = aNBT.getInteger("mCoilTier"); - } - - @Override - public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { - log("Found GT_MetaTileEntity_Hatch_Catalysts"); - return addToMachineListInternal(mCatalystBuses, aMetaTileEntity, aBaseCasingIndex); - } - return super.addToMachineList(aTileEntity, aBaseCasingIndex); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - // Same speed bonus as pyro oven - public int getSpeedBonus() { - return 50 * (this.mCoilTier - 1); - } - - public int getMaxCatalystDurability() { - return 50; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mCatalystBuses.clear(); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public byte getUpdateData() { - return (byte) mSolidCasingTier; - } - - @Override - public void receiveClientEvent(byte aEventID, byte aValue) { - super.receiveClientEvent(aEventID, aValue); - if (aEventID == GregTechTileClientEvents.CHANGE_CUSTOM_DATA && (aValue & 0x80) == 0) { - // received an update data from above method - // if no &0x80 clause it might catch the noop texture page event - mSolidCasingTier = aValue; - } - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), getSpeedBonus()); - } - - @Override - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - ArrayList tItems = getStoredInputs(); - ArrayList tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); - } - - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - //GT_Recipe tRecipe = findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - GT_Recipe tRecipe = findRecipe(mLastRecipe, gregtech.api.enums.GT_Values.V[tTier], getSolidCasingTier(), aItemInputs, aFluidInputs); - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - // checks if it has a catalyst - ItemStack tCatalystRecipe = null; - boolean aDoesRecipeNeedCatalyst = false; - for (ItemStack aInputItem : tRecipe.mInputs) { - if (ItemUtils.isCatalyst(aInputItem)) { - aDoesRecipeNeedCatalyst = true; - break; - } - } - if (aDoesRecipeNeedCatalyst) { - tCatalystRecipe = findCatalyst(aItemInputs, tRecipe.mInputs); - if (tCatalystRecipe == null) { - log("does not have catalyst"); - return false; - } - if (mCatalystBuses.size() != 1) { - log("does not have correct number of catalyst hatches. (Required 1, found "+mCatalystBuses.size()+")"); - return false; - } - } - - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe.mSpecialValue > this.mSolidCasingTier) { - log("solid tier is too low"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // checks if it has enough catalyst durability - ArrayListtCatalysts = null; - int tMaxParallelCatalyst = aMaxParallelRecipes; - if (tCatalystRecipe != null) { - tCatalysts = new ArrayList(); - tMaxParallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); - log("Can process "+tMaxParallelCatalyst+" recipes. If less than "+aMaxParallelRecipes+", catalyst does not have enough durability."); - } - - if (tMaxParallelCatalyst == 0) { - log("found not enough catalysts"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - log("aEUPercent "+aEUPercent); - log("mEUt "+tRecipe.mEUt); - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+tMaxParallelCatalyst); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tEnergy: "+tEnergy); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < tMaxParallelCatalyst && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Damage catalyst once all is said and done. - if (tCatalystRecipe != null) { - log("damaging catalyst"); - damageCatalyst(tCatalystRecipe, parallelRecipes); - } - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - for (GT_MetaTileEntity_Hatch_Catalysts h : mCatalystBuses) { - h.updateSlots(); - h.tryFillUsageSlots(); - } - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } - - private static final HashMap> mTieredRecipeMap = new HashMap>(); - private static final AutoMap aTier0Recipes = new AutoMap(); - private static final AutoMap aTier1Recipes = new AutoMap(); - private static final AutoMap aTier2Recipes = new AutoMap(); - private static final AutoMap aTier3Recipes = new AutoMap(); - private static final AutoMap aTier4Recipes = new AutoMap(); - private static final AutoMap aTier5Recipes = new AutoMap(); - private static final AutoMap aTier6Recipes = new AutoMap(); - private static final AutoMap aTier7Recipes = new AutoMap(); - private static boolean mInitRecipeCache = false; - - private static void initRecipeCaches() { - if (!mInitRecipeCache) { - mTieredRecipeMap.put((long) 0, aTier0Recipes); - mTieredRecipeMap.put((long) 1, aTier1Recipes); - mTieredRecipeMap.put((long) 2, aTier2Recipes); - mTieredRecipeMap.put((long) 3, aTier3Recipes); - mTieredRecipeMap.put((long) 4, aTier4Recipes); - mTieredRecipeMap.put((long) 5, aTier5Recipes); - mTieredRecipeMap.put((long) 6, aTier6Recipes); - mTieredRecipeMap.put((long) 7, aTier7Recipes); - for (GT_Recipe aRecipe : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList) { - if (aRecipe != null) { - switch (aRecipe.mSpecialValue) { - case 0: - aTier0Recipes.add(aRecipe); - continue; - case 1: - aTier1Recipes.add(aRecipe); - continue; - case 2: - aTier2Recipes.add(aRecipe); - continue; - case 3: - aTier3Recipes.add(aRecipe); - continue; - case 4: - aTier4Recipes.add(aRecipe); - continue; - case 5: - aTier5Recipes.add(aRecipe); - continue; - case 6: - aTier6Recipes.add(aRecipe); - continue; - case 7: - aTier7Recipes.add(aRecipe); - continue; - } - } - } - mInitRecipeCache = true; - } - } - - public GT_Recipe findRecipe(final GT_Recipe aRecipe, final long aVoltage, final long aSpecialValue, ItemStack[] aInputs, final FluidStack[] aFluids) { - if (!mInitRecipeCache) { - initRecipeCaches(); - } - if (this.getRecipeMap().mRecipeList.isEmpty()) { - log("No Recipes in Map to search through."); - return null; - } - else { - log("Checking tier "+aSpecialValue+" recipes and below. Using Input Voltage of "+aVoltage+"V."); - log("We have "+aInputs.length+" Items and "+aFluids.length+" Fluids."); - // Try check the cached recipe first - if (aRecipe != null) { - if (aRecipe.isRecipeInputEqual(false, aFluids, aInputs)) { - if (aRecipe.mEUt <= aVoltage) { - Logger.INFO("Using cached recipe."); - return aRecipe; - } - } - } - - // Get all recipes for the tier - AutoMap> aMasterMap = new AutoMap>(); - for (long i=0;i<=aSpecialValue;i++) { - aMasterMap.add(mTieredRecipeMap.get(i)); - } - GT_Recipe aFoundRecipe = null; - - // Iterate the tiers recipes until we find the one with all inputs matching - master : for (AutoMap aTieredMap : aMasterMap) { - for (GT_Recipe aRecipeToCheck : aTieredMap) { - if (aRecipeToCheck.isRecipeInputEqual(false, aFluids, aInputs)) { - log("Found recipe with matching inputs!"); - if (aRecipeToCheck.mSpecialValue <= aSpecialValue) { - if (aRecipeToCheck.mEUt <= aVoltage) { - aFoundRecipe = aRecipeToCheck; - break master; - } - } - } - } - } - - // If we found a recipe, return it - if (aFoundRecipe != null) { - log("Found valid recipe."); - return aFoundRecipe; - } - } - log("Did not find valid recipe."); - return null; - } - - private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList aOutPut) { - int allowedParallel = 0; - for (final ItemStack aInput : aItemInputs) { - if (aRecipeCatalyst.isItemEqual(aInput)) { - int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); - return Math.min(aMaxParrallel, aDurabilityRemaining); - } - } - return allowedParallel; - } - - private ItemStack findCatalyst(ItemStack[] aItemInputs, ItemStack[] aRecipeInputs) { - if (aItemInputs != null) { - for (final ItemStack aInput : aItemInputs) { - if (aInput != null) { - if (ItemUtils.isCatalyst(aInput)) { - for (ItemStack aRecipeInput : aRecipeInputs) { - if (GT_Utility.areStacksEqual(aRecipeInput, aInput, true)) { - return aInput; - } - } - } - } - } - } - return null; - } - - - private void damageCatalyst(ItemStack aStack, int parallelRecipes) { - for (int i=0; i= 10 && this.mPipeCasingTier >= 4) { - log("not consuming catalyst"); - } - else if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { - int damage = getDamage(aStack) + 1; - log("damage catalyst "+damage); - if (damage >= getMaxCatalystDurability()) { - log("consume catalyst"); - addOutput(CI.getEmptyCatalyst(1)); - aStack.stackSize -= 1; - } - else { - log("damaging catalyst"); - setDamage(aStack, damage); - } - } - else { - log("not consuming catalyst"); - } - } - } - - private int getDamage(ItemStack aStack) { - return ItemGenericChemBase.getCatalystDamage(aStack); - } - - private void setDamage(ItemStack aStack,int aAmount) { - ItemGenericChemBase.setCatalystDamage(aStack, aAmount); - } - - /* - * Catalyst Handling - */ - @Override - public ArrayList getStoredInputs() { - ArrayList tItems = super.getStoredInputs(); - if (this.hasSlotInGUI() && this.getGUIItemStack() != null) { - tItems.add(this.getGUIItemStack()); - } - for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - AutoMap aHatchContent = tHatch.getContentUsageSlots(); - if (!aHatchContent.isEmpty()) { - tItems.addAll(aHatchContent); - } - } - } - return tItems; - } +public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private int mSolidCasingTier = 0; + private int mMachineCasingTier = 0; + private int mPipeCasingTier = 0; + private int mCoilTier = 0; + private HeatingCoilLevel checkCoil; + private int[] checkCasing = new int[8]; + private int checkMachine; + private int checkPipe; + private int maxTierOfHatch; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + private final ArrayList mCatalystBuses = + new ArrayList(); + + private static final HashMap> mTieredBlockRegistry = new HashMap<>(); + + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ChemicalPlant(final String aName) { + super(aName); + } + + public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { + Triplet aCasingData = + new Triplet(aBlock, aMeta, aCasingTextureID); + if (mTieredBlockRegistry.containsKey(aTier)) { + CORE.crash("Tried to register a Machine casing for tier " + aTier + + " to the Chemical Plant, however this tier already contains one."); + } + mTieredBlockRegistry.put(aTier, aCasingData); + return true; + } + + private static int getCasingTextureIdForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return 10; + } + int aCasingID = mTieredBlockRegistry.get(aTier).getValue_3(); + // Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); + return aCasingID; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ChemicalPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Chemical Plant"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Chemical Plant") + .addInfo("Heavy Industry, now right at your doorstep!") + .addInfo("Please read the user manual for more information on construction and usage") + .addSeparator() + .addController("Bottom Center") + .addStructureHint("Catalyst Housing", 1) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addOutputHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addSubChannelUsage("casing", "metal machine casing") + .addSubChannelUsage("machine", "tier machine casing") + .addSubChannelUsage("coil", "heating coil blocks") + .addSubChannelUsage("pipe", "pipe casing blocks") + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + public void setMachineMeta(int meta) { + checkMachine = meta; + } + + public int getMachineMeta() { + return checkMachine; + } + + public void setPipeMeta(int meta) { + checkPipe = meta; + } + + public int getPipeMeta() { + return checkPipe; + } + + public void setCoilMeta(HeatingCoilLevel meta) { + checkCoil = meta; + } + + public HeatingCoilLevel getCoilMeta() { + return checkCoil; + } + + public int coilTier(int meta) { + switch (meta) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 3; + case 3: + return 4; + case 4: + return 5; + case 5: + return 7; + case 6: + return 8; + case 7: + return 10; + case 8: + return 11; + case 9: + return 6; + case 10: + return 9; + case 11: + return 12; + case 12: + return 13; + case 13: + return 14; + default: + return 0; + } + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + IStructureElement allCasingsElement = withChannel( + "casing", + ofChain(IntStream.range(0, 8) + .mapToObj(GregtechMTE_ChemicalPlant::ofSolidCasing) + .collect(Collectors.toList()))); + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { + {"XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX"}, + {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, + {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, + {"X X", " ", " HHH ", " HHH ", " HHH ", " ", "X X"}, + {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, + {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, + {"CCC~CCC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CCCCCCC"}, + })) + .addElement( + 'C', + ofChain( + buildHatchAdder(GregtechMTE_ChemicalPlant.class) + .atLeast(Maintenance) + .casingIndex(getCasingTextureID()) + .dot(1) + .build(), + buildHatchAdder(GregtechMTE_ChemicalPlant.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus) + .adder(GregtechMTE_ChemicalPlant::addChemicalPlantList) + .hatchItemFilterAnd((t, s) -> filterByMTETier( + Integer.MIN_VALUE, + s.stackSize >= 10 ? Integer.MAX_VALUE : s.stackSize)) + .casingIndex(getCasingTextureID()) + .dot(1) + .build(), + buildHatchAdder(GregtechMTE_ChemicalPlant.class) + .hatchClass(GT_MetaTileEntity_Hatch_Catalysts.class) + .adder(GregtechMTE_ChemicalPlant::addChemicalPlantList) + .casingIndex(getCasingTextureID()) + .dot(1) + .build(), + allCasingsElement)) + .addElement('X', allCasingsElement) + .addElement( + 'M', + withChannel( + "machine", + addTieredBlock( + GregTech_API.sBlockCasings1, + GregtechMTE_ChemicalPlant::setMachineMeta, + GregtechMTE_ChemicalPlant::getMachineMeta, + 10))) + .addElement( + 'H', + withChannel( + "coil", + ofCoil( + GregtechMTE_ChemicalPlant::setCoilMeta, + GregtechMTE_ChemicalPlant::getCoilMeta))) + .addElement( + 'P', + withChannel( + "pipe", + addTieredBlock( + GregTech_API.sBlockCasings2, + GregtechMTE_ChemicalPlant::setPipeMeta, + GregtechMTE_ChemicalPlant::getPipeMeta, + 12, + 16))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + private static IStructureElement ofSolidCasing(int aIndex) { + return new IStructureElement() { + @Override + public boolean check(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z) { + if (check(aIndex, world, x, y, z)) { + t.checkCasing[aIndex]++; + t.mCasing++; + return true; + } else return false; + } + + private boolean check(int aIndex, World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block target = mTieredBlockRegistry.get(aIndex).getValue_1(); + int targetMeta = mTieredBlockRegistry.get(aIndex).getValue_2(); + return target.equals(block) && meta == targetMeta; + } + + int getIndex(int size) { + if (size > 8) size = 8; + return size - 1; + } + + @Override + public boolean spawnHint(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle( + world, + x, + y, + z, + mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), + mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2()); + return true; + } + + @Override + public boolean placeBlock( + GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock( + x, + y, + z, + mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), + mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2(), + 3); + } + + @Override + public PlaceResult survivalPlaceBlock( + GregtechMTE_ChemicalPlant t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer chatter) { + if (check(getIndex(trigger.stackSize), world, x, y, z)) return PlaceResult.SKIP; + return StructureUtility.survivalPlaceBlock( + mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), + mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2(), + world, + x, + y, + z, + s, + actor, + chatter); + } + }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 3, 6, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 3, 6, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + for (int i = 0; i < 8; i++) { + checkCasing[i] = 0; + } + checkPipe = 0; + checkMachine = 0; + mSolidCasingTier = 0; + mMachineCasingTier = 0; + mPipeCasingTier = 0; + mCoilTier = 0; + mCatalystBuses.clear(); + if (checkPiece(mName, 3, 6, 0) && mCasing >= 70) { + for (int i = 0; i < 8; i++) { + if (checkCasing[i] == mCasing) { + mSolidCasingTier = i; + } else if (checkCasing[i] > 0) return false; + } + mMachineCasingTier = checkMachine - 1; + mPipeCasingTier = checkPipe - 12; + mCoilTier = checkCoil.getTier(); + getBaseMetaTileEntity().sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, getUpdateData()); + updateHatchTexture(); + return mMachineCasingTier >= 9 || mMachineCasingTier >= maxTierOfHatch; + } + return false; + } + + public void updateHatchTexture() { + for (GT_MetaTileEntity_Hatch h : mCatalystBuses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mInputBusses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mMaintenanceHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mEnergyHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mOutputBusses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mInputHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); + } + + public final boolean addChemicalPlantList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_Machine_Controller_Advanced; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureID(); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList.size() == 0) { + generateRecipes(); + } + return GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT; + } + + public static void generateRecipes() { + for (GT_Recipe i : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { + GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.add(i); + } + } + + @Override + public int getMaxParallelRecipes() { + return 2 * getPipeCasingTier(); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + private int getSolidCasingTier() { + return this.mSolidCasingTier; + } + + private int getMachineCasingTier() { + return mMachineCasingTier; + } + + private int getPipeCasingTier() { + return mPipeCasingTier; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mSolidCasingTier; + return getCasingTextureIdForTier(aTier); + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity) { + int aMaxTier = getMachineCasingTier(); + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { + GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; + int aTileTier = aMachineBlock.mTier; + if (aTileTier > aMaxTier) { + log("Hatch tier too high."); + return false; + } else { + return addToMachineList(aTileEntity, getCasingTextureID()); + } + } else { + log("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + return false; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); + aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); + aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); + aNBT.setInteger("mCoilTier", this.mCoilTier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); + mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); + mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); + mCoilTier = aNBT.getInteger("mCoilTier"); + } + + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { + log("Found GT_MetaTileEntity_Hatch_Catalysts"); + return addToMachineListInternal(mCatalystBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + // Same speed bonus as pyro oven + public int getSpeedBonus() { + return 50 * (this.mCoilTier - 1); + } + + public int getMaxCatalystDurability() { + return 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mCatalystBuses.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public byte getUpdateData() { + return (byte) mSolidCasingTier; + } + + @Override + public void receiveClientEvent(byte aEventID, byte aValue) { + super.receiveClientEvent(aEventID, aValue); + if (aEventID == GregTechTileClientEvents.CHANGE_CUSTOM_DATA && (aValue & 0x80) == 0) { + // received an update data from above method + // if no &0x80 clause it might catch the noop texture page event + mSolidCasingTier = aValue; + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), getSpeedBonus()); + } + + @Override + public boolean checkRecipeGeneric( + int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + ArrayList tItems = getStoredInputs(); + ArrayList tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric( + tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + // GT_Recipe tRecipe = findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, + // gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + GT_Recipe tRecipe = findRecipe( + mLastRecipe, gregtech.api.enums.GT_Values.V[tTier], getSolidCasingTier(), aItemInputs, aFluidInputs); + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + // checks if it has a catalyst + ItemStack tCatalystRecipe = null; + boolean aDoesRecipeNeedCatalyst = false; + for (ItemStack aInputItem : tRecipe.mInputs) { + if (ItemUtils.isCatalyst(aInputItem)) { + aDoesRecipeNeedCatalyst = true; + break; + } + } + if (aDoesRecipeNeedCatalyst) { + tCatalystRecipe = findCatalyst(aItemInputs, tRecipe.mInputs); + if (tCatalystRecipe == null) { + log("does not have catalyst"); + return false; + } + if (mCatalystBuses.size() != 1) { + log("does not have correct number of catalyst hatches. (Required 1, found " + mCatalystBuses.size() + + ")"); + return false; + } + } + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe.mSpecialValue > this.mSolidCasingTier) { + log("solid tier is too low"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // checks if it has enough catalyst durability + ArrayList tCatalysts = null; + int tMaxParallelCatalyst = aMaxParallelRecipes; + if (tCatalystRecipe != null) { + tCatalysts = new ArrayList(); + tMaxParallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); + log("Can process " + tMaxParallelCatalyst + " recipes. If less than " + aMaxParallelRecipes + + ", catalyst does not have enough durability."); + } + + if (tMaxParallelCatalyst == 0) { + log("found not enough catalysts"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + log("aEUPercent " + aEUPercent); + log("mEUt " + tRecipe.mEUt); + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + tMaxParallelCatalyst); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tEnergy: " + tEnergy); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < tMaxParallelCatalyst && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Damage catalyst once all is said and done. + if (tCatalystRecipe != null) { + log("damaging catalyst"); + damageCatalyst(tCatalystRecipe, parallelRecipes); + } + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + for (GT_MetaTileEntity_Hatch_Catalysts h : mCatalystBuses) { + h.updateSlots(); + h.tryFillUsageSlots(); + } + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + private static final HashMap> mTieredRecipeMap = new HashMap>(); + private static final AutoMap aTier0Recipes = new AutoMap(); + private static final AutoMap aTier1Recipes = new AutoMap(); + private static final AutoMap aTier2Recipes = new AutoMap(); + private static final AutoMap aTier3Recipes = new AutoMap(); + private static final AutoMap aTier4Recipes = new AutoMap(); + private static final AutoMap aTier5Recipes = new AutoMap(); + private static final AutoMap aTier6Recipes = new AutoMap(); + private static final AutoMap aTier7Recipes = new AutoMap(); + private static boolean mInitRecipeCache = false; + + private static void initRecipeCaches() { + if (!mInitRecipeCache) { + mTieredRecipeMap.put((long) 0, aTier0Recipes); + mTieredRecipeMap.put((long) 1, aTier1Recipes); + mTieredRecipeMap.put((long) 2, aTier2Recipes); + mTieredRecipeMap.put((long) 3, aTier3Recipes); + mTieredRecipeMap.put((long) 4, aTier4Recipes); + mTieredRecipeMap.put((long) 5, aTier5Recipes); + mTieredRecipeMap.put((long) 6, aTier6Recipes); + mTieredRecipeMap.put((long) 7, aTier7Recipes); + for (GT_Recipe aRecipe : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList) { + if (aRecipe != null) { + switch (aRecipe.mSpecialValue) { + case 0: + aTier0Recipes.add(aRecipe); + continue; + case 1: + aTier1Recipes.add(aRecipe); + continue; + case 2: + aTier2Recipes.add(aRecipe); + continue; + case 3: + aTier3Recipes.add(aRecipe); + continue; + case 4: + aTier4Recipes.add(aRecipe); + continue; + case 5: + aTier5Recipes.add(aRecipe); + continue; + case 6: + aTier6Recipes.add(aRecipe); + continue; + case 7: + aTier7Recipes.add(aRecipe); + continue; + } + } + } + mInitRecipeCache = true; + } + } + + public GT_Recipe findRecipe( + final GT_Recipe aRecipe, + final long aVoltage, + final long aSpecialValue, + ItemStack[] aInputs, + final FluidStack[] aFluids) { + if (!mInitRecipeCache) { + initRecipeCaches(); + } + if (this.getRecipeMap().mRecipeList.isEmpty()) { + log("No Recipes in Map to search through."); + return null; + } else { + log("Checking tier " + aSpecialValue + " recipes and below. Using Input Voltage of " + aVoltage + "V."); + log("We have " + aInputs.length + " Items and " + aFluids.length + " Fluids."); + // Try check the cached recipe first + if (aRecipe != null) { + if (aRecipe.isRecipeInputEqual(false, aFluids, aInputs)) { + if (aRecipe.mEUt <= aVoltage) { + Logger.INFO("Using cached recipe."); + return aRecipe; + } + } + } + + // Get all recipes for the tier + AutoMap> aMasterMap = new AutoMap>(); + for (long i = 0; i <= aSpecialValue; i++) { + aMasterMap.add(mTieredRecipeMap.get(i)); + } + GT_Recipe aFoundRecipe = null; + + // Iterate the tiers recipes until we find the one with all inputs matching + master: + for (AutoMap aTieredMap : aMasterMap) { + for (GT_Recipe aRecipeToCheck : aTieredMap) { + if (aRecipeToCheck.isRecipeInputEqual(false, aFluids, aInputs)) { + log("Found recipe with matching inputs!"); + if (aRecipeToCheck.mSpecialValue <= aSpecialValue) { + if (aRecipeToCheck.mEUt <= aVoltage) { + aFoundRecipe = aRecipeToCheck; + break master; + } + } + } + } + } + + // If we found a recipe, return it + if (aFoundRecipe != null) { + log("Found valid recipe."); + return aFoundRecipe; + } + } + log("Did not find valid recipe."); + return null; + } + + private int getCatalysts( + ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList aOutPut) { + int allowedParallel = 0; + for (final ItemStack aInput : aItemInputs) { + if (aRecipeCatalyst.isItemEqual(aInput)) { + int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); + return Math.min(aMaxParrallel, aDurabilityRemaining); + } + } + return allowedParallel; + } + + private ItemStack findCatalyst(ItemStack[] aItemInputs, ItemStack[] aRecipeInputs) { + if (aItemInputs != null) { + for (final ItemStack aInput : aItemInputs) { + if (aInput != null) { + if (ItemUtils.isCatalyst(aInput)) { + for (ItemStack aRecipeInput : aRecipeInputs) { + if (GT_Utility.areStacksEqual(aRecipeInput, aInput, true)) { + return aInput; + } + } + } + } + } + } + return null; + } + + private void damageCatalyst(ItemStack aStack, int parallelRecipes) { + for (int i = 0; i < parallelRecipes; i++) { + // Awakened Draconium Coils with Tungstensteel Pipe Casings (or above) no longer consume catalysts. + if (this.mCoilTier >= 10 && this.mPipeCasingTier >= 4) { + log("not consuming catalyst"); + } else if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { + int damage = getDamage(aStack) + 1; + log("damage catalyst " + damage); + if (damage >= getMaxCatalystDurability()) { + log("consume catalyst"); + addOutput(CI.getEmptyCatalyst(1)); + aStack.stackSize -= 1; + } else { + log("damaging catalyst"); + setDamage(aStack, damage); + } + } else { + log("not consuming catalyst"); + } + } + } + + private int getDamage(ItemStack aStack) { + return ItemGenericChemBase.getCatalystDamage(aStack); + } + + private void setDamage(ItemStack aStack, int aAmount) { + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); + } + + /* + * Catalyst Handling + */ + @Override + public ArrayList getStoredInputs() { + ArrayList tItems = super.getStoredInputs(); + if (this.hasSlotInGUI() && this.getGUIItemStack() != null) { + tItems.add(this.getGUIItemStack()); + } + for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + AutoMap aHatchContent = tHatch.getContentUsageSlots(); + if (!aHatchContent.isEmpty()) { + tItems.addAll(aHatchContent); + } + } + } + return tItems; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java index c6342827da..68cfc44527 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.t import static gtPlusPlus.core.lib.CORE.RANDOM; -import java.util.ArrayList; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -11,6 +9,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import java.util.ArrayList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; @@ -22,7 +21,6 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin super(aID, aName, aNameRegional); } - public GT_MTE_LargeTurbine_Gas(String aName) { super(aName); } @@ -42,24 +40,23 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin return 58; } - - @Override - protected boolean requiresOutputHatch() { - return false; - } + @Override + protected boolean requiresOutputHatch() { + return false; + } @Override public int getPollutionPerSecond(ItemStack aStack) { return 4000; } - + public int getFuelValue(FluidStack aLiquid) { if (aLiquid == null) { - return 0; + return 0; } GT_Recipe tFuel = GT_Recipe_Map.sTurbineFuels.findFuel(aLiquid); if (tFuel != null) { - return tFuel.mSpecialValue; + return tFuel.mSpecialValue; } return 0; } @@ -70,9 +67,11 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin int tEU = 0; int actualOptimalFlow = 0; - FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! + FluidStack firstFuelType = new FluidStack( + aFluids.get(0), + 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! int fuelValue = getFuelValue(firstFuelType); - //log("Fuel Value of "+aFluids.get(0).getLocalizedName()+" is "+fuelValue+"eu"); + // log("Fuel Value of "+aFluids.get(0).getLocalizedName()+" is "+fuelValue+"eu"); if (aOptFlow < fuelValue) { // turbine too weak and/or fuel too powerful // at least consume 1L @@ -86,14 +85,18 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin actualOptimalFlow = GT_Utility.safeInt((long) aOptFlow / fuelValue); this.realOptFlow = actualOptimalFlow; - int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow + * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for + // multi-hatch scenarios. int flow = 0; int totalFlow = 0; storedFluid = 0; for (FluidStack aFluid : aFluids) { if (aFluid.isFluidEqual(firstFuelType)) { - flow = Math.min(aFluid.amount, remainingFlow); // try to use up to 125% of optimal flow w/o exceeding remainingFlow + flow = Math.min( + aFluid.amount, + remainingFlow); // try to use up to 125% of optimal flow w/o exceeding remainingFlow depleteInput(new FluidStack(aFluid, flow)); // deplete that amount this.storedFluid += aFluid.amount; remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches @@ -103,11 +106,11 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin if (totalFlow <= 0) return 0; tEU = GT_Utility.safeInt((long) totalFlow * fuelValue); - //log("Total Flow: "+totalFlow); - //log("Real Optimal Flow: "+actualOptimalFlow); - //log("Flow: "+flow); - //log("Remaining Flow: "+remainingFlow); - + // log("Total Flow: "+totalFlow); + // log("Real Optimal Flow: "+actualOptimalFlow); + // log("Flow: "+flow); + // log("Remaining Flow: "+remainingFlow); + if (totalFlow == actualOptimalFlow) { tEU = GT_Utility.safeInt((long) tEU * (long) aBaseEff / 10000L); } else { @@ -117,7 +120,6 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin } return tEU; - } return 0; } @@ -126,7 +128,7 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin public int getDamageToComponent(ItemStack aStack) { return (RANDOM.nextInt(4) == 0) ? 0 : 1; } - + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); @@ -137,34 +139,33 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin super.loadNBTData(aNBT); } - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Large Gas Turbine"; - } + @Override + public String getCustomGUIResourceName() { + return null; + } - @Override - protected String getTurbineType() { - return "Gas"; - } + @Override + public String getMachineType() { + return "Large Gas Turbine"; + } - @Override - protected String getCasingName() { - return "Reinforced Gas Turbine Casing"; - } + @Override + protected String getTurbineType() { + return "Gas"; + } - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS5); - } + @Override + protected String getCasingName() { + return "Reinforced Gas Turbine Casing"; + } - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS_ACTIVE5); - } + @Override + protected ITexture getTextureFrontFace() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS5); + } + @Override + protected ITexture getTextureFrontFaceActive() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS_ACTIVE5); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java index 3427b40819..517c32441a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; -import java.util.ArrayList; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -9,9 +7,10 @@ import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; -import gregtech.api.util.GT_Utility; +import java.util.ArrayList; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -23,7 +22,6 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur super(aID, aName, aNameRegional); } - public GT_MTE_LargeTurbine_Plasma(String aName) { super(aName); } @@ -43,139 +41,156 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur return 60; } - @Override - protected boolean requiresOutputHatch() { - return true; - } + @Override + protected boolean requiresOutputHatch() { + return true; + } @Override public int getPollutionPerSecond(ItemStack aStack) { return 0; } - + public int getFuelValue(FluidStack aLiquid) { if (aLiquid == null) { - return 0; + return 0; } GT_Recipe tFuel = GT_Recipe_Map.sPlasmaFuels.findFuel(aLiquid); if (tFuel != null) { - return tFuel.mSpecialValue; + return tFuel.mSpecialValue; } return 0; } - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - try { - ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); - if (aEmptyTurbineRotorHatches.size() > 0) { - log("Found "+aEmptyTurbineRotorHatches.size()+" Assemblies without Turbine."); - hatch : for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { - ArrayList aTurbines = getAllBufferedTurbines(); - for (ItemStack aTurbineItem : aTurbines) { - if (aTurbineItem == null) { - continue; - } - if (aHatch.insertTurbine(aTurbineItem.copy())) { - boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); - log("Put Turbine into Assembly - "+aDidDeplete); - continue hatch; - } - } - } - } - - if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - log("BAD RETURN - 1"); - stopMachine(); - return false; - } - - ArrayList tFluids = getStoredFluids(); - - if (tFluids.size() > 0) { - if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() - || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { - counter = 0; - float aTotalBaseEff = 0; - float aTotalOptimalFlow = 0; - ItemStack aStack = getFullTurbineAssemblies().get(0).getTurbine(); - for (int i = 0; i< getSpeedMultiplier(); i++) { - if (i == 0) { - aTotalBaseEff += GT_Utility.safeInt((long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - } - aTotalOptimalFlow += GT_Utility.safeInt((long) Math.max(Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed - * 50)); - } - - baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); - optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); - if(optFlow<=0 || baseEff<=0){ - log("Running checkRecipeGeneric(bad-1)"); - stopMachine();//in case the turbine got removed - return false; - } - } else { - counter++; - } - } - - // How much the turbine should be producing with this flow - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); - int difference = newPower - this.mEUt; // difference between current output and new output - - // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) - // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(200, GT_Utility.safeInt((long) Math.abs(difference) / 5)); - - if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change - int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. - this.mEUt += change; // Apply the change - } - else { - this.mEUt = newPower; - } - if (this.mEUt <= 0) { - this.mEUt=0; - this.mEfficiency=0; - log("Running checkRecipeGeneric(bad-2)"); - return false; - } else { - this.mMaxProgresstime = 20; - this.mEfficiencyIncrease = 200; - // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - //log("GOOD RETURN - Making: "+this.mEUt+" EU/t"); - return true; - } - } - catch (Throwable t) { - t.printStackTrace(); - } - return false; - } + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + + try { + ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); + if (aEmptyTurbineRotorHatches.size() > 0) { + log("Found " + aEmptyTurbineRotorHatches.size() + " Assemblies without Turbine."); + hatch: + for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { + ArrayList aTurbines = getAllBufferedTurbines(); + for (ItemStack aTurbineItem : aTurbines) { + if (aTurbineItem == null) { + continue; + } + if (aHatch.insertTurbine(aTurbineItem.copy())) { + boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); + log("Put Turbine into Assembly - " + aDidDeplete); + continue hatch; + } + } + } + } + + if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { + log("BAD RETURN - 1"); + stopMachine(); + return false; + } + + ArrayList tFluids = getStoredFluids(); + + if (tFluids.size() > 0) { + if (baseEff == 0 + || optFlow == 0 + || counter >= 512 + || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() + || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { + counter = 0; + float aTotalBaseEff = 0; + float aTotalOptimalFlow = 0; + ItemStack aStack = getFullTurbineAssemblies().get(0).getTurbine(); + for (int i = 0; i < getSpeedMultiplier(); i++) { + if (i == 0) { + aTotalBaseEff += GT_Utility.safeInt((long) + ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) + * 1000F)); + } + aTotalOptimalFlow += GT_Utility.safeInt((long) Math.max( + Float.MIN_NORMAL, + ((GT_MetaGenerated_Tool) aStack.getItem()) + .getToolStats(aStack) + .getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed + * 50)); + } + + baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); + optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); + if (optFlow <= 0 || baseEff <= 0) { + log("Running checkRecipeGeneric(bad-1)"); + stopMachine(); // in case the turbine got removed + return false; + } + } else { + counter++; + } + } + + // How much the turbine should be producing with this flow + int newPower = fluidIntoPower(tFluids, optFlow, baseEff); + int difference = newPower - this.mEUt; // difference between current output and new output + + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the + // difference in power level (per tick) + // This is how much the turbine can actually change during this tick + int maxChangeAllowed = Math.max(200, GT_Utility.safeInt((long) Math.abs(difference) / 5)); + + if (Math.abs(difference) + > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change + int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. + this.mEUt += change; // Apply the change + } else { + this.mEUt = newPower; + } + if (this.mEUt <= 0) { + this.mEUt = 0; + this.mEfficiency = 0; + log("Running checkRecipeGeneric(bad-2)"); + return false; + } else { + this.mMaxProgresstime = 20; + this.mEfficiencyIncrease = 200; + // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + // log("GOOD RETURN - Making: "+this.mEUt+" EU/t"); + return true; + } + } catch (Throwable t) { + t.printStackTrace(); + } + return false; + } @Override int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff) { if (aFluids.size() >= 1) { - aOptFlow *= 800;//CHANGED THINGS HERE, check recipe runs once per 20 ticks + aOptFlow *= 800; // CHANGED THINGS HERE, check recipe runs once per 20 ticks int tEU = 0; int actualOptimalFlow = 0; - FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! + FluidStack firstFuelType = new FluidStack( + aFluids.get(0), + 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! int fuelValue = getFuelValue(firstFuelType); actualOptimalFlow = GT_Utility.safeInt((long) Math.ceil((double) aOptFlow / (double) fuelValue)); this.realOptFlow = actualOptimalFlow; // For scanner info - int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow + * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for + // multi-hatch scenarios. int flow = 0; int totalFlow = 0; @@ -204,7 +219,7 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur if (totalFlow <= 0) return 0; tEU = GT_Utility.safeInt((long) ((fuelValue / 20D) * (double) totalFlow)); - //GT_FML_LOGGER.info(totalFlow+" : "+fuelValue+" : "+aOptFlow+" : "+actualOptimalFlow+" : "+tEU); + // GT_FML_LOGGER.info(totalFlow+" : "+fuelValue+" : "+aOptFlow+" : "+actualOptimalFlow+" : "+tEU); if (totalFlow == actualOptimalFlow) { tEU = GT_Utility.safeInt((long) (aBaseEff / 10000D * tEU)); @@ -216,7 +231,6 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur } return tEU; - } return 0; } @@ -226,35 +240,33 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur return 1; } - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Large Plasma Turbine"; - } - - - @Override - protected String getTurbineType() { - return "Plasma"; - } - - @Override - protected String getCasingName() { - return "Reinforced Plasma Turbine Casing"; - } - - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU5); - } - - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU_ACTIVE5); - } + @Override + public String getCustomGUIResourceName() { + return null; + } + @Override + public String getMachineType() { + return "Large Plasma Turbine"; + } + + @Override + protected String getTurbineType() { + return "Plasma"; + } + + @Override + protected String getCasingName() { + return "Reinforced Plasma Turbine Casing"; + } + + @Override + protected ITexture getTextureFrontFace() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU5); + } + + @Override + protected ITexture getTextureFrontFaceActive() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU_ACTIVE5); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java index 2f72b8b54c..248359a80b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; -import java.util.ArrayList; - import gregtech.GT_Mod; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -12,6 +10,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -21,7 +20,7 @@ import net.minecraftforge.fluids.FluidStack; public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTurbineBase { public boolean achievement = false; - private boolean looseFit=false; + private boolean looseFit = false; public GT_MTE_LargeTurbine_SHSteam(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -46,42 +45,44 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu return 59; } - @Override - protected boolean requiresOutputHatch() { - return true; - } + @Override + protected boolean requiresOutputHatch() { + return true; + } @Override public int getPollutionPerSecond(ItemStack aStack) { return 0; } - @Override - public int getFuelValue(FluidStack aLiquid) { - return 0; - } + @Override + public int getFuelValue(FluidStack aLiquid) { + return 0; + } @Override int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff) { - if(looseFit) { - aOptFlow*=4; - if(aBaseEff>10000){ - aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); - aBaseEff=7500; - }else if(aBaseEff>7500){ - aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); - aBaseEff*=0.75f; - }else{ - aBaseEff*=0.75f; + if (looseFit) { + aOptFlow *= 4; + if (aBaseEff > 10000) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff = 7500; + } else if (aBaseEff > 7500) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff *= 0.75f; + } else { + aBaseEff *= 0.75f; } } int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long)(aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + int remainingFlow = MathUtils.safeInt((long) (aOptFlow + * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for + // multi-hatch scenarios. this.realOptFlow = aOptFlow; - storedFluid=0; + storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { String fluidName = aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)); if (fluidName.equals("ic2.fluidSuperheatedSteam")) { @@ -92,25 +93,32 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu totalFlow += flow; // track total input used if (!achievement) { try { - GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "efficientsteam"); + GT_Mod.achievements.issueAchievement( + this.getBaseMetaTileEntity() + .getWorld() + .getPlayerEntityByName( + this.getBaseMetaTileEntity().getOwnerName()), + "efficientsteam"); } catch (Exception e) { } achievement = true; } - }else if(fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name")){ + } else if (fluidName.equals("fluid.steam") + || fluidName.equals("ic2.fluidSteam") + || fluidName.equals("fluid.mfr.steam.still.name")) { depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); } } - if(totalFlow<=0)return 0; + if (totalFlow <= 0) return 0; tEU = totalFlow; addOutput(GT_ModHandler.getSteam(totalFlow)); if (totalFlow != aOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); - //if(totalFlow>aOptFlow){efficiency = 1.0f;} + float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow); + // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1, MathUtils.safeInt((long)tEU * (long)aBaseEff / 10000L)); + tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L)); } else { - tEU = MathUtils.safeInt((long)tEU * (long)aBaseEff / 10000L); + tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L); } return tEU; @@ -118,75 +126,73 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu @Override public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - //Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode - //Whenever there's a mode switch, there will be two messages on the player chat - //The two messages specify which two modes the turbine is on after the change - //(Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) + // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode + // Whenever there's a mode switch, there will be two messages on the player chat + // The two messages specify which two modes the turbine is on after the change + // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) if (aSide == getBaseMetaTileEntity().getFrontFacing()) { - looseFit^=true; - GT_Utility.sendChatToPlayer(aPlayer, looseFit ? "Fitting is Loose (Higher Flow)" : "Fitting is Tight (Higher Efficiency)"); + looseFit ^= true; + GT_Utility.sendChatToPlayer( + aPlayer, looseFit ? "Fitting is Loose (Higher Flow)" : "Fitting is Tight (Higher Efficiency)"); } if (looseFit) { super.onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); - } - else if (mFastMode) { + } else if (mFastMode) { PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } - else { + } else { PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); } } @Override public int getDamageToComponent(ItemStack aStack) { - return (looseFit && CORE.RANDOM.nextInt(4)==0)?0:1; + return (looseFit && CORE.RANDOM.nextInt(4) == 0) ? 0 : 1; } - + public boolean isLooseMode() { - return looseFit; - } - + return looseFit; + } + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("turbineFitting",looseFit); + aNBT.setBoolean("turbineFitting", looseFit); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - looseFit=aNBT.getBoolean("turbineFitting"); + looseFit = aNBT.getBoolean("turbineFitting"); } - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Large Super-heated Steam Turbine"; - } + @Override + public String getCustomGUIResourceName() { + return null; + } - @Override - protected String getTurbineType() { - return "Super-heated Steam"; - } + @Override + public String getMachineType() { + return "Large Super-heated Steam Turbine"; + } - @Override - protected String getCasingName() { - return "Reinforced HP Steam Turbine Casing"; - } + @Override + protected String getTurbineType() { + return "Super-heated Steam"; + } - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TI5); - } + @Override + protected String getCasingName() { + return "Reinforced HP Steam Turbine Casing"; + } - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TI_ACTIVE5); - } + @Override + protected ITexture getTextureFrontFace() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TI5); + } + @Override + protected ITexture getTextureFrontFaceActive() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TI_ACTIVE5); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java index 9d5139f0a3..e15f0f3181 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.t import static gtPlusPlus.core.lib.CORE.RANDOM; -import java.util.ArrayList; - import gregtech.GT_Mod; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -13,6 +11,7 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -23,13 +22,12 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb private float water; private boolean achievement = false; - private boolean looseFit=false; + private boolean looseFit = false; public GT_MTE_LargeTurbine_Steam(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GT_MTE_LargeTurbine_Steam(String aName) { super(aName); } @@ -49,10 +47,10 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb return 16; } - @Override - protected boolean requiresOutputHatch() { - return true; - } + @Override + protected boolean requiresOutputHatch() { + return true; + } @Override public int getPollutionPerSecond(ItemStack aStack) { @@ -65,59 +63,70 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb water = water - usage; return usage; } - + public int getFuelValue(FluidStack aLiquid) { return 0; } @Override int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff) { - if(looseFit) { - aOptFlow*=4; - if(aBaseEff>10000){ - aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); - aBaseEff=7500; - }else if(aBaseEff>7500){ - aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); - aBaseEff*=0.75f; - }else{ - aBaseEff*=0.75f; + if (looseFit) { + aOptFlow *= 4; + if (aBaseEff > 10000) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff = 7500; + } else if (aBaseEff > 7500) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff *= 0.75f; + } else { + aBaseEff *= 0.75f; } } int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long)(aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + int remainingFlow = MathUtils.safeInt((long) (aOptFlow + * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for + // multi-hatch scenarios. this.realOptFlow = aOptFlow; - storedFluid=0; - for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and track totals. + storedFluid = 0; + for (int i = 0; + i < aFluids.size() && remainingFlow > 0; + i++) { // loop through each hatch; extract inputs and track totals. String fluidName = aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)); - if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name")) { + if (fluidName.equals("fluid.steam") + || fluidName.equals("ic2.fluidSteam") + || fluidName.equals("fluid.mfr.steam.still.name")) { flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount this.storedFluid += aFluids.get(i).amount; remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches totalFlow += flow; // track total input used if (!achievement) { - GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam"); + GT_Mod.achievements.issueAchievement( + this.getBaseMetaTileEntity() + .getWorld() + .getPlayerEntityByName( + this.getBaseMetaTileEntity().getOwnerName()), + "muchsteam"); achievement = true; } - }else if(fluidName.equals("ic2.fluidSuperheatedSteam")){ + } else if (fluidName.equals("ic2.fluidSuperheatedSteam")) { depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); } } - if(totalFlow<=0)return 0; + if (totalFlow <= 0) return 0; tEU = totalFlow; int waterToOutput = useWater(totalFlow / 160.0f); addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); if (totalFlow != aOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); - //if(totalFlow>aOptFlow){efficiency = 1.0f;} + float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow); + // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1, MathUtils.safeInt((long)tEU * (long)aBaseEff / 20000L)); + tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L)); } else { - tEU = MathUtils.safeInt((long)tEU * (long)aBaseEff / 20000L); + tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L); } return tEU; @@ -125,75 +134,73 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb @Override public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - //Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode - //Whenever there's a mode switch, there will be two messages on the player chat - //The two messages specify which two modes the turbine is on after the change - //(Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) + // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode + // Whenever there's a mode switch, there will be two messages on the player chat + // The two messages specify which two modes the turbine is on after the change + // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) if (aSide == getBaseMetaTileEntity().getFrontFacing()) { - looseFit^=true; - GT_Utility.sendChatToPlayer(aPlayer, looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); + looseFit ^= true; + GT_Utility.sendChatToPlayer( + aPlayer, looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); } if (looseFit) { super.onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); - } - else if (mFastMode) { + } else if (mFastMode) { PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } - else { + } else { PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); } } @Override public int getDamageToComponent(ItemStack aStack) { - return (looseFit && RANDOM.nextInt(4)==0)?0:1; + return (looseFit && RANDOM.nextInt(4) == 0) ? 0 : 1; } - + public boolean isLooseMode() { - return looseFit; - } - + return looseFit; + } + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("turbineFitting",looseFit); + aNBT.setBoolean("turbineFitting", looseFit); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - looseFit=aNBT.getBoolean("turbineFitting"); + looseFit = aNBT.getBoolean("turbineFitting"); } - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public String getMachineType() { - return "Large Steam Turbine"; - } + @Override + public String getCustomGUIResourceName() { + return null; + } - @Override - protected String getTurbineType() { - return "Steam"; - } + @Override + public String getMachineType() { + return "Large Steam Turbine"; + } - @Override - protected String getCasingName() { - return "Reinforced Steam Turbine Casing"; - } + @Override + protected String getTurbineType() { + return "Steam"; + } - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST5); - } + @Override + protected String getCasingName() { + return "Reinforced Steam Turbine Casing"; + } - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST_ACTIVE5); - } + @Override + protected ITexture getTextureFrontFace() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST5); + } + @Override + protected ITexture getTextureFrontFaceActive() { + return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST_ACTIVE5); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java index 70b72bb60d..009b5c8f43 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java @@ -1,6 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; -import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -31,6 +35,7 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -41,764 +46,806 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; +public abstract class GregtechMetaTileEntity_LargerTurbineBase + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; + protected int baseEff = 0; + protected int optFlow = 0; + protected double realOptFlow = 0; + protected int storedFluid = 0; + protected int counter = 0; + protected boolean mFastMode = false; + protected double mufflerReduction = 1; + + public ITexture frontFace; + public ITexture frontFaceActive; + + public ArrayList mTurbineRotorHatches = + new ArrayList(); + + public GregtechMetaTileEntity_LargerTurbineBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + frontFace = getTextureFrontFace(); + frontFaceActive = getTextureFrontFaceActive(); + } + + public GregtechMetaTileEntity_LargerTurbineBase(String aName) { + super(aName); + frontFace = getTextureFrontFace(); + frontFaceActive = getTextureFrontFaceActive(); + } + + protected abstract ITexture getTextureFrontFace(); + + protected abstract ITexture getTextureFrontFaceActive(); + + protected abstract String getTurbineType(); + + protected abstract String getCasingName(); + + protected abstract boolean requiresOutputHatch(); + + @Override + protected final GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the XL " + getTurbineType() + " Turbine") + .addInfo("Runs as fast as 16 Large Turbines of the same type, takes the space of 12") + .addInfo("Right-click with screwdriver to enable Fast Mode, to run it even faster") + .addInfo("Optimal flow will increase or decrease accordingly on mode switch") + .addInfo("Fast Mode increases speed to 48x instead of 16x, with some penalties") + .addInfo("Maintenance problems and turbine damage happen 12x as often in Fast Mode") + .addInfo("XL Steam Turbines can use Loose Mode with either Slow or Fast Mode") + .addPollutionAmount(getPollutionPerSecond(null)) + .addInfo("Pollution is 3x higher in Fast Mode") + .addSeparator() + .beginStructureBlock(7, 9, 7, false) + .addController("Top Middle") + .addCasingInfo(getCasingName(), 360) + .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) + .addInputBus("Any 4 dot hint (min 1)", 4) + .addInputHatch("Any 4 dot hint(min 1)", 4); + if (requiresOutputHatch()) { + tt.addOutputHatch("Any 4 dot hint(min 1)", 4); + } + tt.addDynamoHatch("Any 4 dot hint(min 1)", 4).addMaintenanceHatch("Any 4 dot hint(min 1)", 4); + if (requiresMufflers()) { + tt.addMufflerHatch("Any 7 dot hint (x4)", 7); + } + tt.toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final ClassValue> + STRUCTURE_DEFINITION = new ClassValue>() { + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + // c = turbine casing + // s = turbine shaft + // t = turbine housing + // h = dynamo/maint + // m = muffler + .addShape(STRUCTURE_PIECE_MAIN, (new String[][] { + {"ccchccc", "ccccccc", "ccmmmcc", "ccm~mcc", "ccmmmcc", "ccccccc", "ccchccc"}, + {"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"}, + {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, + {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, + {"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"}, + {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, + {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, + {"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"}, + {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, + })) + .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + .addElement('s', lazy(t -> ofBlock(t.getCasingBlock(), t.getTurbineShaftMeta()))) + .addElement('t', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) + .adder(GregtechMetaTileEntity_LargerTurbineBase::addTurbineHatch) + .hatchClass(GT_MetaTileEntity_Hatch_Turbine.class) + .casingIndex(t.getCasingTextureIndex()) + .dot(1) + .build())) + .addElement('h', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) + .atLeast(InputBus, InputHatch, OutputHatch, Dynamo.or(TTDynamo), Maintenance) + .casingIndex(t.getCasingTextureIndex()) + .dot(4) + .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) + .addElement('m', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) + .atLeast(Muffler) + .casingIndex(t.getCasingTextureIndex()) + .dot(7) + .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) + .build(); + } + }; + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION.get(getClass()); + } + + private boolean requiresMufflers() { + if (!PollutionUtils.isPollutionEnabled()) { + return false; + } + return getPollutionPerSecond(null) > 0; + } + + public final double getMufflerReduction() { + double totalReduction = 0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + totalReduction += ((double) tHatch.calculatePollutionReduction(100)) / 100; + } + } + return totalReduction / 4; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.mDynamoHatches.clear(); + this.mTecTechDynamoHatches.clear(); + this.mTurbineRotorHatches.clear(); + this.mMaintenanceHatches.clear(); + if (requiresMufflers()) { + this.mMufflerHatches.clear(); + } + this.mInputBusses.clear(); + this.mInputHatches.clear(); + if (requiresOutputHatch()) { + this.mOutputHatches.clear(); + } + // we do not check for casing count here. the bare minimal is 372 but we only require 360 + boolean aStructure = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); + log("Structure Check: " + aStructure); + if (mTurbineRotorHatches.size() != 12 + || mMaintenanceHatches.size() != 1 + || (mDynamoHatches.size() < 1 && mTecTechDynamoHatches.size() < 1) + || (requiresMufflers() && mMufflerHatches.size() != 4) + || mInputBusses.size() < 1 + || mInputHatches.size() < 1 + || (requiresOutputHatch() && mOutputHatches.size() < 1)) { + log("Bad Hatches - Turbine Housings: " + mTurbineRotorHatches.size() + ", Maint: " + + mMaintenanceHatches.size() + ", Dynamo: " + + mDynamoHatches.size() + ", Muffler: " + + mMufflerHatches.size() + ", Input Buses: " + + mInputBusses.size() + ", Input Hatches: " + + mInputHatches.size() + ", Output Hatches: " + + mOutputHatches.size()); + return false; + } + mufflerReduction = getMufflerReduction(); + return aStructure; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); + return survivialBuildPiece(mName, stackSize, 1, 3, 3, realBudget, source, actor, false, true); + } + + public boolean addTurbineHatch(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { + log("Found GT_MetaTileEntity_Hatch_Turbine"); + updateTexture(aTileEntity, aBaseCasingIndex); + GT_MetaTileEntity_Hatch_Turbine aTurbineHatch = (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; + IGregTechTileEntity g = this.getBaseMetaTileEntity(); + if (aTurbineHatch.setController(new BlockPos(g.getXCoord(), g.getYCoord(), g.getZCoord(), g.getWorld()))) { + boolean aDidAdd = this.mTurbineRotorHatches.add(aTurbineHatch); + Logger.INFO("Injected Controller into Turbine Assembly. Found: " + this.mTurbineRotorHatches.size()); + return aDidAdd; + } else { + Logger.INFO("Failed to inject controller into Turbine Assembly Hatch."); + } + } + log("Bad Turbine Housing"); + return false; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeTurbine.png"); + } + + public final Block getCasingBlock() { + return ModBlocks.blockSpecialMultiCasings; + } + + @Override + public final boolean hasSlotInGUI() { + return true; + } + + public abstract int getCasingMeta(); + + public byte getTurbineShaftMeta() { + return 0; + } + + public abstract byte getCasingTextureIndex(); + + public abstract int getFuelValue(FluidStack aLiquid); + + public static boolean isValidTurbine(ItemStack aTurbine) { + return (aTurbine != null + && aTurbine.getItem() instanceof GT_MetaGenerated_Tool + && aTurbine.getItemDamage() >= 170 + && aTurbine.getItemDamage() <= 176); + } + + protected ArrayList getAllBufferedTurbines() { + ArrayList aTurbinesInStorage = new ArrayList<>(); + for (GT_MetaTileEntity_Hatch_InputBus aBus : this.mInputBusses) { + if (isValidMetaTileEntity(aBus)) { + for (ItemStack aContent : aBus.mInventory) { + if (isValidTurbine(aContent)) { + aTurbinesInStorage.add(aContent); + } + } + } + } + return aTurbinesInStorage; + } + + public boolean areAllTurbinesTheSame() { + ArrayList aTurbineAssemblies = getFullTurbineAssemblies(); + if (aTurbineAssemblies.size() < 12) { + log("Found " + aTurbineAssemblies.size() + ", expected 12."); + return false; + } + AutoMap aTurbineMats = new AutoMap<>(); + AutoMap aTurbineSizes = new AutoMap<>(); + for (GT_MetaTileEntity_Hatch_Turbine aHatch : aTurbineAssemblies) { + aTurbineMats.add(GT_MetaGenerated_Tool.getPrimaryMaterial(aHatch.getTurbine())); + aTurbineSizes.add(getTurbineSize(aHatch.getTurbine())); + } + Materials aBaseMat = aTurbineMats.get(0); + int aBaseSize = aTurbineSizes.get(0); + for (int aSize : aTurbineSizes) { + if (aBaseSize != aSize) { + return false; + } + } + for (Materials aMat : aTurbineMats) { + if (aBaseMat != aMat) { + return false; + } + } + return true; + } + + public static int getTurbineSize(ItemStack aTurbine) { + if (isValidTurbine(aTurbine)) { + if (aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() < 172) { + return 1; + } else if (aTurbine.getItemDamage() >= 172 && aTurbine.getItemDamage() < 174) { + return 2; + } else if (aTurbine.getItemDamage() >= 174 && aTurbine.getItemDamage() < 176) { + return 3; + } else if (aTurbine.getItemDamage() >= 176 && aTurbine.getItemDamage() < 178) { + return 4; + } + } + return 0; + } + + public static String getTurbineSizeString(int aSize) { + switch (aSize) { + case 1: + return "Small Turbine"; + case 2: + return "Turbine"; + case 3: + return "Large Turbine"; + case 4: + return "Huge Turbine"; + default: + return ""; + } + } + + protected ArrayList getEmptyTurbineAssemblies() { + ArrayList aEmptyTurbineRotorHatches = + new ArrayList(); + // log("Checking "+mTurbineRotorHatches.size()+" Assemblies for empties."); + for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { + if (!aTurbineHatch.hasTurbine()) { + // log("Found Assembly without Turbine."); + aEmptyTurbineRotorHatches.add(aTurbineHatch); + } + } + return aEmptyTurbineRotorHatches; + } + + protected ArrayList getFullTurbineAssemblies() { + ArrayList aTurbineRotorHatches = + new ArrayList(); + // log("Checking "+mTurbineRotorHatches.size()+" Assemblies for Turbines."); + for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { + if (aTurbineHatch.hasTurbine()) { + // log("Found Assembly with Turbine."); + aTurbineRotorHatches.add(aTurbineHatch); + } + } + return aTurbineRotorHatches; + } + + protected boolean depleteTurbineFromStock(ItemStack aTurbine) { + for (GT_MetaTileEntity_Hatch_InputBus aInputBus : this.mInputBusses) { + for (int slot = 0; slot < aInputBus.mInventory.length; slot++) { + ItemStack aStack = aInputBus.getStackInSlot(slot); + if (aStack != null && GT_Utility.areStacksEqual(aStack, aTurbine)) { + aInputBus.setInventorySlotContents(slot, null); + updateSlots(); + return true; + } + } + } + return false; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + log("1"); + return checkRecipeGeneric( + new ItemStack[] {}, getStoredFluids().toArray(new FluidStack[] {}), 1, 100, 100, 10000); + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + + try { + ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); + if (aEmptyTurbineRotorHatches.size() > 0) { + log("Found " + aEmptyTurbineRotorHatches.size() + " Assemblies without Turbine."); + hatch: + for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { + ArrayList aTurbines = getAllBufferedTurbines(); + for (ItemStack aTurbineItem : aTurbines) { + if (aTurbineItem == null) { + continue; + } + if (aHatch.insertTurbine(aTurbineItem.copy())) { + boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); + log("Put Turbine into Assembly - " + aDidDeplete); + continue hatch; + } + } + } + } + + if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { + log("BAD RETURN - 1"); + stopMachine(); + return false; + } + + ArrayList tFluids = getStoredFluids(); + + if (tFluids.size() > 0) { + if (baseEff == 0 + || optFlow == 0 + || counter >= 512 + || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() + || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { + counter = 0; + + // log("Running checkRecipeGeneric(1)"); + float aTotalBaseEff = 0; + float aTotalOptimalFlow = 0; + + ItemStack aStack = getFullTurbineAssemblies().get(0).getTurbine(); + for (int i = 0; i < getSpeedMultiplier(); i++) { + if (i == 0) { + aTotalBaseEff += GT_Utility.safeInt((long) + ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) + * 1000F)); + // log("Bumped base eff to "+aTotalBaseEff); + } + aTotalOptimalFlow += GT_Utility.safeInt((long) Math.max( + Float.MIN_NORMAL, + ((GT_MetaGenerated_Tool) aStack.getItem()) + .getToolStats(aStack) + .getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed + * 50)); + // log("Bumped base optimal flow to "+aTotalOptimalFlow); + } + + // log("Running checkRecipeGeneric(2)"); + // log("Total base eff: "+aTotalBaseEff); + // log("Total base optimal flow: "+aTotalOptimalFlow); + baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); + optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); + // log("Total eff: "+baseEff); + // log("Total optimal flow: "+optFlow); + if (optFlow <= 0 || baseEff <= 0) { + log("Running checkRecipeGeneric(bad-1)"); + stopMachine(); // in case the turbine got removed + return false; + } + } else { + counter++; + } + } + + // log("Total eff: "+baseEff); + // log("Total optimal flow: "+optFlow); + + // How much the turbine should be producing with this flow + int newPower = fluidIntoPower(tFluids, optFlow, baseEff); + // log("Bumped newPower to "+newPower); + // log("New Power: "+newPower); + int difference = newPower - this.mEUt; // difference between current output and new output + // log("diff: "+difference); + + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the + // difference in power level (per tick) + // This is how much the turbine can actually change during this tick + int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long) Math.abs(difference) / 100)); + // log("Max Change Allowed: "+maxChangeAllowed); + + if (Math.abs(difference) + > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change + int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. + this.mEUt += change; // Apply the change + // log("Applied power change."); + } else { + this.mEUt = newPower; + // log("Using same value."); + } + if (this.mEUt <= 0) { + this.mEUt = 0; + this.mEfficiency = 0; + log("Running checkRecipeGeneric(bad-2)"); + // stopMachine(); + return false; + } else { + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 10; + // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + // log("GOOD RETURN - Making: "+this.mEUt+" EU/t"); + return true; + } + } catch (Throwable t) { + t.printStackTrace(); + } + return false; + } + + public boolean doRandomMaintenanceDamage() { + if (getMaxParallelRecipes() == 0 || getRepairStatus() == 0) { + stopMachine(); + return false; + } + if (mRuntime++ > 1000) { + mRuntime = 0; + + if (getBaseMetaTileEntity().getRandomNumber(6000) < getMaintenanceThreshold()) { + switch (getBaseMetaTileEntity().getRandomNumber(6)) { + case 0: + mWrench = false; + break; + case 1: + mScrewdriver = false; + break; + case 2: + mSoftHammer = false; + break; + case 3: + mHardHammer = false; + break; + case 4: + mSolderingTool = false; + break; + case 5: + mCrowbar = false; + break; + } + } + for (GT_MetaTileEntity_Hatch_Turbine aHatch : getFullTurbineAssemblies()) { + // This cycle depletes durability from the turbine rotors. + // The amount of times it is run depends on turbineDamageMultiplier + // In XL turbines, durability loss is around 5.2-5.3x faster than in singles + // To compensate for that, the mEU/t scaling is divided by 5 to make it only slightly faster + for (int i = 0; i < getTurbineDamageMultiplier(); i++) { + aHatch.damageTurbine(mEUt / 5, damageFactorLow, damageFactorHigh); + } + } + } + return true; + } + + @Override + public int getMaxParallelRecipes() { + return (getFullTurbineAssemblies().size()); + } + + abstract int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff); + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + return this.getMaxParallelRecipes() == 12 ? 10000 : 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public boolean isLooseMode() { + return false; + } + + @Override + public String[] getExtraInfoData() { + int mPollutionReduction = (int) (100 * mufflerReduction); + + String tRunning = mMaxProgresstime > 0 + ? EnumChatFormatting.GREEN + + StatCollector.translateToLocal("GT5U.turbine.running.true") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + + StatCollector.translateToLocal("GT5U.turbine.running.false") + + EnumChatFormatting.RESET; + + String tMaintainance = getIdealStatus() == getRepairStatus() + ? EnumChatFormatting.GREEN + + StatCollector.translateToLocal("GT5U.turbine.maintenance.false") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + + StatCollector.translateToLocal("GT5U.turbine.maintenance.true") + + EnumChatFormatting.RESET; + int tDura = 0; + + StringBuilder aTurbineDamage = new StringBuilder(); + for (GT_MetaTileEntity_Hatch_Turbine aHatch : this.getFullTurbineAssemblies()) { + ItemStack aTurbine = aHatch.getTurbine(); + tDura = MathUtils.safeInt((long) (100.0f + / GT_MetaGenerated_Tool.getToolMaxDamage(aTurbine) + * (GT_MetaGenerated_Tool.getToolDamage(aTurbine)) + + 1)); + aTurbineDamage + .append(EnumChatFormatting.RED) + .append(tDura) + .append(EnumChatFormatting.RESET) + .append("% | "); + } + + long storedEnergy = 0; + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + + boolean aIsSteam = this.getClass().getName().toLowerCase().contains("steam"); + + String[] ret = new String[] { + // 8 Lines available for information panels + tRunning + ": " + EnumChatFormatting.RED + mEUt + EnumChatFormatting.RESET + " EU/t", + tMaintainance, + StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + EnumChatFormatting.YELLOW + + (mEfficiency / 100F) + EnumChatFormatting.RESET + "%", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + + MathUtils.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t" + + EnumChatFormatting.YELLOW + " (" + + (isLooseMode() + ? StatCollector.translateToLocal("GT5U.turbine.loose") + : StatCollector.translateToLocal("GT5U.turbine.tight")) + + ")", + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + EnumChatFormatting.GOLD + storedFluid + + EnumChatFormatting.RESET + "L", + StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + aTurbineDamage, + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + + mPollutionReduction + EnumChatFormatting.RESET + " %" + }; + if (!aIsSteam) + ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + + MathUtils.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t"; + return ret; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public boolean polluteEnvironment(int aPollutionLevel) { + if (this.requiresMufflers()) { + mPollution += aPollutionLevel * getPollutionMultiplier() * mufflerReduction; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (mPollution >= 10000) { + if (PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10000)) { + mPollution -= 10000; + } + } else { + break; + } + } + } + return mPollution < 10000; + } + return true; + } + + @Override + public long maxAmperesOut() { + // This should not be a hard limit, due to TecTech dynamos + if (mFastMode) { + return 64; + } else { + return 16; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mFastMode", mFastMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFastMode = aNBT.getBoolean("mFastMode"); + super.loadNBTData(aNBT); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mFastMode = Utils.invertBoolean(mFastMode); + if (mFastMode) { + PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); + } + } + + @Override + public final ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], + aFacing == aSide + ? getFrontFacingTurbineTexture(aActive) + : Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()) + }; + } + + protected ITexture getFrontFacingTurbineTexture(boolean isActive) { + if (isActive) { + return frontFaceActive; + } + return frontFace; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mUpdate == 1 || mStartUpCheck == 1) { + log("Cleared Rotor Assemblies."); + this.mTurbineRotorHatches.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.maxProgresstime() > 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + enableAllTurbineHatches(); + } + if (this.maxProgresstime() <= 0) { + stopMachine(); + } + } + + @Override + public void startProcess() { + super.startProcess(); + enableAllTurbineHatches(); + } + + @Override + public void stopMachine() { + baseEff = 0; + optFlow = 0; + disableAllTurbineHatches(); + super.stopMachine(); + } + + @Override + public void onRemoval() { + super.onRemoval(); + for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) { + h.clearController(); + } + disableAllTurbineHatches(); + this.mTurbineRotorHatches.clear(); + } + + public void enableAllTurbineHatches() { + updateTurbineHatches(this.isMachineRunning()); + } + + public void disableAllTurbineHatches() { + updateTurbineHatches(false); + } + + private Long mLastHatchUpdate; + + public int updateTurbineHatches(boolean aState) { + int aUpdated = 0; + if (mLastHatchUpdate == null) { + mLastHatchUpdate = System.currentTimeMillis() / 1000; + } + if (this.mTurbineRotorHatches.isEmpty() || ((System.currentTimeMillis() / 1000) - mLastHatchUpdate) <= 2) { + return 0; + } + for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) { + h.setActive(aState); + aUpdated++; + } + + mLastHatchUpdate = System.currentTimeMillis() / 1000; + return aUpdated; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Fix GT bug + if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { + log("Fixing Bad Facing. (GT Bug)"); + this.getBaseMetaTileEntity().setFrontFacing((byte) 1); + } + } -public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected int baseEff = 0; - protected int optFlow = 0; - protected double realOptFlow = 0; - protected int storedFluid = 0; - protected int counter = 0; - protected boolean mFastMode = false; - protected double mufflerReduction = 1; - - public ITexture frontFace; - public ITexture frontFaceActive; - - - public ArrayList mTurbineRotorHatches = new ArrayList(); - - - public GregtechMetaTileEntity_LargerTurbineBase(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - frontFace = getTextureFrontFace(); - frontFaceActive = getTextureFrontFaceActive(); - - } - public GregtechMetaTileEntity_LargerTurbineBase(String aName) { - super(aName); - frontFace = getTextureFrontFace(); - frontFaceActive = getTextureFrontFaceActive(); - } - - - protected abstract ITexture getTextureFrontFace(); - - protected abstract ITexture getTextureFrontFaceActive(); - - protected abstract String getTurbineType(); - - protected abstract String getCasingName(); - - protected abstract boolean requiresOutputHatch(); - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the XL "+getTurbineType()+" Turbine") - .addInfo("Runs as fast as 16 Large Turbines of the same type, takes the space of 12") - .addInfo("Right-click with screwdriver to enable Fast Mode, to run it even faster") - .addInfo("Optimal flow will increase or decrease accordingly on mode switch") - .addInfo("Fast Mode increases speed to 48x instead of 16x, with some penalties") - .addInfo("Maintenance problems and turbine damage happen 12x as often in Fast Mode") - .addInfo("XL Steam Turbines can use Loose Mode with either Slow or Fast Mode") - .addPollutionAmount(getPollutionPerSecond(null)) - .addInfo("Pollution is 3x higher in Fast Mode") - .addSeparator() - .beginStructureBlock(7, 9, 7, false) - .addController("Top Middle") - .addCasingInfo(getCasingName(), 360) - .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) - .addInputBus("Any 4 dot hint (min 1)", 4) - .addInputHatch("Any 4 dot hint(min 1)", 4); - if (requiresOutputHatch()) { - tt.addOutputHatch("Any 4 dot hint(min 1)", 4); - } - tt.addDynamoHatch("Any 4 dot hint(min 1)", 4) - .addMaintenanceHatch("Any 4 dot hint(min 1)", 4); - if (requiresMufflers()) { - tt.addMufflerHatch("Any 7 dot hint (x4)", 7); - } - tt.toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - private static final String STRUCTURE_PIECE_MAIN = "main"; - private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { - @Override - protected IStructureDefinition computeValue(Class type) { - return StructureDefinition.builder() - // c = turbine casing - // s = turbine shaft - // t = turbine housing - // h = dynamo/maint - // m = muffler - .addShape(STRUCTURE_PIECE_MAIN, (new String[][]{ - {"ccchccc", "ccccccc", "ccmmmcc", "ccm~mcc", "ccmmmcc", "ccccccc", "ccchccc"}, - {"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"}, - {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, - {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, - {"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"}, - {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, - {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, - {"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"}, - {"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"}, - })) - - .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) - .addElement('s', lazy(t -> ofBlock(t.getCasingBlock(), t.getTurbineShaftMeta()))) - .addElement('t', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) - .adder(GregtechMetaTileEntity_LargerTurbineBase::addTurbineHatch) - .hatchClass(GT_MetaTileEntity_Hatch_Turbine.class) - .casingIndex(t.getCasingTextureIndex()) - .dot(1) - .build())) - .addElement('h', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) - .atLeast(InputBus, InputHatch, OutputHatch, Dynamo.or(TTDynamo), Maintenance) - .casingIndex(t.getCasingTextureIndex()) - .dot(4) - .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) - .addElement('m', lazy(t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) - .atLeast(Muffler) - .casingIndex(t.getCasingTextureIndex()) - .dot(7) - .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) - .build(); - } - }; - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION.get(getClass()); - } - - private boolean requiresMufflers() { - if (!PollutionUtils.isPollutionEnabled()) { - return false; - } - return getPollutionPerSecond(null) > 0; - } - - public final double getMufflerReduction() { - double totalReduction = 0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - totalReduction += ((double) tHatch.calculatePollutionReduction(100)) / 100; - } - } - return totalReduction / 4; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - this.mDynamoHatches.clear(); - this.mTecTechDynamoHatches.clear(); - this.mTurbineRotorHatches.clear(); - this.mMaintenanceHatches.clear(); - if (requiresMufflers()) { - this.mMufflerHatches.clear(); - } - this.mInputBusses.clear(); - this.mInputHatches.clear(); - if (requiresOutputHatch()) { - this.mOutputHatches.clear(); - } - // we do not check for casing count here. the bare minimal is 372 but we only require 360 - boolean aStructure = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); - log("Structure Check: "+aStructure); - if (mTurbineRotorHatches.size() != 12 || - mMaintenanceHatches.size() != 1 || - (mDynamoHatches.size() < 1 && mTecTechDynamoHatches.size() < 1) || - (requiresMufflers() && mMufflerHatches.size() != 4) || - mInputBusses.size() < 1 || - mInputHatches.size() < 1 || - (requiresOutputHatch() && mOutputHatches.size() < 1) - ) { - log("Bad Hatches - Turbine Housings: "+mTurbineRotorHatches.size()+ - ", Maint: "+mMaintenanceHatches.size()+ - ", Dynamo: "+mDynamoHatches.size()+ - ", Muffler: "+mMufflerHatches.size()+ - ", Input Buses: "+mInputBusses.size()+ - ", Input Hatches: "+mInputHatches.size()+ - ", Output Hatches: "+mOutputHatches.size()); - return false; - } - mufflerReduction = getMufflerReduction(); - return aStructure; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); - return survivialBuildPiece(mName, stackSize, 1, 3, 3, realBudget, source, actor, false, true); - } - - public boolean addTurbineHatch(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { - log("Found GT_MetaTileEntity_Hatch_Turbine"); - updateTexture(aTileEntity, aBaseCasingIndex); - GT_MetaTileEntity_Hatch_Turbine aTurbineHatch = (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; - IGregTechTileEntity g = this.getBaseMetaTileEntity(); - if (aTurbineHatch.setController(new BlockPos(g.getXCoord(), g.getYCoord(), g.getZCoord(), g.getWorld()))) { - boolean aDidAdd = this.mTurbineRotorHatches.add(aTurbineHatch); - Logger.INFO("Injected Controller into Turbine Assembly. Found: "+this.mTurbineRotorHatches.size()); - return aDidAdd; - } - else { - Logger.INFO("Failed to inject controller into Turbine Assembly Hatch."); - } - } - log("Bad Turbine Housing"); - return false; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return getMaxEfficiency(aStack) > 0; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeTurbine.png"); - } - - public final Block getCasingBlock() { - return ModBlocks.blockSpecialMultiCasings; - } - - @Override - public final boolean hasSlotInGUI() { - return true; - } - - public abstract int getCasingMeta(); - - public byte getTurbineShaftMeta() { - return 0; - } - - public abstract byte getCasingTextureIndex(); - - public abstract int getFuelValue(FluidStack aLiquid); - - public static boolean isValidTurbine(ItemStack aTurbine) { - return (aTurbine !=null && aTurbine.getItem() instanceof GT_MetaGenerated_Tool && aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() <= 176); - } - - protected ArrayList getAllBufferedTurbines(){ - ArrayList aTurbinesInStorage = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_InputBus aBus: this.mInputBusses) { - if (isValidMetaTileEntity(aBus)) { - for (ItemStack aContent : aBus.mInventory) { - if (isValidTurbine(aContent)) { - aTurbinesInStorage.add(aContent); - } - } - } - } - return aTurbinesInStorage; - } - - public boolean areAllTurbinesTheSame() { - ArrayList aTurbineAssemblies = getFullTurbineAssemblies(); - if (aTurbineAssemblies.size() < 12) { - log("Found "+aTurbineAssemblies.size()+", expected 12."); - return false; - } - AutoMap aTurbineMats = new AutoMap<>(); - AutoMap aTurbineSizes = new AutoMap<>(); - for (GT_MetaTileEntity_Hatch_Turbine aHatch : aTurbineAssemblies) { - aTurbineMats.add(GT_MetaGenerated_Tool.getPrimaryMaterial(aHatch.getTurbine())); - aTurbineSizes.add(getTurbineSize(aHatch.getTurbine())); - } - Materials aBaseMat = aTurbineMats.get(0); - int aBaseSize = aTurbineSizes.get(0); - for (int aSize : aTurbineSizes) { - if (aBaseSize != aSize) { - return false; - } - } - for (Materials aMat : aTurbineMats) { - if (aBaseMat != aMat) { - return false; - } - } - return true; - } - - public static int getTurbineSize(ItemStack aTurbine) { - if (isValidTurbine(aTurbine)) { - if (aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() < 172) { - return 1; - } - else if (aTurbine.getItemDamage() >= 172 && aTurbine.getItemDamage() < 174) { - return 2; - } - else if (aTurbine.getItemDamage() >= 174 && aTurbine.getItemDamage() < 176) { - return 3; - } - else if (aTurbine.getItemDamage() >= 176 && aTurbine.getItemDamage() < 178) { - return 4; - } - } - return 0; - } - - public static String getTurbineSizeString(int aSize) { - switch (aSize) { - case 1: - return "Small Turbine"; - case 2: - return "Turbine"; - case 3: - return "Large Turbine"; - case 4: - return "Huge Turbine"; - default: - return ""; - } - } - - protected ArrayList getEmptyTurbineAssemblies() { - ArrayList aEmptyTurbineRotorHatches = new ArrayList(); - //log("Checking "+mTurbineRotorHatches.size()+" Assemblies for empties."); - for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { - if (!aTurbineHatch.hasTurbine()) { - //log("Found Assembly without Turbine."); - aEmptyTurbineRotorHatches.add(aTurbineHatch); - } - } - return aEmptyTurbineRotorHatches; - } - - protected ArrayList getFullTurbineAssemblies() { - ArrayList aTurbineRotorHatches = new ArrayList(); - //log("Checking "+mTurbineRotorHatches.size()+" Assemblies for Turbines."); - for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { - if (aTurbineHatch.hasTurbine()) { - //log("Found Assembly with Turbine."); - aTurbineRotorHatches.add(aTurbineHatch); - } - } - return aTurbineRotorHatches; - } - - protected boolean depleteTurbineFromStock(ItemStack aTurbine) { - for (GT_MetaTileEntity_Hatch_InputBus aInputBus : this.mInputBusses) { - for (int slot = 0; slot < aInputBus.mInventory.length; slot++) { - ItemStack aStack = aInputBus.getStackInSlot(slot); - if (aStack != null && GT_Utility.areStacksEqual(aStack, aTurbine)) { - aInputBus.setInventorySlotContents(slot, null); - updateSlots(); - return true; - } - } - } - return false; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - log("1"); - return checkRecipeGeneric(new ItemStack[] {}, getStoredFluids().toArray(new FluidStack[] {}), 1, 100, 100, 10000); - } - - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - try { - ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); - if (aEmptyTurbineRotorHatches.size() > 0) { - log("Found "+aEmptyTurbineRotorHatches.size()+" Assemblies without Turbine."); - hatch : for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { - ArrayList aTurbines = getAllBufferedTurbines(); - for (ItemStack aTurbineItem : aTurbines) { - if (aTurbineItem == null) { - continue; - } - if (aHatch.insertTurbine(aTurbineItem.copy())) { - boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); - log("Put Turbine into Assembly - "+aDidDeplete); - continue hatch; - } - } - } - } - - if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - log("BAD RETURN - 1"); - stopMachine(); - return false; - } - - ArrayList tFluids = getStoredFluids(); - - if (tFluids.size() > 0) { - if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() - || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { - counter = 0; - - //log("Running checkRecipeGeneric(1)"); - float aTotalBaseEff = 0; - float aTotalOptimalFlow = 0; - - ItemStack aStack = getFullTurbineAssemblies().get(0).getTurbine(); - for (int i = 0; i< getSpeedMultiplier(); i++) { - if (i == 0) { - aTotalBaseEff += GT_Utility.safeInt((long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - //log("Bumped base eff to "+aTotalBaseEff); - } - aTotalOptimalFlow += GT_Utility.safeInt((long) Math.max(Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed - * 50)); - //log("Bumped base optimal flow to "+aTotalOptimalFlow); - } - - //log("Running checkRecipeGeneric(2)"); - //log("Total base eff: "+aTotalBaseEff); - //log("Total base optimal flow: "+aTotalOptimalFlow); - baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); - optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); - //log("Total eff: "+baseEff); - //log("Total optimal flow: "+optFlow); - if(optFlow<=0 || baseEff<=0){ - log("Running checkRecipeGeneric(bad-1)"); - stopMachine();//in case the turbine got removed - return false; - } - } else { - counter++; - } - } - - //log("Total eff: "+baseEff); - //log("Total optimal flow: "+optFlow); - - // How much the turbine should be producing with this flow - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); - //log("Bumped newPower to "+newPower); - //log("New Power: "+newPower); - int difference = newPower - this.mEUt; // difference between current output and new output - //log("diff: "+difference); - - // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) - // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long)Math.abs(difference)/100)); - //log("Max Change Allowed: "+maxChangeAllowed); - - if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change - int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. - this.mEUt += change; // Apply the change - //log("Applied power change."); - } - else { - this.mEUt = newPower; - //log("Using same value."); - } - if (this.mEUt <= 0) { - this.mEUt=0; - this.mEfficiency=0; - log("Running checkRecipeGeneric(bad-2)"); - //stopMachine(); - return false; - } else { - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 10; - // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - //log("GOOD RETURN - Making: "+this.mEUt+" EU/t"); - return true; - } - } - catch (Throwable t) { - t.printStackTrace(); - } - return false; - } - - public boolean doRandomMaintenanceDamage() { - if (getMaxParallelRecipes() == 0 || getRepairStatus() == 0) { - stopMachine(); - return false; - } - if (mRuntime++ > 1000) { - mRuntime = 0; - - if (getBaseMetaTileEntity().getRandomNumber(6000) < getMaintenanceThreshold()) { - switch (getBaseMetaTileEntity().getRandomNumber(6)) { - case 0: - mWrench = false; - break; - case 1: - mScrewdriver = false; - break; - case 2: - mSoftHammer = false; - break; - case 3: - mHardHammer = false; - break; - case 4: - mSolderingTool = false; - break; - case 5: - mCrowbar = false; - break; - } - } - for (GT_MetaTileEntity_Hatch_Turbine aHatch : getFullTurbineAssemblies()) { - // This cycle depletes durability from the turbine rotors. - // The amount of times it is run depends on turbineDamageMultiplier - // In XL turbines, durability loss is around 5.2-5.3x faster than in singles - // To compensate for that, the mEU/t scaling is divided by 5 to make it only slightly faster - for (int i = 0; i < getTurbineDamageMultiplier(); i++) { - aHatch.damageTurbine(mEUt / 5, damageFactorLow, damageFactorHigh); - } - } - } - return true; - } - - @Override - public int getMaxParallelRecipes() { - return (getFullTurbineAssemblies().size()); - } - - abstract int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff); - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - - public int getMaxEfficiency(ItemStack aStack) { - return this.getMaxParallelRecipes() == 12 ? 10000 : 0; - } - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - public boolean isLooseMode() { - return false; - } - - @Override - public String[] getExtraInfoData() { - int mPollutionReduction=(int) (100 * mufflerReduction); - - String tRunning = mMaxProgresstime > 0 ? - EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.running.true")+EnumChatFormatting.RESET : - EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.running.false")+EnumChatFormatting.RESET; - - String tMaintainance = getIdealStatus() == getRepairStatus() ? - EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : - EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET ; - int tDura = 0; - - StringBuilder aTurbineDamage = new StringBuilder(); - for (GT_MetaTileEntity_Hatch_Turbine aHatch : this.getFullTurbineAssemblies()) { - ItemStack aTurbine = aHatch.getTurbine(); - tDura = MathUtils.safeInt((long)(100.0f / GT_MetaGenerated_Tool.getToolMaxDamage(aTurbine) * (GT_MetaGenerated_Tool.getToolDamage(aTurbine))+1)); - aTurbineDamage.append(EnumChatFormatting.RED).append(tDura).append(EnumChatFormatting.RESET).append("% | "); - } - - long storedEnergy=0; - long maxEnergy=0; - for(GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - - boolean aIsSteam = this.getClass().getName().toLowerCase().contains("steam"); - - String[] ret = new String[]{ - // 8 Lines available for information panels - tRunning + ": " + EnumChatFormatting.RED+mEUt+EnumChatFormatting.RESET+" EU/t", - tMaintainance, - StatCollector.translateToLocal("GT5U.turbine.efficiency")+": "+EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.RESET+"%", - StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", - StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+MathUtils.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t" + - EnumChatFormatting.YELLOW+" ("+(isLooseMode()?StatCollector.translateToLocal("GT5U.turbine.loose"):StatCollector.translateToLocal("GT5U.turbine.tight"))+")", - StatCollector.translateToLocal("GT5U.turbine.fuel")+": "+EnumChatFormatting.GOLD+storedFluid+EnumChatFormatting.RESET+"L", - StatCollector.translateToLocal("GT5U.turbine.dmg")+": "+aTurbineDamage, - StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" - }; - if (!aIsSteam) - ret[4]=StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+MathUtils.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t"; - return ret; - - - } - - @Override - public boolean isGivingInformation() { - return true; - } - - - public boolean polluteEnvironment(int aPollutionLevel) { - if (this.requiresMufflers()) { - mPollution += aPollutionLevel * getPollutionMultiplier() * mufflerReduction; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (mPollution >= 10000) { - if (PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10000)) { - mPollution -= 10000; - } - } else { - break; - } - } - } - return mPollution < 10000; - } - return true; - } - @Override - public long maxAmperesOut() { - // This should not be a hard limit, due to TecTech dynamos - if (mFastMode) { - return 64; - } - else { - return 16; - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mFastMode", mFastMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFastMode = aNBT.getBoolean("mFastMode"); - super.loadNBTData(aNBT); - } - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mFastMode = Utils.invertBoolean(mFastMode); - if (mFastMode){ - PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); - } - } - - @Override - public final ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? getFrontFacingTurbineTexture(aActive) : Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; - } - - protected ITexture getFrontFacingTurbineTexture(boolean isActive) { - if (isActive) { - return frontFaceActive; - } - return frontFace; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (mUpdate == 1 || mStartUpCheck == 1) { - log("Cleared Rotor Assemblies."); - this.mTurbineRotorHatches.clear(); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.maxProgresstime() > 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - enableAllTurbineHatches(); - } - if (this.maxProgresstime() <= 0) { - stopMachine(); - } - - } - @Override - public void startProcess() { - super.startProcess(); - enableAllTurbineHatches(); - } - - @Override - public void stopMachine() { - baseEff = 0; - optFlow = 0; - disableAllTurbineHatches(); - super.stopMachine(); - } - - @Override - public void onRemoval() { - super.onRemoval(); - for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) { - h.clearController(); - } - disableAllTurbineHatches(); - this.mTurbineRotorHatches.clear(); - } - - public void enableAllTurbineHatches() { - updateTurbineHatches(this.isMachineRunning()); - } - - public void disableAllTurbineHatches() { - updateTurbineHatches(false); - } - - private Long mLastHatchUpdate; - public int updateTurbineHatches(boolean aState) { - int aUpdated = 0; - if (mLastHatchUpdate == null) { - mLastHatchUpdate = System.currentTimeMillis()/1000; - } - if (this.mTurbineRotorHatches.isEmpty() || ((System.currentTimeMillis()/1000)-mLastHatchUpdate) <= 2) { - return 0; - } - for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) { - h.setActive(aState); - aUpdated++; - } - - mLastHatchUpdate = System.currentTimeMillis()/1000; - return aUpdated; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - // Fix GT bug - if (this.getBaseMetaTileEntity().getFrontFacing() != 1) { - log("Fixing Bad Facing. (GT Bug)"); - this.getBaseMetaTileEntity().setFrontFacing((byte) 1); - } - } - /** * Called every tick the Machine runs */ @@ -810,24 +857,24 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM return false; } - @Override - public boolean addEnergyOutput(long aEU) { - if (aEU <= 0) { - return true; - } - if (this.mAllDynamoHatches.size() > 0) { - return addEnergyOutputMultipleDynamos(aEU, true); - } - return false; - } - + @Override + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) { + return true; + } + if (this.mAllDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { int injected = 0; long totalOutput = 0; long aFirstVoltageFound = -1; boolean aFoundMixedDynamos = false; for (GT_MetaTileEntity_Hatch aDynamo : mAllDynamoHatches) { - if(aDynamo == null) { + if (aDynamo == null) { return false; } if (isValidMetaTileEntity(aDynamo)) { @@ -836,8 +883,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM // Check against voltage to check when hatch mixing if (aFirstVoltageFound == -1) { aFirstVoltageFound = aVoltage; - } - else { + } else { if (aFirstVoltageFound != aVoltage) { aFoundMixedDynamos = true; } @@ -857,33 +903,33 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM aVoltage = aDynamo.maxEUOutput(); aAmpsToInject = (int) (leftToInject / aVoltage); aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); - ampsOnCurrentHatch= (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); + ampsOnCurrentHatch = (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); for (int i = 0; i < ampsOnCurrentHatch; i++) { aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false); } - injected+=aVoltage*ampsOnCurrentHatch; - if(aRemainder>0 && ampsOnCurrentHatch 0 && ampsOnCurrentHatch < aDynamo.maxAmperesOut()) { aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false); - injected+=aRemainder; + injected += aRemainder; } } } return injected > 0; } - public int getSpeedMultiplier() { - return mFastMode ? 48 : 16; - } + public int getSpeedMultiplier() { + return mFastMode ? 48 : 16; + } - public int getMaintenanceThreshold() { - return mFastMode ? 12 : 1; - } + public int getMaintenanceThreshold() { + return mFastMode ? 12 : 1; + } - public int getPollutionMultiplier() { - return mFastMode ? 3 : 1; - } + public int getPollutionMultiplier() { + return mFastMode ? 3 : 1; + } - public int getTurbineDamageMultiplier() { - return mFastMode ? 3 : 1; - } + public int getTurbineDamageMultiplier() { + return mFastMode ? 3 : 1; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_MultiTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_MultiTank.java index 6ed14eb2a9..4ec9d0347f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_MultiTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_MultiTank.java @@ -1,33 +1,6 @@ /* package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage; -import java.util.ArrayList; -import java.util.Arrays; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_MultiTank extends GregtechMeta_MultiBlockBase { @@ -46,7 +19,7 @@ extends GregtechMeta_MultiBlockBase { public String getMachineType() { return "Fluid Tank"; } - + @Override public String[] getExtraInfoData() { final ArrayList mTier = this.mEnergyHatches; @@ -77,545 +50,545 @@ extends GregtechMeta_MultiBlockBase { super.saveNBTData(aNBT); */ /*final NBTTagCompound gtCraftingComponentsTag = aNBT.getCompoundTag("GT.CraftingComponents"); - if (gtCraftingComponentsTag != null){ - - Utils.LOG_WARNING("Got Crafting Tag"); - - if (this.internalStorageTank != null){ - Utils.LOG_WARNING("mFluid was not null, Saving TileEntity NBT data."); - - gtCraftingComponentsTag.setString("xFluid", this.internalStorageTank.getFluid().getName()); - gtCraftingComponentsTag.setInteger("xAmount", this.internalStorageTank.amount); - gtCraftingComponentsTag.setLong("xAmountMax", this.maximumFluidStorage); - - aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); - } - else { - Utils.LOG_WARNING("mFluid was null, Saving TileEntity NBT data."); - gtCraftingComponentsTag.removeTag("xFluid"); - gtCraftingComponentsTag.removeTag("xAmount"); - gtCraftingComponentsTag.removeTag("xAmountMax"); - gtCraftingComponentsTag.setLong("xAmountMax", this.maximumFluidStorage); - - - aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); - } - }*//* - - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - */ -/*final NBTTagCompound gtCraftingComponentsTag = aNBT.getCompoundTag("GT.CraftingComponents"); - String xFluid = null; - int xAmount = 0; - if (gtCraftingComponentsTag.hasNoTags()){ - if (this.internalStorageTank != null){ - Utils.LOG_WARNING("mFluid was not null, Creating TileEntity NBT data."); - gtCraftingComponentsTag.setInteger("xAmount", this.internalStorageTank.amount); - gtCraftingComponentsTag.setString("xFluid", this.internalStorageTank.getFluid().getName()); - aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); - } - } - else { - - //internalCraftingComponentsTag = gtCraftingComponentsTag.getCompoundTag("backupTag"); - - if (gtCraftingComponentsTag.hasKey("xFluid")){ - Utils.LOG_WARNING("xFluid was not null, Loading TileEntity NBT data."); - xFluid = gtCraftingComponentsTag.getString("xFluid"); - } - if (gtCraftingComponentsTag.hasKey("xAmount")){ - Utils.LOG_WARNING("xAmount was not null, Loading TileEntity NBT data."); - xAmount = gtCraftingComponentsTag.getInteger("xAmount"); - } - if ((xFluid != null) && (xAmount != 0)){ - Utils.LOG_WARNING("Setting Internal Tank, loading "+xAmount+"L of "+xFluid); - this.setInternalTank(xFluid, xAmount); - } - }*//* +if (gtCraftingComponentsTag != null){ - } - - private boolean setInternalTank(final String fluidName, final int amount){ - final FluidStack temp = FluidUtils.getFluidStack(fluidName, amount); - if (temp != null){ - if (this.internalStorageTank == null){ - this.internalStorageTank = temp; - Logger.WARNING(temp.getFluid().getName()+" Amount: "+temp.amount+"L"); - } - else{ - Logger.WARNING("Retained Fluid."); - Logger.WARNING(this.internalStorageTank.getFluid().getName()+" Amxount: "+this.internalStorageTank.amount+"L"); - } - this.markDirty(); - return true; - } - return false; - } + Utils.LOG_WARNING("Got Crafting Tag"); - @Override - public void onLeftclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - this.tryForceNBTUpdate(); - super.onLeftclick(aBaseMetaTileEntity, aPlayer); - } + if (this.internalStorageTank != null){ + Utils.LOG_WARNING("mFluid was not null, Saving TileEntity NBT data."); - @Override - public boolean onWrenchRightClick(final byte aSide, final byte aWrenchingSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { - this.tryForceNBTUpdate(); - return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); - } + gtCraftingComponentsTag.setString("xFluid", this.internalStorageTank.getFluid().getName()); + gtCraftingComponentsTag.setInteger("xAmount", this.internalStorageTank.amount); + gtCraftingComponentsTag.setLong("xAmountMax", this.maximumFluidStorage); - @Override - public void onRemoval() { - this.tryForceNBTUpdate(); - super.onRemoval(); + aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); } + else { + Utils.LOG_WARNING("mFluid was null, Saving TileEntity NBT data."); + gtCraftingComponentsTag.removeTag("xFluid"); + gtCraftingComponentsTag.removeTag("xAmount"); + gtCraftingComponentsTag.removeTag("xAmountMax"); + gtCraftingComponentsTag.setLong("xAmountMax", this.maximumFluidStorage); - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if ((this.internalStorageTank != null) && this.internalStorageTank.amount >= this.maximumFluidStorage){ - if (this.internalStorageTank.amount > this.maximumFluidStorage){ - this.internalStorageTank.amount = this.maximumFluidStorage; - } - this.stopMachine(); - } - - if (this.mInternalSaveClock != 20){ - this.mInternalSaveClock++; - } - else { - this.mInternalSaveClock = 0; - this.tryForceNBTUpdate(); - } - + aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); } +}*//* - public GregtechMetaTileEntity_MultiTank(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MultiTank(this.mName); - } + } - @Override - public String[] getTooltip() { - return new String[]{ - "Controller Block for the Multitank", - "Size: 3xHx3 (Block behind controller must be air)", - "Structure must be at least 4 blocks tall, maximum 20.", - "Each casing within the structure adds 128000L storage.", - "Multitank Exterior Casings (16 at least!)", - "Controller (front centered)", - "1x Input hatch", - "1x Output hatch", - "1x Energy Hatch", - }; + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + */ +/*final NBTTagCompound gtCraftingComponentsTag = aNBT.getCompoundTag("GT.CraftingComponents"); +String xFluid = null; +int xAmount = 0; +if (gtCraftingComponentsTag.hasNoTags()){ + if (this.internalStorageTank != null){ + Utils.LOG_WARNING("mFluid was not null, Creating TileEntity NBT data."); + gtCraftingComponentsTag.setInteger("xAmount", this.internalStorageTank.amount); + gtCraftingComponentsTag.setString("xFluid", this.internalStorageTank.getFluid().getName()); + aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); } +} +else { - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(11)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Screen_Logo : TexturesGtBlock.Overlay_Machine_Screen_Logo)}; - } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(11))}; - } + //internalCraftingComponentsTag = gtCraftingComponentsTag.getCompoundTag("backupTag"); - @Override - public boolean hasSlotInGUI() { - return false; + if (gtCraftingComponentsTag.hasKey("xFluid")){ + Utils.LOG_WARNING("xFluid was not null, Loading TileEntity NBT data."); + xFluid = gtCraftingComponentsTag.getString("xFluid"); } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; + if (gtCraftingComponentsTag.hasKey("xAmount")){ + Utils.LOG_WARNING("xAmount was not null, Loading TileEntity NBT data."); + xAmount = gtCraftingComponentsTag.getInteger("xAmount"); } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; + if ((xFluid != null) && (xAmount != 0)){ + Utils.LOG_WARNING("Setting Internal Tank, loading "+xAmount+"L of "+xFluid); + this.setInternalTank(xFluid, xAmount); } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - - final ArrayList tInputList = this.getStoredInputs(); - for (int i = 0; i < (tInputList.size() - 1); i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - final ArrayList tFluidList = this.getStoredFluids(); - for (int i = 0; i < (tFluidList.size() - 1); i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); - - if (tFluids.length >= 2){ - Logger.WARNING("Bad"); - return false; - } - - final ArrayList> rList = new ArrayList<>(); - int slotInputCount = 0; - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - boolean containsFluid = false; - if (isValidMetaTileEntity(tHatch)) { - slotInputCount++; - for (int i=0; i(tHatch, containsFluid)); - } - } - if ((tFluids.length <= 0) || (slotInputCount > 1)){ - Logger.WARNING("Bad"); - return false; - } - - Logger.WARNING("Okay - 2"); - if (this.internalStorageTank == null){ - Logger.WARNING("Okay - 3"); - if ((rList.get(0).getKey().mFluid != null) && (rList.get(0).getKey().mFluid.amount > 0)){ - Logger.WARNING("Okay - 4"); - Logger.WARNING("Okay - 1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount */ +}*//* + + } + + private boolean setInternalTank(final String fluidName, final int amount){ + final FluidStack temp = FluidUtils.getFluidStack(fluidName, amount); + if (temp != null){ + if (this.internalStorageTank == null){ + this.internalStorageTank = temp; + Logger.WARNING(temp.getFluid().getName()+" Amount: "+temp.amount+"L"); + } + else{ + Logger.WARNING("Retained Fluid."); + Logger.WARNING(this.internalStorageTank.getFluid().getName()+" Amxount: "+this.internalStorageTank.amount+"L"); + } + this.markDirty(); + return true; + } + return false; + } + + @Override + public void onLeftclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + this.tryForceNBTUpdate(); + super.onLeftclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean onWrenchRightClick(final byte aSide, final byte aWrenchingSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { + this.tryForceNBTUpdate(); + return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + } + + @Override + public void onRemoval() { + this.tryForceNBTUpdate(); + super.onRemoval(); + } + + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if ((this.internalStorageTank != null) && this.internalStorageTank.amount >= this.maximumFluidStorage){ + if (this.internalStorageTank.amount > this.maximumFluidStorage){ + this.internalStorageTank.amount = this.maximumFluidStorage; + } + this.stopMachine(); + } + + if (this.mInternalSaveClock != 20){ + this.mInternalSaveClock++; + } + else { + this.mInternalSaveClock = 0; + this.tryForceNBTUpdate(); + } + + } + + public GregtechMetaTileEntity_MultiTank(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MultiTank(this.mName); + } + + @Override + public String[] getTooltip() { + return new String[]{ + "Controller Block for the Multitank", + "Size: 3xHx3 (Block behind controller must be air)", + "Structure must be at least 4 blocks tall, maximum 20.", + "Each casing within the structure adds 128000L storage.", + "Multitank Exterior Casings (16 at least!)", + "Controller (front centered)", + "1x Input hatch", + "1x Output hatch", + "1x Energy Hatch", + }; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(11)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Screen_Logo : TexturesGtBlock.Overlay_Machine_Screen_Logo)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(11))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + + final ArrayList tInputList = this.getStoredInputs(); + for (int i = 0; i < (tInputList.size() - 1); i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + final ArrayList tFluidList = this.getStoredFluids(); + for (int i = 0; i < (tFluidList.size() - 1); i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); + + if (tFluids.length >= 2){ + Logger.WARNING("Bad"); + return false; + } + + final ArrayList> rList = new ArrayList<>(); + int slotInputCount = 0; + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + boolean containsFluid = false; + if (isValidMetaTileEntity(tHatch)) { + slotInputCount++; + for (int i=0; i(tHatch, containsFluid)); + } + } + if ((tFluids.length <= 0) || (slotInputCount > 1)){ + Logger.WARNING("Bad"); + return false; + } + + Logger.WARNING("Okay - 2"); + if (this.internalStorageTank == null){ + Logger.WARNING("Okay - 3"); + if ((rList.get(0).getKey().mFluid != null) && (rList.get(0).getKey().mFluid.amount > 0)){ + Logger.WARNING("Okay - 4"); + Logger.WARNING("Okay - 1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount */ /*+" internalStorageTank:"+internalStorageTank.amount*//* -); - final FluidStack tempFluidStack = rList.get(0).getKey().mFluid; - final Fluid tempFluid = tempFluidStack.getFluid(); - this.internalStorageTank = FluidUtils.getFluidStack(tempFluid.getName(), tempFluidStack.amount); - rList.get(0).getKey().mFluid.amount = 0; - Logger.WARNING("Okay - 1.1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount +" internalStorageTank:"+this.internalStorageTank.amount); - return true; - } - Logger.WARNING("No Fluid in hatch."); - return false; - } - else if (this.internalStorageTank.isFluidEqual(rList.get(0).getKey().mFluid)){ - Logger.WARNING("Storing "+rList.get(0).getKey().mFluid.amount+"L"); - Logger.WARNING("Contains "+this.internalStorageTank.amount+"L"); - - - int tempAdd = 0; - tempAdd = rList.get(0).getKey().getFluidAmount(); - rList.get(0).getKey().mFluid = null; - Logger.WARNING("adding "+tempAdd); - this.internalStorageTank.amount = this.internalStorageTank.amount + tempAdd; - Logger.WARNING("Tank now Contains "+this.internalStorageTank.amount+"L of "+this.internalStorageTank.getFluid().getName()+"."); - - - //Utils.LOG_WARNING("Tank"); - return true; - } - else { - final FluidStack superTempFluidStack = rList.get(0).getKey().mFluid; - Logger.WARNING("is input fluid equal to stored fluid? "+(this.internalStorageTank.isFluidEqual(superTempFluidStack))); - if (superTempFluidStack != null) { - Logger.WARNING("Input hatch[0] Contains "+superTempFluidStack.amount+"L of "+superTempFluidStack.getFluid().getName()+"."); - } - Logger.WARNING("Large Multi-Tank Contains "+this.internalStorageTank.amount+"L of "+this.internalStorageTank.getFluid().getName()+"."); - - if (this.internalStorageTank.amount <= 0){ - Logger.WARNING("Internal Tank is empty, sitting idle."); - return false; - } - - if ((this.mOutputHatches.get(0).mFluid == null) || this.mOutputHatches.isEmpty() || (this.mOutputHatches.get(0).mFluid.isFluidEqual(this.internalStorageTank) && (this.mOutputHatches.get(0).mFluid.amount < this.mOutputHatches.get(0).getCapacity()))){ - Logger.WARNING("Okay - 3"); - final int tempCurrentStored = this.internalStorageTank.amount; - int tempResult = 0; - final int tempHatchSize = this.mOutputHatches.get(0).getCapacity(); - final int tempHatchCurrentHolding = this.mOutputHatches.get(0).getFluidAmount(); - final int tempHatchRemainingSpace = tempHatchSize - tempHatchCurrentHolding; - final FluidStack tempOutputFluid = this.internalStorageTank; - if (tempHatchRemainingSpace <= 0){ - return false; - } - Logger.WARNING("Okay - 3.1.x"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored: "+tempCurrentStored+" output hatch holds: "+tempHatchCurrentHolding+" tank has "+tempHatchRemainingSpace+"L of space left."); - - if (tempHatchSize >= tempHatchRemainingSpace){ - Logger.WARNING("Okay - 3.1.1"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored: "+tempCurrentStored+" output hatch holds: "+tempHatchCurrentHolding+" tank has "+tempHatchRemainingSpace+"L of space left."); - - int adder; - if ((tempCurrentStored > 0) && (tempCurrentStored <= tempHatchSize)){ - adder = tempCurrentStored; - if (adder >= tempHatchRemainingSpace){ - adder = tempHatchRemainingSpace; - } - } - else { - adder = 0; - if (tempCurrentStored >= tempHatchRemainingSpace){ - adder = tempHatchRemainingSpace; - } - } - - tempResult = adder; - tempOutputFluid.amount = tempResult; - Logger.WARNING("Okay - 3.1.2"+" result: "+tempResult +" tempCurrentStored: "+tempCurrentStored + " filling output hatch with: "+tempOutputFluid.amount+"L of "+tempOutputFluid.getFluid().getName()); - this.mOutputHatches.get(0).fill(tempOutputFluid, true); - //mOutputHatches.get(0).mFluid.amount = tempResult; - this.internalStorageTank.amount = (tempCurrentStored-adder); - Logger.WARNING("Okay - 3.1.3"+" internalTankStorage: "+this.internalStorageTank.amount +"L | output hatch contains: "+this.mOutputHatches.get(0).mFluid.amount+"L of "+this.mOutputHatches.get(0).mFluid.getFluid().getName()); - */ + ); + final FluidStack tempFluidStack = rList.get(0).getKey().mFluid; + final Fluid tempFluid = tempFluidStack.getFluid(); + this.internalStorageTank = FluidUtils.getFluidStack(tempFluid.getName(), tempFluidStack.amount); + rList.get(0).getKey().mFluid.amount = 0; + Logger.WARNING("Okay - 1.1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount +" internalStorageTank:"+this.internalStorageTank.amount); + return true; + } + Logger.WARNING("No Fluid in hatch."); + return false; + } + else if (this.internalStorageTank.isFluidEqual(rList.get(0).getKey().mFluid)){ + Logger.WARNING("Storing "+rList.get(0).getKey().mFluid.amount+"L"); + Logger.WARNING("Contains "+this.internalStorageTank.amount+"L"); + + + int tempAdd = 0; + tempAdd = rList.get(0).getKey().getFluidAmount(); + rList.get(0).getKey().mFluid = null; + Logger.WARNING("adding "+tempAdd); + this.internalStorageTank.amount = this.internalStorageTank.amount + tempAdd; + Logger.WARNING("Tank now Contains "+this.internalStorageTank.amount+"L of "+this.internalStorageTank.getFluid().getName()+"."); + + + //Utils.LOG_WARNING("Tank"); + return true; + } + else { + final FluidStack superTempFluidStack = rList.get(0).getKey().mFluid; + Logger.WARNING("is input fluid equal to stored fluid? "+(this.internalStorageTank.isFluidEqual(superTempFluidStack))); + if (superTempFluidStack != null) { + Logger.WARNING("Input hatch[0] Contains "+superTempFluidStack.amount+"L of "+superTempFluidStack.getFluid().getName()+"."); + } + Logger.WARNING("Large Multi-Tank Contains "+this.internalStorageTank.amount+"L of "+this.internalStorageTank.getFluid().getName()+"."); + + if (this.internalStorageTank.amount <= 0){ + Logger.WARNING("Internal Tank is empty, sitting idle."); + return false; + } + + if ((this.mOutputHatches.get(0).mFluid == null) || this.mOutputHatches.isEmpty() || (this.mOutputHatches.get(0).mFluid.isFluidEqual(this.internalStorageTank) && (this.mOutputHatches.get(0).mFluid.amount < this.mOutputHatches.get(0).getCapacity()))){ + Logger.WARNING("Okay - 3"); + final int tempCurrentStored = this.internalStorageTank.amount; + int tempResult = 0; + final int tempHatchSize = this.mOutputHatches.get(0).getCapacity(); + final int tempHatchCurrentHolding = this.mOutputHatches.get(0).getFluidAmount(); + final int tempHatchRemainingSpace = tempHatchSize - tempHatchCurrentHolding; + final FluidStack tempOutputFluid = this.internalStorageTank; + if (tempHatchRemainingSpace <= 0){ + return false; + } + Logger.WARNING("Okay - 3.1.x"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored: "+tempCurrentStored+" output hatch holds: "+tempHatchCurrentHolding+" tank has "+tempHatchRemainingSpace+"L of space left."); + + if (tempHatchSize >= tempHatchRemainingSpace){ + Logger.WARNING("Okay - 3.1.1"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored: "+tempCurrentStored+" output hatch holds: "+tempHatchCurrentHolding+" tank has "+tempHatchRemainingSpace+"L of space left."); + + int adder; + if ((tempCurrentStored > 0) && (tempCurrentStored <= tempHatchSize)){ + adder = tempCurrentStored; + if (adder >= tempHatchRemainingSpace){ + adder = tempHatchRemainingSpace; + } + } + else { + adder = 0; + if (tempCurrentStored >= tempHatchRemainingSpace){ + adder = tempHatchRemainingSpace; + } + } + + tempResult = adder; + tempOutputFluid.amount = tempResult; + Logger.WARNING("Okay - 3.1.2"+" result: "+tempResult +" tempCurrentStored: "+tempCurrentStored + " filling output hatch with: "+tempOutputFluid.amount+"L of "+tempOutputFluid.getFluid().getName()); + this.mOutputHatches.get(0).fill(tempOutputFluid, true); + //mOutputHatches.get(0).mFluid.amount = tempResult; + this.internalStorageTank.amount = (tempCurrentStored-adder); + Logger.WARNING("Okay - 3.1.3"+" internalTankStorage: "+this.internalStorageTank.amount +"L | output hatch contains: "+this.mOutputHatches.get(0).mFluid.amount+"L of "+this.mOutputHatches.get(0).mFluid.getFluid().getName()); + */ /*if (internalStorageTank.amount <= 0) - internalStorageTank = null;*//* - - } - Logger.WARNING("Tank ok."); - return true; - } - } - //this.getBaseMetaTileEntity().(tFluids[0].amount, true); - Logger.WARNING("Tank"); - return false; - } - - @Override - public int getMaxParallelRecipes() { - return 1; +internalStorageTank = null;*//* + + } + Logger.WARNING("Tank ok."); + return true; + } + } + //this.getBaseMetaTileEntity().(tFluids[0].amount, true); + Logger.WARNING("Tank"); + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + Logger.WARNING("Must be hollow."); + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 19; h++) { + if ((h != 0) || ((((xDir + i) != 0) || ((zDir + j) != 0)) && ((i != 0) || (j != 0)))) { + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!this.addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11)))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + if (h < 3){ + Logger.WARNING("Casing Expected."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { + if (h < 3){ + Logger.WARNING("Wrong Meta."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (h < 3){ + tAmount++; + } + else if (h >= 3){ + if ((aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air) || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ + Logger.WARNING("Found air"); + } + else { + Logger.WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); + tAmount++; + } + } + } + } + } + } + } + this.multiblockCasingCount = (short) tAmount; + this.maximumFluidStorage = getMaximumTankStorage(tAmount); + Logger.INFO("Your Multitank can be 20 blocks tall."); + Logger.INFO("Casings Count: "+this.multiblockCasingCount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+this.maximumFluidStorage+"L"); + this.tryForceNBTUpdate(); + return tAmount >= 16; + } + + */ +/*public int countCasings() { + Utils.LOG_INFO("Counting Machine Casings"); + try{ + if (this.getBaseMetaTileEntity().getWorld() == null){ + Utils.LOG_INFO("Tile Entity's world was null for casing count."); + return 0; } - - @Override - public int getEuDiscountForParallelism() { + if (this.getBaseMetaTileEntity() == null){ + Utils.LOG_INFO("Tile Entity was null for casing count."); return 0; } - - @Override - public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - Logger.WARNING("Must be hollow."); - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 19; h++) { - if ((h != 0) || ((((xDir + i) != 0) || ((zDir + j) != 0)) && ((i != 0) || (j != 0)))) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!this.addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11)))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - if (h < 3){ - Logger.WARNING("Casing Expected."); - return false; - } - else if (h >= 3){ - //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); - } + } catch(NullPointerException r){ + Utils.LOG_INFO("Null Pointer Exception caught."); + return 0; + } + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; + if (!this.getBaseMetaTileEntity().getAirOffset(xDir, 0, zDir)) { + Utils.LOG_INFO("Failed due to air being misplaced."); + Utils.LOG_WARNING("Must be hollow."); + return 0; + } + int tAmount = 0; + Utils.LOG_INFO("Casing Count set to 0."); + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 19; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11)))) { + if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + if (h < 3){ + Utils.LOG_WARNING("Casing Expected."); + return 0; } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { - if (h < 3){ - Logger.WARNING("Wrong Meta."); - return false; - } - else if (h >= 3){ - //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); - } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); } + } + if (this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, h, zDir + j) != 11) { if (h < 3){ - tAmount++; + Utils.LOG_WARNING("Wrong Meta."); + return 0; } else if (h >= 3){ - if ((aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air) || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ - Logger.WARNING("Found air"); - } - else { - Logger.WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); - tAmount++; - } + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); } } - } - } - } - } - this.multiblockCasingCount = (short) tAmount; - this.maximumFluidStorage = getMaximumTankStorage(tAmount); - Logger.INFO("Your Multitank can be 20 blocks tall."); - Logger.INFO("Casings Count: "+this.multiblockCasingCount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+this.maximumFluidStorage+"L"); - this.tryForceNBTUpdate(); - return tAmount >= 16; - } - - */ -/*public int countCasings() { - Utils.LOG_INFO("Counting Machine Casings"); - try{ - if (this.getBaseMetaTileEntity().getWorld() == null){ - Utils.LOG_INFO("Tile Entity's world was null for casing count."); - return 0; - } - if (this.getBaseMetaTileEntity() == null){ - Utils.LOG_INFO("Tile Entity was null for casing count."); - return 0; - } - } catch(NullPointerException r){ - Utils.LOG_INFO("Null Pointer Exception caught."); - return 0; - } - int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; - if (!this.getBaseMetaTileEntity().getAirOffset(xDir, 0, zDir)) { - Utils.LOG_INFO("Failed due to air being misplaced."); - Utils.LOG_WARNING("Must be hollow."); - return 0; - } - int tAmount = 0; - Utils.LOG_INFO("Casing Count set to 0."); - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 19; h++) { - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11)))) { - if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - if (h < 3){ - Utils.LOG_WARNING("Casing Expected."); - return 0; - } - else if (h >= 3){ - //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); - } - } - if (this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, h, zDir + j) != 11) { - if (h < 3){ - Utils.LOG_WARNING("Wrong Meta."); - return 0; - } - else if (h >= 3){ - //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); - } + if (h < 3){ + tAmount++; + } + else if (h >= 3){ + if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j) == Blocks.air || this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ + Utils.LOG_WARNING("Found air"); } - if (h < 3){ + else { + Utils.LOG_WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); tAmount++; } - else if (h >= 3){ - if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j) == Blocks.air || this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ - Utils.LOG_WARNING("Found air"); - } - else { - Utils.LOG_WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); - tAmount++; - } - } } } } } } - Utils.LOG_INFO("Finished counting."); - multiblockCasingCount = (short) tAmount; - //Utils.LOG_INFO("Your Multitank can be 20 blocks tall."); - Utils.LOG_INFO("Casings Count: "+tAmount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+getMaximumTankStorage(tAmount)+"L"); - return tAmount; - }*//* - - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 5; } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { + Utils.LOG_INFO("Finished counting."); + multiblockCasingCount = (short) tAmount; + //Utils.LOG_INFO("Your Multitank can be 20 blocks tall."); + Utils.LOG_INFO("Casings Count: "+tAmount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+getMaximumTankStorage(tAmount)+"L"); + return tAmount; +}*//* + + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 5; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private static short getStorageMultiplier(final int casingCount){ + final int tsm = 1*casingCount; + if (tsm <= 0){ + return 1; + } + return (short) tsm; + } + + private static int getMaximumTankStorage(final int casingCount){ + final int multiplier = getStorageMultiplier(casingCount); + final int tempTankStorageMax = 128000*multiplier; + if (tempTankStorageMax <= 0){return 128000;} + return tempTankStorageMax; + } + + private boolean tryForceNBTUpdate(){ + */ +/* +//Block is invalid. +if ((this == null) || (this.getBaseMetaTileEntity() == null)){ + Utils.LOG_WARNING("Block was not valid for saving data."); + return false; +} + +//Don't need this to run clientside. +if (!this.getBaseMetaTileEntity().isServerSide()) { + return false; +} + +//Internal Tag was not valid. +try{ + if (this.internalCraftingComponentsTag == null){ + Utils.LOG_WARNING("Internal NBT data tag was null."); return false; } +} catch (final NullPointerException x){ + Utils.LOG_WARNING("Caught null NBT."); +} - private static short getStorageMultiplier(final int casingCount){ - final int tsm = 1*casingCount; - if (tsm <= 0){ - return 1; - } - return (short) tsm; - } - - private static int getMaximumTankStorage(final int casingCount){ - final int multiplier = getStorageMultiplier(casingCount); - final int tempTankStorageMax = 128000*multiplier; - if (tempTankStorageMax <= 0){return 128000;} - return tempTankStorageMax; - } - - private boolean tryForceNBTUpdate(){ -*/ -/* - //Block is invalid. - if ((this == null) || (this.getBaseMetaTileEntity() == null)){ - Utils.LOG_WARNING("Block was not valid for saving data."); - return false; - } - - //Don't need this to run clientside. - if (!this.getBaseMetaTileEntity().isServerSide()) { - return false; - } - - //Internal Tag was not valid. - try{ - if (this.internalCraftingComponentsTag == null){ - Utils.LOG_WARNING("Internal NBT data tag was null."); - return false; - } - } catch (final NullPointerException x){ - Utils.LOG_WARNING("Caught null NBT."); - } +//Internal tag was valid. +this.saveNBTData(this.internalCraftingComponentsTag); - //Internal tag was valid. - this.saveNBTData(this.internalCraftingComponentsTag); +//Mark block for update +int x,y,z = 0; +x = this.getBaseMetaTileEntity().getXCoord(); +y = this.getBaseMetaTileEntity().getYCoord(); +z = this.getBaseMetaTileEntity().getZCoord(); +this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(x, y, z); - //Mark block for update - int x,y,z = 0; - x = this.getBaseMetaTileEntity().getXCoord(); - y = this.getBaseMetaTileEntity().getYCoord(); - z = this.getBaseMetaTileEntity().getZCoord(); - this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(x, y, z); +//Mark block dirty, let chunk know it's data has changed and it must be saved to disk. (Albeit slowly) +this.getBaseMetaTileEntity().markDirty();*//* - //Mark block dirty, let chunk know it's data has changed and it must be saved to disk. (Albeit slowly) - this.getBaseMetaTileEntity().markDirty();*//* - - return true; - } -}*/ + return true; + } + }*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index 57f0b83100..3f62a67101 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -1,6 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage; -import java.util.function.Consumer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_HatchElement.Dynamo; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTEnergy; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -31,6 +38,7 @@ import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_PowerSubStation; import gtPlusPlus.xmod.gregtech.api.gui.GUI_PowerSubStation; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.util.function.Consumer; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -42,750 +50,767 @@ import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTEnergy; - -public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private static enum TopState { - MayBeTop, - Top, - NotTop - } - protected long mAverageEuUsage = 0; - protected final MovingAverageLong mAverageEuAdded = new MovingAverageLong(20); - protected final MovingAverageLong mAverageEuConsumed = new MovingAverageLong(20); - protected long mTotalEnergyAdded = 0; - protected long mTotalEnergyConsumed = 0; - protected long mTotalEnergyLost = 0; - protected boolean mIsOutputtingPower = false; - protected long mBatteryCapacity = 0; - - private final int ENERGY_TAX = 5; - - private int mCasing; - private int[] cellCount = new int[6]; - private TopState topState = TopState.MayBeTop; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_PowerSubStationController(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_PowerSubStationController(final String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Energy Buffer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Consumes " + this.ENERGY_TAX + "% of the average voltage of all energy type hatches") - .addInfo("Does not require maintenance") - .addInfo("Can be built with variable height between " + (CELL_HEIGHT_MIN + 2) + "-" + (CELL_HEIGHT_MAX + 2) + "") - .addInfo("Hatches can be placed nearly anywhere") - .addInfo("HV Energy/Dynamo Hatches are the lowest tier you can use") - .addInfo("Supports voltages >= UHV using MAX tier components.") - .addSeparator() - .addController("Bottom Center") - .addCasingInfo("Sub-Station External Casings", 10) - .addDynamoHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder); - return tt; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(24)), - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER)}; - } - if (aSide == this.getBaseMetaTileEntity().getBackFacing()) { - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(24)), - mIsOutputtingPower ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[(int) this.getOutputTier()] : Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[(int) this.getInputTier()]}; - } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(23))}; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - //if (mBatteryCapacity <= 0) return false; - if (!aBaseMetaTileEntity.isClientSide()) { - aBaseMetaTileEntity.openGUI(aPlayer); - } - return true; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_PowerSubStation(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "Ergon Energy - Sub Station"); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_PowerSubStation(aPlayerInventory, aBaseMetaTileEntity); - } - - private void checkMachineProblem(String msg, int xOff, int yOff, int zOff) { - final IGregTechTileEntity te = this.getBaseMetaTileEntity(); - final Block tBlock = te.getBlockOffset(xOff, yOff, zOff); - final byte tMeta = te.getMetaIDOffset(xOff, yOff, zOff); - String name = tBlock.getLocalizedName(); - String problem = msg + ": (" + xOff + ", " + yOff + ", " + zOff + ") " + name + ":" + tMeta; - checkMachineProblem(problem); - } - private void checkMachineProblem(String msg) { - if (!AsmConfig.disableAllLogging) { - Logger.INFO("Power Sub-Station problem: " + msg); - } - } - - public static int getCellTier(Block aBlock, int aMeta) { - if (aBlock == ModBlocks.blockCasings2Misc && aMeta == 7) { - return 4; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 4) { - return 5; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 5) { - return 6; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 6) { - return 7; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 7) { - return 8; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 8) { - return 9; - } else { - return -1; - } - } - - public static int getMetaFromTier(int tier) { - if (tier == 4) return 7; - if (tier >= 5 && tier <= 9) return tier - 1; - return 0; - } - - public static Block getBlockFromTier(int tier) { - switch (tier) { - case 4: return ModBlocks.blockCasings2Misc; - case 5: case 6: case 7: case 8: case 9: return ModBlocks.blockCasings3Misc; - default: return null; - } - } - - public static int getMaxHatchTier(int aCellTier) { - switch(aCellTier) { - case 9: - return GT_Values.VOLTAGE_NAMES[9].equals("Ultimate High Voltage") ? 15 : 9; - default: - if (aCellTier < 4) { - return 0; - } - else { - return aCellTier; - } - } - } - - public static final int CELL_HEIGHT_MAX = 16; - public static final int CELL_HEIGHT_MIN = 2; - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName + "bottom", transpose(new String[][]{ - {"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"} - })) - .addShape(mName + "layer", transpose(new String[][]{ - {"CCCCC", "CIIIC", "CIIIC", "CIIIC", "CCCCC"} - })) - .addShape(mName + "mid", transpose(new String[][]{ - {"CCCCC", "CHHHC", "CHHHC", "CHHHC", "CCCCC"} - })) - .addShape(mName + "top", transpose(new String[][]{ - {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"} - })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_PowerSubStationController.class) - .atLeast(Energy.or(TTEnergy), Dynamo.or(TTDynamo), Maintenance) - .casingIndex(TAE.GTPP_INDEX(24)) - .dot(1) - .buildAndChain( - onElementPass( - x -> ++x.mCasing, - ofBlock( - ModBlocks.blockCasings2Misc, 8 - ) - ) - ) - ) - .addElement( - 'I', - ofChain( - onlyIf( - x -> x.topState != TopState.NotTop, - onElementPass( - x -> x.topState = TopState.Top, - ofHatchAdderOptional(GregtechMetaTileEntity_PowerSubStationController::addPowerSubStationList, TAE.GTPP_INDEX(24), 1, ModBlocks.blockCasings2Misc, 8) - ) - ), - onlyIf( - x -> x.topState != TopState.Top, - onElementPass( - x -> x.topState = TopState.NotTop, - ofChain( - onElementPass( - x -> ++x.cellCount[0], - ofCell(4) - ), - onElementPass( - x -> ++x.cellCount[1], - ofCell(5) - ), - onElementPass( - x -> ++x.cellCount[2], - ofCell(6) - ), - onElementPass( - x -> ++x.cellCount[3], - ofCell(7) - ), - onElementPass( - x -> ++x.cellCount[4], - ofCell(8) - ), - onElementPass( - x -> ++x.cellCount[5], - ofCell(9) - ) - ) - ) - ) - ) - ) - .addElement('H', ofCell(4)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - public static IStructureElement ofCell(int aIndex) { - return new IStructureElement() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - int tier = getCellTier(block, meta); - return aIndex == tier; - } - - public int getIndex(int size) { - if (size > 6) size = 6; - return size + 3; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, getBlockFromTier(getIndex(trigger.stackSize)), getMetaFromTier(getIndex(trigger.stackSize))); - return true; - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return world.setBlock(x, y, z, getBlockFromTier(getIndex(trigger.stackSize)), getMetaFromTier(getIndex(trigger.stackSize)), 3); - } - - @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer chatter) { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - int tier = getCellTier(block, meta); - if (tier >= 0) return PlaceResult.SKIP; - return StructureUtility.survivalPlaceBlock(getBlockFromTier(getIndex(trigger.stackSize)), getMetaFromTier(getIndex(trigger.stackSize)), world, x, y, z, s, actor, chatter); - } - }; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - int layer = Math.min(stackSize.stackSize + 3, 18); - log("Layer: "+layer); - log("Building 0"); - buildPiece(mName + "bottom" , stackSize, hintsOnly, 2, 0, 0); - log("Built 0"); - for (int i = 1; i < layer - 1; i++) { - log("Building "+i); - buildPiece(mName + "mid", stackSize, hintsOnly, 2, i, 0); - log("Built "+i); - } - log("Building "+(layer - 1)); - buildPiece(mName + "top", stackSize, hintsOnly, 2, layer - 1, 0); - log("Built "+(layer - 1)); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; - int layer = Math.min(stackSize.stackSize + 3, 18); - int built; - built = survivialBuildPiece(mName + "bottom", stackSize, 2, 0, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - for (int i = 1; i < layer - 1; i++) { - built = survivialBuildPiece(mName + "mid", stackSize, 2, i, 0, elementBudget, source, actor, false, true); - if (built >= 0) return built; - } - return survivialBuildPiece(mName + "top", stackSize, 2, layer - 1, 0, elementBudget, source, actor, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mEnergyHatches.clear(); - mDynamoHatches.clear(); - mTecTechEnergyHatches.clear(); - mTecTechDynamoHatches.clear(); - mAllEnergyHatches.clear(); - mAllDynamoHatches.clear(); - for (int i = 0; i < 6; i++) { - cellCount[i] = 0; - } - log("Checking 0"); - if (!checkPiece(mName + "bottom", 2, 0, 0)) { - log("Failed on Layer 0"); - return false; - } - log("Pass 0"); - int layer = 1; - topState = TopState.MayBeTop; - while (true) { - if (!checkPiece(mName + "layer", 2, layer, 0)) - return false; - layer ++; - if (topState == TopState.Top) - break; // top found, break out - topState = TopState.MayBeTop; - if (layer > 18) - return false; // too many layers - } - int level = 0; - for (int i = 0; i < 6; i++) { - if (cellCount[i] != 0) { - if (level == 0) { - level = i + 4; - } - else { - return false; - } - } - } - int tier = getMaxHatchTier(level); - long volSum = 0; - for (GT_MetaTileEntity_Hatch hatch : mAllDynamoHatches) { - if (hatch.mTier > tier || hatch.mTier < 3) { - return false; - } - volSum += (8L << (hatch.mTier * 2)); - } - for (GT_MetaTileEntity_Hatch hatch : mAllEnergyHatches) { - if (hatch.mTier > tier || hatch.mTier < 3) { - return false; - } - volSum += (8L << (hatch.mTier * 2)); - } - mBatteryCapacity = getCapacityFromCellTier(level) * cellCount[level - 4]; - if (mAllEnergyHatches.size() + mAllDynamoHatches.size() > 0) { - mAverageEuUsage = volSum / (mAllEnergyHatches.size() + mAllDynamoHatches.size()); - } - else mAverageEuUsage = 0; - fixAllMaintenanceIssue(); - return true; - } - - public final boolean addPowerSubStationList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - else if (LoadedMods.TecTech) { - if (isThisHatchMultiDynamo(aMetaTileEntity)) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (isThisHatchMultiEnergy(aMetaTileEntity)) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - } - return false; - } - - // Define storage capacity of smallest cell tier (EV) and compute higher tiers from it - private static final long CELL_TIER_EV_CAPACITY = 100 * 1000 * 1000; - private static final long CELL_TIER_MULTIPLIER = 4; // each tier's capacity is this many times the previous tier - - public static long getCapacityFromCellTier(int aOverallCellTier) { - // Use integer math instead of `Math.pow` to avoid range/precision errors - if (aOverallCellTier < 4) return 0; - aOverallCellTier -= 4; - long capacity = CELL_TIER_EV_CAPACITY; - while (aOverallCellTier > 0) { - capacity *= CELL_TIER_MULTIPLIER; - aOverallCellTier--; - } - return capacity; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_PowerSubStationController(this.mName); - } - - //mTotalEnergyAdded - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setLong("mAverageEuUsage", this.mAverageEuUsage); - this.mAverageEuAdded.write(aNBT, "mAverageEuAdded"); - this.mAverageEuConsumed.write(aNBT, "mAverageEuConsumed"); - - //Usage Stats - aNBT.setLong("mTotalEnergyAdded", this.mTotalEnergyAdded); - aNBT.setLong("mTotalEnergyLost", this.mTotalEnergyLost); - aNBT.setLong("mTotalEnergyConsumed", this.mTotalEnergyConsumed); - aNBT.setLong("mTotalRunTime", this.mTotalRunTime); - aNBT.setBoolean("mIsOutputtingPower", this.mIsOutputtingPower); - aNBT.setLong("mBatteryCapacity", this.mBatteryCapacity); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - - // Best not to get a long if the Tag Map is holding an int - if (aNBT.hasKey("mAverageEuUsage")) { - this.mAverageEuUsage = aNBT.getLong("mAverageEuUsage"); - } - switch (aNBT.func_150299_b("mAverageEuAdded")) { - case NBT.TAG_BYTE_ARRAY: - this.mAverageEuAdded.read(aNBT, "mAverageEuAdded"); - break; - case NBT.TAG_LONG: - this.mAverageEuAdded.set(aNBT.getLong("mAverageEuAdded")); - break; - } - switch (aNBT.func_150299_b("mAverageEuConsumed")) { - case NBT.TAG_BYTE_ARRAY: - this.mAverageEuConsumed.read(aNBT, "mAverageEuConsumed"); - break; - case NBT.TAG_LONG: - this.mAverageEuConsumed.set(aNBT.getLong("mAverageEuConsumed")); - break; - } - - //Usage Stats - this.mTotalEnergyAdded = aNBT.getLong("mTotalEnergyAdded"); - this.mTotalEnergyLost = aNBT.getLong("mTotalEnergyLost"); - this.mTotalEnergyConsumed = aNBT.getLong("mTotalEnergyConsumed"); - this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); - - this.mIsOutputtingPower = aNBT.getBoolean("mIsOutputtingPower"); - - this.mBatteryCapacity = aNBT.getLong("mBatteryCapacity"); - - super.loadNBTData(aNBT); - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - this.mProgresstime = 0; - this.mMaxProgresstime = 200; - this.mEUt = 0; - this.mEfficiencyIncrease = 10000; - this.fixAllMaintenanceIssue(); - return true; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - private long drawEnergyFromHatch(MetaTileEntity aHatch) { - if (!isValidMetaTileEntity(aHatch)) { - return 0; - } - - long stored = aHatch.getEUVar(); - long voltage = aHatch.maxEUInput() * aHatch.maxAmperesIn(); - - if (voltage > stored) { - return 0; - } - - if (this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false)) { - aHatch.setEUVar((stored - voltage)); - this.mTotalEnergyAdded += voltage; - return voltage; - } - return 0; - } - - private long addEnergyToHatch(MetaTileEntity aHatch) { - if (!isValidMetaTileEntity(aHatch)) { - return 0; - } - - long voltage = aHatch.maxEUOutput() * aHatch.maxAmperesOut(); - - if (aHatch.getEUVar() > aHatch.maxEUStore() - voltage) { - return 0; - } - - if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(voltage, false)) { - aHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false); - this.mTotalEnergyConsumed+=voltage; - return voltage; - } - return 0; - } - - private long computeEnergyTax() { - float mTax = mAverageEuUsage * (ENERGY_TAX / 100f); - - // Increase tax up to 2x if machine is not fully repaired - mTax = mTax * (1f + (10000f - mEfficiency) / 10000f); - - return MathUtils.roundToClosestLong(mTax); - } - - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - this.fixAllMaintenanceIssue(); - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - // First, decay overcharge (1% of stored energy plus 1000 EU per tick) - if (this.getEUVar() > this.mBatteryCapacity) { - long energy = (long) (this.getEUVar() * 0.990f) - 1000; - this.setEUVar(energy); - } - - // Pay Tax - long mDecrease = computeEnergyTax(); - this.mTotalEnergyLost += Math.min(mDecrease, this.getEUVar()); - this.setEUVar(Math.max(0, this.getEUVar() - mDecrease)); - - long aInputAverage = 0; - long aOutputAverage = 0; - // Input Power - for (GT_MetaTileEntity_Hatch THatch : this.mDischargeHatches) { - aInputAverage += drawEnergyFromHatch(THatch); - } - for (GT_MetaTileEntity_Hatch tHatch : this.mAllEnergyHatches) { - aInputAverage += drawEnergyFromHatch(tHatch); - } - - // Output Power - for (GT_MetaTileEntity_Hatch THatch : this.mChargeHatches) { - aOutputAverage += addEnergyToHatch(THatch); - } - for (GT_MetaTileEntity_Hatch tHatch : this.mAllDynamoHatches) { - aOutputAverage += addEnergyToHatch(tHatch); - } - // reset progress time - mProgresstime = 0; - - this.mAverageEuAdded.sample(aInputAverage); - this.mAverageEuConsumed.sample(aOutputAverage); - - return true; - - } - - @Override - public boolean drainEnergyInput(long aEU) { - // Not applicable to this machine - return true; - } - - @Override - public boolean addEnergyOutput(long aEU) { - // Not applicable to this machine - return true; - } - - @Override - public long maxEUStore() { - return mBatteryCapacity; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public String[] getExtraInfoData() { - String mode; - if (mIsOutputtingPower) { - mode = EnumChatFormatting.GOLD + "Output" + EnumChatFormatting.RESET; - } else { - mode = EnumChatFormatting.BLUE + "Input" + EnumChatFormatting.RESET; - } - - String storedEnergyText; - if (this.getEUVar() > this.mBatteryCapacity) { - storedEnergyText = EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; - } else { - storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; - } - - int errorCode = this.getBaseMetaTileEntity().getErrorDisplayID(); - boolean mMaint = (errorCode != 0); - - return new String[]{ - "Ergon Energy - District Sub-Station", - "Stored EU: " + storedEnergyText, - "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, - "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.computeEnergyTax()) + EnumChatFormatting.RESET + " EU/t", - "Controller Mode: " + mode, - "Requires Maintenance: " + (!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED)+ mMaint + EnumChatFormatting.RESET +" | Code: ["+(!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + errorCode + EnumChatFormatting.RESET +"]", - "----------------------", - "Stats for Nerds", - "Average Input: " + EnumChatFormatting.BLUE + this.mAverageEuAdded + EnumChatFormatting.RESET + " EU", - "Average Output: " + EnumChatFormatting.GOLD + this.mAverageEuConsumed + EnumChatFormatting.RESET + " EU", - "Total Input: " + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(this.mTotalEnergyAdded) + EnumChatFormatting.RESET + " EU", - "Total Output: " + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(this.mTotalEnergyConsumed) + EnumChatFormatting.RESET + " EU", - "Total Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.mTotalEnergyLost) + EnumChatFormatting.RESET + " EU", - }; - } - - @Override - public void explodeMultiblock() { - // TODO Auto-generated method stub - super.explodeMultiblock(); - } - - @Override - public void doExplosion(long aExplosionPower) { - // TODO Auto-generated method stub - super.doExplosion(aExplosionPower); - } - - @Override - public long getMaxInputVoltage() { - return 32768; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isEnetInput() { - return !mIsOutputtingPower; - } - - @Override - public boolean isEnetOutput() { - return mIsOutputtingPower; - } - - @Override - public boolean isInputFacing(byte aSide) { - return (aSide == this.getBaseMetaTileEntity().getBackFacing() && !mIsOutputtingPower); - } - - @Override - public boolean isOutputFacing(byte aSide) { - return (aSide == this.getBaseMetaTileEntity().getBackFacing() && mIsOutputtingPower); - } - - @Override - public long maxAmperesIn() { - return 32; - } - - @Override - public long maxAmperesOut() { - return 32; - } - - @Override - public long maxEUInput() { - return 32768; - } - - @Override - public long maxEUOutput() { - return 32768; - } - - public final long getAverageEuAdded() { - return this.mAverageEuAdded.get(); - } - - public final long getAverageEuConsumed() { - return this.mAverageEuConsumed.get(); - } - - @Override - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mIsOutputtingPower = Utils.invertBoolean(mIsOutputtingPower); - if (mIsOutputtingPower) { - PlayerUtils.messagePlayer(aPlayer, "Sub-Station is now outputting power from the controller."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Sub-Station is now inputting power into the controller."); - } - } - -} \ No newline at end of file +public class GregtechMetaTileEntity_PowerSubStationController + extends GregtechMeta_MultiBlockBase + implements ISurvivalConstructable { + + private static enum TopState { + MayBeTop, + Top, + NotTop + } + + protected long mAverageEuUsage = 0; + protected final MovingAverageLong mAverageEuAdded = new MovingAverageLong(20); + protected final MovingAverageLong mAverageEuConsumed = new MovingAverageLong(20); + protected long mTotalEnergyAdded = 0; + protected long mTotalEnergyConsumed = 0; + protected long mTotalEnergyLost = 0; + protected boolean mIsOutputtingPower = false; + protected long mBatteryCapacity = 0; + + private final int ENERGY_TAX = 5; + + private int mCasing; + private int[] cellCount = new int[6]; + private TopState topState = TopState.MayBeTop; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_PowerSubStationController( + final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_PowerSubStationController(final String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Energy Buffer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Consumes " + this.ENERGY_TAX + "% of the average voltage of all energy type hatches") + .addInfo("Does not require maintenance") + .addInfo("Can be built with variable height between " + (CELL_HEIGHT_MIN + 2) + "-" + + (CELL_HEIGHT_MAX + 2) + "") + .addInfo("Hatches can be placed nearly anywhere") + .addInfo("HV Energy/Dynamo Hatches are the lowest tier you can use") + .addInfo("Supports voltages >= UHV using MAX tier components.") + .addSeparator() + .addController("Bottom Center") + .addCasingInfo("Sub-Station External Casings", 10) + .addDynamoHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(24)), + new GT_RenderedTexture( + aActive + ? Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE + : Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER) + }; + } + if (aSide == this.getBaseMetaTileEntity().getBackFacing()) { + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(24)), + mIsOutputtingPower + ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[(int) this.getOutputTier()] + : Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[(int) this.getInputTier()] + }; + } + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(23))}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + // if (mBatteryCapacity <= 0) return false; + if (!aBaseMetaTileEntity.isClientSide()) { + aBaseMetaTileEntity.openGUI(aPlayer); + } + return true; + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_PowerSubStation( + aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "Ergon Energy - Sub Station"); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_PowerSubStation(aPlayerInventory, aBaseMetaTileEntity); + } + + private void checkMachineProblem(String msg, int xOff, int yOff, int zOff) { + final IGregTechTileEntity te = this.getBaseMetaTileEntity(); + final Block tBlock = te.getBlockOffset(xOff, yOff, zOff); + final byte tMeta = te.getMetaIDOffset(xOff, yOff, zOff); + String name = tBlock.getLocalizedName(); + String problem = msg + ": (" + xOff + ", " + yOff + ", " + zOff + ") " + name + ":" + tMeta; + checkMachineProblem(problem); + } + + private void checkMachineProblem(String msg) { + if (!AsmConfig.disableAllLogging) { + Logger.INFO("Power Sub-Station problem: " + msg); + } + } + + public static int getCellTier(Block aBlock, int aMeta) { + if (aBlock == ModBlocks.blockCasings2Misc && aMeta == 7) { + return 4; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 4) { + return 5; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 5) { + return 6; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 6) { + return 7; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 7) { + return 8; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 8) { + return 9; + } else { + return -1; + } + } + + public static int getMetaFromTier(int tier) { + if (tier == 4) return 7; + if (tier >= 5 && tier <= 9) return tier - 1; + return 0; + } + + public static Block getBlockFromTier(int tier) { + switch (tier) { + case 4: + return ModBlocks.blockCasings2Misc; + case 5: + case 6: + case 7: + case 8: + case 9: + return ModBlocks.blockCasings3Misc; + default: + return null; + } + } + + public static int getMaxHatchTier(int aCellTier) { + switch (aCellTier) { + case 9: + return GT_Values.VOLTAGE_NAMES[9].equals("Ultimate High Voltage") ? 15 : 9; + default: + if (aCellTier < 4) { + return 0; + } else { + return aCellTier; + } + } + } + + public static final int CELL_HEIGHT_MAX = 16; + public static final int CELL_HEIGHT_MIN = 2; + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName + "bottom", transpose(new String[][] {{"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}})) + .addShape( + mName + "layer", transpose(new String[][] {{"CCCCC", "CIIIC", "CIIIC", "CIIIC", "CCCCC"}})) + .addShape(mName + "mid", transpose(new String[][] {{"CCCCC", "CHHHC", "CHHHC", "CHHHC", "CCCCC"}})) + .addShape(mName + "top", transpose(new String[][] {{"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}})) + .addElement( + 'C', + buildHatchAdder(GregtechMetaTileEntity_PowerSubStationController.class) + .atLeast(Energy.or(TTEnergy), Dynamo.or(TTDynamo), Maintenance) + .casingIndex(TAE.GTPP_INDEX(24)) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 8)))) + .addElement( + 'I', + ofChain( + onlyIf( + x -> x.topState != TopState.NotTop, + onElementPass( + x -> x.topState = TopState.Top, + ofHatchAdderOptional( + GregtechMetaTileEntity_PowerSubStationController + ::addPowerSubStationList, + TAE.GTPP_INDEX(24), + 1, + ModBlocks.blockCasings2Misc, + 8))), + onlyIf( + x -> x.topState != TopState.Top, + onElementPass( + x -> x.topState = TopState.NotTop, + ofChain( + onElementPass(x -> ++x.cellCount[0], ofCell(4)), + onElementPass(x -> ++x.cellCount[1], ofCell(5)), + onElementPass(x -> ++x.cellCount[2], ofCell(6)), + onElementPass(x -> ++x.cellCount[3], ofCell(7)), + onElementPass(x -> ++x.cellCount[4], ofCell(8)), + onElementPass(x -> ++x.cellCount[5], ofCell(9))))))) + .addElement('H', ofCell(4)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public static IStructureElement ofCell(int aIndex) { + return new IStructureElement() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + int tier = getCellTier(block, meta); + return aIndex == tier; + } + + public int getIndex(int size) { + if (size > 6) size = 6; + return size + 3; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle( + world, + x, + y, + z, + getBlockFromTier(getIndex(trigger.stackSize)), + getMetaFromTier(getIndex(trigger.stackSize))); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock( + x, + y, + z, + getBlockFromTier(getIndex(trigger.stackSize)), + getMetaFromTier(getIndex(trigger.stackSize)), + 3); + } + + @Override + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer chatter) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + int tier = getCellTier(block, meta); + if (tier >= 0) return PlaceResult.SKIP; + return StructureUtility.survivalPlaceBlock( + getBlockFromTier(getIndex(trigger.stackSize)), + getMetaFromTier(getIndex(trigger.stackSize)), + world, + x, + y, + z, + s, + actor, + chatter); + } + }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + int layer = Math.min(stackSize.stackSize + 3, 18); + log("Layer: " + layer); + log("Building 0"); + buildPiece(mName + "bottom", stackSize, hintsOnly, 2, 0, 0); + log("Built 0"); + for (int i = 1; i < layer - 1; i++) { + log("Building " + i); + buildPiece(mName + "mid", stackSize, hintsOnly, 2, i, 0); + log("Built " + i); + } + log("Building " + (layer - 1)); + buildPiece(mName + "top", stackSize, hintsOnly, 2, layer - 1, 0); + log("Built " + (layer - 1)); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + int layer = Math.min(stackSize.stackSize + 3, 18); + int built; + built = survivialBuildPiece(mName + "bottom", stackSize, 2, 0, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + for (int i = 1; i < layer - 1; i++) { + built = survivialBuildPiece(mName + "mid", stackSize, 2, i, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + } + return survivialBuildPiece( + mName + "top", stackSize, 2, layer - 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mEnergyHatches.clear(); + mDynamoHatches.clear(); + mTecTechEnergyHatches.clear(); + mTecTechDynamoHatches.clear(); + mAllEnergyHatches.clear(); + mAllDynamoHatches.clear(); + for (int i = 0; i < 6; i++) { + cellCount[i] = 0; + } + log("Checking 0"); + if (!checkPiece(mName + "bottom", 2, 0, 0)) { + log("Failed on Layer 0"); + return false; + } + log("Pass 0"); + int layer = 1; + topState = TopState.MayBeTop; + while (true) { + if (!checkPiece(mName + "layer", 2, layer, 0)) return false; + layer++; + if (topState == TopState.Top) break; // top found, break out + topState = TopState.MayBeTop; + if (layer > 18) return false; // too many layers + } + int level = 0; + for (int i = 0; i < 6; i++) { + if (cellCount[i] != 0) { + if (level == 0) { + level = i + 4; + } else { + return false; + } + } + } + int tier = getMaxHatchTier(level); + long volSum = 0; + for (GT_MetaTileEntity_Hatch hatch : mAllDynamoHatches) { + if (hatch.mTier > tier || hatch.mTier < 3) { + return false; + } + volSum += (8L << (hatch.mTier * 2)); + } + for (GT_MetaTileEntity_Hatch hatch : mAllEnergyHatches) { + if (hatch.mTier > tier || hatch.mTier < 3) { + return false; + } + volSum += (8L << (hatch.mTier * 2)); + } + mBatteryCapacity = getCapacityFromCellTier(level) * cellCount[level - 4]; + if (mAllEnergyHatches.size() + mAllDynamoHatches.size() > 0) { + mAverageEuUsage = volSum / (mAllEnergyHatches.size() + mAllDynamoHatches.size()); + } else mAverageEuUsage = 0; + fixAllMaintenanceIssue(); + return true; + } + + public final boolean addPowerSubStationList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (LoadedMods.TecTech) { + if (isThisHatchMultiDynamo(aMetaTileEntity)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (isThisHatchMultiEnergy(aMetaTileEntity)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + } + return false; + } + + // Define storage capacity of smallest cell tier (EV) and compute higher tiers from it + private static final long CELL_TIER_EV_CAPACITY = 100 * 1000 * 1000; + private static final long CELL_TIER_MULTIPLIER = 4; // each tier's capacity is this many times the previous tier + + public static long getCapacityFromCellTier(int aOverallCellTier) { + // Use integer math instead of `Math.pow` to avoid range/precision errors + if (aOverallCellTier < 4) return 0; + aOverallCellTier -= 4; + long capacity = CELL_TIER_EV_CAPACITY; + while (aOverallCellTier > 0) { + capacity *= CELL_TIER_MULTIPLIER; + aOverallCellTier--; + } + return capacity; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_PowerSubStationController(this.mName); + } + + // mTotalEnergyAdded + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setLong("mAverageEuUsage", this.mAverageEuUsage); + this.mAverageEuAdded.write(aNBT, "mAverageEuAdded"); + this.mAverageEuConsumed.write(aNBT, "mAverageEuConsumed"); + + // Usage Stats + aNBT.setLong("mTotalEnergyAdded", this.mTotalEnergyAdded); + aNBT.setLong("mTotalEnergyLost", this.mTotalEnergyLost); + aNBT.setLong("mTotalEnergyConsumed", this.mTotalEnergyConsumed); + aNBT.setLong("mTotalRunTime", this.mTotalRunTime); + aNBT.setBoolean("mIsOutputtingPower", this.mIsOutputtingPower); + aNBT.setLong("mBatteryCapacity", this.mBatteryCapacity); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + + // Best not to get a long if the Tag Map is holding an int + if (aNBT.hasKey("mAverageEuUsage")) { + this.mAverageEuUsage = aNBT.getLong("mAverageEuUsage"); + } + switch (aNBT.func_150299_b("mAverageEuAdded")) { + case NBT.TAG_BYTE_ARRAY: + this.mAverageEuAdded.read(aNBT, "mAverageEuAdded"); + break; + case NBT.TAG_LONG: + this.mAverageEuAdded.set(aNBT.getLong("mAverageEuAdded")); + break; + } + switch (aNBT.func_150299_b("mAverageEuConsumed")) { + case NBT.TAG_BYTE_ARRAY: + this.mAverageEuConsumed.read(aNBT, "mAverageEuConsumed"); + break; + case NBT.TAG_LONG: + this.mAverageEuConsumed.set(aNBT.getLong("mAverageEuConsumed")); + break; + } + + // Usage Stats + this.mTotalEnergyAdded = aNBT.getLong("mTotalEnergyAdded"); + this.mTotalEnergyLost = aNBT.getLong("mTotalEnergyLost"); + this.mTotalEnergyConsumed = aNBT.getLong("mTotalEnergyConsumed"); + this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); + + this.mIsOutputtingPower = aNBT.getBoolean("mIsOutputtingPower"); + + this.mBatteryCapacity = aNBT.getLong("mBatteryCapacity"); + + super.loadNBTData(aNBT); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + this.mProgresstime = 0; + this.mMaxProgresstime = 200; + this.mEUt = 0; + this.mEfficiencyIncrease = 10000; + this.fixAllMaintenanceIssue(); + return true; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + private long drawEnergyFromHatch(MetaTileEntity aHatch) { + if (!isValidMetaTileEntity(aHatch)) { + return 0; + } + + long stored = aHatch.getEUVar(); + long voltage = aHatch.maxEUInput() * aHatch.maxAmperesIn(); + + if (voltage > stored) { + return 0; + } + + if (this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false)) { + aHatch.setEUVar((stored - voltage)); + this.mTotalEnergyAdded += voltage; + return voltage; + } + return 0; + } + + private long addEnergyToHatch(MetaTileEntity aHatch) { + if (!isValidMetaTileEntity(aHatch)) { + return 0; + } + + long voltage = aHatch.maxEUOutput() * aHatch.maxAmperesOut(); + + if (aHatch.getEUVar() > aHatch.maxEUStore() - voltage) { + return 0; + } + + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(voltage, false)) { + aHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false); + this.mTotalEnergyConsumed += voltage; + return voltage; + } + return 0; + } + + private long computeEnergyTax() { + float mTax = mAverageEuUsage * (ENERGY_TAX / 100f); + + // Increase tax up to 2x if machine is not fully repaired + mTax = mTax * (1f + (10000f - mEfficiency) / 10000f); + + return MathUtils.roundToClosestLong(mTax); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.fixAllMaintenanceIssue(); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + // First, decay overcharge (1% of stored energy plus 1000 EU per tick) + if (this.getEUVar() > this.mBatteryCapacity) { + long energy = (long) (this.getEUVar() * 0.990f) - 1000; + this.setEUVar(energy); + } + + // Pay Tax + long mDecrease = computeEnergyTax(); + this.mTotalEnergyLost += Math.min(mDecrease, this.getEUVar()); + this.setEUVar(Math.max(0, this.getEUVar() - mDecrease)); + + long aInputAverage = 0; + long aOutputAverage = 0; + // Input Power + for (GT_MetaTileEntity_Hatch THatch : this.mDischargeHatches) { + aInputAverage += drawEnergyFromHatch(THatch); + } + for (GT_MetaTileEntity_Hatch tHatch : this.mAllEnergyHatches) { + aInputAverage += drawEnergyFromHatch(tHatch); + } + + // Output Power + for (GT_MetaTileEntity_Hatch THatch : this.mChargeHatches) { + aOutputAverage += addEnergyToHatch(THatch); + } + for (GT_MetaTileEntity_Hatch tHatch : this.mAllDynamoHatches) { + aOutputAverage += addEnergyToHatch(tHatch); + } + // reset progress time + mProgresstime = 0; + + this.mAverageEuAdded.sample(aInputAverage); + this.mAverageEuConsumed.sample(aOutputAverage); + + return true; + } + + @Override + public boolean drainEnergyInput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public boolean addEnergyOutput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public long maxEUStore() { + return mBatteryCapacity; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public String[] getExtraInfoData() { + String mode; + if (mIsOutputtingPower) { + mode = EnumChatFormatting.GOLD + "Output" + EnumChatFormatting.RESET; + } else { + mode = EnumChatFormatting.BLUE + "Input" + EnumChatFormatting.RESET; + } + + String storedEnergyText; + if (this.getEUVar() > this.mBatteryCapacity) { + storedEnergyText = + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } else { + storedEnergyText = + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } + + int errorCode = this.getBaseMetaTileEntity().getErrorDisplayID(); + boolean mMaint = (errorCode != 0); + + return new String[] { + "Ergon Energy - District Sub-Station", + "Stored EU: " + storedEnergyText, + "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + + EnumChatFormatting.RESET, + "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.computeEnergyTax()) + + EnumChatFormatting.RESET + " EU/t", + "Controller Mode: " + mode, + "Requires Maintenance: " + (!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + mMaint + + EnumChatFormatting.RESET + " | Code: [" + + (!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + errorCode + + EnumChatFormatting.RESET + "]", + "----------------------", + "Stats for Nerds", + "Average Input: " + EnumChatFormatting.BLUE + this.mAverageEuAdded + EnumChatFormatting.RESET + " EU", + "Average Output: " + EnumChatFormatting.GOLD + this.mAverageEuConsumed + EnumChatFormatting.RESET + " EU", + "Total Input: " + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(this.mTotalEnergyAdded) + + EnumChatFormatting.RESET + " EU", + "Total Output: " + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(this.mTotalEnergyConsumed) + + EnumChatFormatting.RESET + " EU", + "Total Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.mTotalEnergyLost) + + EnumChatFormatting.RESET + " EU", + }; + } + + @Override + public void explodeMultiblock() { + // TODO Auto-generated method stub + super.explodeMultiblock(); + } + + @Override + public void doExplosion(long aExplosionPower) { + // TODO Auto-generated method stub + super.doExplosion(aExplosionPower); + } + + @Override + public long getMaxInputVoltage() { + return 32768; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetInput() { + return !mIsOutputtingPower; + } + + @Override + public boolean isEnetOutput() { + return mIsOutputtingPower; + } + + @Override + public boolean isInputFacing(byte aSide) { + return (aSide == this.getBaseMetaTileEntity().getBackFacing() && !mIsOutputtingPower); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return (aSide == this.getBaseMetaTileEntity().getBackFacing() && mIsOutputtingPower); + } + + @Override + public long maxAmperesIn() { + return 32; + } + + @Override + public long maxAmperesOut() { + return 32; + } + + @Override + public long maxEUInput() { + return 32768; + } + + @Override + public long maxEUOutput() { + return 32768; + } + + public final long getAverageEuAdded() { + return this.mAverageEuAdded.get(); + } + + public final long getAverageEuConsumed() { + return this.mAverageEuConsumed.get(); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mIsOutputtingPower = Utils.invertBoolean(mIsOutputtingPower); + if (mIsOutputtingPower) { + PlayerUtils.messagePlayer(aPlayer, "Sub-Station is now outputting power from the controller."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Sub-Station is now inputting power into the controller."); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java index 67999087f3..4a24de7c5a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java @@ -3,9 +3,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.misc; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes; -import java.util.ArrayList; -import java.util.Collections; - import Ic2ExpReactorPlanner.SimulationData; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; @@ -26,6 +23,8 @@ import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_GUIContainer_ComputerCube; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description; import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Simulator; +import java.util.ArrayList; +import java.util.Collections; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -37,884 +36,929 @@ import net.minecraft.world.World; public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { - public static int MODE_MAIN = 0; - public static int MODE_REACTOR_PLANNER = 1; - public static int MODE_SCANNER = 2; - public static int MODE_CENTRIFUGE = 3; - public static int MODE_FUSION = 4; - public static int MODE_INFO = 5; - public static int MODE_ELECTROLYZER = 6; - - public static boolean mSeedscanner = true; + public static int MODE_MAIN = 0; + public static int MODE_REACTOR_PLANNER = 1; + public static int MODE_SCANNER = 2; + public static int MODE_CENTRIFUGE = 3; + public static int MODE_FUSION = 4; + public static int MODE_INFO = 5; + public static int MODE_ELECTROLYZER = 6; + + public static boolean mSeedscanner = true; + + public static boolean mReactorplanner = true; + + public static ArrayList sReactorList; + + public boolean mStarted = false; + + public int mMode = 0; + + public int mHeat = 0; + + public long mEUOut = 0; + + public int mMaxHeat = 1; + + public long mEU = 0; + + public int mProgress = 0; + public int mMaxProgress = 0; + + public int mEUTimer = 0; + + public int mEULast1 = 0; + + public int mEULast2 = 0; + + public int mEULast3 = 0; + + public int mEULast4 = 0; + + public float mHEM = 1.0F, mExplosionStrength = 0.0F; + + public String mFusionOutput = ""; + + private boolean mNeedsUpdate; + + private GT_Computercube_Simulator mSimulator; + + public GT_TileEntity_ComputerCube(final int aID, final String aDescription) { + super(aID, "computer.cube", "Computer Cube MKII", 5, 114, aDescription); + } + + public GT_TileEntity_ComputerCube(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 114, aDescription, aTextures); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + Logger.INFO("CC-Sever ID: " + aID); + return new GT_Container_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + Logger.INFO("CC-Client ID: " + aID); + return new GT_GUIContainer_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Built in Reactor Planner", + "Built in Scanner", + "Built in Info-Bank", + "Displays Fusion Recipes", + CORE.GT_Tooltip + }; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer, mMode); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_TileEntity_ComputerCube(this.mName, this.mDescription, this.mTextures); + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + ItemStack tStack = aPlayer.getCurrentEquippedItem(); + if (tStack != null && ItemList.Tool_DataOrb.isStackEqual(tStack)) { + return false; + } + return true; + } + + public final GT_Computercube_Simulator getSimulator() { + return this.mSimulator; + } + + public final void setSimulator(GT_Computercube_Simulator mSimulator) { + this.mSimulator = mSimulator; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aDirection) { + return true; + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public long maxEUInput() { + return GT_Values.V[4]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[5] * 1024; + } + + @Override + public boolean ownerControl() { + return false; + } + + @Override + public int getSizeInventory() { + return 114; + } + + @Override + public boolean isValidSlot(int aIndex) { + return (aIndex > 53 && aIndex < 58); + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + public void saveNuclearReactor() { + for (int i = 0; i < 54; i++) { + if (this.mInventory[i] == null) { + this.mInventory[i + 59] = null; + } else { + this.mInventory[i + 59] = this.mInventory[i].copy(); + } + } + } + + public void loadNuclearReactor() { + for (int i = 0; i < 54; i++) { + if (this.mInventory[i + 59] == null) { + this.mInventory[i] = null; + } else { + this.mInventory[i] = this.mInventory[i + 59].copy(); + } + } + } + + public int getXCoord() { + return this.getBaseMetaTileEntity().getXCoord(); + } + + public int getYCoord() { + return this.getBaseMetaTileEntity().getYCoord(); + } + + public int getZCoord() { + return this.getBaseMetaTileEntity().getZCoord(); + } + + public void reset() { + this.mEU = 0; + this.mHeat = 0; + this.mEUOut = 0; + this.mMaxHeat = 10000; + this.mHEM = 1.0F; + this.mExplosionStrength = 0.0F; + this.mProgress = 0; + this.mMaxProgress = 0; + this.mFusionOutput = ""; + this.mInventory[113] = null; + int i; + for (i = 0; i < 54; i++) { + this.mInventory[i] = null; + this.mInventory[i + 59] = null; + } + for (i = 54; i < 58; i++) { + if (this.mInventory[i] != null) { + if (!this.getWorld().isRemote) + this.getWorld().spawnEntityInWorld((Entity) new EntityItem( + this.getWorld(), + this.getXCoord() + 0.5D, + this.getYCoord() + 0.5D, + this.getZCoord() + 0.5D, + this.mInventory[i])); + this.mInventory[i] = null; + } + } + } + + public void switchModeForward() { + int aTempMode = mMode; + aTempMode++; + if (aTempMode == MODE_ELECTROLYZER || aTempMode == MODE_CENTRIFUGE) { + aTempMode++; + } + if (aTempMode >= 7) { + aTempMode = 0; + } + mMode = aTempMode; + switchMode(); + } + + public void switchModeBackward() { + int aTempMode = mMode; + aTempMode--; + if (aTempMode == MODE_ELECTROLYZER || aTempMode == MODE_CENTRIFUGE) { + aTempMode--; + } + if (aTempMode < 0) { + aTempMode = 6; + } + mMode = aTempMode; + switchMode(); + } + + private void switchMode() { + reset(); + if (this.mMode == MODE_REACTOR_PLANNER && !mReactorplanner) { + switchMode(); + return; + } + if (this.mMode == MODE_SCANNER && !mSeedscanner) { + switchMode(); + return; + } + if (this.mMode == MODE_CENTRIFUGE) { + showCentrifugeRecipe(0); + } + if (this.mMode == MODE_FUSION) { + showFusionRecipe(0); + } + if (this.mMode == MODE_INFO) { + showDescription(0); + } + if (this.mMode == MODE_ELECTROLYZER) { + showElectrolyzerRecipe(0); + } + this.getWorld() + .addBlockEvent( + this.getXCoord(), + this.getYCoord(), + this.getZCoord(), + GregTech_API.sBlockMachines, + 10, + this.mMode); + this.getWorld() + .addBlockEvent( + this.getXCoord(), + this.getYCoord(), + this.getZCoord(), + GregTech_API.sBlockMachines, + 11, + this.mMaxHeat); + } + + public void showDescription(int aIndex) { + this.mExplosionStrength = 0.0F; + if (GT_Computercube_Description.sDescriptions.isEmpty()) { + return; + } + if (aIndex >= GT_Computercube_Description.sDescriptions.size() || aIndex < 0) aIndex = 0; + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[0] == null) { + this.mInventory[59] = null; + } else { + this.mInventory[59] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[0].copy(); + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[1] == null) { + this.mInventory[60] = null; + } else { + this.mInventory[60] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[1].copy(); + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[2] == null) { + this.mInventory[61] = null; + } else { + this.mInventory[61] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[2].copy(); + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[3] == null) { + this.mInventory[62] = null; + } else { + this.mInventory[62] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[3].copy(); + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[4] == null) { + this.mInventory[63] = null; + } else { + this.mInventory[63] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[4].copy(); + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[5] == null) { + this.mInventory[64] = null; + } else { + this.mInventory[64] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[5].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[6] == null) { + this.mInventory[65] = null; + } else { + this.mInventory[65] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[6].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[7] == null) { + this.mInventory[66] = null; + } else { + this.mInventory[66] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[7].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[8] == null) { + this.mInventory[67] = null; + } else { + this.mInventory[67] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[8].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[9] == null) { + this.mInventory[68] = null; + } else { + this.mInventory[68] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[9].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[10] == null) { + this.mInventory[69] = null; + } else { + this.mInventory[69] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[10].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[11] == null) { + this.mInventory[70] = null; + } else { + this.mInventory[70] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[11].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[12] == null) { + this.mInventory[71] = null; + } else { + this.mInventory[71] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[12].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[13] == null) { + this.mInventory[72] = null; + } else { + this.mInventory[72] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)) + .mStacks[13].copy(); + this.mExplosionStrength = 100.0F; + } + this.mMaxHeat = aIndex; + this.getWorld() + .addBlockEvent( + this.getXCoord(), + this.getYCoord(), + this.getZCoord(), + GregTech_API.sBlockMachines, + 11, + this.mMaxHeat); + } + + public void switchDescriptionPageForward() { + if (++this.mMaxHeat >= GT_Computercube_Description.sDescriptions.size()) this.mMaxHeat = 0; + showDescription(this.mMaxHeat); + } + + public void switchDescriptionPageBackward() { + if (--this.mMaxHeat < 0) this.mMaxHeat = GT_Computercube_Description.sDescriptions.size() - 1; + showDescription(this.mMaxHeat); + } + + public void showCentrifugeRecipe(int aIndex) { + /* + if (aIndex >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() || aIndex < 0) + aIndex = 0; + GT_Recipe tRecipe = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mInput1 == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = tRecipe.mInput1.copy(); + } + if (tRecipe.mInput2 == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = tRecipe.mInput2.copy(); + } + if (tRecipe.mOutput1 == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = tRecipe.mOutput1.copy(); + } + if (tRecipe.mOutput2 == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = tRecipe.mOutput2.copy(); + } + if (tRecipe.mOutput3 == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = tRecipe.mOutput3.copy(); + } + if (tRecipe.mOutput4 == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = tRecipe.mOutput4.copy(); + } + this.mEU = tRecipe.mDuration * 5; + this.mMaxHeat = aIndex; + } + this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + */ } + + public void switchCentrifugePageForward() { + if (++this.mMaxHeat >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size()) this.mMaxHeat = 0; + // showCentrifugeRecipe(this.mMaxHeat); + } + + public void switchCentrifugePageBackward() { + if (--this.mMaxHeat < 0) this.mMaxHeat = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() - 1; + // showCentrifugeRecipe(this.mMaxHeat); + } + + public void showElectrolyzerRecipe(int aIndex) { + /* + if (aIndex >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() || aIndex < 0) + aIndex = 0; + GT_Recipe tRecipe = GT_Recipe_Map.sElectrolyzerRecipes.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mInput1 == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = tRecipe.mInput1.copy(); + } + if (tRecipe.mInput2 == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = tRecipe.mInput2.copy(); + } + if (tRecipe.mOutput1 == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = tRecipe.mOutput1.copy(); + } + if (tRecipe.mOutput2 == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = tRecipe.mOutput2.copy(); + } + if (tRecipe.mOutput3 == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = tRecipe.mOutput3.copy(); + } + if (tRecipe.mOutput4 == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = tRecipe.mOutput4.copy(); + } + this.mEU = tRecipe.mDuration * tRecipe.mEUt; + this.mMaxHeat = aIndex; + } + this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + */ } + + public void switchElectrolyzerPageForward() { + if (++this.mMaxHeat >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size()) this.mMaxHeat = 0; + showElectrolyzerRecipe(this.mMaxHeat); + } - public static boolean mReactorplanner = true; - - public static ArrayList sReactorList; + public void switchElectrolyzerPageBackward() { + if (--this.mMaxHeat < 0) this.mMaxHeat = GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() - 1; + showElectrolyzerRecipe(this.mMaxHeat); + } + + public static ArrayList sFusionReactorRecipes = new ArrayList(); + + public void showFusionRecipe(int aIndex) { + + if (sFusionReactorRecipes.isEmpty()) { + for (GT_Recipe aRecipe : GT_Recipe_Map.sFusionRecipes.mRecipeList) { + sFusionReactorRecipes.add(aRecipe); + } + Collections.sort(sFusionReactorRecipes); + } + + if (aIndex >= sFusionReactorRecipes.size() || aIndex < 0) { + aIndex = 0; + } + GT_Recipe tRecipe = sFusionReactorRecipes.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mFluidInputs[0] == null) { + this.mInventory[59] = null; + } else { + this.mInventory[59] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[0], true); + } + if (tRecipe.mFluidInputs[1] == null) { + this.mInventory[60] = null; + } else { + this.mInventory[60] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[1], true); + } + if (tRecipe.mFluidOutputs[0] == null) { + this.mInventory[61] = null; + } else { + this.mInventory[61] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[0], true); + } + this.mEU = tRecipe.mSpecialValue; + this.mEUOut = tRecipe.mEUt; + this.mHeat = tRecipe.mDuration; + this.mMaxHeat = aIndex; + this.mFusionOutput = tRecipe.mFluidOutputs[0].getLocalizedName(); + } + this.getWorld() + .addBlockEvent( + this.getXCoord(), + this.getYCoord(), + this.getZCoord(), + GregTech_API.sBlockMachines, + 11, + this.mMaxHeat); + } + + public void switchFusionPageForward() { + if (++this.mMaxHeat >= sFusionReactorRecipes.size()) this.mMaxHeat = 0; + showFusionRecipe(this.mMaxHeat); + } + + public void switchFusionPageBackward() { + if (--this.mMaxHeat < 0) this.mMaxHeat = sFusionReactorRecipes.size() - 1; + showFusionRecipe(this.mMaxHeat); + } + + public void switchNuclearReactor() { + if (this.mStarted) { + stopNuclearReactor(); + } else { + startNuclearReactor(); + } + } + + public void startNuclearReactor() { + this.mStarted = true; + this.mHeat = 0; + this.mEU = 0; + mSimulator.simulate(); + } + + public void stopNuclearReactor() { + this.mStarted = false; + mSimulator.simulate(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mMode", this.mMode); + aNBT.setInteger("mProgress", this.mProgress); + aNBT.setInteger("mMaxProgress", this.mMaxProgress); + aNBT.setBoolean("mStarted", this.mStarted); + int[] aSplitLong1 = MathUtils.splitLongIntoTwoIntegers(mEU); + aNBT.setInteger("mEU1", aSplitLong1[0]); + aNBT.setInteger("mEU2", aSplitLong1[1]); + aNBT.setInteger("mHeat", this.mHeat); + int[] aSplitLong2 = MathUtils.splitLongIntoTwoIntegers(mEUOut); + aNBT.setInteger("mEUOut1", aSplitLong2[0]); + aNBT.setInteger("mEUOut2", aSplitLong2[1]); + aNBT.setInteger("mMaxHeat", this.mMaxHeat); + aNBT.setFloat("mHEM", this.mHEM); + aNBT.setFloat("mExplosionStrength", this.mExplosionStrength); + aNBT.setString("mFusionOutput", this.mFusionOutput); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mMode = aNBT.getInteger("mMode"); + this.mProgress = aNBT.getInteger("mProgress"); + this.mMaxProgress = aNBT.getInteger("mMaxProgress"); + this.mStarted = aNBT.getBoolean("mStarted"); + int partA = aNBT.getInteger("mEU1"); + int partB = aNBT.getInteger("mEU2"); + this.mEU = MathUtils.combineTwoIntegersToLong(partA, partB); + this.mHeat = aNBT.getInteger("mHeat"); + partA = aNBT.getInteger("mEUOut1"); + partB = aNBT.getInteger("mEUOut2"); + this.mEUOut = MathUtils.combineTwoIntegersToLong(partA, partB); + this.mMaxHeat = aNBT.getInteger("mMaxHeat"); + this.mHEM = aNBT.getFloat("mHEM"); + this.mExplosionStrength = aNBT.getFloat("mExplosionStrength"); + this.mFusionOutput = aNBT.getString("mFusionOutput"); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (mSimulator == null) { + mSimulator = new GT_Computercube_Simulator(this); + } + if (this.getBaseMetaTileEntity().isClientSide()) { + this.getWorld().markBlockForUpdate(this.getXCoord(), this.getYCoord(), this.getZCoord()); + this.mNeedsUpdate = false; + } else { + this.mNeedsUpdate = false; + } + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mMode == MODE_SCANNER) { + /*if (this.mInventory[55] == null) { + this.mInventory[55] = this.mInventory[54]; + this.mInventory[54] = null; + }*/ + if (this.mInventory[57] == null) { + this.mInventory[57] = this.mInventory[56]; + this.mInventory[56] = null; + } + + // 54 - 55 || 56 - 57 + // Do scanny bits + if (mSeedscanner && this.mMode == MODE_SCANNER) { + /*if (doScan(this.mInventory[55]) == 4) { + if ((this.mInventory[57] != null) && (this.mInventory[57].getUnlocalizedName().equals("gt.metaitem.01.32707"))) { + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "scanning"); + } + }*/ + /*if (this.mEU > 0) { + if (!this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mEU, false)) { + this.mProgress = 0; + } + }*/ + } + + /*if (mSeedscanner && this.mInventory[55] != null && GT_Utility.areStacksEqual(this.mInventory[55], Ic2Items.cropSeed, true) && this.mInventory[55].getTagCompound() != null) { + if (this.mInventory[55].getTagCompound().getByte("scan") < 4) { + if (this.mProgress >= 100) { + this.mInventory[55].getTagCompound().setByte("scan", (byte) 4); + this.mProgress = 0; + } + else if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(100, false)) { + this.mProgress++; + } + } + else { + this.mProgress = 0; + if (this.mInventory[56] == null) { + this.mInventory[56] = this.mInventory[55]; + this.mInventory[55] = null; + } + } + } + else { + this.mProgress = 0; + if (this.mInventory[56] == null) { + this.mInventory[56] = this.mInventory[55]; + this.mInventory[55] = null; + } + }*/ + } + + if (this.mMode == MODE_REACTOR_PLANNER + && mReactorplanner + && this.mSimulator != null + && this.mSimulator.simulator != null + && this.mSimulator.simulatedReactor != null) { + SimulationData aData = this.mSimulator.simulator.getData(); + if (aData != null && aData.totalReactorTicks > 0 && this.mProgress != aData.totalReactorTicks) { + Logger.INFO("Updating Variables"); + this.mEU = aData.avgEUoutput; + this.mEUOut = (aData.totalEUoutput / aData.totalReactorTicks); + this.mHeat = aData.avgHUoutput; + this.mMaxHeat = aData.maxHUoutput; + this.mExplosionStrength = aData.explosionPower; + this.mHEM = (float) aData.hullHeating; + this.mProgress = aData.totalReactorTicks; + } + } + + if (aTick % 20L == 0L) { + this.getWorld() + .addBlockEvent( + this.getXCoord(), + this.getYCoord(), + this.getZCoord(), + GregTech_API.sBlockMachines, + 10, + this.mMode); + this.getWorld() + .addBlockEvent( + this.getXCoord(), + this.getYCoord(), + this.getZCoord(), + GregTech_API.sBlockMachines, + 11, + this.mMaxHeat); + } + } + } + + @Override + public void receiveClientEvent(byte aEventID, byte aValue) { + super.receiveClientEvent(aEventID, aValue); + if (this.getWorld().isRemote) + switch (aEventID) { + case 10: + this.mNeedsUpdate = true; + this.mMode = aValue; + break; + case 11: + this.mMaxHeat = aValue; + break; + } + return; + } + + @Override + public void onValueUpdate(byte aValue) { + super.onValueUpdate(aValue); + this.mNeedsUpdate = true; + } + + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + this.mNeedsUpdate = true; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return (this.mMode == MODE_SCANNER) ? ((i == 54 || i == 55)) : false; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return (this.mMode == MODE_SCANNER) ? ((i == 56 || i == 57)) : false; + } + + public World getWorld() { + return this.getBaseMetaTileEntity().getWorld(); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getSides(i); + rTextures[3][i + 1] = this.getSides(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getSides(i); + rTextures[7][i + 1] = this.getSides(i); + rTextures[8][i + 1] = this.getSides(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_3)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Computer_Cube)}; + } + + protected static final int DID_NOT_FIND_RECIPE = 0, + FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, + FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - public boolean mStarted = false; - - public int mMode = 0; - - public int mHeat = 0; - - public long mEUOut = 0; - - public int mMaxHeat = 1; - - public long mEU = 0; - - public int mProgress = 0; - public int mMaxProgress = 0; - - public int mEUTimer = 0; - - public int mEULast1 = 0; - - public int mEULast2 = 0; - - public int mEULast3 = 0; - - public int mEULast4 = 0; - - public float mHEM = 1.0F, mExplosionStrength = 0.0F; - - public String mFusionOutput = ""; - - private boolean mNeedsUpdate; - - private GT_Computercube_Simulator mSimulator; - - public GT_TileEntity_ComputerCube(final int aID, final String aDescription) { - super(aID, "computer.cube", "Computer Cube MKII", 5, 114, aDescription); - } - - public GT_TileEntity_ComputerCube(final String aName, final String aDescription, final ITexture[][][] aTextures) { - super(aName, 5, 114, aDescription, aTextures); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - Logger.INFO("CC-Sever ID: "+aID); - return new GT_Container_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - Logger.INFO("CC-Client ID: "+aID); - return new GT_GUIContainer_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Built in Reactor Planner", - "Built in Scanner", - "Built in Info-Bank", - "Displays Fusion Recipes", - CORE.GT_Tooltip}; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer, mMode); - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_TileEntity_ComputerCube(this.mName, this.mDescription, this.mTextures); - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - ItemStack tStack = aPlayer.getCurrentEquippedItem(); - if (tStack != null && ItemList.Tool_DataOrb.isStackEqual(tStack)) { - return false; - } - return true; - } - - public final GT_Computercube_Simulator getSimulator() { - return this.mSimulator; - } - - public final void setSimulator(GT_Computercube_Simulator mSimulator) { - this.mSimulator = mSimulator; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isInputFacing(byte aDirection) { - return true; - } - - @Override - public long maxAmperesIn() { - return 4; - } - - @Override - public long maxEUInput() { - return GT_Values.V[4]; - } - - @Override - public long maxEUStore() { - return GT_Values.V[5] * 1024; - } - - @Override - public boolean ownerControl() { - return false; - } - - @Override - public int getSizeInventory() { - return 114; - } - - @Override - public boolean isValidSlot(int aIndex) { - return (aIndex > 53 && aIndex < 58); - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - public void saveNuclearReactor() { - for (int i = 0; i < 54; i++) { - if (this.mInventory[i] == null) { - this.mInventory[i + 59] = null; - } - else { - this.mInventory[i + 59] = this.mInventory[i].copy(); - } - } - } - - public void loadNuclearReactor() { - for (int i = 0; i < 54; i++) { - if (this.mInventory[i + 59] == null) { - this.mInventory[i] = null; - } - else { - this.mInventory[i] = this.mInventory[i + 59].copy(); - } - } - } - - public int getXCoord() { - return this.getBaseMetaTileEntity().getXCoord(); - } - - public int getYCoord() { - return this.getBaseMetaTileEntity().getYCoord(); - } - - public int getZCoord() { - return this.getBaseMetaTileEntity().getZCoord(); - } - - public void reset() { - this.mEU = 0; - this.mHeat = 0; - this.mEUOut = 0; - this.mMaxHeat = 10000; - this.mHEM = 1.0F; - this.mExplosionStrength = 0.0F; - this.mProgress = 0; - this.mMaxProgress = 0; - this.mFusionOutput = ""; - this.mInventory[113] = null; - int i; - for (i = 0; i < 54; i++) { - this.mInventory[i] = null; - this.mInventory[i + 59] = null; - } - for (i = 54; i < 58; i++) { - if (this.mInventory[i] != null) { - if (!this.getWorld().isRemote) - this.getWorld().spawnEntityInWorld((Entity) new EntityItem(this.getWorld(), this.getXCoord() + 0.5D, this.getYCoord() + 0.5D, this.getZCoord() + 0.5D, this.mInventory[i])); - this.mInventory[i] = null; - } - } - } - - public void switchModeForward() { - int aTempMode = mMode; - aTempMode++; - if (aTempMode == MODE_ELECTROLYZER ||aTempMode == MODE_CENTRIFUGE) { - aTempMode++; - } - if (aTempMode >= 7) { - aTempMode = 0; - } - mMode = aTempMode; - switchMode(); - } - - public void switchModeBackward() { - int aTempMode = mMode; - aTempMode--; - if (aTempMode == MODE_ELECTROLYZER ||aTempMode == MODE_CENTRIFUGE) { - aTempMode--; - } - if (aTempMode < 0) { - aTempMode = 6; - } - mMode = aTempMode; - switchMode(); - } - - private void switchMode() { - reset(); - if (this.mMode == MODE_REACTOR_PLANNER && !mReactorplanner) { - switchMode(); - return; - } - if (this.mMode == MODE_SCANNER && !mSeedscanner) { - switchMode(); - return; - } - if (this.mMode == MODE_CENTRIFUGE) { - showCentrifugeRecipe(0); - } - if (this.mMode == MODE_FUSION) { - showFusionRecipe(0); - } - if (this.mMode == MODE_INFO) { - showDescription(0); - } - if (this.mMode == MODE_ELECTROLYZER) { - showElectrolyzerRecipe(0); - } - this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 10, this.mMode); - this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); - } - - public void showDescription(int aIndex) { - this.mExplosionStrength = 0.0F; - if (GT_Computercube_Description.sDescriptions.isEmpty()) { - return; - } - if (aIndex >= GT_Computercube_Description.sDescriptions.size() || aIndex < 0) - aIndex = 0; - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[0] == null) { - this.mInventory[59] = null; - } - else { - this.mInventory[59] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[0].copy(); - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[1] == null) { - this.mInventory[60] = null; - } - else { - this.mInventory[60] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[1].copy(); - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[2] == null) { - this.mInventory[61] = null; - } - else { - this.mInventory[61] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[2].copy(); - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[3] == null) { - this.mInventory[62] = null; - } - else { - this.mInventory[62] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[3].copy(); - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[4] == null) { - this.mInventory[63] = null; - } - else { - this.mInventory[63] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[4].copy(); - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[5] == null) { - this.mInventory[64] = null; - } - else { - this.mInventory[64] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[5].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[6] == null) { - this.mInventory[65] = null; - } - else { - this.mInventory[65] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[6].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[7] == null) { - this.mInventory[66] = null; - } - else { - this.mInventory[66] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[7].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[8] == null) { - this.mInventory[67] = null; - } - else { - this.mInventory[67] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[8].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[9] == null) { - this.mInventory[68] = null; - } - else { - this.mInventory[68] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[9].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[10] == null) { - this.mInventory[69] = null; - } - else { - this.mInventory[69] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[10].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[11] == null) { - this.mInventory[70] = null; - } - else { - this.mInventory[70] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[11].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[12] == null) { - this.mInventory[71] = null; - } - else { - this.mInventory[71] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[12].copy(); - this.mExplosionStrength = 100.0F; - } - if (((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[13] == null) { - this.mInventory[72] = null; - } - else { - this.mInventory[72] = ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(aIndex)).mStacks[13].copy(); - this.mExplosionStrength = 100.0F; - } - this.mMaxHeat = aIndex; - this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); - } - - public void switchDescriptionPageForward() { - if (++this.mMaxHeat >= GT_Computercube_Description.sDescriptions.size()) - this.mMaxHeat = 0; - showDescription(this.mMaxHeat); - } - - public void switchDescriptionPageBackward() { - if (--this.mMaxHeat < 0) - this.mMaxHeat = GT_Computercube_Description.sDescriptions.size() - 1; - showDescription(this.mMaxHeat); - } - - public void showCentrifugeRecipe(int aIndex) { - /* - if (aIndex >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() || aIndex < 0) - aIndex = 0; - GT_Recipe tRecipe = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.get(aIndex); - if (tRecipe != null) { - if (tRecipe.mInput1 == null) { - this.mInventory[59] = null; - } - else { - this.mInventory[59] = tRecipe.mInput1.copy(); - } - if (tRecipe.mInput2 == null) { - this.mInventory[60] = null; - } - else { - this.mInventory[60] = tRecipe.mInput2.copy(); - } - if (tRecipe.mOutput1 == null) { - this.mInventory[61] = null; - } - else { - this.mInventory[61] = tRecipe.mOutput1.copy(); - } - if (tRecipe.mOutput2 == null) { - this.mInventory[62] = null; - } - else { - this.mInventory[62] = tRecipe.mOutput2.copy(); - } - if (tRecipe.mOutput3 == null) { - this.mInventory[63] = null; - } - else { - this.mInventory[63] = tRecipe.mOutput3.copy(); - } - if (tRecipe.mOutput4 == null) { - this.mInventory[64] = null; - } - else { - this.mInventory[64] = tRecipe.mOutput4.copy(); - } - this.mEU = tRecipe.mDuration * 5; - this.mMaxHeat = aIndex; - } - this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); - */} - - public void switchCentrifugePageForward() { - if (++this.mMaxHeat >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size()) - this.mMaxHeat = 0; - // showCentrifugeRecipe(this.mMaxHeat); - } - - public void switchCentrifugePageBackward() { - if (--this.mMaxHeat < 0) - this.mMaxHeat = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() - 1; - // showCentrifugeRecipe(this.mMaxHeat); - } - - public void showElectrolyzerRecipe(int aIndex) { - /* - if (aIndex >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() || aIndex < 0) - aIndex = 0; - GT_Recipe tRecipe = GT_Recipe_Map.sElectrolyzerRecipes.get(aIndex); - if (tRecipe != null) { - if (tRecipe.mInput1 == null) { - this.mInventory[59] = null; - } - else { - this.mInventory[59] = tRecipe.mInput1.copy(); - } - if (tRecipe.mInput2 == null) { - this.mInventory[60] = null; - } - else { - this.mInventory[60] = tRecipe.mInput2.copy(); - } - if (tRecipe.mOutput1 == null) { - this.mInventory[61] = null; - } - else { - this.mInventory[61] = tRecipe.mOutput1.copy(); - } - if (tRecipe.mOutput2 == null) { - this.mInventory[62] = null; - } - else { - this.mInventory[62] = tRecipe.mOutput2.copy(); - } - if (tRecipe.mOutput3 == null) { - this.mInventory[63] = null; - } - else { - this.mInventory[63] = tRecipe.mOutput3.copy(); - } - if (tRecipe.mOutput4 == null) { - this.mInventory[64] = null; - } - else { - this.mInventory[64] = tRecipe.mOutput4.copy(); - } - this.mEU = tRecipe.mDuration * tRecipe.mEUt; - this.mMaxHeat = aIndex; - } - this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); - */} - - public void switchElectrolyzerPageForward() { - if (++this.mMaxHeat >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size()) - this.mMaxHeat = 0; - showElectrolyzerRecipe(this.mMaxHeat); - } - - public void switchElectrolyzerPageBackward() { - if (--this.mMaxHeat < 0) - this.mMaxHeat = GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() - 1; - showElectrolyzerRecipe(this.mMaxHeat); - } - - public static ArrayList sFusionReactorRecipes = new ArrayList(); - - public void showFusionRecipe(int aIndex) { - - if (sFusionReactorRecipes.isEmpty()) { - for (GT_Recipe aRecipe : GT_Recipe_Map.sFusionRecipes.mRecipeList) { - sFusionReactorRecipes.add(aRecipe); - } - Collections.sort(sFusionReactorRecipes); - } - - if (aIndex >= sFusionReactorRecipes.size() || aIndex < 0) { - aIndex = 0; - } - GT_Recipe tRecipe = sFusionReactorRecipes.get(aIndex); - if (tRecipe != null) { - if (tRecipe.mFluidInputs[0] == null) { - this.mInventory[59] = null; - } - else { - this.mInventory[59] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[0], true); - } - if (tRecipe.mFluidInputs[1] == null) { - this.mInventory[60] = null; - } - else { - this.mInventory[60] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[1], true); - } - if (tRecipe.mFluidOutputs[0] == null) { - this.mInventory[61] = null; - } - else { - this.mInventory[61] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[0], true); - } - this.mEU = tRecipe.mSpecialValue; - this.mEUOut = tRecipe.mEUt; - this.mHeat = tRecipe.mDuration; - this.mMaxHeat = aIndex; - this.mFusionOutput = tRecipe.mFluidOutputs[0].getLocalizedName(); - } - this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); - } - - public void switchFusionPageForward() { - if (++this.mMaxHeat >= sFusionReactorRecipes.size()) - this.mMaxHeat = 0; - showFusionRecipe(this.mMaxHeat); - } - - public void switchFusionPageBackward() { - if (--this.mMaxHeat < 0) - this.mMaxHeat = sFusionReactorRecipes.size() - 1; - showFusionRecipe(this.mMaxHeat); - } - - public void switchNuclearReactor() { - if (this.mStarted) { - stopNuclearReactor(); - } - else { - startNuclearReactor(); - } - } - - public void startNuclearReactor() { - this.mStarted = true; - this.mHeat = 0; - this.mEU = 0; - mSimulator.simulate(); - } - - public void stopNuclearReactor() { - this.mStarted = false; - mSimulator.simulate(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mMode", this.mMode); - aNBT.setInteger("mProgress", this.mProgress); - aNBT.setInteger("mMaxProgress", this.mMaxProgress); - aNBT.setBoolean("mStarted", this.mStarted); - int[] aSplitLong1 = MathUtils.splitLongIntoTwoIntegers(mEU); - aNBT.setInteger("mEU1", aSplitLong1[0]); - aNBT.setInteger("mEU2", aSplitLong1[1]); - aNBT.setInteger("mHeat", this.mHeat); - int[] aSplitLong2 = MathUtils.splitLongIntoTwoIntegers(mEUOut); - aNBT.setInteger("mEUOut1", aSplitLong2[0]); - aNBT.setInteger("mEUOut2", aSplitLong2[1]); - aNBT.setInteger("mMaxHeat", this.mMaxHeat); - aNBT.setFloat("mHEM", this.mHEM); - aNBT.setFloat("mExplosionStrength", this.mExplosionStrength); - aNBT.setString("mFusionOutput", this.mFusionOutput); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mMode = aNBT.getInteger("mMode"); - this.mProgress = aNBT.getInteger("mProgress"); - this.mMaxProgress = aNBT.getInteger("mMaxProgress"); - this.mStarted = aNBT.getBoolean("mStarted"); - int partA = aNBT.getInteger("mEU1"); - int partB = aNBT.getInteger("mEU2"); - this.mEU = MathUtils.combineTwoIntegersToLong(partA, partB); - this.mHeat = aNBT.getInteger("mHeat"); - partA = aNBT.getInteger("mEUOut1"); - partB = aNBT.getInteger("mEUOut2"); - this.mEUOut = MathUtils.combineTwoIntegersToLong(partA, partB); - this.mMaxHeat = aNBT.getInteger("mMaxHeat"); - this.mHEM = aNBT.getFloat("mHEM"); - this.mExplosionStrength = aNBT.getFloat("mExplosionStrength"); - this.mFusionOutput = aNBT.getString("mFusionOutput"); - } - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (mSimulator == null) { - mSimulator = new GT_Computercube_Simulator(this); - } - if(this.getBaseMetaTileEntity().isClientSide()) { - this.getWorld().markBlockForUpdate(this.getXCoord(), this.getYCoord(), this.getZCoord()); - this.mNeedsUpdate = false; - } - else { - this.mNeedsUpdate = false; - } - if (this.getBaseMetaTileEntity().isServerSide()) { - if (this.mMode == MODE_SCANNER) { - /*if (this.mInventory[55] == null) { - this.mInventory[55] = this.mInventory[54]; - this.mInventory[54] = null; - }*/ - if (this.mInventory[57] == null) { - this.mInventory[57] = this.mInventory[56]; - this.mInventory[56] = null; - } - - // 54 - 55 || 56 - 57 - // Do scanny bits - if (mSeedscanner && this.mMode == MODE_SCANNER) { - /*if (doScan(this.mInventory[55]) == 4) { - if ((this.mInventory[57] != null) && (this.mInventory[57].getUnlocalizedName().equals("gt.metaitem.01.32707"))) { - GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "scanning"); - } - }*/ - /*if (this.mEU > 0) { - if (!this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mEU, false)) { - this.mProgress = 0; - } - }*/ - } - - /*if (mSeedscanner && this.mInventory[55] != null && GT_Utility.areStacksEqual(this.mInventory[55], Ic2Items.cropSeed, true) && this.mInventory[55].getTagCompound() != null) { - if (this.mInventory[55].getTagCompound().getByte("scan") < 4) { - if (this.mProgress >= 100) { - this.mInventory[55].getTagCompound().setByte("scan", (byte) 4); - this.mProgress = 0; - } - else if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(100, false)) { - this.mProgress++; - } - } - else { - this.mProgress = 0; - if (this.mInventory[56] == null) { - this.mInventory[56] = this.mInventory[55]; - this.mInventory[55] = null; - } - } - } - else { - this.mProgress = 0; - if (this.mInventory[56] == null) { - this.mInventory[56] = this.mInventory[55]; - this.mInventory[55] = null; - } - }*/ - } - - if (this.mMode == MODE_REACTOR_PLANNER && mReactorplanner && this.mSimulator != null && this.mSimulator.simulator != null && this.mSimulator.simulatedReactor != null) { - SimulationData aData = this.mSimulator.simulator.getData(); - if (aData != null && aData.totalReactorTicks > 0 && this.mProgress != aData.totalReactorTicks) { - Logger.INFO("Updating Variables"); - this.mEU = aData.avgEUoutput; - this.mEUOut = (aData.totalEUoutput / aData.totalReactorTicks); - this.mHeat = aData.avgHUoutput; - this.mMaxHeat = aData.maxHUoutput; - this.mExplosionStrength = aData.explosionPower; - this.mHEM = (float) aData.hullHeating; - this.mProgress = aData.totalReactorTicks; - } - } - - if (aTick % 20L == 0L) { - this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 10, this.mMode); - this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockMachines, 11, this.mMaxHeat); - } - } - } - - @Override - public void receiveClientEvent(byte aEventID, byte aValue) { - super.receiveClientEvent(aEventID, aValue); - if (this.getWorld().isRemote) - switch (aEventID) { - case 10 : - this.mNeedsUpdate = true; - this.mMode = aValue; - break; - case 11 : - this.mMaxHeat = aValue; - break; - } - return; - } - - @Override - public void onValueUpdate(byte aValue) { - super.onValueUpdate(aValue); - this.mNeedsUpdate = true; - } - - @Override - public void onMachineBlockUpdate() { - super.onMachineBlockUpdate(); - this.mNeedsUpdate = true; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return (this.mMode == MODE_SCANNER) ? ((i == 54 || i == 55)) : false; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return (this.mMode == MODE_SCANNER) ? ((i == 56 || i == 57)) : false; - } - - public World getWorld() { - return this.getBaseMetaTileEntity().getWorld(); - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return false; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getSides(i); - rTextures[2][i + 1] = this.getSides(i); - rTextures[3][i + 1] = this.getSides(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getSides(i); - rTextures[7][i + 1] = this.getSides(i); - rTextures[8][i + 1] = this.getSides(i); - rTextures[9][i + 1] = this.getSides(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_3)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Computer_Cube)}; - } - - protected static final int - DID_NOT_FIND_RECIPE = 0, - FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, - FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - /** * Calcualtes overclocked ness using long integers * @param aEUt - recipe EUt * @param aDuration - recipe Duration */ protected void calculateOverclockedNess(int aEUt, int aDuration) { - if(mTier==0){ - //Long time calculation - long xMaxProgresstime = ((long)aDuration)<<1; - if(xMaxProgresstime>Integer.MAX_VALUE-1){ - //make impossible if too long - mEU=Integer.MAX_VALUE-1; - mMaxProgress=Integer.MAX_VALUE-1; - }else{ - mEU=aEUt>>2; - mMaxProgress=(int)xMaxProgresstime; + if (mTier == 0) { + // Long time calculation + long xMaxProgresstime = ((long) aDuration) << 1; + if (xMaxProgresstime > Integer.MAX_VALUE - 1) { + // make impossible if too long + mEU = Integer.MAX_VALUE - 1; + mMaxProgress = Integer.MAX_VALUE - 1; + } else { + mEU = aEUt >> 2; + mMaxProgress = (int) xMaxProgresstime; } - }else{ - //Long EUt calculation - long xEUt=aEUt; - //Isnt too low EUt check? + } else { + // Long EUt calculation + long xEUt = aEUt; + // Isnt too low EUt check? long tempEUt = Math.max(xEUt, V[1]); mMaxProgress = aDuration; - while (tempEUt <= V[mTier -1] * (long)this.maxAmperesIn()) { - tempEUt<<=2;//this actually controls overclocking - //xEUt *= 4;//this is effect of everclocking - mMaxProgress>>=1;//this is effect of overclocking - xEUt = mMaxProgress==0 ? xEUt>>1 : xEUt<<2;//U know, if the time is less than 1 tick make the machine use 2x less power + while (tempEUt <= V[mTier - 1] * (long) this.maxAmperesIn()) { + tempEUt <<= 2; // this actually controls overclocking + // xEUt *= 4;//this is effect of everclocking + mMaxProgress >>= 1; // this is effect of overclocking + xEUt = mMaxProgress == 0 + ? xEUt >> 1 + : xEUt << 2; // U know, if the time is less than 1 tick make the machine use 2x less power } - if(xEUt>Integer.MAX_VALUE-1){ - mEU = Integer.MAX_VALUE-1; - mMaxProgress = Integer.MAX_VALUE-1; - }else{ - mEU = (int)xEUt; - if(mEU==0) - mEU = 1; - if(mMaxProgress==0) - mMaxProgress = 1;//set time to 1 tick + if (xEUt > Integer.MAX_VALUE - 1) { + mEU = Integer.MAX_VALUE - 1; + mMaxProgress = Integer.MAX_VALUE - 1; + } else { + mEU = (int) xEUt; + if (mEU == 0) mEU = 1; + if (mMaxProgress == 0) mMaxProgress = 1; // set time to 1 tick } } } - + public int doScan(ItemStack aInput) { - if (this.mMode != MODE_SCANNER) { - return DID_NOT_FIND_RECIPE; - } + if (this.mMode != MODE_SCANNER) { + return DID_NOT_FIND_RECIPE; + } ItemStack aStack = aInput; if (this.mInventory[56] != null) { return DID_NOT_FIND_RECIPE; } else if ((GT_Utility.isStackValid(aStack)) && (aStack.stackSize > 0)) { - - + if (ItemList.IC2_Crop_Seeds.isStackEqual(aStack, true, true)) { NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT == null) { @@ -923,7 +967,7 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { if (tNBT.getByte("scan") < 4) { tNBT.setByte("scan", (byte) 4); calculateOverclockedNess(8, 160); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgress == Integer.MAX_VALUE - 1 && mEU == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } else { @@ -935,20 +979,24 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { this.mInventory[57].setTagCompound(tNBT); return 2; } - - + if (ItemList.Tool_DataOrb.isStackEqual(getSpecialSlot(), false, true)) { if (ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) { aStack.stackSize -= 1; this.mInventory[57] = GT_Utility.copyAmount(1L, getSpecialSlot()); calculateOverclockedNess(30, 512); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgress == Integer.MAX_VALUE - 1 && mEU == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; } ItemData tData = GT_OreDictUnificator.getAssociation(aStack); - if ((tData != null) && ((tData.mPrefix == OrePrefixes.dust) || (tData.mPrefix == OrePrefixes.cell)) && (tData.mMaterial.mMaterial.mElement != null) && (!tData.mMaterial.mMaterial.mElement.mIsIsotope) && (tData.mMaterial.mMaterial != Materials.Magic) && (tData.mMaterial.mMaterial.getMass() > 0L)) { + if ((tData != null) + && ((tData.mPrefix == OrePrefixes.dust) || (tData.mPrefix == OrePrefixes.cell)) + && (tData.mMaterial.mMaterial.mElement != null) + && (!tData.mMaterial.mMaterial.mElement.mIsIsotope) + && (tData.mMaterial.mMaterial != Materials.Magic) + && (tData.mMaterial.mMaterial.getMass() > 0L)) { getSpecialSlot().stackSize -= 1; aStack.stackSize -= 1; @@ -956,20 +1004,19 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { Behaviour_DataOrb.setDataTitle(this.mInventory[57], "Elemental-Scan"); Behaviour_DataOrb.setDataName(this.mInventory[57], tData.mMaterial.mMaterial.mElement.name()); calculateOverclockedNess(30, GT_Utility.safeInt(tData.mMaterial.mMaterial.getMass() * 8192L)); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgress == Integer.MAX_VALUE - 1 && mEU == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; } } - - + if (ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true)) { if (ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) { aStack.stackSize -= 1; this.mInventory[57] = GT_Utility.copyAmount(1L, getSpecialSlot()); calculateOverclockedNess(30, 128); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgress == Integer.MAX_VALUE - 1 && mEU == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; @@ -981,7 +1028,7 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { this.mInventory[57] = GT_Utility.copyAmount(1L, getSpecialSlot()); this.mInventory[57].setTagCompound(aStack.getTagCompound()); calculateOverclockedNess(30, 128); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgress == Integer.MAX_VALUE - 1 && mEU == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; @@ -991,16 +1038,16 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { aStack.stackSize -= 1; this.mInventory[57] = GT_Utility.copyAmount(1L, getSpecialSlot()); - this.mInventory[57].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "map_id", (short) aStack.getItemDamage())); + this.mInventory[57].setTagCompound(GT_Utility.getNBTContainingShort( + new NBTTagCompound(), "map_id", (short) aStack.getItemDamage())); calculateOverclockedNess(30, 128); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgress == Integer.MAX_VALUE - 1 && mEU == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; } + } - } - if (ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true) && aStack != null) { for (GT_Recipe.GT_Recipe_AssemblyLine tRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { if (GT_Utility.areStacksEqual(tRecipe.mResearchItem, aStack, true)) { @@ -1014,39 +1061,32 @@ public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank { if (failScanner) { return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } - String s = tRecipe.mOutput.getDisplayName(); if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName()); - if (s == null) - s = tRecipe.mOutput.getDisplayName(); + if (s == null) s = tRecipe.mOutput.getDisplayName(); } this.mInventory[57] = GT_Utility.copyAmount(1L, getSpecialSlot()); - // Use Assline Utils if (GT_AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(this.mInventory[57], tRecipe)) { - aStack.stackSize -= 1; + aStack.stackSize -= 1; calculateOverclockedNess(30, tRecipe.mResearchTime); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgress == Integer.MAX_VALUE - 1 && mEU == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; getSpecialSlot().stackSize -= 1; return 2; } - } } } - } return 0; } - private ItemStack getSpecialSlot() { - return this.mInventory[54]; - } - - + private ItemStack getSpecialSlot() { + return this.mInventory[54]; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java index 4b73bba6df..cc1592cdaa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java @@ -8,341 +8,359 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachi import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_SolarTower; -import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class TileEntitySolarHeater extends GT_MetaTileEntity_TieredMachineBlock { - public boolean mHasTower = false; - private GregtechMetaTileEntity_SolarTower mTower = null; - - private int mTX, mTY, mTZ; - private Byte mRequiredFacing; - - public TileEntitySolarHeater(final int aID, final String aName, final String aNameRegional, final int aTier, - final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public TileEntitySolarHeater(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] { - this.mDescription, - "Point me at a Solar Tower", - CORE.GT_Tooltip }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex - + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new TileEntitySolarHeater(this.mName, this.mTier, this.mDescription, this.mTextures, 0); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - return new String[] { - this.getLocalName(), - "Testificate" - }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public long maxEUStore() { - return 0; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing >= 2; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mHasTower", mHasTower); - if (mHasTower) { - aNBT.setInteger("mTX", mTX); - aNBT.setInteger("mTY", mTY); - aNBT.setInteger("mTZ", mTZ); - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mHasTower = aNBT.getBoolean("mHasTower"); - if (this.mHasTower) { - if (aNBT.hasKey("mTX")) - this.mTX = aNBT.getInteger("mTX"); - if (aNBT.hasKey("mTY")) - this.mTY = aNBT.getInteger("mTY"); - if (aNBT.hasKey("mTZ")) - this.mTZ = aNBT.getInteger("mTZ"); - } - } - - @Override - public long getInputTier() { - return 0; - } - - @Override - public long getOutputTier() { - return 0; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return false; - } - - @Override - public void onExplosion() { - - } - - public boolean hasSolarTower() { - return mHasTower; - } - - public GregtechMetaTileEntity_SolarTower getSolarTower() { - if (this.mHasTower) { - return mTower; - } - return null; - } - - public boolean canSeeSky() { - if (this.getBaseMetaTileEntity().getWorld().canBlockSeeTheSky(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord())) { - return true; - } - return false; - } - - - public boolean setSolarTower(GregtechMetaTileEntity_SolarTower aTowerTile) { - if (!hasSolarTower()) { - this.mTX = aTowerTile.getBaseMetaTileEntity().getXCoord(); - this.mTY = (int) aTowerTile.getBaseMetaTileEntity().getYCoord(); - this.mTZ = aTowerTile.getBaseMetaTileEntity().getZCoord(); - this.mHasTower = true; - this.mTower = aTowerTile; - return true; - } - return false; - } - - public boolean clearSolarTower() { - if (mHasTower || mRequiredFacing != null || this.mTower != null) { - this.mTX = 0; - this.mTY = 0; - this.mTZ = 0; - this.mRequiredFacing = null; - this.mTower = null; - this.mHasTower = false; - return true; - } - return false; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - } - - @Override - public void onRemoval() { - super.onRemoval(); - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide > 1; - } - - @Override - public boolean isInputFacing(byte aSide) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public void onFacingChange() { - super.onFacingChange(); - } - - @Override - public void doExplosion(long aExplosionPower) { - - } + public boolean mHasTower = false; + private GregtechMetaTileEntity_SolarTower mTower = null; + + private int mTX, mTY, mTZ; + private Byte mRequiredFacing; + + public TileEntitySolarHeater( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public TileEntitySolarHeater( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Point me at a Solar Tower", CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) + }; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new TileEntitySolarHeater(this.mName, this.mTier, this.mDescription, this.mTextures, 0); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return new String[] {this.getLocalName(), "Testificate"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing >= 2; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mHasTower", mHasTower); + if (mHasTower) { + aNBT.setInteger("mTX", mTX); + aNBT.setInteger("mTY", mTY); + aNBT.setInteger("mTZ", mTZ); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mHasTower = aNBT.getBoolean("mHasTower"); + if (this.mHasTower) { + if (aNBT.hasKey("mTX")) this.mTX = aNBT.getInteger("mTX"); + if (aNBT.hasKey("mTY")) this.mTY = aNBT.getInteger("mTY"); + if (aNBT.hasKey("mTZ")) this.mTZ = aNBT.getInteger("mTZ"); + } + } + + @Override + public long getInputTier() { + return 0; + } + + @Override + public long getOutputTier() { + return 0; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return false; + } + + @Override + public void onExplosion() {} + + public boolean hasSolarTower() { + return mHasTower; + } + + public GregtechMetaTileEntity_SolarTower getSolarTower() { + if (this.mHasTower) { + return mTower; + } + return null; + } + + public boolean canSeeSky() { + if (this.getBaseMetaTileEntity() + .getWorld() + .canBlockSeeTheSky( + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getYCoord(), + this.getBaseMetaTileEntity().getZCoord())) { + return true; + } + return false; + } + + public boolean setSolarTower(GregtechMetaTileEntity_SolarTower aTowerTile) { + if (!hasSolarTower()) { + this.mTX = aTowerTile.getBaseMetaTileEntity().getXCoord(); + this.mTY = (int) aTowerTile.getBaseMetaTileEntity().getYCoord(); + this.mTZ = aTowerTile.getBaseMetaTileEntity().getZCoord(); + this.mHasTower = true; + this.mTower = aTowerTile; + return true; + } + return false; + } + + public boolean clearSolarTower() { + if (mHasTower || mRequiredFacing != null || this.mTower != null) { + this.mTX = 0; + this.mTY = 0; + this.mTZ = 0; + this.mRequiredFacing = null; + this.mTower = null; + this.mHasTower = false; + return true; + } + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onRemoval() { + super.onRemoval(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public void onFacingChange() { + super.onFacingChange(); + } + + @Override + public void doExplosion(long aExplosionPower) {} } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java index 9bb2443683..2f88c6a784 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java @@ -12,110 +12,128 @@ import net.minecraft.nbt.NBTTagCompound; public abstract class GT_MetaTileEntity_RedstoneBase extends GT_MetaTileEntity_TieredMachineBlock { - protected int mOpenerCount; - - public GT_MetaTileEntity_RedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_RedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_RedstoneBase(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_RedstoneBase(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public final boolean isSimpleMachine() { - return false; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return aSide != getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public final boolean isValidSlot(int aIndex) { - return false; - } - - @Override - public final boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public final boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public abstract void saveNBTData(NBTTagCompound aNBT); - - @Override - public abstract void loadNBTData(NBTTagCompound aNBT); - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - return false; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, gregtech.api.interfaces.tileentity.IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, gregtech.api.interfaces.tileentity.IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public final void onOpenGUI() { - super.onOpenGUI(); - mOpenerCount++; - } - - @Override - public final void onCloseGUI() { - super.onCloseGUI(); - mOpenerCount--; - } - - public boolean hasRedstoneSignal() { - if (getBaseMetaTileEntity().getStrongestRedstone() > 0) { - return true; - } - for (byte i=0;i<6;i++) { - if (getBaseMetaTileEntity().getOutputRedstoneSignal(i) > 0) { - return true; - } - } - return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip - }; - } - + protected int mOpenerCount; + + public GT_MetaTileEntity_RedstoneBase( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_RedstoneBase( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String[] aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_RedstoneBase( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_RedstoneBase( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public final boolean isSimpleMachine() { + return false; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public final boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public final boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public final boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public abstract void saveNBTData(NBTTagCompound aNBT); + + @Override + public abstract void loadNBTData(NBTTagCompound aNBT); + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + return false; + } + + @Override + public Object getServerGUI( + int aID, + InventoryPlayer aPlayerInventory, + gregtech.api.interfaces.tileentity.IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI( + int aID, + InventoryPlayer aPlayerInventory, + gregtech.api.interfaces.tileentity.IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public final void onOpenGUI() { + super.onOpenGUI(); + mOpenerCount++; + } + + @Override + public final void onCloseGUI() { + super.onCloseGUI(); + mOpenerCount--; + } + + public boolean hasRedstoneSignal() { + if (getBaseMetaTileEntity().getStrongestRedstone() > 0) { + return true; + } + for (byte i = 0; i < 6; i++) { + if (getBaseMetaTileEntity().getOutputRedstoneSignal(i) > 0) { + return true; + } + } + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java index 0c0cc44d93..3cf868a998 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java @@ -12,196 +12,250 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_RedstoneButtonPanel extends GT_MetaTileEntity_RedstoneBase { - - public byte mRedstoneStrength = 0, mType = 0, mUpdate = 0; - - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[64]; - - static { - for (int i=0;i<64;i++) { - sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/ButtonPanel/"+i); - } - } - - public GT_MetaTileEntity_RedstoneButtonPanel(int aID) { - super(aID, "redstone.button.panel", "Button Panel", 5, 0, "Right-click with Screwdriver to change Button Design"); - } - - public GT_MetaTileEntity_RedstoneButtonPanel(final String aName, String aDescription, final ITexture[][][] aTextures) { - super(aName, 5, 0, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneButtonPanel(this.mName, mDescription, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mRedstoneStrength", mRedstoneStrength); - aNBT.setByte("mType", mType); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); - mType = aNBT.getByte("mType"); - } - - @Override - public void onValueUpdate(byte aValue) { - mRedstoneStrength = (byte)(aValue & 15); - mType = (byte)(aValue >>> 4); - } - - @Override - public byte getUpdateData() { - return (byte)((mRedstoneStrength & 15) | (mType << 4)); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { - if (getBaseMetaTileEntity().isServerSide()) { - mUpdate = 2; - switch (mType) { - case 0: default: - switch (aSide) { - case 0: case 1: - mRedstoneStrength = (byte)((byte)( aX*4) + 4 * (byte)( aZ*4)); - break; - case 2: - mRedstoneStrength = (byte)((byte)(4-aX*4) + 4 * (byte)(4-aY*4)); - break; - case 3: - mRedstoneStrength = (byte)((byte)( aX*4) + 4 * (byte)(4-aY*4)); - break; - case 4: - mRedstoneStrength = (byte)((byte)( aZ*4) + 4 * (byte)(4-aY*4)); - break; - case 5: - mRedstoneStrength = (byte)((byte)(4-aZ*4) + 4 * (byte)(4-aY*4)); - break; - } - break; - case 1: - switch (aSide) { - case 0: case 1: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)( aX*2) + 2 * (byte)( aZ*2))))); - break; - case 2: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)(2-aX*2) + 2 * (byte)(2-aY*2))))); - break; - case 3: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)( aX*2) + 2 * (byte)(2-aY*2))))); - break; - case 4: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)( aZ*2) + 2 * (byte)(2-aY*2))))); - break; - case 5: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)(2-aZ*2) + 2 * (byte)(2-aY*2))))); - break; - } - break; - case 2: - switch (aSide) { - case 0: case 1: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)( aZ*4)))); - break; - case 2: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); - break; - case 3: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); - break; - case 4: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); - break; - case 5: - mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); - break; - } - break; - } - } - return true; - } - return false; - } - - @Override + + public byte mRedstoneStrength = 0, mType = 0, mUpdate = 0; + + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[64]; + + static { + for (int i = 0; i < 64; i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/ButtonPanel/" + i); + } + } + + public GT_MetaTileEntity_RedstoneButtonPanel(int aID) { + super( + aID, + "redstone.button.panel", + "Button Panel", + 5, + 0, + "Right-click with Screwdriver to change Button Design"); + } + + public GT_MetaTileEntity_RedstoneButtonPanel( + final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneButtonPanel(this.mName, mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mRedstoneStrength", mRedstoneStrength); + aNBT.setByte("mType", mType); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); + mType = aNBT.getByte("mType"); + } + + @Override + public void onValueUpdate(byte aValue) { + mRedstoneStrength = (byte) (aValue & 15); + mType = (byte) (aValue >>> 4); + } + + @Override + public byte getUpdateData() { + return (byte) ((mRedstoneStrength & 15) | (mType << 4)); + } + + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + if (getBaseMetaTileEntity().isServerSide()) { + mUpdate = 2; + switch (mType) { + case 0: + default: + switch (aSide) { + case 0: + case 1: + mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (aZ * 4)); + break; + case 2: + mRedstoneStrength = (byte) ((byte) (4 - aX * 4) + 4 * (byte) (4 - aY * 4)); + break; + case 3: + mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (4 - aY * 4)); + break; + case 4: + mRedstoneStrength = (byte) ((byte) (aZ * 4) + 4 * (byte) (4 - aY * 4)); + break; + case 5: + mRedstoneStrength = (byte) ((byte) (4 - aZ * 4) + 4 * (byte) (4 - aY * 4)); + break; + } + break; + case 1: + switch (aSide) { + case 0: + case 1: + mRedstoneStrength = + (byte) (mRedstoneStrength ^ (1 << (((byte) (aX * 2) + 2 * (byte) (aZ * 2))))); + break; + case 2: + mRedstoneStrength = (byte) + (mRedstoneStrength ^ (1 << (((byte) (2 - aX * 2) + 2 * (byte) (2 - aY * 2))))); + break; + case 3: + mRedstoneStrength = (byte) + (mRedstoneStrength ^ (1 << (((byte) (aX * 2) + 2 * (byte) (2 - aY * 2))))); + break; + case 4: + mRedstoneStrength = (byte) + (mRedstoneStrength ^ (1 << (((byte) (aZ * 2) + 2 * (byte) (2 - aY * 2))))); + break; + case 5: + mRedstoneStrength = (byte) + (mRedstoneStrength ^ (1 << (((byte) (2 - aZ * 2) + 2 * (byte) (2 - aY * 2))))); + break; + } + break; + case 2: + switch (aSide) { + case 0: + case 1: + mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (aZ * 4)))); + break; + case 2: + mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + break; + case 3: + mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + break; + case 4: + mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + break; + case 5: + mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + break; + } + break; + } + } + return true; + } + return false; + } + + @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (getBaseMetaTileEntity().isServerSide()) { - getBaseMetaTileEntity().setGenericRedstoneOutput(true); - if (mUpdate > 0) { - mUpdate--; - } - else if (getBaseMetaTileEntity().isAllowedToWork()) { - mRedstoneStrength = 0; - } - for (byte i = 0; i < 6; i++) { - getBaseMetaTileEntity().setStrongOutputRedstoneSignal(i, i == getBaseMetaTileEntity().getFrontFacing()?(byte)0:mRedstoneStrength); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(i, i == getBaseMetaTileEntity().getFrontFacing()?(byte)0:mRedstoneStrength); - } - } - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) mType=(byte)((mType+1)%3); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getSides(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getSidesActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(sIconList[mType*16+mRedstoneStrength])}; - } - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_Off)}; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_On)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_Off)}; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_On)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_Off)}; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_On)}; - } + if (getBaseMetaTileEntity().isServerSide()) { + getBaseMetaTileEntity().setGenericRedstoneOutput(true); + if (mUpdate > 0) { + mUpdate--; + } else if (getBaseMetaTileEntity().isAllowedToWork()) { + mRedstoneStrength = 0; + } + for (byte i = 0; i < 6; i++) { + getBaseMetaTileEntity() + .setStrongOutputRedstoneSignal( + i, i == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength); + getBaseMetaTileEntity() + .setInternalOutputRedstoneSignal( + i, i == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength); + } + } + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 3); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getSidesActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) + }; + } + return this.mTextures[ + (aActive || hasRedstoneSignal() ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_Off) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_On) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_Off) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_On) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_Off) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_On) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java index 379345ec6a..caba805f65 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java @@ -1,11 +1,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; -import java.util.*; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Textures; -import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.IRedstoneCircuitBlock; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -17,6 +13,7 @@ import gregtech.api.util.*; import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_Container_RedstoneCircuitBlock; import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_GUIContainer_RedstoneCircuitBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.*; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -24,475 +21,482 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_RedstoneBase implements IRedstoneCircuitBlock { - - public int mGate = 0, mGateData[] = new int[]{0, 0, 0, 0, 0, 0, 0, 0}; - public boolean bOutput = true; - - public GT_MetaTileEntity_RedstoneCircuitBlock(int aID) { - super(aID, "redstone.circuit", "Redstone Circuit Block", 1, 5, "Computes Redstone"); - } - - public GT_MetaTileEntity_RedstoneCircuitBlock(final String aName, String aDescription, final ITexture[][][] aTextures) { - super(aName, 1, 5, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneCircuitBlock(this.mName, mDescription, this.mTextures); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_RedstoneCircuitBlock(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_RedstoneCircuitBlock(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public boolean hasSidedRedstoneOutputBehavior() { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return !this.isOutputFacing(aSide); - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isPneumatic() { - return false; - } - - @Override - public boolean isSteampowered() { - return false; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide == this.getOutputFacing(); - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public long maxEUInput() { - return GT_Values.V[1]; - } - - @Override - public long maxEUOutput() { - return bOutput ? GT_Values.V[1] : 0; - } - - @Override - public long maxAmperesIn() { - return 2; - } - - @Override - public long maxAmperesOut() { - return 1; - } - - @Override - public int getSizeInventory() { - return 5; - } - - @Override - public long maxEUStore() { - return GT_Values.V[3] * 1024; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer, 147); - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mGate", mGate); - aNBT.setIntArray("mGateData", mGateData); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mGate = aNBT.getInteger("mGate"); - mGateData = aNBT.getIntArray("mGateData"); - if (mGateData.length != 8) - mGateData = new int[]{0, 0, 0, 0, 0, 0, 0, 0}; - } - - public void switchOutput() { - bOutput = !bOutput; - } - - public void switchGateForward(boolean aShift) { - try { - Set tKeys = GregTech_API.sCircuitryBehaviors.keySet(); - ArrayList tList = new ArrayList(); - tList.addAll(tKeys); - if (tList.size() <= 0) - return; - Collections.sort(tList); - if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) - mGate = tList.get(0); - int tIndex = Collections.binarySearch(tList, mGate); - tIndex += aShift ? 16 : 1; - while (tIndex >= tList.size()) - tIndex -= tList.size(); - mGate = tList.get(tIndex); - switchGate(); - } - catch (Throwable e) { - GT_Log.err.print(e); - } - } - - public void switchGateBackward(boolean aShift) { - try { - Set tKeys = GregTech_API.sCircuitryBehaviors.keySet(); - ArrayList tList = new ArrayList(); - tList.addAll(tKeys); - if (tList.size() <= 0) - return; - Collections.sort(tList); - if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) - mGate = tList.get(0); - int tIndex = Collections.binarySearch(tList, mGate); - tIndex -= aShift ? 16 : 1; - while (tIndex < 0) - tIndex += tList.size(); - mGate = tList.get(tIndex); - switchGate(); - } - catch (Throwable e) { - GT_Log.err.print(e); - } - } - - @Override - public void onFacingChange() { - resetRedstone(); - } - - private void resetRedstone() { - getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 0, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 1, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 2, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 3, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 4, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 5, (byte) 0); - } - - public void changeGateData(int aIndex, int aValue) { - mGateData[aIndex] += aValue; - validateGateData(); - } - - public void stackGateData(int aIndex, ItemStack aStack) { - mGateData[aIndex] = GT_Utility.stackToInt(aStack); - validateGateData(); - } - - private void switchGate() { - resetRedstone(); - for (int i = 0; i < mGateData.length; i++) - mGateData[i] = 0; - GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tBehaviour != null) - try { - tBehaviour.initParameters(mGateData, this); - } - catch (Throwable e) { - GT_Log.err.print(e); - } - validateGateData(); - } - - private void validateGateData() { - GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tBehaviour != null) - try { - tBehaviour.validateParameters(mGateData, this); - } - catch (Throwable e) { - GT_Log.err.print(e); - } - } - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - getBaseMetaTileEntity().setGenericRedstoneOutput(true); - validateGateData(); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - getBaseMetaTileEntity().setGenericRedstoneOutput(true); - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { - mInventory[0] = mInventory[1] = mInventory[2] = mInventory[3] = mInventory[4] = null; - if (getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { - if (getBaseMetaTileEntity().isActive()) { - GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tBehaviour != null) { - try { - tBehaviour.onTick(mGateData, this); - if (tBehaviour.displayItemStack(mGateData, this, 0)) - mInventory[1] = getCoverByID(mGateData[0]); - if (tBehaviour.displayItemStack(mGateData, this, 1)) - mInventory[2] = getCoverByID(mGateData[1]); - if (tBehaviour.displayItemStack(mGateData, this, 2)) - mInventory[3] = getCoverByID(mGateData[2]); - if (tBehaviour.displayItemStack(mGateData, this, 3)) - mInventory[4] = getCoverByID(mGateData[3]); - } - catch (Throwable e) { - GT_Log.err.print(e); - } - } - } - getBaseMetaTileEntity().setErrorDisplayID(0); - } - else { - getBaseMetaTileEntity().setErrorDisplayID(1); - } - } - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - //Only Calc server-side - if (!this.getBaseMetaTileEntity().isServerSide()) { - return; - } - //Emit Redstone - for (byte i=0;i<6;i++) { - byte aRedstone = getBaseMetaTileEntity().getOutputRedstoneSignal(i); - this.getBaseMetaTileEntity().setInternalOutputRedstoneSignal(i, aRedstone); - } - - } - - @Override - public final boolean hasRedstoneSignal() { - for (byte i=0;i<6;i++) { - if (getBaseMetaTileEntity().getOutputRedstoneSignal(i) > 0) { - return true; - } - } - return false; - } - - @Override - public boolean allowGeneralRedstoneOutput() { - return true; - } - - /** The Item List for Covers */ - public static final Map sCoversItems = new HashMap(); - - private static void initCovers() { - for (GT_ItemStack aKey : GregTech_API.sCovers.keySet()) { - ItemStack aStack = aKey.toStack().copy(); - if (aStack != null) { - sCoversItems.put(GT_Utility.stackToInt(aStack), aStack); - } - } - } - - public static ItemStack getCoverByID(int aStack) { - if (sCoversItems.isEmpty()) { - initCovers(); - } - return sCoversItems.get(Integer.valueOf(aStack)); - } - - @Override - public byte getOutputFacing() { - return getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean setRedstone(byte aStrength, byte aSide) { - if (getOutputRedstone(aSide) != aStrength) { - if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(1, false)) { - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(aSide, aStrength); - getBaseMetaTileEntity().setErrorDisplayID(0); - return true; - } - else { - getBaseMetaTileEntity().setErrorDisplayID(1); - return false; - } - } - return false; - } - - /* @Override - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { - if (aSide == getOutputFacing()) { - if (aSide == 0) - return aRedstone ? 56 : 54; - if (aSide == 1) - return aRedstone ? 53 : 52; - return aRedstone ? 94 : 93; - } - if (aSide == 0) - return aRedstone ? 60 : 59; - if (aSide == 1) - return aRedstone ? 58 : 57; - return aRedstone ? 62 : 61; - }*/ - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public byte getOutputRedstone(byte aSide) { - return getBaseMetaTileEntity().getOutputRedstoneSignal(aSide); - } - - @Override - public byte getInputRedstone(byte aSide) { - return getBaseMetaTileEntity().getInternalInputRedstoneSignal(aSide); - } - - @Override - public Block getBlockAtSide(byte aSide) { - return getBaseMetaTileEntity().getBlockAtSide(aSide); - } - - @Override - public byte getMetaIDAtSide(byte aSide) { - return getBaseMetaTileEntity().getMetaIDAtSide(aSide); - } - - @Override - public TileEntity getTileEntityAtSide(byte aSide) { - return getBaseMetaTileEntity().getTileEntityAtSide(aSide); - } - - @Override - public int getRandom(int aRange) { - return getBaseMetaTileEntity().getRandomNumber(aRange); - } - - @Override - public GT_CoverBehavior getCover(byte aSide) { - return getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide); - } - - @Override - public int getCoverID(byte aSide) { - return getBaseMetaTileEntity().getCoverIDAtSide(aSide); - } - - @Override - public int getCoverVariable(byte aSide) { - return getBaseMetaTileEntity().getCoverDataAtSide(aSide); - } - - @Override - public ICoverable getOwnTileEntity() { - return getBaseMetaTileEntity(); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getSides(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getSidesActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex - + 1]; - } - - private GT_RenderedTexture getBase() { - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off)}; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On)}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off), new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red)}; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On), new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off)}; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off)}; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On)}; - } - +public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_RedstoneBase + implements IRedstoneCircuitBlock { + + public int mGate = 0, mGateData[] = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; + public boolean bOutput = true; + + public GT_MetaTileEntity_RedstoneCircuitBlock(int aID) { + super(aID, "redstone.circuit", "Redstone Circuit Block", 1, 5, "Computes Redstone"); + } + + public GT_MetaTileEntity_RedstoneCircuitBlock( + final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, 1, 5, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneCircuitBlock(this.mName, mDescription, this.mTextures); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_RedstoneCircuitBlock(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_RedstoneCircuitBlock(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !this.isOutputFacing(aSide); + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isSteampowered() { + return false; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == this.getOutputFacing(); + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUInput() { + return GT_Values.V[1]; + } + + @Override + public long maxEUOutput() { + return bOutput ? GT_Values.V[1] : 0; + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long maxAmperesOut() { + return 1; + } + + @Override + public int getSizeInventory() { + return 5; + } + + @Override + public long maxEUStore() { + return GT_Values.V[3] * 1024; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer, 147); + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mGate", mGate); + aNBT.setIntArray("mGateData", mGateData); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mGate = aNBT.getInteger("mGate"); + mGateData = aNBT.getIntArray("mGateData"); + if (mGateData.length != 8) mGateData = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; + } + + public void switchOutput() { + bOutput = !bOutput; + } + + public void switchGateForward(boolean aShift) { + try { + Set tKeys = GregTech_API.sCircuitryBehaviors.keySet(); + ArrayList tList = new ArrayList(); + tList.addAll(tKeys); + if (tList.size() <= 0) return; + Collections.sort(tList); + if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0); + int tIndex = Collections.binarySearch(tList, mGate); + tIndex += aShift ? 16 : 1; + while (tIndex >= tList.size()) tIndex -= tList.size(); + mGate = tList.get(tIndex); + switchGate(); + } catch (Throwable e) { + GT_Log.err.print(e); + } + } + + public void switchGateBackward(boolean aShift) { + try { + Set tKeys = GregTech_API.sCircuitryBehaviors.keySet(); + ArrayList tList = new ArrayList(); + tList.addAll(tKeys); + if (tList.size() <= 0) return; + Collections.sort(tList); + if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0); + int tIndex = Collections.binarySearch(tList, mGate); + tIndex -= aShift ? 16 : 1; + while (tIndex < 0) tIndex += tList.size(); + mGate = tList.get(tIndex); + switchGate(); + } catch (Throwable e) { + GT_Log.err.print(e); + } + } + + @Override + public void onFacingChange() { + resetRedstone(); + } + + private void resetRedstone() { + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 0, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 1, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 2, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 3, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 4, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 5, (byte) 0); + } + + public void changeGateData(int aIndex, int aValue) { + mGateData[aIndex] += aValue; + validateGateData(); + } + + public void stackGateData(int aIndex, ItemStack aStack) { + mGateData[aIndex] = GT_Utility.stackToInt(aStack); + validateGateData(); + } + + private void switchGate() { + resetRedstone(); + for (int i = 0; i < mGateData.length; i++) mGateData[i] = 0; + GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); + if (tBehaviour != null) + try { + tBehaviour.initParameters(mGateData, this); + } catch (Throwable e) { + GT_Log.err.print(e); + } + validateGateData(); + } + + private void validateGateData() { + GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); + if (tBehaviour != null) + try { + tBehaviour.validateParameters(mGateData, this); + } catch (Throwable e) { + GT_Log.err.print(e); + } + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + getBaseMetaTileEntity().setGenericRedstoneOutput(true); + validateGateData(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + getBaseMetaTileEntity().setGenericRedstoneOutput(true); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + mInventory[0] = mInventory[1] = mInventory[2] = mInventory[3] = mInventory[4] = null; + if (getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { + if (getBaseMetaTileEntity().isActive()) { + GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); + if (tBehaviour != null) { + try { + tBehaviour.onTick(mGateData, this); + if (tBehaviour.displayItemStack(mGateData, this, 0)) + mInventory[1] = getCoverByID(mGateData[0]); + if (tBehaviour.displayItemStack(mGateData, this, 1)) + mInventory[2] = getCoverByID(mGateData[1]); + if (tBehaviour.displayItemStack(mGateData, this, 2)) + mInventory[3] = getCoverByID(mGateData[2]); + if (tBehaviour.displayItemStack(mGateData, this, 3)) + mInventory[4] = getCoverByID(mGateData[3]); + } catch (Throwable e) { + GT_Log.err.print(e); + } + } + } + getBaseMetaTileEntity().setErrorDisplayID(0); + } else { + getBaseMetaTileEntity().setErrorDisplayID(1); + } + } + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + // Only Calc server-side + if (!this.getBaseMetaTileEntity().isServerSide()) { + return; + } + // Emit Redstone + for (byte i = 0; i < 6; i++) { + byte aRedstone = getBaseMetaTileEntity().getOutputRedstoneSignal(i); + this.getBaseMetaTileEntity().setInternalOutputRedstoneSignal(i, aRedstone); + } + } + + @Override + public final boolean hasRedstoneSignal() { + for (byte i = 0; i < 6; i++) { + if (getBaseMetaTileEntity().getOutputRedstoneSignal(i) > 0) { + return true; + } + } + return false; + } + + @Override + public boolean allowGeneralRedstoneOutput() { + return true; + } + + /** The Item List for Covers */ + public static final Map sCoversItems = new HashMap(); + + private static void initCovers() { + for (GT_ItemStack aKey : GregTech_API.sCovers.keySet()) { + ItemStack aStack = aKey.toStack().copy(); + if (aStack != null) { + sCoversItems.put(GT_Utility.stackToInt(aStack), aStack); + } + } + } + + public static ItemStack getCoverByID(int aStack) { + if (sCoversItems.isEmpty()) { + initCovers(); + } + return sCoversItems.get(Integer.valueOf(aStack)); + } + + @Override + public byte getOutputFacing() { + return getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean setRedstone(byte aStrength, byte aSide) { + if (getOutputRedstone(aSide) != aStrength) { + if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(1, false)) { + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(aSide, aStrength); + getBaseMetaTileEntity().setErrorDisplayID(0); + return true; + } else { + getBaseMetaTileEntity().setErrorDisplayID(1); + return false; + } + } + return false; + } + + /* @Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == getOutputFacing()) { + if (aSide == 0) + return aRedstone ? 56 : 54; + if (aSide == 1) + return aRedstone ? 53 : 52; + return aRedstone ? 94 : 93; + } + if (aSide == 0) + return aRedstone ? 60 : 59; + if (aSide == 1) + return aRedstone ? 58 : 57; + return aRedstone ? 62 : 61; + }*/ + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public byte getOutputRedstone(byte aSide) { + return getBaseMetaTileEntity().getOutputRedstoneSignal(aSide); + } + + @Override + public byte getInputRedstone(byte aSide) { + return getBaseMetaTileEntity().getInternalInputRedstoneSignal(aSide); + } + + @Override + public Block getBlockAtSide(byte aSide) { + return getBaseMetaTileEntity().getBlockAtSide(aSide); + } + + @Override + public byte getMetaIDAtSide(byte aSide) { + return getBaseMetaTileEntity().getMetaIDAtSide(aSide); + } + + @Override + public TileEntity getTileEntityAtSide(byte aSide) { + return getBaseMetaTileEntity().getTileEntityAtSide(aSide); + } + + @Override + public int getRandom(int aRange) { + return getBaseMetaTileEntity().getRandomNumber(aRange); + } + + @Override + public GT_CoverBehavior getCover(byte aSide) { + return getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide); + } + + @Override + public int getCoverID(byte aSide) { + return getBaseMetaTileEntity().getCoverIDAtSide(aSide); + } + + @Override + public int getCoverVariable(byte aSide) { + return getBaseMetaTileEntity().getCoverDataAtSide(aSide); + } + + @Override + public ICoverable getOwnTileEntity() { + return getBaseMetaTileEntity(); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getSides(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getSidesActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive || hasRedstoneSignal() ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + private GT_RenderedTexture getBase() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off)}; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + getBase(), + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off), + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red) + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + getBase(), + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On), + new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off)}; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] {getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On)}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java index 81517c83b9..dfb844654b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java @@ -10,66 +10,67 @@ import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_RedstoneLamp extends GT_MetaTileEntity_RedstoneBase { - public byte mRedstoneStrength = 0, mType = 0; - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[2]; - - static { - sIconList[0] = new CustomIcon("TileEntities/gt4/redstone/Lamp/off"); - sIconList[1] = new CustomIcon("TileEntities/gt4/redstone/Lamp/on"); - } - - public GT_MetaTileEntity_RedstoneLamp(int aID) { - super(aID, "redstone.lamp", "Redstone Controlled Lamp", 0, 0, "Redstone Controlled Lamp"); - } + public byte mRedstoneStrength = 0, mType = 0; + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[2]; + + static { + sIconList[0] = new CustomIcon("TileEntities/gt4/redstone/Lamp/off"); + sIconList[1] = new CustomIcon("TileEntities/gt4/redstone/Lamp/on"); + } + + public GT_MetaTileEntity_RedstoneLamp(int aID) { + super(aID, "redstone.lamp", "Redstone Controlled Lamp", 0, 0, "Redstone Controlled Lamp"); + } + + public GT_MetaTileEntity_RedstoneLamp(final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, 0, 0, aDescription, aTextures); + } - public GT_MetaTileEntity_RedstoneLamp(final String aName, String aDescription, final ITexture[][][] aTextures) { - super(aName, 0, 0, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneLamp(this.mName, mDescription, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - - } - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { - getBaseMetaTileEntity().setLightValue(getBaseMetaTileEntity().getStrongestRedstone()); - getBaseMetaTileEntity().setActive(getBaseMetaTileEntity().getStrongestRedstone()>0); - } + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneLamp(this.mName, mDescription, this.mTextures); } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getSides(i); - rTextures[1][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 1 : 0)][aColorIndex + 1]; - } + @Override + public void saveNBTData(NBTTagCompound aNBT) {} + + @Override + public void loadNBTData(NBTTagCompound aNBT) {} - public ITexture[] getSides(final byte aColor) { - return new ITexture[] {new GT_RenderedTexture(sIconList[0])}; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] {new GT_RenderedTexture(sIconList[1])}; - } - + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + getBaseMetaTileEntity().setLightValue(getBaseMetaTileEntity().getStrongestRedstone()); + getBaseMetaTileEntity().setActive(getBaseMetaTileEntity().getStrongestRedstone() > 0); + } + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getSides(i); + rTextures[1][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[(aActive ? 1 : 0)][aColorIndex + 1]; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(sIconList[0])}; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(sIconList[1])}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java index 1f65385793..3b07f8b3ff 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java @@ -1,7 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; import gregtech.api.enums.Textures; -import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -14,131 +13,164 @@ import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_RedstoneStrengthDisplay extends GT_MetaTileEntity_RedstoneBase { - public byte mRedstoneStrength = 0, mType = 0; - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[144]; - - static { - for (int i=0;i<144;i++) { - sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Display/"+i); - } - } - - public GT_MetaTileEntity_RedstoneStrengthDisplay(int aID, String aUnlocal, String aLocal, String aDescription) { - super(aID, aUnlocal, aLocal, 5, 0, aDescription); - } - - public GT_MetaTileEntity_RedstoneStrengthDisplay(final String aName, String aDescription, final ITexture[][][] aTextures) { - super(aName, 5, 0, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneStrengthDisplay(this.mName, mDescription, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mRedstoneStrength", mRedstoneStrength); - aNBT.setByte("mType", mType); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); - mType = aNBT.getByte("mType"); - } - - @Override - public void onValueUpdate(byte aValue) { - mRedstoneStrength = (byte) (aValue & 15); - mType = (byte) (aValue >>> 4); - } - - @Override - public byte getUpdateData() { - return (byte) ((mRedstoneStrength & 15) | (mType << 4)); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { - mRedstoneStrength = getBaseMetaTileEntity().getStrongestRedstone(); - } - } - - /*@Override - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { - if (aSide == 0) - return aRedstone ? 60 : 59; - if (aSide == 1) - return aRedstone ? 58 : 57; - return aRedstone ? 62 : 61; - }*/ - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) - mType = (byte) ((mType + 1) % 6); - } - - /*@Override - public IIcon getTextureIcon(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { - return aSide == aFacing ? sIconList[mType * 16 + mRedstoneStrength] : null; - }*/ - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getSides(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getSidesActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength])}; - } - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off)}; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off)}; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off)}; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On)}; - } - + public byte mRedstoneStrength = 0, mType = 0; + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[144]; + + static { + for (int i = 0; i < 144; i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Display/" + i); + } + } + + public GT_MetaTileEntity_RedstoneStrengthDisplay(int aID, String aUnlocal, String aLocal, String aDescription) { + super(aID, aUnlocal, aLocal, 5, 0, aDescription); + } + + public GT_MetaTileEntity_RedstoneStrengthDisplay( + final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneStrengthDisplay(this.mName, mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mRedstoneStrength", mRedstoneStrength); + aNBT.setByte("mType", mType); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); + mType = aNBT.getByte("mType"); + } + + @Override + public void onValueUpdate(byte aValue) { + mRedstoneStrength = (byte) (aValue & 15); + mType = (byte) (aValue >>> 4); + } + + @Override + public byte getUpdateData() { + return (byte) ((mRedstoneStrength & 15) | (mType << 4)); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + mRedstoneStrength = getBaseMetaTileEntity().getStrongestRedstone(); + } + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == 0) + return aRedstone ? 60 : 59; + if (aSide == 1) + return aRedstone ? 58 : 57; + return aRedstone ? 62 : 61; + }*/ + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 6); + } + + /*@Override + public IIcon getTextureIcon(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? sIconList[mType * 16 + mRedstoneStrength] : null; + }*/ + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getSidesActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) + }; + } + return this.mTextures[ + (aActive || hasRedstoneSignal() ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java index efa3763370..8945f3f7b5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java @@ -12,39 +12,54 @@ import net.minecraft.entity.player.EntityPlayer; public class GT_MetaTileEntity_RedstoneStrengthScale extends GT_MetaTileEntity_RedstoneStrengthDisplay { - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[32]; - - static { - for (int i=0;i<32;i++) { - sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Scale/"+i); - } - } - - public GT_MetaTileEntity_RedstoneStrengthScale(int aID) { - super(aID, "redstone.display.scale", "Redstone Scale", "Redstone Strength on a Scale"); - } - - public GT_MetaTileEntity_RedstoneStrengthScale(final String aName, String aDescription, final ITexture[][][] aTextures) { - super(aName, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneStrengthScale(this.mName, mDescription, this.mTextures); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) - mType = (byte) ((mType + 1) % 2); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength])}; - } - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[32]; + static { + for (int i = 0; i < 32; i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Scale/" + i); + } + } + + public GT_MetaTileEntity_RedstoneStrengthScale(int aID) { + super(aID, "redstone.display.scale", "Redstone Scale", "Redstone Strength on a Scale"); + } + + public GT_MetaTileEntity_RedstoneStrengthScale( + final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneStrengthScale(this.mName, mDescription, this.mTextures); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 2); + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) + }; + } + return this.mTextures[ + (aActive || hasRedstoneSignal() ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java index 0b815bfae7..bb9865c8e5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_AdvancedCraftingTable.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage; -import java.util.ArrayList; - import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -17,6 +15,7 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.workbench.GT_Container_AdvancedWorkbench; import gtPlusPlus.xmod.gregtech.api.gui.workbench.GT_GUIContainer_AdvancedWorkbench; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -25,527 +24,547 @@ import net.minecraft.nbt.NBTTagList; public class GT_MetaTileEntity_AdvancedCraftingTable extends GT_MetaTileEntity_BasicTank { - public boolean mFlushMode = false; - - protected String mLocalName; - - public GT_MetaTileEntity_AdvancedCraftingTable(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription) { - super(aID, aName, aNameRegional, aTier, 35, aDescription); - mLocalName = aNameRegional; - } - - public GT_MetaTileEntity_AdvancedCraftingTable(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 35, aDescription, aTextures); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity, mLocalName); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - @Override - public boolean isSimpleMachine() { - return true; - } - @Override - public boolean isValidSlot(int aIndex) { - return aIndex < 31 || aIndex > 32; - } - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - @Override - public boolean isEnetInput() { - return isElectric(); - } - @Override - public boolean isInputFacing(byte aSide) { - return true; - } - @Override - public long maxEUInput() { - return isElectric() ? GT_Values.V[3] : 0; - } - @Override - public long maxEUStore() { - return isElectric() ? GT_Values.V[3] * 1024 : 0; - } - - @Override - public boolean isElectric() { - return isAdvanced(); - } - - @Override - public boolean isPneumatic() { - return false; - } - - @Override - public boolean isSteampowered() { - return false; - } - - @Override - public long maxAmperesIn() { - return isElectric() ? 2 : 0; - } - - @Override - public long getMinimumStoredEU() { - return isElectric() ? GT_Values.V[3] * 2 : 0; - } - - @Override - public int getSizeInventory() { - return 35; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_AdvancedCraftingTable(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public boolean doesFillContainers() { - return false; - } - @Override - public boolean doesEmptyContainers() { - return false; - } - @Override - public boolean canTankBeFilled() { - return true; - } - @Override - public boolean canTankBeEmptied() { - return true; - } - @Override - public boolean displaysItemStack() { - return false; - } - @Override - public boolean displaysStackSize() { - return false; - } - - public void sortIntoTheInputSlots() { - for (byte i = 21; i < 30; i++) - if (mInventory[i] != null) { - if (mInventory[i].stackSize == 0) { - mInventory[i] = null; - } - if (mInventory[i] != null) - for (byte j = 0; j < 16; j++) { - if (GT_Utility.areStacksEqual( - mInventory[i], mInventory[j] - )) { - GT_Utility.moveStackFromSlotAToSlotB( - getBaseMetaTileEntity(), getBaseMetaTileEntity(), i, j, (byte) 64, (byte) 1, (byte) 64, (byte) 1 - ); - } - } - if (mInventory[i] != null) - for (byte j = 0; j < 16; j++) { - if (mInventory[j] == null) { - GT_Utility.moveStackFromSlotAToSlotB( - getBaseMetaTileEntity(), getBaseMetaTileEntity(), i, j, (byte) 64, (byte) 1, (byte) 64, (byte) 1 - ); - } - } - } - } - - private void fillLiquidContainers() { - for (byte i = 16; i < 21 && mFluid != null; i++) { - ItemStack tOutput = GT_Utility.fillFluidContainer(mFluid, mInventory[i], false, true); - if (tOutput != null) { - if (mInventory[i].stackSize == 1) { - mFluid.amount -= GT_Utility.getFluidForFilledItem( - tOutput, true - ).amount * tOutput.stackSize; - mInventory[i] = tOutput; - } - else - for (byte j = 16; j < 21; j++) { - if (mInventory[j] == null || (GT_Utility.areStacksEqual( - tOutput, mInventory[j] - ) && mInventory[j].stackSize - + tOutput.stackSize <= tOutput.getMaxStackSize())) { - mFluid.amount -= GT_Utility.getFluidForFilledItem( - tOutput, true - ).amount * tOutput.stackSize; - getBaseMetaTileEntity().decrStackSize(i, 1); - if (mInventory[j] == null) { - mInventory[j] = tOutput; - } - else { - mInventory[j].stackSize++; - } - break; - } - } - if (mFluid != null && mFluid.amount <= 0) - mFluid = null; - } - } - if (mFluid != null && mFluid.amount <= 0) - mFluid = null; - } - - public void setBluePrint(ItemStack aStack) { - if (aStack == null) { - aStack = mInventory[30]; - Logger.INFO("Using Slot 30 supply."); - } - if (mInventory[31] == null || aStack == null || aStack.getItem() == null - || aStack.getItemDamage() != 0 || aStack.stackSize != 1 - || !(aStack.getItem() instanceof ItemBlueprint)) { - try { - Logger.INFO( - "Could not set Blueprint. Slot 31: " - + (mInventory[31] != null ? mInventory[31].getDisplayName() : "Null") - + ", aStack: "+(aStack != null ? aStack.getDisplayName() : "Null") - + ", Damage: "+(aStack != null ? aStack.getItemDamage() : "Null")); - } - catch (Throwable t) { - t.printStackTrace(); - } - return; - } - if (!aStack.getTagCompound().hasKey("Inventory")) { - NBTTagCompound tNBT = new NBTTagCompound(); - NBTTagList tNBT_ItemList = new NBTTagList(); - for (int i = 0; i < 9; i++) { - ItemStack tStack = mInventory[i + 21]; - if (tStack != null) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) i); - tStack.writeToNBT(tag); - tNBT_ItemList.appendTag(tag); - } - } - tNBT.setTag("Inventory", tNBT_ItemList); - tNBT.setBoolean("mBlueprint", true); - tNBT.setInteger("mID", MathUtils.randInt(1, Short.MAX_VALUE)); - tNBT.setString("mName", mInventory[31].getDisplayName()); - aStack.setTagCompound(tNBT); - Logger.INFO("Set NBT of crafting table to Stack in slot 30."); - } - else { - Logger.INFO("Blueprint already has recipe tags."); - } - - } - - public ItemStack getCraftingOutput() { - if (mInventory[30] != null && mInventory[30].getItem() != null - && mInventory[30].getItemDamage() == 0 - && mInventory[30].hasTagCompound() && mInventory[30].getItem() instanceof ItemBlueprint) { - //Logger.INFO("Getting Blueprint Data in slot 30. "+mInventory[30].getDisplayName()); - NBTTagCompound tNBT = mInventory[30].getTagCompound(); - NBTTagList tNBT_ItemList = tNBT.getTagList("Blueprint", 10); - for (int i = 0; i < tNBT_ItemList.tagCount() && i < 9; i++) { - NBTTagCompound tag = (NBTTagCompound) tNBT_ItemList.getCompoundTagAt( - i - ); - byte slot = tag.getByte("Slot"); - if (slot >= 0 && slot < 9 && mInventory[slot + 21] == null) { - mInventory[slot + 21] = GT_Utility.loadItem(tag); - if (mInventory[slot + 21] != null) - mInventory[slot + 21].stackSize = 0; - } - } - } - mInventory[31] = GT_ModHandler.getAllRecipeOutput( - getBaseMetaTileEntity().getWorld(), new ItemStack[]{ - mInventory[21], mInventory[22], mInventory[23], - mInventory[24], mInventory[25], mInventory[26], - mInventory[27], mInventory[28], mInventory[29] - } - ); - return mInventory[31]; - } - - public boolean canDoCraftingOutput() { - if (mInventory[31] == null) - return false; - for (ItemStack tStack : recipeContent()) { - if (tStack.stackSize > getAmountOf(tStack)) { - return false; - } - } - return true; - } - - private int getAmountOf(ItemStack aStack) { - int tAmount = 0; - for (byte i = 0; i < 30 && tAmount < 9; i++) { - if (GT_Utility.areStacksOrToolsEqual(aStack, mInventory[i])) { - tAmount += mInventory[i].stackSize; - } - } - return tAmount; - } - - private ArrayList recipeContent() { - ArrayList tList = new ArrayList(); - for (byte i = 21; i < 30; i++) { - if (mInventory[i] != null) { - boolean temp = false; - for (byte j = 0; j < tList.size(); j++) { - if (GT_Utility.areStacksOrToolsEqual( - mInventory[i], tList.get(j) - )) { - tList.get(j).stackSize++; - temp = true; - break; - } - } - if (!temp) - tList.add(GT_Utility.copy(1, mInventory[i])); - } - } - return tList; - } - - public ItemStack consumeMaterials(EntityPlayer aPlayer, ItemStack aHoldStack) { - if (mInventory[31] == null) - return aHoldStack; - if (aHoldStack != null) { - if (!GT_Utility.areStacksEqual(aHoldStack, mInventory[31])) - return aHoldStack; - if (aHoldStack.stackSize - + mInventory[31].stackSize > aHoldStack.getMaxStackSize()) - return aHoldStack; - } - for (byte i = 21; i < 30; i++) - if (mInventory[i] != null) { - for (byte j = 0; j <= i; j++) { - if (j < 21 || j == i) { - if (GT_Utility.areStacksOrToolsEqual( - mInventory[i], mInventory[j] - ) && mInventory[j].stackSize > 0) { - ItemStack tStack = GT_Utility.getContainerItem( - mInventory[j], true - ); - if (tStack == null - || (tStack.isItemStackDamageable() - && tStack.getItemDamage() >= tStack.getMaxDamage())) { - getBaseMetaTileEntity().decrStackSize(j, 1); - } - else if (mInventory[j].stackSize == 1) { - mInventory[j] = tStack; - } - else { - getBaseMetaTileEntity().decrStackSize(j, 1); - for (byte k = 0; k < 21; k++) { - if (mInventory[k] == null) { - mInventory[k] = tStack; - break; - } - else { - if (GT_Utility.areStacksEqual( - tStack, mInventory[k] - )) { - if (tStack.stackSize - + mInventory[k].stackSize <= mInventory[k].getMaxStackSize()) { - mInventory[k].stackSize += tStack.stackSize; - break; - } - } - } - } - } - break; - } - } - } - } - if (aHoldStack == null) { - aHoldStack = GT_Utility.copy(mInventory[31]); - aHoldStack.onCrafting( - getBaseMetaTileEntity().getWorld(), aPlayer, mInventory[31].stackSize - ); - } - else { - aHoldStack.stackSize += mInventory[31].stackSize; - aHoldStack.onCrafting( - getBaseMetaTileEntity().getWorld(), aPlayer, mInventory[31].stackSize - ); - } - - fillLiquidContainers(); - - return aHoldStack; - } - - @Override - public int rechargerSlotStartIndex() { - return 16; - } - - @Override - public int rechargerSlotCount() { - return 5; - } - - @Override - public long getOutputTier() { - return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); - } - - @Override - public int getCapacity() { - return 64000; - } - - @Override - public int getTankPressure() { - return -100; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 33 || (mFlushMode && aIndex >= 21 && aIndex < 30); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aIndex < 16) { - for (byte i = 0; i < 16; i++) - if (GT_Utility.areStacksOrToolsEqual(aStack, mInventory[i])) - return aIndex == i; - return true; - } - return false; - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - getCraftingOutput(); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (getBaseMetaTileEntity().isServerSide()) { - if (getBaseMetaTileEntity().hasInventoryBeenModified()) - getCraftingOutput(); - fillLiquidContainers(); - if (mFlushMode) { - mFlushMode = false; - for (byte i = 21; i < 30; i++) { - if (mInventory[i] != null) { - if (mInventory[i].stackSize == 0) { - mInventory[i] = null; - } - else { - mFlushMode = true; - break; - } - } - } - } - } - /*if (aTick % 100 == 0) { - for (int i = 0; i < this.mInventory.length; i++) { - ItemStack aSlot = mInventory[i]; - Logger.INFO("Slot "+i+" "+(aSlot != null ? "contains "+aSlot.getDisplayName() : "is empty")); - } - }*/ - } - - @Override - public String[] getDescription() { - return new String[] { - isAdvanced() ? "For the very large Projects" : "For the smaller Projects", - "Hold Shift in GUI to see slot usage", - this.mDescription, - CORE.GT_Tooltip }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getBack(i); - rTextures[7][i + 1] = this.getBottom(i); - rTextures[8][i + 1] = this.getTop(i); - rTextures[9][i + 1] = this.getSides(i); - } - return rTextures; - } - - protected boolean isAdvanced() { - return true; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex - + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { isAdvanced() ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Side) : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Side)}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { isAdvanced() ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Side) : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Side)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { isAdvanced() ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Bottom) : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Bottom)}; - } - - public ITexture[] getTop(final byte aColor) { - if (isAdvanced()) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Top), - new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; - } - else { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Top), - new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Crafting_Overlay) }; - } - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { isAdvanced() ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Side) : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Side)}; - } - + public boolean mFlushMode = false; + + protected String mLocalName; + + public GT_MetaTileEntity_AdvancedCraftingTable( + final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription) { + super(aID, aName, aNameRegional, aTier, 35, aDescription); + mLocalName = aNameRegional; + } + + public GT_MetaTileEntity_AdvancedCraftingTable( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 35, aDescription, aTextures); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_AdvancedWorkbench(aPlayerInventory, aBaseMetaTileEntity, mLocalName); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 31 || aIndex > 32; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return isElectric(); + } + + @Override + public boolean isInputFacing(byte aSide) { + return true; + } + + @Override + public long maxEUInput() { + return isElectric() ? GT_Values.V[3] : 0; + } + + @Override + public long maxEUStore() { + return isElectric() ? GT_Values.V[3] * 1024 : 0; + } + + @Override + public boolean isElectric() { + return isAdvanced(); + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isSteampowered() { + return false; + } + + @Override + public long maxAmperesIn() { + return isElectric() ? 2 : 0; + } + + @Override + public long getMinimumStoredEU() { + return isElectric() ? GT_Values.V[3] * 2 : 0; + } + + @Override + public int getSizeInventory() { + return 35; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_AdvancedCraftingTable(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + public void sortIntoTheInputSlots() { + for (byte i = 21; i < 30; i++) + if (mInventory[i] != null) { + if (mInventory[i].stackSize == 0) { + mInventory[i] = null; + } + if (mInventory[i] != null) + for (byte j = 0; j < 16; j++) { + if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j])) { + GT_Utility.moveStackFromSlotAToSlotB( + getBaseMetaTileEntity(), + getBaseMetaTileEntity(), + i, + j, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } + } + if (mInventory[i] != null) + for (byte j = 0; j < 16; j++) { + if (mInventory[j] == null) { + GT_Utility.moveStackFromSlotAToSlotB( + getBaseMetaTileEntity(), + getBaseMetaTileEntity(), + i, + j, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } + } + } + } + + private void fillLiquidContainers() { + for (byte i = 16; i < 21 && mFluid != null; i++) { + ItemStack tOutput = GT_Utility.fillFluidContainer(mFluid, mInventory[i], false, true); + if (tOutput != null) { + if (mInventory[i].stackSize == 1) { + mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; + mInventory[i] = tOutput; + } else + for (byte j = 16; j < 21; j++) { + if (mInventory[j] == null + || (GT_Utility.areStacksEqual(tOutput, mInventory[j]) + && mInventory[j].stackSize + tOutput.stackSize <= tOutput.getMaxStackSize())) { + mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount * tOutput.stackSize; + getBaseMetaTileEntity().decrStackSize(i, 1); + if (mInventory[j] == null) { + mInventory[j] = tOutput; + } else { + mInventory[j].stackSize++; + } + break; + } + } + if (mFluid != null && mFluid.amount <= 0) mFluid = null; + } + } + if (mFluid != null && mFluid.amount <= 0) mFluid = null; + } + + public void setBluePrint(ItemStack aStack) { + if (aStack == null) { + aStack = mInventory[30]; + Logger.INFO("Using Slot 30 supply."); + } + if (mInventory[31] == null + || aStack == null + || aStack.getItem() == null + || aStack.getItemDamage() != 0 + || aStack.stackSize != 1 + || !(aStack.getItem() instanceof ItemBlueprint)) { + try { + Logger.INFO("Could not set Blueprint. Slot 31: " + + (mInventory[31] != null ? mInventory[31].getDisplayName() : "Null") + + ", aStack: " + (aStack != null ? aStack.getDisplayName() : "Null") + + ", Damage: " + (aStack != null ? aStack.getItemDamage() : "Null")); + } catch (Throwable t) { + t.printStackTrace(); + } + return; + } + if (!aStack.getTagCompound().hasKey("Inventory")) { + NBTTagCompound tNBT = new NBTTagCompound(); + NBTTagList tNBT_ItemList = new NBTTagList(); + for (int i = 0; i < 9; i++) { + ItemStack tStack = mInventory[i + 21]; + if (tStack != null) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("Slot", (byte) i); + tStack.writeToNBT(tag); + tNBT_ItemList.appendTag(tag); + } + } + tNBT.setTag("Inventory", tNBT_ItemList); + tNBT.setBoolean("mBlueprint", true); + tNBT.setInteger("mID", MathUtils.randInt(1, Short.MAX_VALUE)); + tNBT.setString("mName", mInventory[31].getDisplayName()); + aStack.setTagCompound(tNBT); + Logger.INFO("Set NBT of crafting table to Stack in slot 30."); + } else { + Logger.INFO("Blueprint already has recipe tags."); + } + } + + public ItemStack getCraftingOutput() { + if (mInventory[30] != null + && mInventory[30].getItem() != null + && mInventory[30].getItemDamage() == 0 + && mInventory[30].hasTagCompound() + && mInventory[30].getItem() instanceof ItemBlueprint) { + // Logger.INFO("Getting Blueprint Data in slot 30. "+mInventory[30].getDisplayName()); + NBTTagCompound tNBT = mInventory[30].getTagCompound(); + NBTTagList tNBT_ItemList = tNBT.getTagList("Blueprint", 10); + for (int i = 0; i < tNBT_ItemList.tagCount() && i < 9; i++) { + NBTTagCompound tag = (NBTTagCompound) tNBT_ItemList.getCompoundTagAt(i); + byte slot = tag.getByte("Slot"); + if (slot >= 0 && slot < 9 && mInventory[slot + 21] == null) { + mInventory[slot + 21] = GT_Utility.loadItem(tag); + if (mInventory[slot + 21] != null) mInventory[slot + 21].stackSize = 0; + } + } + } + mInventory[31] = + GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), new ItemStack[] { + mInventory[21], mInventory[22], mInventory[23], + mInventory[24], mInventory[25], mInventory[26], + mInventory[27], mInventory[28], mInventory[29] + }); + return mInventory[31]; + } + + public boolean canDoCraftingOutput() { + if (mInventory[31] == null) return false; + for (ItemStack tStack : recipeContent()) { + if (tStack.stackSize > getAmountOf(tStack)) { + return false; + } + } + return true; + } + + private int getAmountOf(ItemStack aStack) { + int tAmount = 0; + for (byte i = 0; i < 30 && tAmount < 9; i++) { + if (GT_Utility.areStacksOrToolsEqual(aStack, mInventory[i])) { + tAmount += mInventory[i].stackSize; + } + } + return tAmount; + } + + private ArrayList recipeContent() { + ArrayList tList = new ArrayList(); + for (byte i = 21; i < 30; i++) { + if (mInventory[i] != null) { + boolean temp = false; + for (byte j = 0; j < tList.size(); j++) { + if (GT_Utility.areStacksOrToolsEqual(mInventory[i], tList.get(j))) { + tList.get(j).stackSize++; + temp = true; + break; + } + } + if (!temp) tList.add(GT_Utility.copy(1, mInventory[i])); + } + } + return tList; + } + + public ItemStack consumeMaterials(EntityPlayer aPlayer, ItemStack aHoldStack) { + if (mInventory[31] == null) return aHoldStack; + if (aHoldStack != null) { + if (!GT_Utility.areStacksEqual(aHoldStack, mInventory[31])) return aHoldStack; + if (aHoldStack.stackSize + mInventory[31].stackSize > aHoldStack.getMaxStackSize()) return aHoldStack; + } + for (byte i = 21; i < 30; i++) + if (mInventory[i] != null) { + for (byte j = 0; j <= i; j++) { + if (j < 21 || j == i) { + if (GT_Utility.areStacksOrToolsEqual(mInventory[i], mInventory[j]) + && mInventory[j].stackSize > 0) { + ItemStack tStack = GT_Utility.getContainerItem(mInventory[j], true); + if (tStack == null + || (tStack.isItemStackDamageable() + && tStack.getItemDamage() >= tStack.getMaxDamage())) { + getBaseMetaTileEntity().decrStackSize(j, 1); + } else if (mInventory[j].stackSize == 1) { + mInventory[j] = tStack; + } else { + getBaseMetaTileEntity().decrStackSize(j, 1); + for (byte k = 0; k < 21; k++) { + if (mInventory[k] == null) { + mInventory[k] = tStack; + break; + } else { + if (GT_Utility.areStacksEqual(tStack, mInventory[k])) { + if (tStack.stackSize + mInventory[k].stackSize + <= mInventory[k].getMaxStackSize()) { + mInventory[k].stackSize += tStack.stackSize; + break; + } + } + } + } + } + break; + } + } + } + } + if (aHoldStack == null) { + aHoldStack = GT_Utility.copy(mInventory[31]); + aHoldStack.onCrafting(getBaseMetaTileEntity().getWorld(), aPlayer, mInventory[31].stackSize); + } else { + aHoldStack.stackSize += mInventory[31].stackSize; + aHoldStack.onCrafting(getBaseMetaTileEntity().getWorld(), aPlayer, mInventory[31].stackSize); + } + + fillLiquidContainers(); + + return aHoldStack; + } + + @Override + public int rechargerSlotStartIndex() { + return 16; + } + + @Override + public int rechargerSlotCount() { + return 5; + } + + @Override + public long getOutputTier() { + return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); + } + + @Override + public int getCapacity() { + return 64000; + } + + @Override + public int getTankPressure() { + return -100; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 33 || (mFlushMode && aIndex >= 21 && aIndex < 30); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aIndex < 16) { + for (byte i = 0; i < 16; i++) + if (GT_Utility.areStacksOrToolsEqual(aStack, mInventory[i])) return aIndex == i; + return true; + } + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + getCraftingOutput(); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isServerSide()) { + if (getBaseMetaTileEntity().hasInventoryBeenModified()) getCraftingOutput(); + fillLiquidContainers(); + if (mFlushMode) { + mFlushMode = false; + for (byte i = 21; i < 30; i++) { + if (mInventory[i] != null) { + if (mInventory[i].stackSize == 0) { + mInventory[i] = null; + } else { + mFlushMode = true; + break; + } + } + } + } + } + /*if (aTick % 100 == 0) { + for (int i = 0; i < this.mInventory.length; i++) { + ItemStack aSlot = mInventory[i]; + Logger.INFO("Slot "+i+" "+(aSlot != null ? "contains "+aSlot.getDisplayName() : "is empty")); + } + }*/ + } + + @Override + public String[] getDescription() { + return new String[] { + isAdvanced() ? "For the very large Projects" : "For the smaller Projects", + "Hold Shift in GUI to see slot usage", + this.mDescription, + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getBack(i); + rTextures[7][i + 1] = this.getBottom(i); + rTextures[8][i + 1] = this.getTop(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + protected boolean isAdvanced() { + return true; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + isAdvanced() + ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Side) + : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Side) + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + isAdvanced() + ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Side) + : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Side) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + isAdvanced() + ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Bottom) + : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Bottom) + }; + } + + public ITexture[] getTop(final byte aColor) { + if (isAdvanced()) { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Top), + new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) + }; + } else { + return new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Top), + new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Crafting_Overlay) + }; + } + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + isAdvanced() + ? new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Side) + : new GT_RenderedTexture(TexturesGtBlock.Casing_Workbench_Side) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java index f421d391c0..9e21e51f07 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_BronzeCraftingTable.java @@ -5,79 +5,82 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_ItemStack; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.workbench.GT_Container_BronzeWorkbench; import gtPlusPlus.xmod.gregtech.api.gui.workbench.GT_GUIContainer_BronzeWorkbench; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; public class GT_MetaTileEntity_BronzeCraftingTable extends GT_MetaTileEntity_AdvancedCraftingTable { - - public GT_MetaTileEntity_BronzeCraftingTable(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription) { - super(aID, aName, aNameRegional, aTier, aDescription); - } - public GT_MetaTileEntity_BronzeCraftingTable(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity); - } + public GT_MetaTileEntity_BronzeCraftingTable( + final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription) { + super(aID, aName, aNameRegional, aTier, aDescription); + } + + public GT_MetaTileEntity_BronzeCraftingTable( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity, mLocalName); - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public boolean isInputFacing(byte aSide) { - return false; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BronzeCraftingTable(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @SuppressWarnings("deprecation") - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return GregTech_API.getCoverBehavior(aStack.toStack()).isSimpleCover(); - } + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BronzeWorkbench(aPlayerInventory, aBaseMetaTileEntity, mLocalName); + } - @Override + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_BronzeCraftingTable(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @SuppressWarnings("deprecation") + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return GregTech_API.getCoverBehavior(aStack.toStack()).isSimpleCover(); + } + + @Override public int rechargerSlotStartIndex() { - return 0; + return 0; } - - @Override + + @Override public int rechargerSlotCount() { - return 0; + return 0; + } + + @Override + public int getCapacity() { + return 16000; + } + + @Override + protected boolean isAdvanced() { + return false; } - - @Override - public int getCapacity() { - return 16000; - } - - @Override - protected boolean isAdvanced() { - return false; - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java index a3c11d486b..1c0e682b62 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java @@ -1,12 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage; -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.tileentity.TileEntity; - import gregtech.api.GregTech_API; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; @@ -16,7 +9,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; @@ -24,551 +16,554 @@ import gtPlusPlus.core.util.data.ArrayUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SuperChest; import gtPlusPlus.xmod.gregtech.api.gui.GUI_SuperChest; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +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.tileentity.TileEntity; public class GT_MetaTileEntity_ConnectableCrate extends GT_MetaTileEntity_TieredMachineBlock { - /*sides.put(getUp()); - sides.put(getDown()); - sides.put(getXPos()); - sides.put(getXNeg()); - sides.put(getZPos()); - sides.put(getZNeg());*/ - - public int mItemCount = 0; - public ItemStack mItemStack = null; - private final static double mStorageFactor = 2; - - //Meta Tile ID - public final static int mCrateID = 955; - - //Sides - public final static int SIDE_Up = 0; - public final static int SIDE_Down = 1; - public final static int SIDE_XPos = 2; - public final static int SIDE_XNeg = 3; - public final static int SIDE_ZPos = 4; - public final static int SIDE_ZNeg = 5; - public final static int[] SIDES = new int[] {SIDE_Up, SIDE_Down, SIDE_XPos, SIDE_XNeg, SIDE_ZPos, SIDE_ZNeg}; - - //Neighbour Cache - private GT_MetaTileEntity_ConnectableCrate[] mNeighbourCache = new GT_MetaTileEntity_ConnectableCrate[6]; - //Cached Crate Location - private BlockPos mCurrentPos = null; - //Master Crate Position - protected BlockPos mMasterCrateLocation = null; - //Is Master? - protected boolean mIsMaster = false; - //Is Connected? - protected boolean mIsConnected[] = new boolean[] {false, false, false, false, false, false}; - //How many are connected? - protected int mConnectedCount = 0; - //Map of connected locations - protected AutoMap mConnectedCache = new AutoMap(); - - - public GT_MetaTileEntity_ConnectableCrate(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, - "This Crate stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", new ITexture[0]); - } - - public GT_MetaTileEntity_ConnectableCrate(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip}; - } - - public boolean isSimpleMachine() { - return true; - } - - public boolean isFacingValid(byte aFacing) { - return true; - } - - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - public boolean isValidSlot(int aIndex) { - return true; - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_ConnectableCrate(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public int getOppositeSide(int side) { - if (side == SIDE_Up) { - return SIDE_Down; - } - else if (side == SIDE_Down) { - return SIDE_Up; - } - else if (side == SIDE_XNeg) { - return SIDE_XPos; - } - else if (side == SIDE_XPos) { - return SIDE_XNeg; - } - else if (side == SIDE_ZNeg) { - return SIDE_ZPos; - } - else { - return SIDE_ZNeg; - } - } - - public boolean calculateOwnershipIfConnected() { - if (mCurrentPos == null) { - mCurrentPos = new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld()); - } - AutoMap n = mCurrentPos.getSurroundingBlocks(); - int p = 0; - for (BlockPos i : n) { - if (i != null) { - if (doesSideContainCrate(p)) { - GT_MetaTileEntity_ConnectableCrate yu = getCrateAtBlockPos(i); - if (yu != null) { - mNeighbourCache[p] = yu; - } - } - } - p++; - } - - int e4 = 0; - if (mNeighbourCache.length > 0) { - for (GT_MetaTileEntity_ConnectableCrate e : mNeighbourCache) { - this.mConnectedCount = this.mConnectedCache.size(); - if (e != null) { - //First, we check if this Crate is a Master, if not, continue checking what it is. - if (this.mIsMaster) { - //So this other Crate is also a master? Which is more Powerful - if (e.mIsMaster) { - //This crate holds more connected, it becomes master now. - if (this.mConnectedCount > e.mConnectedCount) { - e.mIsMaster = false; - e.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - this.mConnectedCache = ArrayUtils.mergeTwoMaps(this.mConnectedCache, e.mConnectedCache); - continue; - } - //Other crate held more connected, it is now master. - else { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mCurrentPos; - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - e.mConnectedCache = ArrayUtils.mergeTwoMaps(e.mConnectedCache, this.mConnectedCache); - //Best wipe our cache of connected blocks then, since they no longer hold value. - mConnectedCache.clear(); - continue; - } - } - //Other Crate was not a Master, but we are, time to inherit it into our connection hivemind. - else { - //It would appear this controller has another master, time to query it. - if (e.mMasterCrateLocation != null && !e.mMasterCrateLocation.getUniqueIdentifier().equalsIgnoreCase(this.mMasterCrateLocation.getUniqueIdentifier())) { - GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); - if (gM != null) { - //Lets compare controller strengths - int gM_Owned = gM.mConnectedCount; - //We are stronger, let's inherit it. - if (this.mConnectedCount > gM_Owned) { - e.mIsMaster = false; - e.mMasterCrateLocation = this.mCurrentPos; - gM.mIsMaster = false; - gM.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - this.mConnectedCache = ArrayUtils.mergeTwoMaps(this.mConnectedCache, gM.mConnectedCache); - continue; - } - //We lost, time to submit to a new master crate - else { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mMasterCrateLocation; - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - gM.mConnectedCache = ArrayUtils.mergeTwoMaps(gM.mConnectedCache, this.mConnectedCache); - //Best wipe our cache of connected blocks then, since they no longer hold value. - mConnectedCache.clear(); - continue; - } - } - else { - //Could not get the Tile Entity for the Other Master Crate.. Guess I can just ignore this case for now~ TODO - continue; - } - } - //Either the other crate has no known Master or it is already this crate. - else { - //The other crate has no master, time to inherit. - if (e.mMasterCrateLocation == null || (!e.mIsConnected[getOppositeSide(e4)])) { - e.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); - continue; - } - else { - //Do nothing, we own this Crate already :) - continue; - } - - - } - } - } - - //We are not a Storage Master Crate, into a brave new world we go - else { - //Best wipe our cache of connected blocks then, since they no longer hold value. - mConnectedCache.clear(); - - //Dang, the other crate is a master, time to get incorporated. - if (e.mIsMaster) { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mCurrentPos; - this.mIsConnected[e4] = true; - if (!e.mIsConnected[e4]) { - e.mIsConnected[e4] = true; - } - if (e.mMasterCrateLocation == null) { - e.mMasterCrateLocation = e.mCurrentPos; - } - e.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); - continue; - } - //So the Crate we Checked is not a Master, so let's see if it knows where one is - else { - //So, this Crate we have found knows about a master - if (e.mMasterCrateLocation != null) { - GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); - //Found the master crate - if (gM != null) { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mMasterCrateLocation; - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - gM.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); - continue; - } - else { - //Could not get the Tile Entity for the Other Master Crate.. Guess I can just ignore this case for now~ TODO - continue; - } - } - //This crate has no master, not going to check if it's connected. - else { - this.mIsMaster = true; - this.mMasterCrateLocation = this.mCurrentPos; - e.mIsMaster = false; - e.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); - continue; - } - } - } - } - e4++; - } - return true; - } - else { - return false; - } - - - - - } - - public boolean doesSideContainCrate(int side) { - return checkSideForDataType(0, side); - } - - public boolean isCrateAtSideController(int side) { - return checkSideForDataType(1, side); - } - - private boolean checkSideForDataType(int aType, int aSide) { - BlockPos mPosToCheck = - aSide == SIDE_Up ? mCurrentPos.getUp() : - aSide == SIDE_Down ? mCurrentPos.getDown() : - aSide == SIDE_XPos ? mCurrentPos.getXPos() : - aSide == SIDE_XNeg ? mCurrentPos.getXNeg() : - aSide == SIDE_ZPos ? mCurrentPos.getZPos() : - mCurrentPos.getZNeg(); - GT_MetaTileEntity_ConnectableCrate g = getCrateAtBlockPos(mPosToCheck); - if (g != null) { - if (aType == 0) { - return true; - } - else { - if (g.mIsMaster) { - return true; - } - } - } - return false; - } - - public GT_MetaTileEntity_ConnectableCrate getCrateAtBlockPos(BlockPos pos) { - if (pos != null) { - Block b = pos.getBlockAtPos(); - int m = pos.getMetaAtPos(); - TileEntity t = pos.world.getTileEntity(pos.xPos, pos.yPos, pos.zPos); - if (b != null && t != null) { - if (b == GregTech_API.sBlockMachines && m == mCrateID) { - if (t instanceof IGregTechTileEntity) { - IGregTechTileEntity g = (IGregTechTileEntity) t; - final IMetaTileEntity aMetaTileEntity = g.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return null; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_ConnectableCrate) { - return ((GT_MetaTileEntity_ConnectableCrate) aMetaTileEntity); - - } - } - } - } - } - return null; - } - - - - - - - - - - - - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } else { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } - - - - - - - - - - - - - - - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { - if (this.getItemCount() <= 0) { - this.mItemStack = null; - this.mItemCount = 0; - } - - if (this.mItemStack == null && this.mInventory[0] != null) { - this.mItemStack = this.mInventory[0].copy(); - } - - if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() - && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { - this.mItemCount += this.mInventory[0].stackSize; - if (this.mItemCount > this.getMaxItemCount()) { - this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); - this.mItemCount = this.getMaxItemCount(); - } else { - this.mInventory[0] = null; - } - } - - if (this.mInventory[1] == null && this.mItemStack != null) { - this.mInventory[1] = this.mItemStack.copy(); - this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - this.mItemCount -= this.mInventory[1].stackSize; - } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) - && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { - int tmp = Math.min(this.mItemCount, - this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); - this.mInventory[1].stackSize += tmp; - this.mItemCount -= tmp; - } - - if (this.mItemStack != null) { - this.mInventory[2] = this.mItemStack.copy(); - this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - } else { - this.mInventory[2] = null; - } - } - - } - - private int getItemCount() { - return this.mItemCount; - } - - public void setItemCount(int aCount) { - this.mItemCount = aCount; - } - - public int getProgresstime() { - return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) - + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); - } - - public int maxProgresstime() { - return this.getMaxItemCount(); - } - - public int getMaxItemCount() { - return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); - } - - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 1; - } - - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); - } - - public String[] getInfoData() { - return this.mItemStack == null - ? new String[]{"Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0), - Integer.toString(this.getMaxItemCount())} - : new String[]{"Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(), - Integer.toString(this.mItemCount), Integer.toString(this.getMaxItemCount())}; - } - - public boolean isGivingInformation() { - return true; - } - - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mItemCount", this.mItemCount); - if (this.mItemStack != null) { - aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); - } - aNBT.setString("mMasterCrateLocation", mMasterCrateLocation.getUniqueIdentifier()); - aNBT.setBoolean("mIsMaster", mIsMaster); - for (int y=0;y mConnectedCache = new AutoMap(); + + public GT_MetaTileEntity_ConnectableCrate(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 3, + "This Crate stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", + new ITexture[0]); + } + + public GT_MetaTileEntity_ConnectableCrate(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ConnectableCrate(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public int getOppositeSide(int side) { + if (side == SIDE_Up) { + return SIDE_Down; + } else if (side == SIDE_Down) { + return SIDE_Up; + } else if (side == SIDE_XNeg) { + return SIDE_XPos; + } else if (side == SIDE_XPos) { + return SIDE_XNeg; + } else if (side == SIDE_ZNeg) { + return SIDE_ZPos; + } else { + return SIDE_ZNeg; + } + } + + public boolean calculateOwnershipIfConnected() { + if (mCurrentPos == null) { + mCurrentPos = new BlockPos( + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getYCoord(), + this.getBaseMetaTileEntity().getZCoord(), + this.getBaseMetaTileEntity().getWorld()); + } + AutoMap n = mCurrentPos.getSurroundingBlocks(); + int p = 0; + for (BlockPos i : n) { + if (i != null) { + if (doesSideContainCrate(p)) { + GT_MetaTileEntity_ConnectableCrate yu = getCrateAtBlockPos(i); + if (yu != null) { + mNeighbourCache[p] = yu; + } + } + } + p++; + } + + int e4 = 0; + if (mNeighbourCache.length > 0) { + for (GT_MetaTileEntity_ConnectableCrate e : mNeighbourCache) { + this.mConnectedCount = this.mConnectedCache.size(); + if (e != null) { + // First, we check if this Crate is a Master, if not, continue checking what it is. + if (this.mIsMaster) { + // So this other Crate is also a master? Which is more Powerful + if (e.mIsMaster) { + // This crate holds more connected, it becomes master now. + if (this.mConnectedCount > e.mConnectedCount) { + e.mIsMaster = false; + e.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + this.mConnectedCache = ArrayUtils.mergeTwoMaps(this.mConnectedCache, e.mConnectedCache); + continue; + } + // Other crate held more connected, it is now master. + else { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mCurrentPos; + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + e.mConnectedCache = ArrayUtils.mergeTwoMaps(e.mConnectedCache, this.mConnectedCache); + // Best wipe our cache of connected blocks then, since they no longer hold value. + mConnectedCache.clear(); + continue; + } + } + // Other Crate was not a Master, but we are, time to inherit it into our connection hivemind. + else { + // It would appear this controller has another master, time to query it. + if (e.mMasterCrateLocation != null + && !e.mMasterCrateLocation + .getUniqueIdentifier() + .equalsIgnoreCase(this.mMasterCrateLocation.getUniqueIdentifier())) { + GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); + if (gM != null) { + // Lets compare controller strengths + int gM_Owned = gM.mConnectedCount; + // We are stronger, let's inherit it. + if (this.mConnectedCount > gM_Owned) { + e.mIsMaster = false; + e.mMasterCrateLocation = this.mCurrentPos; + gM.mIsMaster = false; + gM.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + this.mConnectedCache = + ArrayUtils.mergeTwoMaps(this.mConnectedCache, gM.mConnectedCache); + continue; + } + // We lost, time to submit to a new master crate + else { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mMasterCrateLocation; + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + gM.mConnectedCache = + ArrayUtils.mergeTwoMaps(gM.mConnectedCache, this.mConnectedCache); + // Best wipe our cache of connected blocks then, since they no longer hold + // value. + mConnectedCache.clear(); + continue; + } + } else { + // Could not get the Tile Entity for the Other Master Crate.. Guess I can just + // ignore this case for now~ TODO + continue; + } + } + // Either the other crate has no known Master or it is already this crate. + else { + // The other crate has no master, time to inherit. + if (e.mMasterCrateLocation == null || (!e.mIsConnected[getOppositeSide(e4)])) { + e.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); + continue; + } else { + // Do nothing, we own this Crate already :) + continue; + } + } + } + } + + // We are not a Storage Master Crate, into a brave new world we go + else { + // Best wipe our cache of connected blocks then, since they no longer hold value. + mConnectedCache.clear(); + + // Dang, the other crate is a master, time to get incorporated. + if (e.mIsMaster) { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mCurrentPos; + this.mIsConnected[e4] = true; + if (!e.mIsConnected[e4]) { + e.mIsConnected[e4] = true; + } + if (e.mMasterCrateLocation == null) { + e.mMasterCrateLocation = e.mCurrentPos; + } + e.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); + continue; + } + // So the Crate we Checked is not a Master, so let's see if it knows where one is + else { + // So, this Crate we have found knows about a master + if (e.mMasterCrateLocation != null) { + GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); + // Found the master crate + if (gM != null) { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mMasterCrateLocation; + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + gM.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); + continue; + } else { + // Could not get the Tile Entity for the Other Master Crate.. Guess I can just + // ignore this case for now~ TODO + continue; + } + } + // This crate has no master, not going to check if it's connected. + else { + this.mIsMaster = true; + this.mMasterCrateLocation = this.mCurrentPos; + e.mIsMaster = false; + e.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); + continue; + } + } + } + } + e4++; + } + return true; + } else { + return false; + } + } + + public boolean doesSideContainCrate(int side) { + return checkSideForDataType(0, side); + } + + public boolean isCrateAtSideController(int side) { + return checkSideForDataType(1, side); + } + + private boolean checkSideForDataType(int aType, int aSide) { + BlockPos mPosToCheck = aSide == SIDE_Up + ? mCurrentPos.getUp() + : aSide == SIDE_Down + ? mCurrentPos.getDown() + : aSide == SIDE_XPos + ? mCurrentPos.getXPos() + : aSide == SIDE_XNeg + ? mCurrentPos.getXNeg() + : aSide == SIDE_ZPos ? mCurrentPos.getZPos() : mCurrentPos.getZNeg(); + GT_MetaTileEntity_ConnectableCrate g = getCrateAtBlockPos(mPosToCheck); + if (g != null) { + if (aType == 0) { + return true; + } else { + if (g.mIsMaster) { + return true; + } + } + } + return false; + } + + public GT_MetaTileEntity_ConnectableCrate getCrateAtBlockPos(BlockPos pos) { + if (pos != null) { + Block b = pos.getBlockAtPos(); + int m = pos.getMetaAtPos(); + TileEntity t = pos.world.getTileEntity(pos.xPos, pos.yPos, pos.zPos); + if (b != null && t != null) { + if (b == GregTech_API.sBlockMachines && m == mCrateID) { + if (t instanceof IGregTechTileEntity) { + IGregTechTileEntity g = (IGregTechTileEntity) t; + final IMetaTileEntity aMetaTileEntity = g.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return null; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_ConnectableCrate) { + return ((GT_MetaTileEntity_ConnectableCrate) aMetaTileEntity); + } + } + } + } + } + return null; + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (this.getBaseMetaTileEntity().isServerSide() + && this.getBaseMetaTileEntity().isAllowedToWork()) { + if (this.getItemCount() <= 0) { + this.mItemStack = null; + this.mItemCount = 0; + } + + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = this.mInventory[0].copy(); + } + + if (this.mInventory[0] != null + && this.mItemCount < this.getMaxItemCount() + && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > this.getMaxItemCount()) { + this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); + this.mItemCount = this.getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + + if (this.mInventory[1] == null && this.mItemStack != null) { + this.mInventory[1] = this.mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if (this.mItemCount > 0 + && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) + && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + int tmp = + Math.min(this.mItemCount, this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + this.mInventory[1].stackSize += tmp; + this.mItemCount -= tmp; + } + + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + } else { + this.mInventory[2] = null; + } + } + } + + private int getItemCount() { + return this.mItemCount; + } + + public void setItemCount(int aCount) { + this.mItemCount = aCount; + } + + public int getProgresstime() { + return this.mItemCount + + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) + + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); + } + + public int maxProgresstime() { + return this.getMaxItemCount(); + } + + public int getMaxItemCount() { + return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 1; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); + } + + public String[] getInfoData() { + return this.mItemStack == null + ? new String[] { + "Super Storage Chest", + "Stored Items:", + "No Items", + Integer.toString(0), + Integer.toString(this.getMaxItemCount()) + } + : new String[] { + "Super Storage Chest", + "Stored Items:", + this.mItemStack.getDisplayName(), + Integer.toString(this.mItemCount), + Integer.toString(this.getMaxItemCount()) + }; + } + + public boolean isGivingInformation() { + return true; + } + + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) { + aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); + } + aNBT.setString("mMasterCrateLocation", mMasterCrateLocation.getUniqueIdentifier()); + aNBT.setBoolean("mIsMaster", mIsMaster); + for (int y = 0; y < this.mIsConnected.length; y++) { + aNBT.setBoolean("mIsConnected" + y, mIsConnected[y]); + } + aNBT.setInteger("mConnectedCount", mConnectedCount); + } + + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) { + this.mItemCount = aNBT.getInteger("mItemCount"); + } + if (aNBT.hasKey("mItemStack")) { + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + if (aNBT.hasKey("mMasterCrateLocation")) { + this.mMasterCrateLocation = BlockPos.generateBlockPos(aNBT.getString("mMasterCrateLocation")); + } + if (aNBT.hasKey("mIsMaster")) { + this.mIsMaster = aNBT.getBoolean("mIsMaster"); + } + + for (int y = 0; y < this.mIsConnected.length; y++) { + if (aNBT.hasKey("mIsConnected" + y)) { + this.mIsConnected[y] = aNBT.getBoolean("mIsConnected" + y); + } + } + + if (aNBT.hasKey("mConnectedCount")) { + this.mConnectedCount = aNBT.getInteger("mConnectedCount"); + } + } + + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return aBaseMetaTileEntity.getFrontFacing() == 0 && aSide == 4 + ? new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON), + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) + } + : (aSide == aBaseMetaTileEntity.getFrontFacing() + ? new ITexture[] { + new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON), + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) + } + : new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON)}); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public void onExplosion() { + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public void onRemoval() { + // TODO Auto-generated method stub + super.onRemoval(); + } + + @Override + public void onMachineBlockUpdate() { + // TODO Auto-generated method stub + super.onMachineBlockUpdate(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java index 951b4223dc..b5dcd8cd73 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java @@ -1,10 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -15,185 +10,213 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SuperChest; import gtPlusPlus.xmod.gregtech.api.gui.GUI_SuperChest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_TieredChest extends GT_MetaTileEntity_TieredMachineBlock { - public int mItemCount = 0; - public ItemStack mItemStack = null; - private final static double mStorageFactor = (270000.0D/16); - - public GT_MetaTileEntity_TieredChest(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, - "This Chest stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", new ITexture[0]); - } - - public GT_MetaTileEntity_TieredChest(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - /*public GT_MetaTileEntity_TieredChest(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - }*/ - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip}; - } - - public boolean isSimpleMachine() { - return true; - } - - public boolean isFacingValid(byte aFacing) { - return true; - } - - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - public boolean isValidSlot(int aIndex) { - return true; - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TieredChest(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } else { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { - if (this.getItemCount() <= 0) { - this.mItemStack = null; - this.mItemCount = 0; - } - - if (this.mItemStack == null && this.mInventory[0] != null) { - this.mItemStack = this.mInventory[0].copy(); - } - - if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() - && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { - this.mItemCount += this.mInventory[0].stackSize; - if (this.mItemCount > this.getMaxItemCount()) { - this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); - this.mItemCount = this.getMaxItemCount(); - } else { - this.mInventory[0] = null; - } - } - - if (this.mInventory[1] == null && this.mItemStack != null) { - this.mInventory[1] = this.mItemStack.copy(); - this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - this.mItemCount -= this.mInventory[1].stackSize; - } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) - && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { - int tmp = Math.min(this.mItemCount, - this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); - this.mInventory[1].stackSize += tmp; - this.mItemCount -= tmp; - } - - if (this.mItemStack != null) { - this.mInventory[2] = this.mItemStack.copy(); - this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - } else { - this.mInventory[2] = null; - } - } - - } - - private int getItemCount() { - return this.mItemCount; - } - - public void setItemCount(int aCount) { - this.mItemCount = aCount; - } - - public int getProgresstime() { - return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) - + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); - } - - public int maxProgresstime() { - return this.getMaxItemCount(); - } - - public int getMaxItemCount() { - return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); - } - - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 1; - } - - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); - } - - public String[] getInfoData() { - return this.mItemStack == null - ? new String[]{"Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0), - Integer.toString(this.getMaxItemCount())} - : new String[]{"Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(), - Integer.toString(this.mItemCount), Integer.toString(this.getMaxItemCount())}; - } - - public boolean isGivingInformation() { - return true; - } - - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mItemCount", this.mItemCount); - if (this.mItemStack != null) { - aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); - } - - } - - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mItemCount")) { - this.mItemCount = aNBT.getInteger("mItemCount"); - } - - if (aNBT.hasKey("mItemStack")) { - this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); - } - - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return aBaseMetaTileEntity.getFrontFacing() == 0 && aSide == 4 - ? new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)} - : (aSide == aBaseMetaTileEntity.getFrontFacing() - ? new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)} - : new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]}); - } - - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } -} \ No newline at end of file + public int mItemCount = 0; + public ItemStack mItemStack = null; + private static final double mStorageFactor = (270000.0D / 16); + + public GT_MetaTileEntity_TieredChest(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 3, + "This Chest stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", + new ITexture[0]); + } + + public GT_MetaTileEntity_TieredChest(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + /*public GT_MetaTileEntity_TieredChest(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + }*/ + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TieredChest(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (this.getBaseMetaTileEntity().isServerSide() + && this.getBaseMetaTileEntity().isAllowedToWork()) { + if (this.getItemCount() <= 0) { + this.mItemStack = null; + this.mItemCount = 0; + } + + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = this.mInventory[0].copy(); + } + + if (this.mInventory[0] != null + && this.mItemCount < this.getMaxItemCount() + && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > this.getMaxItemCount()) { + this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); + this.mItemCount = this.getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + + if (this.mInventory[1] == null && this.mItemStack != null) { + this.mInventory[1] = this.mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if (this.mItemCount > 0 + && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) + && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + int tmp = + Math.min(this.mItemCount, this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + this.mInventory[1].stackSize += tmp; + this.mItemCount -= tmp; + } + + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + } else { + this.mInventory[2] = null; + } + } + } + + private int getItemCount() { + return this.mItemCount; + } + + public void setItemCount(int aCount) { + this.mItemCount = aCount; + } + + public int getProgresstime() { + return this.mItemCount + + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) + + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); + } + + public int maxProgresstime() { + return this.getMaxItemCount(); + } + + public int getMaxItemCount() { + return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 1; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); + } + + public String[] getInfoData() { + return this.mItemStack == null + ? new String[] { + "Super Storage Chest", + "Stored Items:", + "No Items", + Integer.toString(0), + Integer.toString(this.getMaxItemCount()) + } + : new String[] { + "Super Storage Chest", + "Stored Items:", + this.mItemStack.getDisplayName(), + Integer.toString(this.mItemCount), + Integer.toString(this.getMaxItemCount()) + }; + } + + public boolean isGivingInformation() { + return true; + } + + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) { + aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); + } + } + + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) { + this.mItemCount = aNBT.getInteger("mItemCount"); + } + + if (aNBT.hasKey("mItemStack")) { + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + } + + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return aBaseMetaTileEntity.getFrontFacing() == 0 && aSide == 4 + ? new ITexture[] { + BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) + } + : (aSide == aBaseMetaTileEntity.getFrontFacing() + ? new ITexture[] { + BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) + } + : new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]}); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java index ef7fe829d4..22537dc5cf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -10,151 +7,172 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.preloader.asm.AsmConfig; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_TieredTank extends GT_MetaTileEntity_BasicTank { - public GT_MetaTileEntity_TieredTank(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); - } - - public GT_MetaTileEntity_TieredTank(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid", aTextures); - } - - @Override - public String[] getDescription() { - String[] aTip; - - String aTankPortableness = "portable"; - - if (this.mFluid == null) { - aTip = new String[] {this.mDescription, "A "+aTankPortableness+" tank.", CORE.GT_Tooltip}; - } - else { - aTip = new String[] {this.mDescription, "A "+aTankPortableness+" tank.", "Fluid: "+mFluid.getLocalizedName()+" "+mFluid.amount+"L", CORE.GT_Tooltip}; - } - return aTip; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public final byte getUpdateData() { - return 0x00; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public String[] getInfoData() { - - if (this.mFluid == null) { - return new String[]{ - GT_Values.VOLTAGE_NAMES[this.mTier]+" Fluid Tank", - "Stored Fluid:", - "No Fluid", - Integer.toString(0) + "L", - Integer.toString(this.getCapacity()) + "L"}; - } - return new String[]{ - GT_Values.VOLTAGE_NAMES[this.mTier]+" Fluid Tank", - "Stored Fluid:", - this.mFluid.getLocalizedName(), - Integer.toString(this.mFluid.amount) + "L", - Integer.toString(this.getCapacity()) + "L"}; - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TieredTank(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public int getCapacity() { - return (int) (Math.pow(2, this.mTier) * 32000); - } - - @Override - public int getTankPressure() { - return 100; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()){ - //setVars(); - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { - if (mFluid != null){ - Logger.WARNING("Setting item fluid nbt"); - aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - if (aNBT.hasKey("mFluid")) { - Logger.WARNING("Set mFluid to NBT."); - } - } - } - } - -} \ No newline at end of file + public GT_MetaTileEntity_TieredTank( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); + } + + public GT_MetaTileEntity_TieredTank( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid", aTextures); + } + + @Override + public String[] getDescription() { + String[] aTip; + + String aTankPortableness = "portable"; + + if (this.mFluid == null) { + aTip = new String[] {this.mDescription, "A " + aTankPortableness + " tank.", CORE.GT_Tooltip}; + } else { + aTip = new String[] { + this.mDescription, + "A " + aTankPortableness + " tank.", + "Fluid: " + mFluid.getLocalizedName() + " " + mFluid.amount + "L", + CORE.GT_Tooltip + }; + } + return aTip; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return aSide == 1 + ? new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE) + } + : new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER) + }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public final byte getUpdateData() { + return 0x00; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public String[] getInfoData() { + + if (this.mFluid == null) { + return new String[] { + GT_Values.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", + "Stored Fluid:", + "No Fluid", + Integer.toString(0) + "L", + Integer.toString(this.getCapacity()) + "L" + }; + } + return new String[] { + GT_Values.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", + "Stored Fluid:", + this.mFluid.getLocalizedName(), + Integer.toString(this.mFluid.amount) + "L", + Integer.toString(this.getCapacity()) + "L" + }; + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TieredTank(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getCapacity() { + return (int) (Math.pow(2, this.mTier) * 32000); + } + + @Override + public int getTankPressure() { + return 100; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + // setVars(); + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { + if (mFluid != null) { + Logger.WARNING("Setting item fluid nbt"); + aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + if (aNBT.hasKey("mFluid")) { + Logger.WARNING("Set mFluid to NBT."); + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java index e18f5d4bfc..775c10666e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java @@ -24,396 +24,507 @@ import net.minecraft.world.World; public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { - protected byte aCurrentOutputAmperage = 4; - - public GregtechMetaEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaEnergyBuffer(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {this.mDescription, - "Defaults 4A In/Out", - "Change output Amperage with a screwdriver", - "Now Portable!", - CORE.GT_Tooltip}; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { - if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { - return true; - } - return super.allowCoverOnSide(aSide, aCover); - } - - /* - * MACHINE_STEEL_SIDE - */ - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; - } - - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; - } - - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - /*@Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[2][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_HEATPROOFCASING) }; - rTextures[1][i + 1] = new ITexture[] { - new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_HEATPROOFCASING), - mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] - : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; - } - return rTextures; - }*/ - - /* - * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { - * ITexture[][][] rTextures = new ITexture[5][17][]; for (byte i = -1; i < - * 16; i = (byte) (i + 1)) { ITexture[] tmp0 = { new GT_RenderedTexture( - * Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i, - * Dyes._NULL.mRGBa)) }; rTextures[0][(i + 1)] = tmp0; ITexture[] tmp1 = { - * new GT_RenderedTexture( Textures.BlockIcons.MACHINE_STEEL_TOP) }; - * rTextures[1][(i + 1)] = tmp1; ITexture[] tmp2 = { new GT_RenderedTexture( - * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, - * Dyes._NULL.mRGBa)), new - * GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; rTextures[2][(i + - * 1)] = tmp2; ITexture[] tmp4 = { new GT_RenderedTexture( - * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, - * Dyes._NULL.mRGBa)), new - * GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; rTextures[3][(i + - * 1)] = tmp4; ITexture[] tmp5 = { new GT_RenderedTexture( - * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, - * Dyes._NULL.mRGBa)), new GT_RenderedTexture( - * Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; rTextures[4][(i + 1)] = tmp5; - * } return rTextures; } - */ - - /*@Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; - }*/ - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(final int aIndex) {return true;} - @Override public boolean isFacingValid(final byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return V[this.mTier]*2;} - @Override public long maxEUStore() {return V[this.mTier]*250000;} - - @Override - public long maxEUInput() { - return V[this.mTier]; - } - - @Override - public long maxEUOutput() { - return V[this.mTier]; - } - - @Override - public long maxAmperesIn() { - return aCurrentOutputAmperage; - } - - @Override - public long maxAmperesOut() { - return aCurrentOutputAmperage; - } - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return 0;} - @Override public int dechargerSlotCount() {return 0;} - @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} - @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); - if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { - long aEU = this.getBaseMetaTileEntity().getStoredEU(); - if (aEU > 0){ - aNBT.setLong("aStoredEU", aEU); - if (aNBT.hasKey("aStoredEU")) { - Logger.WARNING("Set aStoredEU to NBT."); - } - } - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - aCurrentOutputAmperage = aNBT.getByte("aCurrentOutputAmperage"); - if (aNBT.hasKey("aStoredEU")) { - this.setEUVar(aNBT.getLong("aStoredEU")); - } - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - Logger.WARNING("Right Click on MTE by Player"); - if (aBaseMetaTileEntity.isClientSide()) - { - return true; - //aBaseMetaTileEntity.openGUI(aPlayer); - } - - Logger.WARNING("MTE is Client-side"); - this.showEnergy(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - protected void showEnergy(final World worldIn, final EntityPlayer playerIn){ - final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); - final double c = ((double) tempStorage / this.maxEUStore()) * 100; - final double roundOff = Math.round(c * 100.00) / 100.00; - PlayerUtils.messagePlayer(playerIn, "Energy: " + GT_Utility.formatNumbers(tempStorage) + " EU at "+V[this.mTier]+"v ("+roundOff+"%)"); - PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut())+"A"); - - } - //Utils.LOG_WARNING("Begin Show Energy"); - /* - * - //Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" C: "+c); - Utils.LOG_INFO("getProgressTime: "+getProgresstime()); - Utils.LOG_INFO("maxProgressTime: "+maxProgresstime()); - Utils.LOG_INFO("getMinimumStoredEU: "+getMinimumStoredEU()); - Utils.LOG_INFO("maxEUStore: "+maxEUStore());*/ - /*final long d = (tempStorage * 100L) / maxEUStore(); - Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" D: "+d); - final double roundOff2 = Math.round(d * 100.00) / 100.00; - Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff2+"%)"); - Utils.LOG_WARNING("Making new instance of Guihandler"); - GuiHandler block = new GuiHandler(); - Utils.LOG_WARNING("Guihandler.toString(): "+block.toString()); - block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);*/ - - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - String cur = GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getStoredEU()); - String max = GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getEUCapacity()); - - // Right-align current storage with maximum storage - String fmt = String.format("%%%ds", max.length()); - cur = String.format(fmt, cur); - - return new String[] { - cur+" EU stored", - max+" EU capacity"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { - } - - @Override - public String getInventoryName() { - return super.getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { - aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); - long aEU = this.getBaseMetaTileEntity().getStoredEU(); - if (aEU > 0){ - aNBT.setLong("aStoredEU", aEU); - if (aNBT.hasKey("aStoredEU")) { - Logger.WARNING("Set aStoredEU to NBT."); - } - } - } - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - byte aTest = (byte) (aCurrentOutputAmperage + 1); - if (aTest > 16 || aTest <= 0 ) { - aTest = 1; - } - aCurrentOutputAmperage = aTest; - PlayerUtils.messagePlayer(aPlayer, "Now handling "+aCurrentOutputAmperage+" Amps."); - } - - - - - - -} \ No newline at end of file + protected byte aCurrentOutputAmperage = 4; + + public GregtechMetaEnergyBuffer( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaEnergyBuffer( + final String aName, + final int aTier, + final String aDescription, + final ITexture[][][] aTextures, + final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Defaults 4A In/Out", + "Change output Amperage with a screwdriver", + "Now Portable!", + CORE.GT_Tooltip + }; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { + if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(aSide, aCover); + } + + /* + * MACHINE_STEEL_SIDE + */ + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) + }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + /*@Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[2][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_HEATPROOFCASING) }; + rTextures[1][i + 1] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_HEATPROOFCASING), + mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; + } + return rTextures; + }*/ + + /* + * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { + * ITexture[][][] rTextures = new ITexture[5][17][]; for (byte i = -1; i < + * 16; i = (byte) (i + 1)) { ITexture[] tmp0 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)) }; rTextures[0][(i + 1)] = tmp0; ITexture[] tmp1 = { + * new GT_RenderedTexture( Textures.BlockIcons.MACHINE_STEEL_TOP) }; + * rTextures[1][(i + 1)] = tmp1; ITexture[] tmp2 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new + * GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; rTextures[2][(i + + * 1)] = tmp2; ITexture[] tmp4 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new + * GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; rTextures[3][(i + + * 1)] = tmp4; ITexture[] tmp5 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new GT_RenderedTexture( + * Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; rTextures[4][(i + 1)] = tmp5; + * } return rTextures; } + */ + + /*@Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; + }*/ + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaEnergyBuffer( + this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return V[this.mTier] * 2; + } + + @Override + public long maxEUStore() { + return V[this.mTier] * 250000; + } + + @Override + public long maxEUInput() { + return V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxAmperesIn() { + return aCurrentOutputAmperage; + } + + @Override + public long maxAmperesOut() { + return aCurrentOutputAmperage; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); + if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { + long aEU = this.getBaseMetaTileEntity().getStoredEU(); + if (aEU > 0) { + aNBT.setLong("aStoredEU", aEU); + if (aNBT.hasKey("aStoredEU")) { + Logger.WARNING("Set aStoredEU to NBT."); + } + } + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + aCurrentOutputAmperage = aNBT.getByte("aCurrentOutputAmperage"); + if (aNBT.hasKey("aStoredEU")) { + this.setEUVar(aNBT.getLong("aStoredEU")); + } + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + Logger.WARNING("Right Click on MTE by Player"); + if (aBaseMetaTileEntity.isClientSide()) { + return true; + // aBaseMetaTileEntity.openGUI(aPlayer); + } + + Logger.WARNING("MTE is Client-side"); + this.showEnergy(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + protected void showEnergy(final World worldIn, final EntityPlayer playerIn) { + final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); + final double c = ((double) tempStorage / this.maxEUStore()) * 100; + final double roundOff = Math.round(c * 100.00) / 100.00; + PlayerUtils.messagePlayer( + playerIn, + "Energy: " + GT_Utility.formatNumbers(tempStorage) + " EU at " + V[this.mTier] + "v (" + roundOff + + "%)"); + PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut()) + "A"); + } + // Utils.LOG_WARNING("Begin Show Energy"); + /* + * + //Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" C: "+c); + Utils.LOG_INFO("getProgressTime: "+getProgresstime()); + Utils.LOG_INFO("maxProgressTime: "+maxProgresstime()); + Utils.LOG_INFO("getMinimumStoredEU: "+getMinimumStoredEU()); + Utils.LOG_INFO("maxEUStore: "+maxEUStore());*/ + /*final long d = (tempStorage * 100L) / maxEUStore(); + Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" D: "+d); + final double roundOff2 = Math.round(d * 100.00) / 100.00; + Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff2+"%)"); + Utils.LOG_WARNING("Making new instance of Guihandler"); + GuiHandler block = new GuiHandler(); + Utils.LOG_WARNING("Guihandler.toString(): "+block.toString()); + block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);*/ + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String cur = GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getStoredEU()); + String max = GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getEUCapacity()); + + // Right-align current storage with maximum storage + String fmt = String.format("%%%ds", max.length()); + cur = String.format(fmt, cur); + + return new String[] {cur + " EU stored", max + " EU capacity"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return super.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { + aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); + long aEU = this.getBaseMetaTileEntity().getStoredEU(); + if (aEU > 0) { + aNBT.setLong("aStoredEU", aEU); + if (aNBT.hasKey("aStoredEU")) { + Logger.WARNING("Set aStoredEU to NBT."); + } + } + } + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + byte aTest = (byte) (aCurrentOutputAmperage + 1); + if (aTest > 16 || aTest <= 0) { + aTest = 1; + } + aCurrentOutputAmperage = aTest; + PlayerUtils.messagePlayer(aPlayer, "Now handling " + aCurrentOutputAmperage + " Amps."); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java index 63042d4702..064312fae2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java @@ -1,62 +1,71 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage; -import net.minecraft.entity.player.InventoryPlayer; - 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.objects.GT_RenderedTexture; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SafeBlock; import gtPlusPlus.xmod.gregtech.api.gui.GUI_SafeBlock; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; +import net.minecraft.entity.player.InventoryPlayer; + +public class GregtechMetaSafeBlock extends GregtechMetaSafeBlockBase { + + public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 28, "Protecting your items from sticky fingers."); + } + + public GregtechMetaSafeBlock( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final int aInvSlotCount, + final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaSafeBlock( + final String aName, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaSafeBlock( + this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); + } + + @Override + public ITexture getOverlayIcon() { + return new GT_RenderedTexture(Textures.BlockIcons.VOID); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < (this.mInventory.length - 1); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SafeBlock(aPlayerInventory, aBaseMetaTileEntity); + } -public class GregtechMetaSafeBlock -extends GregtechMetaSafeBlockBase { - - public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, 28, "Protecting your items from sticky fingers."); - } - - public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); - } - - public GregtechMetaSafeBlock(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip}; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaSafeBlock(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); - } - - @Override - public ITexture getOverlayIcon() { - return new GT_RenderedTexture(Textures.BlockIcons.VOID); - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex < (this.mInventory.length - 1); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_SafeBlock(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_SafeBlock(aPlayerInventory, aBaseMetaTileEntity); - } + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SafeBlock(aPlayerInventory, aBaseMetaTileEntity); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java index fb37f33055..1ca167925c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java @@ -1,9 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage.creative; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -11,95 +7,95 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_TieredChest { - public GT_MetaTileEntity_InfiniteItemHolder(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_InfiniteItemHolder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip}; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.getWorld().isRemote) { - return false; - } - - if (!KeyboardUtils.isShiftKeyDown()) { - if (this.mItemStack == null) { - if (aPlayer.getHeldItem() != null) { - this.mItemStack = aPlayer.getHeldItem().copy(); - this.mItemCount = Short.MAX_VALUE; - aPlayer.setCurrentItemOrArmor(0, null); - PlayerUtils.messagePlayer(aPlayer, "Now holding "+this.mItemStack.getDisplayName()+" x"+Short.MAX_VALUE+"."); - return true; - } - } - else { - if (aPlayer.getHeldItem() == null) { - aPlayer.entityDropItem(mItemStack, 1); - this.mItemStack = null; - this.mItemCount = 0; - PlayerUtils.messagePlayer(aPlayer, "Emptying."); - return true; - } - } - } - - PlayerUtils.messagePlayer(aPlayer, "Currently holding: "+(this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing")+" x"+this.mItemCount); - return true; - //return super.onRightclick(aBaseMetaTileEntity, aPlayer); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (mItemStack != null) { - setItemCount(0); - } - super.onPostTick(aBaseMetaTileEntity, aTimer); - } - - @Override - public void setItemCount(int aCount) { - super.setItemCount(Short.MAX_VALUE); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_InfiniteItemHolder(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - - - - + public GT_MetaTileEntity_InfiniteItemHolder(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_InfiniteItemHolder( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.getWorld().isRemote) { + return false; + } + + if (!KeyboardUtils.isShiftKeyDown()) { + if (this.mItemStack == null) { + if (aPlayer.getHeldItem() != null) { + this.mItemStack = aPlayer.getHeldItem().copy(); + this.mItemCount = Short.MAX_VALUE; + aPlayer.setCurrentItemOrArmor(0, null); + PlayerUtils.messagePlayer( + aPlayer, "Now holding " + this.mItemStack.getDisplayName() + " x" + Short.MAX_VALUE + "."); + return true; + } + } else { + if (aPlayer.getHeldItem() == null) { + aPlayer.entityDropItem(mItemStack, 1); + this.mItemStack = null; + this.mItemCount = 0; + PlayerUtils.messagePlayer(aPlayer, "Emptying."); + return true; + } + } + } + + PlayerUtils.messagePlayer( + aPlayer, + "Currently holding: " + (this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing") + " x" + + this.mItemCount); + return true; + // return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (mItemStack != null) { + setItemCount(0); + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } + + @Override + public void setItemCount(int aCount) { + super.setItemCount(Short.MAX_VALUE); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_InfiniteItemHolder(this.mName, this.mTier, this.mDescription, this.mTextures); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java index 43d5cffe82..18e95861b3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java @@ -1,10 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -14,346 +9,366 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class GT4Entity_Shelf extends GT_MetaTileEntity_BasicHull_NonElectric { - public byte mType = 0; - public String mOldDesc = ""; - public boolean mLocked = false; - protected byte mIndex = (byte) MathUtils.randInt(1, 3); - public static GT_RenderedTexture texBottom = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_bottom")); - public static GT_RenderedTexture texTop = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_top")); - public static GT_RenderedTexture texSide = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_side")); - public static GT_RenderedTexture texSideCabinet = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_side_cabinet")); - - public GT4Entity_Shelf(final int aID, final String aName, final String aNameRegional, final String aDescription) { - super(aID, aName, aNameRegional, 0, aDescription); - mOldDesc = aDescription; - } - - public GT4Entity_Shelf(final String aName, final String aDescription, final ITexture[][][] aTextures) { - super(aName, 0, aDescription, aTextures); - mOldDesc = aDescription; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - public int getInvSize() { - return 1; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - if (this.getBaseMetaTileEntity().getOwnerName().equalsIgnoreCase(aPlayer.getDisplayName())) { - return true; - } - PlayerUtils.messagePlayer(aPlayer, "This container belongs to "+this.getBaseMetaTileEntity().getOwnerName()+"."); - return false; - } - - @Override - public boolean ownerControl() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean isInputFacing(byte aSide) { - return false; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aTile, EntityPlayer aPlayer) { - if (aTile.isClientSide()) { - return true; - } - ItemStack tStack = aPlayer.inventory.getStackInSlot(aPlayer.inventory.currentItem); - if (tStack == null) { - if (KeyboardUtils.isCtrlKeyDown()) { - if (this.mInventory[0] != null) { - PlayerUtils.messagePlayer(aPlayer, "Contains "+this.mInventory[0].getDisplayName()+" x"+this.mInventory[0].stackSize+"."); - } - return false; - } - else { - if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { - if (!this.mLocked) { - PlayerUtils.messagePlayer(aPlayer, "Removed "+this.mInventory[0].getDisplayName()+" x"+this.mInventory[0].stackSize+"."); - aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, this.mInventory[0]); - getBaseMetaTileEntity().setInventorySlotContents(0, null); - this.mType = 0; - return true; - } - else { - PlayerUtils.messagePlayer(aPlayer, "This container is locked. It belongs to "+aTile.getOwnerName()+"."); - return false; - } - } - return false; - } - } - else if (tStack != null && this.mInventory[0] == null) { - - if (KeyboardUtils.isCtrlKeyDown() || GT_MetaGenerated_Tool_01.class.isInstance(tStack.getItem())) { - return false; - } - PlayerUtils.messagePlayer(aPlayer, "Stored "+tStack.getDisplayName()+" x"+tStack.stackSize+"."); - aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, null); - getBaseMetaTileEntity().setInventorySlotContents(0, tStack); - this.mType = (byte) MathUtils.randInt(1, 3); - return true; - } - else { - if (this.mInventory[0] == null) { - this.mType = 0; - } - return super.onRightclick(aTile, aPlayer); - } - } - - @Override - public void onLeftclick(IGregTechTileEntity aTile,EntityPlayer aPlayer) { - if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { - ItemStack tOutput = GT_Utility.copy(new Object[] { this.mInventory[0] }); - if (!aPlayer.isSneaking()) { - tOutput.stackSize = 1; - } - getBaseMetaTileEntity().decrStackSize(0, tOutput.stackSize); - EntityItem tEntity = new EntityItem(getBaseMetaTileEntity().getWorld(), - getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, - getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, - getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, tOutput); - tEntity.motionX = 0.0D; - tEntity.motionY = 0.0D; - tEntity.motionZ = 0.0D; - getBaseMetaTileEntity().getWorld().spawnEntityInWorld(tEntity); - if (this.mInventory[0] == null) { - this.mType = 0; - } - } - super.onLeftclick(aTile, aPlayer); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf(this.mName, this.mDescription, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) {//mLocked - aNBT.setInteger("mType", this.mType); - aNBT.setBoolean("mLocked", this.mLocked); - aNBT.setByte("mIndex", this.mIndex); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mIndex")) { - this.mType = ((byte) aNBT.getInteger("mType")); - } - if (aNBT.hasKey("mIndex")) { - this.mLocked = (aNBT.getBoolean("mLocked")); - } - if (aNBT.hasKey("mIndex")) { - this.mIndex = aNBT.getByte("mIndex"); - } - } - - @Override - public void onValueUpdate(byte aValue) { - this.mType = aValue; - } - - @Override - public byte getUpdateData() { - return this.mType; - } - - @Override - public String[] getDescription() { - return new String[] { - mOldDesc, - "Decorative Item Storage", - "Right click to store/remove something", - "Ctrl + Rmb to check contents", - "Ctrl + Rmb with a screwdriver to lock", - }; - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - //return aSide != getBaseMetaTileEntity().getFrontFacing(); - return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity p0, int p1, byte p2, ItemStack p3) { - return true; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity p0, int p1, byte p2, ItemStack p3) { - return false; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[7][17][]; - for (byte i = -1; i < 16; i = (byte) (i + 1)) { - ITexture[] tmp0 = {this.getBottom((byte) 0)[0]}; - rTextures[0][(i + 1)] = tmp0; - ITexture[] tmp1 = { this.getTop((byte) 0)[0]}; - rTextures[1][(i + 1)] = tmp1; - ITexture[] tmp2 = { this.getSides((byte) 0)[0]}; - rTextures[2][(i + 1)] = tmp2; - ITexture[] tmp4 = {this.getSides((byte) 0)[0]}; - rTextures[3][(i + 1)] = tmp4; - ITexture[] tmp5 = {this.getSides((byte) 0)[0], getFront((byte) 0)[0]}; - rTextures[4][(i + 1)] = tmp5; - ITexture[] tmp6 = {this.getSides((byte) 0)[0], getFront((byte) 1)[0]}; - rTextures[5][(i + 1)] = tmp6; - ITexture[] tmp7 = {this.getSides((byte) 0)[0], getFront((byte) 2)[0]}; - rTextures[6][(i + 1)] = tmp7; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, - final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, - final boolean aRedstone) { - - ITexture[] tmp = this.mTextures[(aSide >= 2) ? ((aSide != aFacing) ? 2 : ((byte) this.mType == 0 ? 4 : this.mType == 1 || this.mType == 2 ? 5 : this.mType == 3 ? 6 : 0)) : aSide][aColorIndex + 1]; - if (aSide != aFacing && tmp.length == 2) { - tmp = new ITexture[]{tmp[0]}; - } - return tmp; - } - - private static GT_RenderedTexture x1 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_FRONT); - private static GT_RenderedTexture x2 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_PAPER_FRONT); - private static GT_RenderedTexture x3 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_CANS_FRONT); - - public ITexture[] getFrontNormal() { - return new ITexture[]{x1}; - } - public ITexture[] getFrontActive() { - return new ITexture[]{x2}; - } - public ITexture[] getFrontAlternative() { - return new ITexture[]{x3}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFrontNormal(); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - public ITexture[] getFront(byte aColour) { - if (aColour == 1) { - return getFrontActive(); - } - else if (aColour == 2) { - return getFrontAlternative(); - } - return getFrontNormal(); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (KeyboardUtils.isCtrlKeyDown()) { - if (!aPlayer.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())) { - PlayerUtils.messagePlayer(aPlayer, "Container is not yours to lock."); - } - else { - this.mLocked = Utils.invertBoolean(this.mLocked); - if (this.mLocked) { - PlayerUtils.messagePlayer(aPlayer, "Container is now locked."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Container is now unlocked."); - } - } - } - else { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - } - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - } - + public byte mType = 0; + public String mOldDesc = ""; + public boolean mLocked = false; + protected byte mIndex = (byte) MathUtils.randInt(1, 3); + public static GT_RenderedTexture texBottom = + new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_bottom")); + public static GT_RenderedTexture texTop = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_top")); + public static GT_RenderedTexture texSide = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_side")); + public static GT_RenderedTexture texSideCabinet = + new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_side_cabinet")); + + public GT4Entity_Shelf(final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, 0, aDescription); + mOldDesc = aDescription; + } + + public GT4Entity_Shelf(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 0, aDescription, aTextures); + mOldDesc = aDescription; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + public int getInvSize() { + return 1; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity().getOwnerName().equalsIgnoreCase(aPlayer.getDisplayName())) { + return true; + } + PlayerUtils.messagePlayer( + aPlayer, + "This container belongs to " + this.getBaseMetaTileEntity().getOwnerName() + "."); + return false; + } + + @Override + public boolean ownerControl() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aTile, EntityPlayer aPlayer) { + if (aTile.isClientSide()) { + return true; + } + ItemStack tStack = aPlayer.inventory.getStackInSlot(aPlayer.inventory.currentItem); + if (tStack == null) { + if (KeyboardUtils.isCtrlKeyDown()) { + if (this.mInventory[0] != null) { + PlayerUtils.messagePlayer( + aPlayer, + "Contains " + this.mInventory[0].getDisplayName() + " x" + this.mInventory[0].stackSize + + "."); + } + return false; + } else { + if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { + if (!this.mLocked) { + PlayerUtils.messagePlayer( + aPlayer, + "Removed " + this.mInventory[0].getDisplayName() + " x" + this.mInventory[0].stackSize + + "."); + aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, this.mInventory[0]); + getBaseMetaTileEntity().setInventorySlotContents(0, null); + this.mType = 0; + return true; + } else { + PlayerUtils.messagePlayer( + aPlayer, "This container is locked. It belongs to " + aTile.getOwnerName() + "."); + return false; + } + } + return false; + } + } else if (tStack != null && this.mInventory[0] == null) { + + if (KeyboardUtils.isCtrlKeyDown() || GT_MetaGenerated_Tool_01.class.isInstance(tStack.getItem())) { + return false; + } + PlayerUtils.messagePlayer(aPlayer, "Stored " + tStack.getDisplayName() + " x" + tStack.stackSize + "."); + aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, null); + getBaseMetaTileEntity().setInventorySlotContents(0, tStack); + this.mType = (byte) MathUtils.randInt(1, 3); + return true; + } else { + if (this.mInventory[0] == null) { + this.mType = 0; + } + return super.onRightclick(aTile, aPlayer); + } + } + + @Override + public void onLeftclick(IGregTechTileEntity aTile, EntityPlayer aPlayer) { + if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { + ItemStack tOutput = GT_Utility.copy(new Object[] {this.mInventory[0]}); + if (!aPlayer.isSneaking()) { + tOutput.stackSize = 1; + } + getBaseMetaTileEntity().decrStackSize(0, tOutput.stackSize); + EntityItem tEntity = new EntityItem( + getBaseMetaTileEntity().getWorld(), + getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, + getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, + getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, + tOutput); + tEntity.motionX = 0.0D; + tEntity.motionY = 0.0D; + tEntity.motionZ = 0.0D; + getBaseMetaTileEntity().getWorld().spawnEntityInWorld(tEntity); + if (this.mInventory[0] == null) { + this.mType = 0; + } + } + super.onLeftclick(aTile, aPlayer); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf(this.mName, this.mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { // mLocked + aNBT.setInteger("mType", this.mType); + aNBT.setBoolean("mLocked", this.mLocked); + aNBT.setByte("mIndex", this.mIndex); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mIndex")) { + this.mType = ((byte) aNBT.getInteger("mType")); + } + if (aNBT.hasKey("mIndex")) { + this.mLocked = (aNBT.getBoolean("mLocked")); + } + if (aNBT.hasKey("mIndex")) { + this.mIndex = aNBT.getByte("mIndex"); + } + } + + @Override + public void onValueUpdate(byte aValue) { + this.mType = aValue; + } + + @Override + public byte getUpdateData() { + return this.mType; + } + + @Override + public String[] getDescription() { + return new String[] { + mOldDesc, + "Decorative Item Storage", + "Right click to store/remove something", + "Ctrl + Rmb to check contents", + "Ctrl + Rmb with a screwdriver to lock", + }; + } + + @Override + public byte getTileEntityBaseType() { + return 0; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + // return aSide != getBaseMetaTileEntity().getFrontFacing(); + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity p0, int p1, byte p2, ItemStack p3) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity p0, int p1, byte p2, ItemStack p3) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[7][17][]; + for (byte i = -1; i < 16; i = (byte) (i + 1)) { + ITexture[] tmp0 = {this.getBottom((byte) 0)[0]}; + rTextures[0][(i + 1)] = tmp0; + ITexture[] tmp1 = {this.getTop((byte) 0)[0]}; + rTextures[1][(i + 1)] = tmp1; + ITexture[] tmp2 = {this.getSides((byte) 0)[0]}; + rTextures[2][(i + 1)] = tmp2; + ITexture[] tmp4 = {this.getSides((byte) 0)[0]}; + rTextures[3][(i + 1)] = tmp4; + ITexture[] tmp5 = {this.getSides((byte) 0)[0], getFront((byte) 0)[0]}; + rTextures[4][(i + 1)] = tmp5; + ITexture[] tmp6 = {this.getSides((byte) 0)[0], getFront((byte) 1)[0]}; + rTextures[5][(i + 1)] = tmp6; + ITexture[] tmp7 = {this.getSides((byte) 0)[0], getFront((byte) 2)[0]}; + rTextures[6][(i + 1)] = tmp7; + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + + ITexture[] tmp = this.mTextures[ + (aSide >= 2) + ? ((aSide != aFacing) + ? 2 + : ((byte) this.mType == 0 + ? 4 + : this.mType == 1 || this.mType == 2 ? 5 : this.mType == 3 ? 6 : 0)) + : aSide][ + aColorIndex + 1]; + if (aSide != aFacing && tmp.length == 2) { + tmp = new ITexture[] {tmp[0]}; + } + return tmp; + } + + private static GT_RenderedTexture x1 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_FRONT); + private static GT_RenderedTexture x2 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_PAPER_FRONT); + private static GT_RenderedTexture x3 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_CANS_FRONT); + + public ITexture[] getFrontNormal() { + return new ITexture[] {x1}; + } + + public ITexture[] getFrontActive() { + return new ITexture[] {x2}; + } + + public ITexture[] getFrontAlternative() { + return new ITexture[] {x3}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFrontNormal(); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + public ITexture[] getFront(byte aColour) { + if (aColour == 1) { + return getFrontActive(); + } else if (aColour == 2) { + return getFrontAlternative(); + } + return getFrontNormal(); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (KeyboardUtils.isCtrlKeyDown()) { + if (!aPlayer.getDisplayName() + .equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())) { + PlayerUtils.messagePlayer(aPlayer, "Container is not yours to lock."); + } else { + this.mLocked = Utils.invertBoolean(this.mLocked); + if (this.mLocked) { + PlayerUtils.messagePlayer(aPlayer, "Container is now locked."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Container is now unlocked."); + } + } + } else { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java index 7dcb76a22e..93361a523f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java @@ -1,39 +1,38 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; -import net.minecraft.entity.player.EntityPlayer; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; public class GT4Entity_Shelf_Compartment extends GT4Entity_Shelf { - - public GT4Entity_Shelf_Compartment(final int aID, final String aName, final String aNameRegional, final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_Compartment(String mName, String mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } + public GT4Entity_Shelf_Compartment( + final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_Compartment(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Compartment(this.mName, this.mDescription, this.mTextures); - } + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Compartment(this.mName, this.mDescription, this.mTextures); + } - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { - this.mType = ((byte) ((this.mType + 1) % 16)); - PlayerUtils.messagePlayer(aPlayer, "Set type to "+this.mType+"."); - } - } + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + this.mType = ((byte) ((this.mType + 1) % 16)); + PlayerUtils.messagePlayer(aPlayer, "Set type to " + this.mType + "."); + } + } - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{TexturesGtBlock.OVERLAYS_COMPARTMENT_FRONT[this.mType < 16 ? this.mType : 0]}; - } + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {TexturesGtBlock.OVERLAYS_COMPARTMENT_FRONT[this.mType < 16 ? this.mType : 0]}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java index 2c7186a3ce..c9472e157c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java @@ -4,42 +4,42 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GT4Entity_Shelf_Desk extends GT4Entity_Shelf { - public GT4Entity_Shelf_Desk(final int aID, final String aName, final String aNameRegional, final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_Desk(String mName, String mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Desk(this.mName, this.mDescription, this.mTextures); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0]}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; - } + public GT4Entity_Shelf_Desk( + final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_Desk(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Desk(this.mName, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java index 93bb7d5bb9..9c4ae3aefa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java @@ -1,55 +1,54 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; -import net.minecraft.entity.player.EntityPlayer; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; - import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; public class GT4Entity_Shelf_FileCabinet extends GT4Entity_Shelf { - public GT4Entity_Shelf_FileCabinet(final int aID, final String aName, final String aNameRegional, final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_FileCabinet(String mName, String mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { - this.mType = ((byte) ((this.mType + 1) % 16)); - PlayerUtils.messagePlayer(aPlayer, "Set type to "+this.mType+"."); - } - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_FileCabinet(this.mName, this.mDescription, this.mTextures); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0]}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{texSide}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{texBottom}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{texTop}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{texSide}; - } + public GT4Entity_Shelf_FileCabinet( + final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_FileCabinet(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + this.mType = ((byte) ((this.mType + 1) % 16)); + PlayerUtils.messagePlayer(aPlayer, "Set type to " + this.mType + "."); + } + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_FileCabinet(this.mName, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {texSide}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {texBottom}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {texTop}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {texSide}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java index 606496501f..17110e691b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java @@ -6,36 +6,37 @@ import gregtech.api.metatileentity.MetaTileEntity; public class GT4Entity_Shelf_Iron extends GT4Entity_Shelf { - public GT4Entity_Shelf_Iron(final int aID, final String aName, final String aNameRegional, final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_Iron(String mName, String mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Iron(this.mName, this.mDescription, this.mTextures); - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{texSideCabinet}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{texSide}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{texBottom}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{texTop}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{texSide}; - } + public GT4Entity_Shelf_Iron( + final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_Iron(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Iron(this.mName, this.mDescription, this.mTextures); + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {texSideCabinet}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {texSide}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {texBottom}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {texTop}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {texSide}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java index cc17f49d83..03735ad381 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java @@ -1,266 +1,264 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SuperChest; import gtPlusPlus.xmod.gregtech.api.gui.GUI_SuperChest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; public class GT4Entity_Shelf_Large extends GT4Entity_Shelf { - private final int mSize; - public int mItemCount; - public ItemStack mItemStack; - - - public GT4Entity_Shelf_Large(final int aID, final String aName, final String aNameRegional, final String aDescription, final int aSize) { - super(aID, aName, aNameRegional, aDescription); - this.mSize = aSize; - this.mItemCount = 0; - this.mItemStack = null; - } - - public GT4Entity_Shelf_Large(String mName, String mDescriptionArray, final int aSize, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - this.mSize = aSize; - this.mItemCount = 0; - this.mItemStack = null; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Large(this.mName, this.mDescription, mSize, this.mTextures); - } - - /*@Override - public int getInvSize() { - return (mSize > 0 && mSize < 255 ? mSize : 255); - }*/ - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean isDigitalChest() { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - if (KeyboardUtils.isCtrlKeyDown()) { - String itemName = (this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing."); - String itemAmount = (this.mItemCount > 0 ? ""+this.mItemCount : "bad"); - String itemMessage = "This container currently holds "+(itemAmount.equalsIgnoreCase("bad") ? "nothing." : itemName+" x"+itemAmount+"."); - PlayerUtils.messagePlayer(aPlayer, itemMessage); - } - else { - aBaseMetaTileEntity.openGUI(aPlayer); - } - return true; - } - - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); - } - - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mItemCount", this.mItemCount); - if (this.mItemStack != null) { - aNBT.setTag("mItemStack", (NBTBase) this.mItemStack.writeToNBT(new NBTTagCompound())); - } - super.saveNBTData(aNBT); - - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mItemCount")) { - this.mItemCount = aNBT.getInteger("mItemCount"); - } - if (aNBT.hasKey("mItemStack")) { - this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); - } - super.loadNBTData(aNBT); - } - - @Override - public void onOpenGUI() { - super.onOpenGUI(); - } - - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { - try { - if (this.mInventory[0] != null) { - this.mType = (byte) this.mIndex; - } - else { - this.mType = 0; - } - - if (this.getItemCount() <= 0) { - this.mItemStack = null; - this.mItemCount = 0; - } - if (this.mItemStack == null && this.mInventory[0] != null) { - this.mItemStack = this.mInventory[0].copy(); - } - if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() - && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { - this.mItemCount += this.mInventory[0].stackSize; - if (this.mItemCount > this.getMaxItemCount()) { - this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); - this.mItemCount = this.getMaxItemCount(); - } else { - this.mInventory[0] = null; - } - } - if (this.mInventory[1] == null && this.mItemStack != null) { - this.mInventory[1] = this.mItemStack.copy(); - this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - this.mItemCount -= this.mInventory[1].stackSize; - } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) - && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { - final int tmp = Math.min(this.mItemCount, - this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); - final ItemStack itemStack = this.mInventory[1]; - itemStack.stackSize += tmp; - this.mItemCount -= tmp; - } - if (this.mItemStack != null) { - this.mInventory[2] = this.mItemStack.copy(); - this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - } else { - this.mInventory[2] = null; - } - } - catch (Throwable t) { - if (t instanceof ArrayIndexOutOfBoundsException) { - - } - } - } - } - - private int getItemCount() { - return this.mItemCount; - } - - public void setItemCount(final int aCount) { - this.mItemCount = aCount; - } - - public int getProgresstime() { - try { - return this.mItemCount + ((this.mInventory[0] == null) ? 0 : this.mInventory[0].stackSize) - + ((this.mInventory[1] == null) ? 0 : this.mInventory[1].stackSize); - } - catch (Throwable t) { - return 0; - } - } - - public int maxProgresstime() { - return this.getMaxItemCount(); - } - - public int getMaxItemCount() { - return this.mSize; - } - - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return aIndex == 1; - } - - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return aIndex == 0 && ((this.mInventory[0] == null && this.mItemStack == null) || GT_Utility.areStacksEqual(this.mInventory[0], aStack) || (this.mItemStack != null && GT_Utility.areStacksEqual(this.mItemStack, aStack))); - } - - public String[] getInfoData() { - if (this.mItemStack == null) { - return new String[]{ - this.getLocalName(), "No Items Stored", "Free Space: "+Integer.toString(this.getMaxItemCount())}; - } - return new String[]{ - this.getLocalName(), - "Storing: "+this.mItemStack.getDisplayName()+" x"+Integer.toString(this.mItemCount), - "Space Remaining: "+Integer.toString(this.getMaxItemCount()-this.getItemCount())+"/"+Integer.toString(this.getMaxItemCount())}; - } - - @Override - public String[] getDescription() { - String[] mSuper = super.getDescription(); - String[] desc = new String[mSuper.length+1]; - for (int i=0;i>mSuper.length;i++) { - desc[i] = mSuper[i]; - } - desc[desc.length-1] = "Control + Rmb block to check contents"; - return desc; - } - - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - Logger.INFO("1:"+aIndex); - if (aIndex == 2) { - if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { - return true; - } - else { - if (mItemStack == null) { - return true; - } - return false; - } - } - return super.isItemValidForSlot(aIndex, aStack); - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - Logger.INFO("2:"+aIndex); - if (aIndex == 0) { - if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { - return true; - } - else { - if (mItemStack == null) { - return true; - } - return false; - } - } - return super.canInsertItem(aIndex, aStack, aSide); - } - - + private final int mSize; + public int mItemCount; + public ItemStack mItemStack; + + public GT4Entity_Shelf_Large( + final int aID, final String aName, final String aNameRegional, final String aDescription, final int aSize) { + super(aID, aName, aNameRegional, aDescription); + this.mSize = aSize; + this.mItemCount = 0; + this.mItemStack = null; + } + + public GT4Entity_Shelf_Large(String mName, String mDescriptionArray, final int aSize, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + this.mSize = aSize; + this.mItemCount = 0; + this.mItemStack = null; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Large(this.mName, this.mDescription, mSize, this.mTextures); + } + + /*@Override + public int getInvSize() { + return (mSize > 0 && mSize < 255 ? mSize : 255); + }*/ + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isDigitalChest() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + if (KeyboardUtils.isCtrlKeyDown()) { + String itemName = (this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing."); + String itemAmount = (this.mItemCount > 0 ? "" + this.mItemCount : "bad"); + String itemMessage = "This container currently holds " + + (itemAmount.equalsIgnoreCase("bad") ? "nothing." : itemName + " x" + itemAmount + "."); + PlayerUtils.messagePlayer(aPlayer, itemMessage); + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + } + return true; + } + + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) { + aNBT.setTag("mItemStack", (NBTBase) this.mItemStack.writeToNBT(new NBTTagCompound())); + } + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) { + this.mItemCount = aNBT.getInteger("mItemCount"); + } + if (aNBT.hasKey("mItemStack")) { + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + super.loadNBTData(aNBT); + } + + @Override + public void onOpenGUI() { + super.onOpenGUI(); + } + + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { + if (this.getBaseMetaTileEntity().isServerSide() + && this.getBaseMetaTileEntity().isAllowedToWork()) { + try { + if (this.mInventory[0] != null) { + this.mType = (byte) this.mIndex; + } else { + this.mType = 0; + } + + if (this.getItemCount() <= 0) { + this.mItemStack = null; + this.mItemCount = 0; + } + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = this.mInventory[0].copy(); + } + if (this.mInventory[0] != null + && this.mItemCount < this.getMaxItemCount() + && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > this.getMaxItemCount()) { + this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); + this.mItemCount = this.getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + if (this.mInventory[1] == null && this.mItemStack != null) { + this.mInventory[1] = this.mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if (this.mItemCount > 0 + && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) + && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + final int tmp = Math.min( + this.mItemCount, this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + final ItemStack itemStack = this.mInventory[1]; + itemStack.stackSize += tmp; + this.mItemCount -= tmp; + } + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + } else { + this.mInventory[2] = null; + } + } catch (Throwable t) { + if (t instanceof ArrayIndexOutOfBoundsException) {} + } + } + } + + private int getItemCount() { + return this.mItemCount; + } + + public void setItemCount(final int aCount) { + this.mItemCount = aCount; + } + + public int getProgresstime() { + try { + return this.mItemCount + + ((this.mInventory[0] == null) ? 0 : this.mInventory[0].stackSize) + + ((this.mInventory[1] == null) ? 0 : this.mInventory[1].stackSize); + } catch (Throwable t) { + return 0; + } + } + + public int maxProgresstime() { + return this.getMaxItemCount(); + } + + public int getMaxItemCount() { + return this.mSize; + } + + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex == 1; + } + + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex == 0 + && ((this.mInventory[0] == null && this.mItemStack == null) + || GT_Utility.areStacksEqual(this.mInventory[0], aStack) + || (this.mItemStack != null && GT_Utility.areStacksEqual(this.mItemStack, aStack))); + } + + public String[] getInfoData() { + if (this.mItemStack == null) { + return new String[] { + this.getLocalName(), "No Items Stored", "Free Space: " + Integer.toString(this.getMaxItemCount()) + }; + } + return new String[] { + this.getLocalName(), + "Storing: " + this.mItemStack.getDisplayName() + " x" + Integer.toString(this.mItemCount), + "Space Remaining: " + Integer.toString(this.getMaxItemCount() - this.getItemCount()) + "/" + + Integer.toString(this.getMaxItemCount()) + }; + } + + @Override + public String[] getDescription() { + String[] mSuper = super.getDescription(); + String[] desc = new String[mSuper.length + 1]; + for (int i = 0; i > mSuper.length; i++) { + desc[i] = mSuper[i]; + } + desc[desc.length - 1] = "Control + Rmb block to check contents"; + return desc; + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + Logger.INFO("1:" + aIndex); + if (aIndex == 2) { + if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { + return true; + } else { + if (mItemStack == null) { + return true; + } + return false; + } + } + return super.isItemValidForSlot(aIndex, aStack); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + Logger.INFO("2:" + aIndex); + if (aIndex == 0) { + if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { + return true; + } else { + if (mItemStack == null) { + return true; + } + return false; + } + } + return super.canInsertItem(aIndex, aStack, aSide); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java index 27f118e363..e8b72c7ea9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java @@ -1,19 +1,16 @@ package gtPlusPlus.xmod.gregtech.common.tools; -import java.util.Arrays; -import java.util.List; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures.ItemIcons; import gregtech.api.interfaces.IIconContainer; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.items.behaviors.Behaviour_None; import gregtech.common.tools.GT_Tool; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; -import gtPlusPlus.xmod.gregtech.common.items.behaviours.Behaviour_Choocher; +import java.util.Arrays; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -26,174 +23,178 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; import net.minecraftforge.event.world.BlockEvent; -public class TOOL_Gregtech_AngleGrinder -extends GT_Tool { - - public static final List mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); - - - @Override - public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { - String tName = aEntity.getClass().getName(); - tName = tName.substring(tName.lastIndexOf(".") + 1); - return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; - } - - @Override - public int getToolDamagePerBlockBreak() { - return 50; - } - - @Override - public int getToolDamagePerDropConversion() { - return 100; - } - - @Override - public int getToolDamagePerContainerCraft() { - return 400; - } - - @Override - public int getToolDamagePerEntityAttack() { - return 100; - } - - @Override - public int getBaseQuality() { - return 0; - } - - @Override - public float getBaseDamage() { - return 8.0F; - } - - @Override - public float getSpeedMultiplier() { - return 2F; - } - - @Override - public float getMaxDurabilityMultiplier() { - return 1.8F; - } - - @Override - public String getCraftingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(1)); - } - - @Override - public String getEntityHitSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(2)); - } - - @Override - public String getBreakingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(0)); - } - - @Override - public String getMiningSound() { - return null; - } - - @Override - public boolean canBlock() { - return false; - } - - public boolean isWrench(){ - return false; - } - - @Override - public boolean isCrowbar() { - return false; - } - - @Override - public boolean isWeapon() { - return true; - } - - @Override - public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { - final String tTool = aBlock.getHarvestTool(aMetaData); - return (tTool != null) && (tTool.equals("sword") || tTool.equals("file")); - } - - - @Override - public int convertBlockDrops(final List aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { - int rConversions = 0; - /*GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{new ItemStack(aBlock, 1, aMetaData)}); - if ((tRecipe == null) || (aBlock.hasTileEntity(aMetaData))) { - for (final ItemStack tDrop : aDrops) { - tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{GT_Utility.copyAmount(1L, new Object[]{tDrop})}); - if (tRecipe != null) { - final ItemStack tHammeringOutput = tRecipe.getOutput(0); - if (tHammeringOutput != null) { - rConversions += tDrop.stackSize; - tDrop.stackSize *= tHammeringOutput.stackSize; - tHammeringOutput.stackSize = tDrop.stackSize; - GT_Utility.setStack(tDrop, tHammeringOutput); - } - } - } - } else { - aDrops.clear(); - aDrops.add(tRecipe.getOutput(0)); - rConversions++; - }*/ - return rConversions; - } - - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { - return (IIconContainer) (aIsToolHead - ? TexturesGtTools.ANGLE_GRINDER - : ItemIcons.POWER_UNIT_HV); - } - - public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { - return aIsToolHead - ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa - : Materials.TungstenSteel.mRGBa; - } - - - - - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - super.onToolCrafted(aStack, aPlayer); - aPlayer.triggerAchievement(AchievementList.buildSword); - try { - GT_Mod.achievements.issueAchievement(aPlayer, "tools"); - GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); - } catch (final Exception e) { - } - } - - @Override - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Ground out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); - } - - @Override - public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { - aItem.addItemBehavior(aID, new Behaviour_None()); - } - - @Override - public boolean isGrafter() { - return false; - } - +public class TOOL_Gregtech_AngleGrinder extends GT_Tool { + + public static final List mEffectiveList = + Arrays.asList(new String[] {EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + @Override + public float getNormalDamageAgainstEntity( + final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 8.0F; + } + + @Override + public float getSpeedMultiplier() { + return 2F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.8F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return false; + } + + public boolean isWrench() { + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + final String tTool = aBlock.getHarvestTool(aMetaData); + return (tTool != null) && (tTool.equals("sword") || tTool.equals("file")); + } + + @Override + public int convertBlockDrops( + final List aDrops, + final ItemStack aStack, + final EntityPlayer aPlayer, + final Block aBlock, + final int aX, + final int aY, + final int aZ, + final byte aMetaData, + final int aFortune, + final boolean aSilkTouch, + final BlockEvent.HarvestDropsEvent aEvent) { + int rConversions = 0; + /*GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{new ItemStack(aBlock, 1, aMetaData)}); + if ((tRecipe == null) || (aBlock.hasTileEntity(aMetaData))) { + for (final ItemStack tDrop : aDrops) { + tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{GT_Utility.copyAmount(1L, new Object[]{tDrop})}); + if (tRecipe != null) { + final ItemStack tHammeringOutput = tRecipe.getOutput(0); + if (tHammeringOutput != null) { + rConversions += tDrop.stackSize; + tDrop.stackSize *= tHammeringOutput.stackSize; + tHammeringOutput.stackSize = tDrop.stackSize; + GT_Utility.setStack(tDrop, tHammeringOutput); + } + } + } + } else { + aDrops.clear(); + aDrops.add(tRecipe.getOutput(0)); + rConversions++; + }*/ + return rConversions; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead ? TexturesGtTools.ANGLE_GRINDER : ItemIcons.POWER_UNIT_HV); + } + + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : Materials.TungstenSteel.mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + + " has been Ground out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_None()); + } + + @Override + public boolean isGrafter() { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Base.java index 97f9a43187..db93f8fdd1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Base.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Base.java @@ -1,7 +1,10 @@ package gtPlusPlus.xmod.gregtech.common.tools; +import gregtech.api.GregTech_API; +import gregtech.api.damagesources.GT_DamageSources; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; @@ -12,169 +15,178 @@ import net.minecraft.stats.AchievementList; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSource; import net.minecraft.util.IChatComponent; - -import gregtech.api.GregTech_API; -import gregtech.api.damagesources.GT_DamageSources; - -import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; -import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; import net.minecraftforge.event.world.BlockEvent; -public abstract class TOOL_Gregtech_Base -implements Interface_ToolStats { - public static final Enchantment[] FORTUNE_ENCHANTMENT = {Enchantment.fortune}; - public static final Enchantment[] LOOTING_ENCHANTMENT = {Enchantment.looting}; - public static final Enchantment[] ZERO_ENCHANTMENTS = new Enchantment[0]; - public static final int[] ZERO_ENCHANTMENT_LEVELS = new int[0]; - - @Override - public int getToolDamagePerBlockBreak() { - return 100; - } - - @Override - public int getToolDamagePerDropConversion() { - return 100; - } - - @Override - public int getToolDamagePerContainerCraft() { - return 800; - } - - @Override - public int getToolDamagePerEntityAttack() { - return 200; - } - - @Override - public float getSpeedMultiplier() { - return 1.0F; - } - - @Override - public float getMaxDurabilityMultiplier() { - return 1.0F; - } - - @Override - public int getHurtResistanceTime(final int aOriginalHurtResistance, final Entity aEntity) { - return aOriginalHurtResistance; - } - - @Override - public String getMiningSound() { - return null; - } - - @Override - public String getCraftingSound() { - return null; - } - - @Override - public String getEntityHitSound() { - return null; - } - - @Override - public String getBreakingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(0)); - } - - @Override - public int getBaseQuality() { - return 0; - } - - @Override - public boolean canBlock() { - return false; - } - - @Override - public boolean isCrowbar() { - return false; - } - - @Override - public boolean isWrench() { - return false; - } - - @Override - public boolean isWeapon() { - return false; - } - - @Override - public boolean isRangedWeapon() { - return false; - } - - @Override - public boolean isMiningTool() { - return true; - } - - public boolean isChainsaw(){ - return false; - } - - - @Override - public boolean isGrafter(){ - return false; - } - - - @Override - public DamageSource getDamageSource(final EntityLivingBase aPlayer, final Entity aEntity) { - return GT_DamageSources.getCombatDamage((aPlayer instanceof EntityPlayer) ? "player" : "mob", aPlayer, (aEntity instanceof EntityLivingBase) ? this.getDeathMessage(aPlayer, (EntityLivingBase) aEntity) : null); - } - - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new EntityDamageSource((aPlayer instanceof EntityPlayer) ? "player" : "mob", aPlayer).func_151519_b(aEntity); - } - - @Override - public int convertBlockDrops(final List aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { - return 0; - } - - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - @Override - public Enchantment[] getEnchantments(final ItemStack aStack) { - return ZERO_ENCHANTMENTS; - } - - @Override - public int[] getEnchantmentLevels(final ItemStack aStack) { - return ZERO_ENCHANTMENT_LEVELS; - } - - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - aPlayer.triggerAchievement(AchievementList.openInventory); - aPlayer.triggerAchievement(AchievementList.mineWood); - aPlayer.triggerAchievement(AchievementList.buildWorkBench); - } - - @Override - public void onStatsAddedToTool(final Gregtech_MetaTool aItem, final int aID) { - } - - @Override - public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { - return aOriginalDamage; - } - - @Override - public float getMagicDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { - return aOriginalDamage; - } +public abstract class TOOL_Gregtech_Base implements Interface_ToolStats { + public static final Enchantment[] FORTUNE_ENCHANTMENT = {Enchantment.fortune}; + public static final Enchantment[] LOOTING_ENCHANTMENT = {Enchantment.looting}; + public static final Enchantment[] ZERO_ENCHANTMENTS = new Enchantment[0]; + public static final int[] ZERO_ENCHANTMENT_LEVELS = new int[0]; + + @Override + public int getToolDamagePerBlockBreak() { + return 100; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 800; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 200; + } + + @Override + public float getSpeedMultiplier() { + return 1.0F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.0F; + } + + @Override + public int getHurtResistanceTime(final int aOriginalHurtResistance, final Entity aEntity) { + return aOriginalHurtResistance; + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public String getCraftingSound() { + return null; + } + + @Override + public String getEntityHitSound() { + return null; + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public boolean canBlock() { + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWrench() { + return false; + } + + @Override + public boolean isWeapon() { + return false; + } + + @Override + public boolean isRangedWeapon() { + return false; + } + + @Override + public boolean isMiningTool() { + return true; + } + + public boolean isChainsaw() { + return false; + } + + @Override + public boolean isGrafter() { + return false; + } + + @Override + public DamageSource getDamageSource(final EntityLivingBase aPlayer, final Entity aEntity) { + return GT_DamageSources.getCombatDamage( + (aPlayer instanceof EntityPlayer) ? "player" : "mob", + aPlayer, + (aEntity instanceof EntityLivingBase) + ? this.getDeathMessage(aPlayer, (EntityLivingBase) aEntity) + : null); + } + + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new EntityDamageSource((aPlayer instanceof EntityPlayer) ? "player" : "mob", aPlayer) + .func_151519_b(aEntity); + } + + @Override + public int convertBlockDrops( + final List aDrops, + final ItemStack aStack, + final EntityPlayer aPlayer, + final Block aBlock, + final int aX, + final int aY, + final int aZ, + final byte aMetaData, + final int aFortune, + final boolean aSilkTouch, + final BlockEvent.HarvestDropsEvent aEvent) { + return 0; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + @Override + public Enchantment[] getEnchantments(final ItemStack aStack) { + return ZERO_ENCHANTMENTS; + } + + @Override + public int[] getEnchantmentLevels(final ItemStack aStack) { + return ZERO_ENCHANTMENT_LEVELS; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + aPlayer.triggerAchievement(AchievementList.openInventory); + aPlayer.triggerAchievement(AchievementList.mineWood); + aPlayer.triggerAchievement(AchievementList.buildWorkBench); + } + + @Override + public void onStatsAddedToTool(final Gregtech_MetaTool aItem, final int aID) {} + + @Override + public float getNormalDamageAgainstEntity( + final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + return aOriginalDamage; + } + + @Override + public float getMagicDamageAgainstEntity( + final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + return aOriginalDamage; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Choocher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Choocher.java index 1fd1e8241a..efdf8b18e9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Choocher.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Choocher.java @@ -1,8 +1,16 @@ package gtPlusPlus.xmod.gregtech.common.tools; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tools.GT_Tool; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; +import gtPlusPlus.xmod.gregtech.common.items.behaviours.Behaviour_Choocher; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -15,182 +23,217 @@ import net.minecraft.stats.AchievementList; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; - -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.tools.GT_Tool; - -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; -import gtPlusPlus.xmod.gregtech.common.items.behaviours.Behaviour_Choocher; import net.minecraftforge.event.world.BlockEvent; -public class TOOL_Gregtech_Choocher -extends GT_Tool { - - public static final List mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); - - - @Override - public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { - String tName = aEntity.getClass().getName(); - tName = tName.substring(tName.lastIndexOf(".") + 1); - return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; - } - - @Override - public int getToolDamagePerBlockBreak() { - return 50; - } - - @Override - public int getToolDamagePerDropConversion() { - return 100; - } - - @Override - public int getToolDamagePerContainerCraft() { - return 400; - } - - @Override - public int getToolDamagePerEntityAttack() { - return 100; - } - - @Override - public int getBaseQuality() { - return 0; - } - - @Override - public float getBaseDamage() { - return 4.0F; - } - - @Override - public float getSpeedMultiplier() { - return 0.85F; - } - - @Override - public float getMaxDurabilityMultiplier() { - return 1.2F; - } - - @Override - public String getCraftingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(1)); - } - - @Override - public String getEntityHitSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(2)); - } - - @Override - public String getBreakingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(0)); - } - - @Override - public String getMiningSound() { - return null; - } - - @Override - public boolean canBlock() { - return true; - } - - public boolean isWrench(){ - return true; - } - - @Override - public boolean isCrowbar() { - return false; - } - - @Override - public boolean isWeapon() { - return true; - } - - @Override - public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { - final String tTool = aBlock.getHarvestTool(aMetaData); - return ((tTool != null) && ((tTool.equals("sword")) || (tTool.equals("wrench")) || (tTool.equals("hammer")) || (tTool.equals("pickaxe")))) || (aBlock.getMaterial() == Material.rock) || (aBlock.getMaterial() == Material.glass) || (aBlock.getMaterial() == Material.piston) || (aBlock == Blocks.hopper) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock.getMaterial() == Material.ice) || (aBlock.getMaterial() == Material.packedIce) || (GT_Recipe.GT_Recipe_Map.sHammerRecipes.containsInput(new ItemStack(aBlock, 1, aMetaData))) || (aBlock.getMaterial() == Material.sand) || (aBlock.getMaterial() == Material.grass) || (aBlock.getMaterial() == Material.ground) || (aBlock.getMaterial() == Material.snow) || (aBlock.getMaterial() == Material.clay) || (aBlock.getMaterial() == Material.leaves) || (aBlock.getMaterial() == Material.vine) || (aBlock.getMaterial() == Material.wood) || (aBlock.getMaterial() == Material.cactus) || (aBlock.getMaterial() == Material.circuits) || (aBlock.getMaterial() == Material.gourd) || (aBlock.getMaterial() == Material.web) || (aBlock.getMaterial() == Material.cloth) || (aBlock.getMaterial() == Material.carpet) || (aBlock.getMaterial() == Material.plants) || (aBlock.getMaterial() == Material.cake) || (aBlock.getMaterial() == Material.tnt) || (aBlock.getMaterial() == Material.sponge); - } - - @Override - public int convertBlockDrops(final List aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { - int rConversions = 0; - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{new ItemStack(aBlock, 1, aMetaData)}); - if ((tRecipe == null) || (aBlock.hasTileEntity(aMetaData))) { - for (final ItemStack tDrop : aDrops) { - tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{GT_Utility.copyAmount(1L, new Object[]{tDrop})}); - if (tRecipe != null) { - final ItemStack tHammeringOutput = tRecipe.getOutput(0); - if (tHammeringOutput != null) { - rConversions += tDrop.stackSize; - tDrop.stackSize *= tHammeringOutput.stackSize; - tHammeringOutput.stackSize = tDrop.stackSize; - GT_Utility.setStack(tDrop, tHammeringOutput); - } - } - } - } else { - aDrops.clear(); - aDrops.add(tRecipe.getOutput(0)); - rConversions++; - } - return rConversions; - } - - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - @Override - public IIconContainer getIcon(final boolean aIsToolHead, final ItemStack aStack) { - //Utils.LOG_INFO("Texture: "+TexturesGtTools.SKOOKUM_CHOOCHER.getTextureFile()); - return TexturesGtTools.SKOOKUM_CHOOCHER; - } - - @Override - public short[] getRGBa(final boolean aIsToolHead, final ItemStack aStack) { - return GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa; - } - - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - super.onToolCrafted(aStack, aPlayer); - aPlayer.triggerAchievement(AchievementList.buildSword); - try { - GT_Mod.achievements.issueAchievement(aPlayer, "tools"); - GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); - } catch (final Exception e) { - } - } - - @Override - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Choochered by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); - } - - @Override - public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { - aItem.addItemBehavior(aID, new Behaviour_Choocher()); - } - - @Override - public boolean isGrafter() { - return false; - } - +public class TOOL_Gregtech_Choocher extends GT_Tool { + + public static final List mEffectiveList = + Arrays.asList(new String[] {EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + @Override + public float getNormalDamageAgainstEntity( + final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 4.0F; + } + + @Override + public float getSpeedMultiplier() { + return 0.85F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.2F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return true; + } + + public boolean isWrench() { + return true; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + final String tTool = aBlock.getHarvestTool(aMetaData); + return ((tTool != null) + && ((tTool.equals("sword")) + || (tTool.equals("wrench")) + || (tTool.equals("hammer")) + || (tTool.equals("pickaxe")))) + || (aBlock.getMaterial() == Material.rock) + || (aBlock.getMaterial() == Material.glass) + || (aBlock.getMaterial() == Material.piston) + || (aBlock == Blocks.hopper) + || (aBlock == Blocks.dispenser) + || (aBlock == Blocks.dropper) + || (aBlock.getMaterial() == Material.ice) + || (aBlock.getMaterial() == Material.packedIce) + || (GT_Recipe.GT_Recipe_Map.sHammerRecipes.containsInput(new ItemStack(aBlock, 1, aMetaData))) + || (aBlock.getMaterial() == Material.sand) + || (aBlock.getMaterial() == Material.grass) + || (aBlock.getMaterial() == Material.ground) + || (aBlock.getMaterial() == Material.snow) + || (aBlock.getMaterial() == Material.clay) + || (aBlock.getMaterial() == Material.leaves) + || (aBlock.getMaterial() == Material.vine) + || (aBlock.getMaterial() == Material.wood) + || (aBlock.getMaterial() == Material.cactus) + || (aBlock.getMaterial() == Material.circuits) + || (aBlock.getMaterial() == Material.gourd) + || (aBlock.getMaterial() == Material.web) + || (aBlock.getMaterial() == Material.cloth) + || (aBlock.getMaterial() == Material.carpet) + || (aBlock.getMaterial() == Material.plants) + || (aBlock.getMaterial() == Material.cake) + || (aBlock.getMaterial() == Material.tnt) + || (aBlock.getMaterial() == Material.sponge); + } + + @Override + public int convertBlockDrops( + final List aDrops, + final ItemStack aStack, + final EntityPlayer aPlayer, + final Block aBlock, + final int aX, + final int aY, + final int aZ, + final byte aMetaData, + final int aFortune, + final boolean aSilkTouch, + final BlockEvent.HarvestDropsEvent aEvent) { + int rConversions = 0; + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe( + null, true, 2147483647L, null, new ItemStack[] {new ItemStack(aBlock, 1, aMetaData)}); + if ((tRecipe == null) || (aBlock.hasTileEntity(aMetaData))) { + for (final ItemStack tDrop : aDrops) { + tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe( + null, true, 2147483647L, null, new ItemStack[] {GT_Utility.copyAmount(1L, new Object[] {tDrop}) + }); + if (tRecipe != null) { + final ItemStack tHammeringOutput = tRecipe.getOutput(0); + if (tHammeringOutput != null) { + rConversions += tDrop.stackSize; + tDrop.stackSize *= tHammeringOutput.stackSize; + tHammeringOutput.stackSize = tDrop.stackSize; + GT_Utility.setStack(tDrop, tHammeringOutput); + } + } + } + } else { + aDrops.clear(); + aDrops.add(tRecipe.getOutput(0)); + rConversions++; + } + return rConversions; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + @Override + public IIconContainer getIcon(final boolean aIsToolHead, final ItemStack aStack) { + // Utils.LOG_INFO("Texture: "+TexturesGtTools.SKOOKUM_CHOOCHER.getTextureFile()); + return TexturesGtTools.SKOOKUM_CHOOCHER; + } + + @Override + public short[] getRGBa(final boolean aIsToolHead, final ItemStack aStack) { + return GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + + " has been Choochered by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_Choocher()); + } + + @Override + public boolean isGrafter() { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricButcherKnife.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricButcherKnife.java index 7aa7529817..06e429514e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricButcherKnife.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricButcherKnife.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tools; -import java.util.Arrays; -import java.util.List; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; @@ -12,6 +9,8 @@ import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.items.behaviors.Behaviour_None; import gregtech.common.tools.GT_Tool; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; +import java.util.Arrays; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; @@ -23,170 +22,163 @@ import net.minecraft.stats.AchievementList; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; -import net.minecraftforge.event.world.BlockEvent; - -public class TOOL_Gregtech_ElectricButcherKnife -extends GT_Tool { - - public static final List mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); - - - @Override - public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { - String tName = aEntity.getClass().getName(); - tName = tName.substring(tName.lastIndexOf(".") + 1); - return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; - } - - @Override - public int getToolDamagePerBlockBreak() { - return 100; - } - - @Override - public int getToolDamagePerDropConversion() { - return 100; - } - - @Override - public int getToolDamagePerContainerCraft() { - return 100; - } - - @Override - public int getToolDamagePerEntityAttack() { - return 200; - } - - @Override - public int getBaseQuality() { - return 0; - } - - @Override - public float getBaseDamage() { - return 8.0F; - } - - @Override - public float getSpeedMultiplier() { - return 2F; - } - - @Override - public float getMaxDurabilityMultiplier() { - return 1.8F; - } - - @Override - public String getCraftingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(1)); - } - - @Override - public String getEntityHitSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(2)); - } - - @Override - public String getBreakingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(0)); - } - - @Override - public String getMiningSound() { - return null; - } - - @Override - public boolean canBlock() { - return false; - } - - public boolean isWrench(){ - return false; - } - - @Override - public boolean isCrowbar() { - return false; - } - - @Override - public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { - final String tTool = aBlock.getHarvestTool(aMetaData); - return (tTool != null) && (tTool.equals("sword") || tTool.equals("knife")); - } - - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { - return (IIconContainer) (aIsToolHead - ? TexturesGtTools.ELECTRIC_BUTCHER_KNIFE - : ItemIcons.POWER_UNIT_HV); - } - - public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { - return aIsToolHead - ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa - : Materials.RedSteel.mRGBa; - } - - - - - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - super.onToolCrafted(aStack, aPlayer); - aPlayer.triggerAchievement(AchievementList.buildSword); - try { - GT_Mod.achievements.issueAchievement(aPlayer, "tools"); - GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); - } catch (final Exception e) { - } - } - - @Override - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Sliced out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); - } - - @Override - public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { - aItem.addItemBehavior(aID, new Behaviour_None()); - } - - @Override - public boolean isGrafter() { - return false; - } - - @Override - public int getHurtResistanceTime(int aOriginalHurtResistance, Entity aEntity) { - return aOriginalHurtResistance * 2; - } - - @Override - public boolean isWeapon() { - return true; - } - - @Override - public boolean isMiningTool() { - return false; - } - - @Override - public Enchantment[] getEnchantments(ItemStack aStack) { - return LOOTING_ENCHANTMENT; - } - - @Override - public int[] getEnchantmentLevels(ItemStack aStack) { - return new int[]{(4 + GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolQuality) / 2}; - } - + +public class TOOL_Gregtech_ElectricButcherKnife extends GT_Tool { + + public static final List mEffectiveList = + Arrays.asList(new String[] {EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + @Override + public float getNormalDamageAgainstEntity( + final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 100; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 100; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 200; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 8.0F; + } + + @Override + public float getSpeedMultiplier() { + return 2F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.8F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return false; + } + + public boolean isWrench() { + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + final String tTool = aBlock.getHarvestTool(aMetaData); + return (tTool != null) && (tTool.equals("sword") || tTool.equals("knife")); + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead ? TexturesGtTools.ELECTRIC_BUTCHER_KNIFE : ItemIcons.POWER_UNIT_HV); + } + + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : Materials.RedSteel.mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + + " has been Sliced out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_None()); + } + + @Override + public boolean isGrafter() { + return false; + } + + @Override + public int getHurtResistanceTime(int aOriginalHurtResistance, Entity aEntity) { + return aOriginalHurtResistance * 2; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMiningTool() { + return false; + } + + @Override + public Enchantment[] getEnchantments(ItemStack aStack) { + return LOOTING_ENCHANTMENT; + } + + @Override + public int[] getEnchantmentLevels(ItemStack aStack) { + return new int[] {(4 + GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolQuality) / 2}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricLighter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricLighter.java index 395a7c42cb..b1f4385a11 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricLighter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricLighter.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tools; -import java.util.Arrays; -import java.util.List; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; @@ -12,6 +9,8 @@ import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.tools.GT_Tool; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; import gtPlusPlus.xmod.gregtech.common.items.behaviours.Behaviour_Electric_Lighter; +import java.util.Arrays; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -23,144 +22,141 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; -public class TOOL_Gregtech_ElectricLighter -extends GT_Tool { - - public static final List mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); - - - @Override - public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { - String tName = aEntity.getClass().getName(); - tName = tName.substring(tName.lastIndexOf(".") + 1); - return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; - } - - @Override - public int getToolDamagePerBlockBreak() { - return 50; - } - - @Override - public int getToolDamagePerDropConversion() { - return 100; - } - - @Override - public int getToolDamagePerContainerCraft() { - return 400; - } - - @Override - public int getToolDamagePerEntityAttack() { - return 100; - } - - @Override - public int getBaseQuality() { - return 0; - } - - @Override - public float getBaseDamage() { - return 8.0F; - } - - @Override - public float getSpeedMultiplier() { - return 2F; - } - - @Override - public float getMaxDurabilityMultiplier() { - return 1.8F; - } - - @Override - public String getCraftingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(1)); - } - - @Override - public String getEntityHitSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(2)); - } - - @Override - public String getBreakingSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(0)); - } - - @Override - public String getMiningSound() { - return null; - } - - @Override - public boolean canBlock() { - return false; - } - - public boolean isWrench(){ - return false; - } - - @Override - public boolean isCrowbar() { - return false; - } - - @Override - public boolean isWeapon() { - return true; - } - - @Override - public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { - return false; - } - - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { - return (IIconContainer) (aIsToolHead - ? TexturesGtTools.ELECTRIC_LIGHTER - : ItemIcons.POWER_UNIT_HV); - } - - public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { - return !aIsToolHead - ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa - : Materials.Silver.mRGBa; - } - - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - super.onToolCrafted(aStack, aPlayer); - aPlayer.triggerAchievement(AchievementList.buildSword); - try { - GT_Mod.achievements.issueAchievement(aPlayer, "tools"); - GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); - } catch (final Exception e) { - } - } - - @Override - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been burnt out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); - } - - @Override - public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { - aItem.addItemBehavior(aID, new Behaviour_Electric_Lighter()); - } - - @Override - public boolean isGrafter() { - return false; - } - +public class TOOL_Gregtech_ElectricLighter extends GT_Tool { + + public static final List mEffectiveList = + Arrays.asList(new String[] {EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + @Override + public float getNormalDamageAgainstEntity( + final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 8.0F; + } + + @Override + public float getSpeedMultiplier() { + return 2F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.8F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return false; + } + + public boolean isWrench() { + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + return false; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead ? TexturesGtTools.ELECTRIC_LIGHTER : ItemIcons.POWER_UNIT_HV); + } + + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return !aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : Materials.Silver.mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + + " has been burnt out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_Electric_Lighter()); + } + + @Override + public boolean isGrafter() { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java index 2277ce339f..ae477cd7bb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java @@ -15,83 +15,76 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; -public class TOOL_Gregtech_ElectricSnips -extends GT_Tool_WireCutter { +public class TOOL_Gregtech_ElectricSnips extends GT_Tool_WireCutter { + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } - @Override - public int getToolDamagePerBlockBreak() { - return 50; - } + @Override + public int getToolDamagePerDropConversion() { + return 100; + } - @Override - public int getToolDamagePerDropConversion() { - return 100; - } + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } - @Override - public int getToolDamagePerContainerCraft() { - return 400; - } + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } - @Override - public int getToolDamagePerEntityAttack() { - return 100; - } + @Override + public int getBaseQuality() { + return 0; + } - @Override - public int getBaseQuality() { - return 0; - } + @Override + public float getBaseDamage() { + return 4.0F; + } - @Override - public float getBaseDamage() { - return 4.0F; - } + @Override + public float getSpeedMultiplier() { + return 1F; + } - @Override - public float getSpeedMultiplier() { - return 1F; - } + @Override + public float getMaxDurabilityMultiplier() { + return 1.4F; + } - @Override - public float getMaxDurabilityMultiplier() { - return 1.4F; - } + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { - return (IIconContainer) (aIsToolHead - ? TexturesGtTools.ELECTRIC_SNIPS - : ItemIcons.POWER_UNIT_MV); - } + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead ? TexturesGtTools.ELECTRIC_SNIPS : ItemIcons.POWER_UNIT_MV); + } - public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { - return aIsToolHead - ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa - : Materials.TungstenSteel.mRGBa; - } - - + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : Materials.TungstenSteel.mRGBa; + } - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - super.onToolCrafted(aStack, aPlayer); - aPlayer.triggerAchievement(AchievementList.buildSword); - try { - GT_Mod.achievements.issueAchievement(aPlayer, "tools"); - GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); - } catch (final Exception e) { - } - } + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } - @Override - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Snipped out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); - } - + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + + " has been Snipped out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + + EnumChatFormatting.WHITE); + } } -- cgit