From 6d1b2216464d4dad449ac6fcfec476832224a55e Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Fri, 24 May 2024 19:50:35 +0100 Subject: Merge addon sources --- .../bartworks/API/API_ConfigValues.java | 20 + .../bartworks/API/BioObjectAdder.java | 197 + .../bartworks/API/BioObjectGetter.java | 112 + .../bartworks/API/BioRecipeAdder.java | 126 + .../bartworks/API/BioVatLogicAdder.java | 325 ++ .../bartworks/API/BorosilicateGlass.java | 211 + .../bartimaeusnek/bartworks/API/INoiseGen.java | 29 + .../bartimaeusnek/bartworks/API/IRadMaterial.java | 39 + .../bartworks/API/ITileAddsInformation.java | 19 + .../bartworks/API/ITileDropsContent.java | 23 + .../API/ITileHasDifferentTextureSides.java | 39 + .../bartimaeusnek/bartworks/API/SideReference.java | 39 + .../bartworks/API/VoidMinerDropAdder.java | 25 + .../bartimaeusnek/bartworks/API/WerkstoffAPI.java | 35 + .../bartworks/API/WerkstoffAdderRegistry.java | 31 + .../bartworks/API/modularUI/BW_UITextures.java | 61 + .../bartimaeusnek/bartworks/API/package-info.java | 17 + .../API/recipe/BWNBTDependantCraftingRecipe.java | 76 + .../bartworks/API/recipe/BacterialVatFrontend.java | 92 + .../bartworks/API/recipe/BartWorksRecipeMaps.java | 91 + .../bartworks/API/recipe/DynamicGTRecipe.java | 34 + .../bartworks/API/recipe/RadioHatchFrontend.java | 45 + .../bartimaeusnek/bartworks/ASM/ASMUtils.java | 54 + .../github/bartimaeusnek/bartworks/ASM/BWCore.java | 84 + .../bartimaeusnek/bartworks/ASM/BWCorePlugin.java | 82 + .../ASM/BWCoreStaticReplacementMethodes.java | 113 + .../bartworks/ASM/BWCoreTransformer.java | 227 + .../github/bartimaeusnek/bartworks/GuiHandler.java | 35 + .../github/bartimaeusnek/bartworks/MainMod.java | 239 + .../client/ClientEventHandler/TooltipCache.java | 53 + .../ClientEventHandler/TooltipEventHandler.java | 127 + .../bartworks/client/creativetabs/BioTab.java | 32 + .../bartworks/client/creativetabs/GT2Tab.java | 31 + .../client/creativetabs/bartworksTab.java | 31 + .../client/gui/BW_GUIContainer_RotorBlock.java | 90 + .../client/renderer/BW_EICPistonVisualizer.java | 112 + .../client/renderer/BW_GT_ItemRenderer.java | 137 + .../client/renderer/BW_GT_Vanilla_Texture.java | 56 + .../client/renderer/BW_Renderer_Block_Ores.java | 159 + .../client/renderer/RendererGlasBlock.java | 111 + .../renderer/RendererSwitchingColorFluid.java | 333 ++ .../client/textures/PrefixTextureLinker.java | 92 + .../bartworks/common/blocks/BW_Blocks.java | 135 + .../bartworks/common/blocks/BW_GlasBlocks.java | 188 + .../bartworks/common/blocks/BW_GlasBlocks2.java | 180 + .../common/blocks/BW_TileEntityContainer.java | 204 + .../BW_TileEntityContainer_MachineBlock.java | 44 + .../blocks/BW_TileEntityContainer_Multiple.java | 164 + .../bartworks/common/blocks/BioFluidBlock.java | 93 + .../bartworks/common/commands/ChangeConfig.java | 72 + .../common/commands/ClearCraftingCache.java | 39 + .../common/commands/GetWorkingDirectory.java | 37 + .../common/commands/PrintRecipeListToFile.java | 62 + .../bartworks/common/commands/RunGC.java | 38 + .../bartworks/common/commands/SummonRuin.java | 46 + .../bartworks/common/configs/ConfigHandler.java | 334 ++ .../bartworks/common/items/BW_ItemBlocks.java | 98 + .../bartworks/common/items/BW_SimpleWindMeter.java | 79 + .../bartworks/common/items/BW_Stonage_Rotors.java | 165 + .../bartworks/common/items/Circuit_Programmer.java | 238 + .../common/items/GT_Destructopack_Item.java | 90 + .../bartworks/common/items/GT_Rockcutter_Item.java | 185 + .../bartworks/common/items/GT_Teslastaff_Item.java | 143 + .../bartworks/common/items/LabModule.java | 41 + .../bartworks/common/items/LabParts.java | 154 + .../bartworks/common/items/SimpleIconItem.java | 35 + .../bartworks/common/items/SimpleSubItemClass.java | 78 + .../common/loaders/ArtificialMicaLine.java | 199 + .../bartworks/common/loaders/BeforeGTPreload.java | 128 + .../bartworks/common/loaders/BioCultureLoader.java | 104 + .../bartworks/common/loaders/BioItemList.java | 107 + .../bartworks/common/loaders/BioLabLoader.java | 23 + .../bartworks/common/loaders/BioRecipeLoader.java | 194 + .../ElectricImplosionCompressorRecipes.java | 213 + .../bartworks/common/loaders/FluidLoader.java | 146 + .../bartworks/common/loaders/GTNHBlocks.java | 147 + .../bartworks/common/loaders/ItemRegistry.java | 453 ++ .../common/loaders/LocalisationLoader.java | 62 + .../common/loaders/RadioHatchMaterialLoader.java | 224 + .../bartworks/common/loaders/RecipeLoader.java | 60 + .../common/loaders/RegisterServerCommands.java | 35 + .../common/loaders/StaticRecipeChangeLoaders.java | 583 +++ .../common/loaders/recipes/Assembler.java | 294 ++ .../common/loaders/recipes/AssemblyLine.java | 85 + .../common/loaders/recipes/Autoclave.java | 41 + .../common/loaders/recipes/Centrifuge.java | 144 + .../common/loaders/recipes/ChemicalBath.java | 84 + .../common/loaders/recipes/ChemicalReactor.java | 29 + .../common/loaders/recipes/CraftingRecipes.java | 462 ++ .../common/loaders/recipes/Electrolyzer.java | 152 + .../common/loaders/recipes/Extractor.java | 45 + .../common/loaders/recipes/FakeRecipes.java | 11 + .../common/loaders/recipes/FluidHeater.java | 27 + .../common/loaders/recipes/FluidSolidifier.java | 103 + .../common/loaders/recipes/FormingPress.java | 77 + .../common/loaders/recipes/LaserEngraver.java | 28 + .../bartworks/common/loaders/recipes/Mixer.java | 65 + .../common/loaders/recipes/Pulverizer.java | 98 + .../common/loaders/recipes/PyrolyseOven.java | 24 + .../bartworks/common/net/BW_Network.java | 162 + .../common/net/CircuitProgrammerPacket.java | 88 + .../bartworks/common/net/EICPacket.java | 60 + .../bartworks/common/net/MetaBlockPacket.java | 108 + .../bartworks/common/net/OreDictCachePacket.java | 71 + .../bartworks/common/net/RendererPacket.java | 99 + .../bartworks/common/net/ServerJoinedPackage.java | 61 + .../classic/BWTileEntityDimIDBridge.java | 24 + .../common/tileentities/classic/BW_RotorBlock.java | 42 + .../BW_TileEntity_ExperimentalFloodGate.java | 126 + .../classic/BW_TileEntity_HeatedWaterPump.java | 374 ++ .../classic/BW_TileEntity_InfinityTank.java | 163 + .../common/tileentities/debug/CreativeScanner.java | 42 + .../tileentities/multis/GT_TileEntity_BioVat.java | 836 +++ .../multis/GT_TileEntity_CircuitAssemblyLine.java | 641 +++ .../tileentities/multis/GT_TileEntity_DEHP.java | 338 ++ .../GT_TileEntity_ElectricImplosionCompressor.java | 550 ++ .../tileentities/multis/GT_TileEntity_HTGR.java | 614 +++ .../tileentities/multis/GT_TileEntity_LESU.java | 598 +++ .../multis/GT_TileEntity_ManualTrafo.java | 365 ++ .../tileentities/multis/GT_TileEntity_THTR.java | 413 ++ .../multis/GT_TileEntity_Windmill.java | 641 +++ .../mega/GT_TileEntity_MegaBlastFurnace.java | 428 ++ .../mega/GT_TileEntity_MegaChemicalReactor.java | 267 + .../mega/GT_TileEntity_MegaDistillTower.java | 449 ++ .../mega/GT_TileEntity_MegaMultiBlockBase.java | 223 + .../multis/mega/GT_TileEntity_MegaOilCracker.java | 459 ++ .../mega/GT_TileEntity_MegaVacuumFreezer.java | 256 + .../tiered/GT_MetaTileEntity_AcidGenerator.java | 157 + .../tiered/GT_MetaTileEntity_BioLab.java | 412 ++ .../GT_MetaTileEntity_CompressedFluidHatch.java | 62 + .../tiered/GT_MetaTileEntity_Diode.java | 136 + .../GT_MetaTileEntity_EnergyDistributor.java | 87 + .../tiered/GT_MetaTileEntity_GiantOutputHatch.java | 42 + .../GT_MetaTileEntity_HumongousInputHatch.java | 46 + .../tiered/GT_MetaTileEntity_RadioHatch.java | 499 ++ .../tiered/GT_MetaTileEntity_Transistor.java | 157 + .../bartworks/neiHandler/BW_NEI_BioLabHandler.java | 71 + .../bartworks/neiHandler/BW_NEI_BioVatHandler.java | 72 + .../bartworks/neiHandler/BW_NEI_OreHandler.java | 250 + .../bartworks/neiHandler/NEI_BW_Config.java | 97 + .../server/EventHandler/ServerEventHandler.java | 95 + .../system/material/BW_GT_MaterialReference.java | 194 + .../material/BW_MetaGeneratedBlock_Item.java | 107 + .../material/BW_MetaGeneratedBlocks_Casing.java | 121 + .../BW_MetaGeneratedBlocks_CasingAdvanced_TE.java | 51 + .../material/BW_MetaGeneratedBlocks_Casing_TE.java | 51 + .../system/material/BW_MetaGeneratedFrames.java | 144 + .../system/material/BW_MetaGeneratedOreTE.java | 116 + .../material/BW_MetaGeneratedSmallOreTE.java | 128 + .../system/material/BW_MetaGenerated_Block_TE.java | 73 + .../system/material/BW_MetaGenerated_Blocks.java | 131 + .../system/material/BW_MetaGenerated_Items.java | 272 + .../system/material/BW_MetaGenerated_Ores.java | 134 + .../material/BW_MetaGenerated_SmallOres.java | 76 + .../BW_MetaGenerated_WerkstoffBlock_TE.java | 50 + .../material/BW_MetaGenerated_WerkstoffBlocks.java | 65 + .../system/material/BW_NonMeta_MaterialItems.java | 161 + .../CircuitGeneration/BW_CircuitsLoader.java | 39 + .../material/CircuitGeneration/BW_Meta_Items.java | 396 ++ .../material/CircuitGeneration/CircuitData.java | 76 + .../CircuitGeneration/CircuitImprintLoader.java | 368 ++ .../CircuitGeneration/CircuitPartLoader.java | 266 + .../material/GT_Enhancement/BWGTMetaItems.java | 213 + .../GT_Enhancement/GTMetaItemEnhancer.java | 145 + .../GT_Enhancement/PlatinumSludgeOverHaul.java | 1158 +++++ .../bartworks/system/material/Werkstoff.java | 1265 +++++ .../bartworks/system/material/WerkstoffLoader.java | 2092 ++++++++ .../material/processingLoaders/AddSomeRecipes.java | 96 + .../processingLoaders/AdditionalRecipes.java | 671 +++ .../material/processingLoaders/DownTierLoader.java | 48 + .../processingLoaders/LoadItemContainers.java | 77 + .../werkstoff_loaders/IWerkstoffRunnable.java | 21 + .../werkstoff_loaders/recipe/AspectLoader.java | 58 + .../werkstoff_loaders/recipe/BlockLoader.java | 74 + .../werkstoff_loaders/recipe/CasingLoader.java | 78 + .../werkstoff_loaders/recipe/CellLoader.java | 332 ++ .../recipe/CraftingMaterialLoader.java | 296 ++ .../werkstoff_loaders/recipe/CrushedLoader.java | 282 + .../werkstoff_loaders/recipe/DustLoader.java | 529 ++ .../werkstoff_loaders/recipe/GemLoader.java | 296 ++ .../werkstoff_loaders/recipe/MetalLoader.java | 66 + .../werkstoff_loaders/recipe/MoltenCellLoader.java | 377 ++ .../recipe/MultipleMetalLoader.java | 69 + .../werkstoff_loaders/recipe/OreLoader.java | 62 + .../werkstoff_loaders/recipe/RawOreLoader.java | 62 + .../recipe/SimpleMetalLoader.java | 250 + .../werkstoff_loaders/recipe/ToolLoader.java | 602 +++ .../registration/AssociationLoader.java | 42 + .../registration/BridgeMaterialsLoader.java | 173 + .../registration/CasingRegistrator.java | 40 + .../bartworks/system/oredict/OreDictAdder.java | 43 + .../bartworks/system/oredict/OreDictHandler.java | 95 + .../bartworks/system/oregen/BW_OreLayer.java | 273 + .../bartworks/system/oregen/BW_WordGenerator.java | 140 + .../system/oregen/BW_WorldGenRoss128b.java | 213 + .../system/oregen/BW_WorldGenRoss128ba.java | 220 + .../bartworks/system/worldgen/GT_WorldgenUtil.java | 49 + .../bartworks/system/worldgen/MapGenRuins.java | 502 ++ .../bartimaeusnek/bartworks/util/BWRecipes.java | 210 + .../bartimaeusnek/bartworks/util/BW_ColorUtil.java | 220 + .../bartworks/util/BW_Tooltip_Reference.java | 57 + .../bartimaeusnek/bartworks/util/BW_Util.java | 803 +++ .../bartimaeusnek/bartworks/util/BioCulture.java | 253 + .../bartimaeusnek/bartworks/util/BioDNA.java | 51 + .../bartimaeusnek/bartworks/util/BioData.java | 173 + .../bartimaeusnek/bartworks/util/BioPlasmid.java | 51 + .../bartworks/util/CachedReflectionUtils.java | 31 + .../bartworks/util/ChatColorHelper.java | 42 + .../bartworks/util/ConnectedBlocksChecker.java | 187 + .../util/ConnectedBlocksCheckerIteration.java | 146 + .../bartimaeusnek/bartworks/util/Coords.java | 79 + .../bartimaeusnek/bartworks/util/EnumUtils.java | 50 + .../bartimaeusnek/bartworks/util/MathUtils.java | 116 + .../bartimaeusnek/bartworks/util/MurmurHash3.java | 309 ++ .../bartworks/util/NoiseUtil/BartsNoise.java | 172 + .../bartworks/util/NoiseUtil/SimplexNoise.java | 396 ++ .../bartworks/util/NonNullWrappedHashMap.java | 56 + .../bartworks/util/NonNullWrappedHashSet.java | 51 + .../github/bartimaeusnek/bartworks/util/Pair.java | 81 + .../bartworks/util/RecipeFinderForParallel.java | 187 + .../bartworks/util/ResultWrongSievert.java | 82 + .../bartimaeusnek/bartworks/util/StreamUtils.java | 38 + .../accessprioritylist/AccessPriorityList.java | 392 ++ .../AccessPriorityListIterators.java | 163 + .../accessprioritylist/AccessPriorityListNode.java | 72 + .../bartworks/util/flowerset/FlowerSet.java | 146 + .../bartimaeusnek/bartworks/util/log/DebugLog.java | 65 + .../bartimaeusnek/bartworks/util/package-info.java | 19 + .../bartimaeusnek/crossmod/BartWorksCrossmod.java | 98 + .../crossmod/GTpp/loader/RadioHatchCompat.java | 285 + .../bartimaeusnek/crossmod/cls/CLSCompat.java | 104 + .../galacticgreg/GT_TileEntity_VoidMiner_Base.java | 304 ++ .../galacticgreg/GT_TileEntity_VoidMiners.java | 115 + .../crossmod/galacticgreg/VoidMinerUtility.java | 316 ++ .../crossmod/galacticraft/GalacticraftProxy.java | 96 + .../crossmod/galacticraft/PlanetsHelperClass.java | 34 + .../galacticraft/UniversalTeleportType.java | 78 + .../atmosphere/BWAtmosphereManager.java | 121 + .../galacticraft/blocks/UniversalSpaceBlocks.java | 38 + .../galacticraft/creativetabs/SpaceTab.java | 37 + .../planets/AbstractWorldProviderSpace.java | 37 + .../planets/ross128b/ChunkProviderRoss128b.java | 186 + .../planets/ross128b/SkyProviderRoss128b.java | 25 + .../planets/ross128b/WorldProviderRoss128b.java | 155 + .../planets/ross128ba/ChunkProviderRoss128ba.java | 108 + .../planets/ross128ba/WorldProviderRoss128ba.java | 113 + .../solarsystems/Ross128SolarSystem.java | 92 + .../crossmod/openComputers/GT_NBT_DataBase.java | 97 + .../openComputers/TileEntity_GTDataServer.java | 203 + .../crossmod/tectech/TecTechResearchLoader.java | 93 + .../tectech/tileentites/tiered/LowPowerLaser.java | 121 + .../tiered/TT_Abstract_LowPowerLaserThingy.java | 156 + .../tiered/TT_MetaTileEntity_LowPowerLaserBox.java | 177 + .../TT_MetaTileEntity_LowPowerLaserDynamo.java | 98 + .../TT_MetaTileEntity_LowPowerLaserHatch.java | 82 + .../TT_MetaTileEntity_Pipe_Energy_LowPower.java | 163 + .../crossmod/tgregworks/MaterialsInjector.java | 82 + .../tile/GT_Multi_IndustrialCrucible.java | 84 + .../crossmod/thaumcraft/tile/GT_WandBuffer.java | 118 + .../thaumcraft/util/ThaumcraftHandler.java | 166 + .../java/com/github/technus/tectech/Reference.java | 15 + .../java/com/github/technus/tectech/TecTech.java | 119 + .../openComputers/AvrArchitecture.java | 307 ++ .../github/technus/tectech/loader/MainLoader.java | 202 + .../technus/tectech/loader/NetworkDispatcher.java | 25 + .../technus/tectech/loader/TecTechConfig.java | 257 + .../tectech/loader/gui/CreativeTabTecTech.java | 37 + .../technus/tectech/loader/recipe/Assembler.java | 3029 +++++++++++ .../tectech/loader/recipe/AssemblyLine.java | 128 + .../tectech/loader/recipe/BaseRecipeLoader.java | 49 + .../tectech/loader/recipe/CircuitAssembler.java | 46 + .../technus/tectech/loader/recipe/Crafting.java | 57 + .../technus/tectech/loader/recipe/Extractor.java | 57 + .../technus/tectech/loader/recipe/Godforge.java | 563 ++ .../loader/recipe/ResearchStationAssemblyLine.java | 3272 ++++++++++++ .../technus/tectech/loader/thing/CoverLoader.java | 48 + .../tectech/loader/thing/MachineLoader.java | 2101 ++++++++ .../technus/tectech/loader/thing/MuTeLoader.java | 21 + .../technus/tectech/loader/thing/ThingsLoader.java | 99 + .../mechanics/dataTransport/DataPacket.java | 104 + .../dataTransport/InventoryDataPacket.java | 62 + .../mechanics/dataTransport/QuantumDataPacket.java | 50 + .../enderStorage/EnderFluidContainer.java | 134 + .../mechanics/enderStorage/EnderLinkTag.java | 39 + .../mechanics/enderStorage/EnderLinkTank.java | 47 + .../enderStorage/EnderWorldSavedData.java | 145 + .../tectech/mechanics/pipe/IActivePipe.java | 12 + .../mechanics/pipe/IConnectsToDataPipe.java | 17 + .../mechanics/pipe/IConnectsToEnergyTunnel.java | 11 + .../mechanics/pipe/PipeActivityMessage.java | 136 + .../tectech/mechanics/spark/RendererMessage.java | 149 + .../tectech/mechanics/spark/ThaumSpark.java | 57 + .../tectech/mechanics/tesla/ITeslaConnectable.java | 169 + .../mechanics/tesla/ITeslaConnectableSimple.java | 24 + .../mechanics/tesla/TeslaCoverConnection.java | 81 + .../github/technus/tectech/proxy/ClientProxy.java | 182 + .../github/technus/tectech/proxy/CommonProxy.java | 94 + .../tectech/recipe/EyeOfHarmonyFrontend.java | 206 + .../technus/tectech/recipe/EyeOfHarmonyRecipe.java | 499 ++ .../tectech/recipe/EyeOfHarmonyRecipeStorage.java | 184 + .../tectech/recipe/GodforgeExoticFrontend.java | 82 + .../tectech/recipe/GodforgePlasmaFrontend.java | 76 + .../tectech/recipe/ResearchStationFrontend.java | 101 + .../technus/tectech/recipe/TT_recipeAdder.java | 278 + .../technus/tectech/recipe/TecTechRecipeMaps.java | 77 + .../tectech/rendering/EOH/EOH_ItemRenderer.java | 98 + .../tectech/rendering/EOH/EOH_RenderingUtils.java | 270 + .../technus/tectech/rendering/EOH/EOH_TESR.java | 91 + .../technus/tectech/thing/CustomItemList.java | 609 +++ .../tectech/thing/block/EOH_RenderBlock.java | 79 + .../tectech/thing/block/ForgeOfGodsBlock.java | 70 + .../tectech/thing/block/GodforgeGlassBlock.java | 107 + .../tectech/thing/block/GodforgeGlassItem.java | 30 + .../tectech/thing/block/GodforgeGlassRender.java | 122 + .../tectech/thing/block/QuantumGlassBlock.java | 111 + .../tectech/thing/block/QuantumGlassItem.java | 33 + .../tectech/thing/block/QuantumGlassRender.java | 129 + .../tectech/thing/block/QuantumStuffBlock.java | 104 + .../tectech/thing/block/QuantumStuffRender.java | 104 + .../tectech/thing/block/ReactorSimBlock.java | 96 + .../tectech/thing/block/ReactorSimItem.java | 36 + .../tectech/thing/block/RenderForgeOfGods.java | 130 + .../tectech/thing/block/TileEyeOfHarmony.java | 200 + .../tectech/thing/block/TileForgeOfGods.java | 77 + .../tectech/thing/casing/GT_Block_CasingsBA0.java | 227 + .../tectech/thing/casing/GT_Block_CasingsNH.java | 64 + .../tectech/thing/casing/GT_Block_CasingsTT.java | 196 + .../tectech/thing/casing/GT_Item_CasingsBA0.java | 111 + .../tectech/thing/casing/GT_Item_CasingsNH.java | 15 + .../tectech/thing/casing/GT_Item_CasingsTT.java | 133 + .../thing/casing/GT_Item_Casings_Godforge.java | 114 + .../thing/casing/GT_Item_Casings_Spacetime.java | 56 + .../casing/GT_Item_Casings_Stabilisation.java | 47 + .../casing/GT_Item_Casings_TimeAcceleration.java | 46 + .../tectech/thing/casing/GodforgeCasings.java | 124 + .../casing/SpacetimeCompressionFieldCasing.java | 120 + .../thing/casing/StabilisationFieldCasing.java | 117 + .../tectech/thing/casing/TT_Container_Casings.java | 28 + .../thing/casing/TimeAccelerationFieldCasing.java | 120 + .../thing/cover/GT_Cover_TM_EnderFluidLink.java | 252 + .../thing/cover/GT_Cover_TM_PowerPassUpgrade.java | 53 + .../tectech/thing/cover/GT_Cover_TM_TeslaCoil.java | 71 + .../cover/GT_Cover_TM_TeslaCoil_Ultimate.java | 44 + .../tectech/thing/gui/TecTechUITextures.java | 184 + .../tectech/thing/item/AstralArrayFabricator.java | 53 + .../tectech/thing/item/EnderFluidLinkCover.java | 56 + .../technus/tectech/thing/item/EuMeterGT.java | 169 + .../tectech/thing/item/ParametrizerMemoryCard.java | 234 + .../tectech/thing/item/PowerPassUpgradeCover.java | 55 + .../tectech/thing/item/RenderForgeOfGodsItem.java | 91 + .../tectech/thing/item/TeslaCoilCapacitor.java | 108 + .../tectech/thing/item/TeslaCoilComponent.java | 72 + .../technus/tectech/thing/item/TeslaCoilCover.java | 87 + .../technus/tectech/thing/item/TeslaStaff.java | 54 + .../tectech/thing/metaTileEntity/Textures.java | 318 ++ .../hatch/GT_MetaTileEntity_Hatch_Capacitor.java | 268 + .../GT_MetaTileEntity_Hatch_CreativeData.java | 133 + ...T_MetaTileEntity_Hatch_CreativeMaintenance.java | 96 + ...T_MetaTileEntity_Hatch_CreativeUncertainty.java | 58 + .../GT_MetaTileEntity_Hatch_DataConnector.java | 202 + .../hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java | 128 + .../GT_MetaTileEntity_Hatch_DynamoTunnel.java | 225 + .../hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java | 134 + .../GT_MetaTileEntity_Hatch_EnergyTunnel.java | 152 + .../hatch/GT_MetaTileEntity_Hatch_Holder.java | 181 + .../hatch/GT_MetaTileEntity_Hatch_InputData.java | 102 + .../GT_MetaTileEntity_Hatch_InputDataItems.java | 246 + .../hatch/GT_MetaTileEntity_Hatch_OutputData.java | 116 + .../GT_MetaTileEntity_Hatch_OutputDataItems.java | 141 + .../hatch/GT_MetaTileEntity_Hatch_Param.java | 559 ++ .../hatch/GT_MetaTileEntity_Hatch_ParamText.java | 291 ++ .../hatch/GT_MetaTileEntity_Hatch_Rack.java | 470 ++ .../hatch/GT_MetaTileEntity_Hatch_Uncertainty.java | 474 ++ .../GT_MetaTileEntity_Hatch_WirelessMulti.java | 216 + .../multi/ForgeOfGodsRingsStructureString.java | 5101 ++++++++++++++++++ .../multi/ForgeOfGodsStructureString.java | 5429 ++++++++++++++++++++ .../multi/GT_MetaTileEntity_EM_EyeOfHarmony.java | 1767 +++++++ .../multi/GT_MetaTileEntity_EM_ForgeOfGods.java | 2385 +++++++++ .../multi/GT_MetaTileEntity_EM_computer.java | 525 ++ .../multi/GT_MetaTileEntity_EM_dataBank.java | 302 ++ .../multi/GT_MetaTileEntity_EM_infuser.java | 315 ++ .../multi/GT_MetaTileEntity_EM_research.java | 823 +++ .../multi/GT_MetaTileEntity_EM_switch.java | 291 ++ .../multi/GT_MetaTileEntity_EM_transformer.java | 221 + .../multi/GT_MetaTileEntity_TM_microwave.java | 348 ++ .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 1080 ++++ .../base/GT_MetaTileEntity_MultiblockBase_EM.java | 2823 ++++++++++ .../metaTileEntity/multi/base/INameFunction.java | 6 + .../metaTileEntity/multi/base/IStatusFunction.java | 6 + .../thing/metaTileEntity/multi/base/LedStatus.java | 64 + .../metaTileEntity/multi/base/Parameters.java | 327 ++ .../thing/metaTileEntity/multi/base/SoundLoop.java | 59 + .../render/TT_RenderedExtendedFacingTexture.java | 25 + .../GT_MetaTileEntity_EM_BaseModule.java | 497 ++ .../GT_MetaTileEntity_EM_ExoticModule.java | 529 ++ .../GT_MetaTileEntity_EM_MoltenModule.java | 227 + .../GT_MetaTileEntity_EM_PlasmaModule.java | 226 + .../GT_MetaTileEntity_EM_SmeltingModule.java | 228 + .../pipe/GT_MetaTileEntity_PipeBlock_Data.java | 52 + .../pipe/GT_MetaTileEntity_PipeBlock_Energy.java | 52 + .../pipe/GT_MetaTileEntity_Pipe_Data.java | 316 ++ .../pipe/GT_MetaTileEntity_Pipe_Energy.java | 285 + .../single/GT_MetaTileEntity_BuckConverter.java | 271 + .../single/GT_MetaTileEntity_DebugPollutor.java | 246 + .../GT_MetaTileEntity_DebugPowerGenerator.java | 392 ++ .../GT_MetaTileEntity_DebugStructureWriter.java | 300 ++ .../single/GT_MetaTileEntity_OwnerDetector.java | 239 + .../single/GT_MetaTileEntity_TT_Transformer.java | 73 + .../single/GT_MetaTileEntity_TeslaCoil.java | 404 ++ .../single/GT_MetaTileEntity_WetTransformer.java | 49 + .../tectech/thing/multiTileEntity/GodForge.java | 0 .../thing/tileEntity/ReactorSimTileEntity.java | 143 + .../github/technus/tectech/util/CommonValues.java | 33 + .../com/github/technus/tectech/util/Converter.java | 41 + .../technus/tectech/util/FluidStackLong.java | 29 + .../github/technus/tectech/util/GodforgeMath.java | 308 ++ .../github/technus/tectech/util/ItemStackLong.java | 28 + .../github/technus/tectech/util/TT_Utility.java | 192 + 418 files changed, 95274 insertions(+) create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/API_ConfigValues.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/IRadMaterial.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/ITileAddsInformation.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/ITileDropsContent.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/SideReference.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/VoidMinerDropAdder.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAPI.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/package-info.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BacterialVatFrontend.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BartWorksRecipeMaps.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/DynamicGTRecipe.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/RadioHatchFrontend.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/ASM/ASMUtils.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCorePlugin.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/BioTab.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_MachineBlock.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ArtificialMicaLine.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/GTNHBlocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LocalisationLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RegisterServerCommands.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/AssemblyLine.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Autoclave.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Centrifuge.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalBath.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalReactor.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Electrolyzer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Extractor.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FakeRecipes.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidHeater.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidSolidifier.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FormingPress.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/LaserEngraver.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Mixer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Pulverizer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/PyrolyseOven.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BWTileEntityDimIDBridge.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/debug/CreativeScanner.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_CompressedFluidHatch.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_GiantOutputHatch.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_HumongousInputHatch.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_GT_MaterialReference.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AddSomeRecipes.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/LoadItemContainers.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/IWerkstoffRunnable.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/BlockLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CraftingMaterialLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MetalLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MultipleMetalLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/OreLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/SimpleMetalLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/ToolLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/AssociationLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/CasingRegistrator.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128ba.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Tooltip_Reference.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/CachedReflectionUtils.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/EnumUtils.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashMap.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/StreamUtils.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/log/DebugLog.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/package-info.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiners.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/VoidMinerUtility.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/AbstractWorldProviderSpace.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/SkyProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128ba.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserHatch.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_Multi_IndustrialCrucible.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java create mode 100644 src/main/java/com/github/technus/tectech/Reference.java create mode 100644 src/main/java/com/github/technus/tectech/TecTech.java create mode 100644 src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java create mode 100644 src/main/java/com/github/technus/tectech/loader/MainLoader.java create mode 100644 src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java create mode 100644 src/main/java/com/github/technus/tectech/loader/TecTechConfig.java create mode 100644 src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/Assembler.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/AssemblyLine.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/CircuitAssembler.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/Crafting.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/Extractor.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/Godforge.java create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java create mode 100644 src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java create mode 100644 src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java create mode 100644 src/main/java/com/github/technus/tectech/loader/thing/MuTeLoader.java create mode 100644 src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/dataTransport/DataPacket.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/dataTransport/InventoryDataPacket.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/dataTransport/QuantumDataPacket.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderFluidContainer.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTag.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTank.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderWorldSavedData.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/IActivePipe.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToDataPipe.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToEnergyTunnel.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/PipeActivityMessage.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java create mode 100644 src/main/java/com/github/technus/tectech/proxy/ClientProxy.java create mode 100644 src/main/java/com/github/technus/tectech/proxy/CommonProxy.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/GodforgeExoticFrontend.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/GodforgePlasmaFrontend.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java create mode 100644 src/main/java/com/github/technus/tectech/rendering/EOH/EOH_ItemRenderer.java create mode 100644 src/main/java/com/github/technus/tectech/rendering/EOH/EOH_RenderingUtils.java create mode 100644 src/main/java/com/github/technus/tectech/rendering/EOH/EOH_TESR.java create mode 100644 src/main/java/com/github/technus/tectech/thing/CustomItemList.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/EOH_RenderBlock.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/ForgeOfGodsBlock.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassBlock.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassItem.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassRender.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/RenderForgeOfGods.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java create mode 100644 src/main/java/com/github/technus/tectech/thing/block/TileForgeOfGods.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsNH.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Godforge.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Spacetime.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Stabilisation.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_TimeAcceleration.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GodforgeCasings.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/StabilisationFieldCasing.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java create mode 100644 src/main/java/com/github/technus/tectech/thing/casing/TimeAccelerationFieldCasing.java create mode 100644 src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java create mode 100644 src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_PowerPassUpgrade.java create mode 100644 src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java create mode 100644 src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java create mode 100644 src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/AstralArrayFabricator.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/EnderFluidLinkCover.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/PowerPassUpgradeCover.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/RenderForgeOfGodsItem.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/TeslaCoilComponent.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCover.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeUncertainty.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_WirelessMulti.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_ForgeOfGods.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/INameFunction.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/Parameters.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/SoundLoop.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_BaseModule.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_ExoticModule.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_MoltenModule.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_PlasmaModule.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_SmeltingModule.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Data.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Energy.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java create mode 100644 src/main/java/com/github/technus/tectech/thing/multiTileEntity/GodForge.java create mode 100644 src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java create mode 100644 src/main/java/com/github/technus/tectech/util/CommonValues.java create mode 100644 src/main/java/com/github/technus/tectech/util/Converter.java create mode 100644 src/main/java/com/github/technus/tectech/util/FluidStackLong.java create mode 100644 src/main/java/com/github/technus/tectech/util/GodforgeMath.java create mode 100644 src/main/java/com/github/technus/tectech/util/ItemStackLong.java create mode 100644 src/main/java/com/github/technus/tectech/util/TT_Utility.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/API_ConfigValues.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/API_ConfigValues.java new file mode 100644 index 0000000000..68a88b39ce --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/API_ConfigValues.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +public class API_ConfigValues { + + // One-Side-Only + public static boolean debugLog = true; +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java new file mode 100644 index 0000000000..2eee530a70 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.awt.Color; + +import net.minecraft.item.EnumRarity; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import com.github.bartimaeusnek.bartworks.util.BioDNA; +import com.github.bartimaeusnek.bartworks.util.BioData; +import com.github.bartimaeusnek.bartworks.util.BioPlasmid; + +import gregtech.api.enums.FluidState; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.fluid.GT_FluidFactory; +import gregtech.api.util.GT_Utility; + +public final class BioObjectAdder { + + /** + * @param color the color of the Culture + * @param name the name of the Culture + * @param plasmid the cultures plasmid, get it from createAndRegisterBioPlasmid + * @param dna the cultures dna, get it from createAndRegisterBioDNA + * @param breedable if the culture can be inserted into the BacterialVat + * @param rarity visual + * @return + */ + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, + EnumRarity rarity, boolean breedable) { + if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1) + return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, rarity, breedable); + new Exception( + "Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!") + .printStackTrace(); + return null; + } + + /** + * rarity inherits from dna + * + * @param color the color of the Culture + * @param name the name of the Culture + * @param plasmid the cultures plasmid, get it from createAndRegisterBioPlasmid + * @param dna the cultures dna, get it from createAndRegisterBioDNA + * @param breedable if the culture can be inserted into the BacterialVat + * @return + */ + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, + boolean breedable) { + if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1) + return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, breedable); + new Exception( + "Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!") + .printStackTrace(); + return null; + } + + /** + * unspecific Biodata that can be converted into DNA and Plasmid with the propper methodes + * + * @param aName the name of the Biodata + * @param rarity visual only + * @param chance the chanche to extract this BioData + * @param tier the tier of this BioData 0=HV, 1=EV etc. + * @return + */ + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity, int chance, int tier) { + if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) + return BioData.createAndRegisterBioData(aName, rarity, chance, tier); + new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!") + .printStackTrace(); + return null; + } + + /** + * Default Constructor for HV Tier DNA with 75% extraction rate + * + * @param aName Name of the DNA String + * @param rarity visual + * @return + */ + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity) { + if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) return BioDNA.createAndRegisterBioDNA(aName, rarity); + new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!") + .printStackTrace(); + return null; + } + + /** + * Default Constructor for HV Tier Plasmid with 75% extraction rate + * + * @param aName Name of the Plasmid + * @param rarity visual + * @return + */ + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity) { + if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity); + new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!") + .printStackTrace(); + return null; + } + + /** + * @param aName Name of the DNA String + * @param rarity visual + * @param chance chanche of extracting + * @param tier tier needed to extract 0=HV, 1=EV etc. + * @return + */ + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, int chance, int tier) { + if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) return BioDNA.createAndRegisterBioDNA(aName, rarity, chance, tier); + new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!") + .printStackTrace(); + return null; + } + + /** + * @param aName Name of the Plasmid + * @param rarity visual + * @param chance chanche of extracting + * @param tier tier needed to extract 0=HV, 1=EV etc. + * @return + */ + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity, int chance, int tier) { + if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) + return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity, chance, tier); + new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!") + .printStackTrace(); + return null; + } + + /** + * @param voltageTier (i.e. 6 for LuV, 7 for ZPM, only intresting for LuV+) + * @return the propper Bacteria Tier (at least 0) + */ + public static int getBacteriaTierFromVoltageTier(int voltageTier) { + return Math.max(voltageTier - 6, 0); + } + + /** + * If you get NPE's related to BioCultures (most likely because of Load Order or creating BioCultures after the + * postinit Phase) execute this. + */ + public static void regenerateBioFluids() { + FluidStack dnaFluid = Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 100) + : Materials.Biomass.getFluid(100L); + for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { + if (B.getFluidNotSet()) { + B.setFluid( + GT_FluidFactory.builder( + B.getName() + .replace(" ", "") + .toLowerCase() + "fluid") + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) B.getColor() + .getRed(), + (short) B.getColor() + .getBlue(), + (short) B.getColor() + .getGreen() }) + .withStateAndTemperature(FluidState.LIQUID, 300) + .buildAndRegister() + .asFluid()); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(10)) + .fluidInputs(new FluidStack(B.getFluid(), 1000)) + .fluidOutputs(dnaFluid) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(centrifugeRecipes); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java new file mode 100644 index 0000000000..ba1308c427 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import com.github.bartimaeusnek.bartworks.util.BioDNA; +import com.github.bartimaeusnek.bartworks.util.BioData; +import com.github.bartimaeusnek.bartworks.util.BioPlasmid; + +public final class BioObjectGetter { + + public static BioCulture getBioCulture(String aName) { + return BioCulture.getBioCulture(aName); + } + + public static NBTTagCompound getNBTTagFromCulture(BioCulture bioCulture) { + return BioCulture.getNBTTagFromCulture(bioCulture); + } + + public static NBTTagCompound getNBTTagFromBioPlasmid(BioPlasmid bioPlasmid) { + return BioObjectGetter.getNBTTagFromBioData(BioObjectGetter.convertBioPlasmidToData(bioPlasmid)); + } + + public static NBTTagCompound getNBTTagFromBioDNA(BioDNA bioDNA) { + return BioObjectGetter.getNBTTagFromBioData(BioObjectGetter.convertBioDNAtoData(bioDNA)); + } + + public static NBTTagCompound getNBTTagFromBioData(BioData bioData) { + return BioData.getNBTTagFromBioData(bioData); + } + + public static BioDNA convertDataToDNA(BioData bioData) { + return BioDNA.convertDataToDNA(bioData); + } + + public static BioPlasmid convertDataToPlasmid(BioData bioData) { + return BioPlasmid.convertDataToPlasmid(bioData); + } + + public static BioData convertBioPlasmidToData(BioPlasmid bioPlasmid) { + return BioData.convertBioPlasmidToBioData(bioPlasmid); + } + + public static BioData convertDataToDNA(BioDNA bioData) { + return BioData.convertBioDNAToBioData(bioData); + } + + public static BioData convertBioDNAtoData(BioDNA bioDNA) { + return BioData.convertBioDNAToBioData(bioDNA); + } + + public static BioPlasmid convertBioDNAtoBioPlasmid(BioDNA bioDNA) { + return BioObjectGetter.convertDataToPlasmid(BioObjectGetter.convertBioDNAtoData(bioDNA)); + } + + public static BioDNA convertBioPlasmidtoBioDNA(BioPlasmid bioPlasmid) { + return BioObjectGetter.convertDataToDNA(BioObjectGetter.convertBioPlasmidToData(bioPlasmid)); + } + + // UNSAFE needs to be reworked! + + public static Collection getAllPetriDishes() { + return BioItemList.getAllPetriDishes(); + } + + public static Collection getAllDNASampleFlasks() { + return BioItemList.getAllDNASampleFlasks(); + } + + public static Collection getAllPlasmidCells() { + return BioItemList.getAllPlasmidCells(); + } + + public static ItemStack getDNASampleFlask(BioDNA dna) { + return BioItemList.getDNASampleFlask(dna); + } + + public static ItemStack getPetriDish(BioCulture culture) { + return BioItemList.getPetriDish(culture); + } + + public static ItemStack getPlasmidCell(BioPlasmid plasmid) { + return BioItemList.getPlasmidCell(plasmid); + } + + /** + * 1 - DetergentPowder 2 - Agarose 3 - IncubationModule 4 - Plasma Membrane + * + * @param selection + * @return the selected Item + */ + public static ItemStack getOther(int selection) { + return BioItemList.getOther(selection); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java new file mode 100644 index 0000000000..6ab854c308 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BioCulture; + +import gregtech.api.enums.Materials; + +public final class BioRecipeAdder { + + public static final int STANDART = 0; + public static final int LOWGRAVITY = -100; + public static final int CLEANROOM = -200; + + public static boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack aSpecialItems, + int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, + int aSpecialValue) { + return BWRecipes.instance.addBioLabRecipe( + aInputs, + aOutput, + aSpecialItems, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue); + } + + /** + * Adds a Incubation Recipe for the BioLab. + * + * @param aInput any item that will be added with a petri dish + * @param aOutput must be a BioCulture + * @param aChances + * @param aFluidInputs + * @param aDuration + * @param aEUt use BW_Util.getMachineVoltageFromTier(tier) to get optimal EU/t + * @param aSpecialValue 0 = STANDART, -100 = LowGravity, -200 = Cleanroom + * @return if the recipe was added. + */ + public static boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, + FluidStack aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { + return BWRecipes.instance + .addBioLabRecipeIncubation(aInput, aOutput, aChances, aFluidInputs, aDuration, aEUt, aSpecialValue); + } + + /** + * @param aInputs Item Inputs, DO NOT PUT INTEGRATED CIRCUITS IN HERE! THEY WILL GET ADDED AUTOMATICALLY!, can + * be null + * @param aCulture the bio culture + * @param aFluidInputs may not be null + * @param aFluidOutputs may not be null + * @param aDuration + * @param aEUt + * @param Sv Manual Sv entry i.e. for custom items + * @param glasTier the glass tier + * @param aSpecialValue Space or Cleanroom, Not yet implemented + * @param exactSv if the recipe needs EXACTLY the Sv or can use less... + * @return + */ + public static boolean addBacterialVatRecipe(ItemStack[] aInputs, @Nonnull BioCulture aCulture, + @Nonnull FluidStack[] aFluidInputs, @Nonnull FluidStack[] aFluidOutputs, @Nonnegative int aDuration, + @Nonnegative int aEUt, int Sv, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + return BWRecipes.instance.addBacterialVatRecipe( + aInputs, + aCulture, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + Sv, + glasTier, + aSpecialValue, + exactSv); + } + + /** + * @param aInputs Item Inputs, DO NOT PUT INTEGRATED CIRCUITS IN HERE! THEY WILL GET ADDED AUTOMATICALLY!, can + * be null + * @param aCulture the bio culture + * @param aFluidInputs may not be null + * @param aFluidOutputs may not be null + * @param aDuration + * @param aEUt + * @param material may be null. used for auto Sv calculation + * @param glasTier the glass tier + * @param aSpecialValue Space or Cleanroom, Not yet implemented + * @param exactSv if the recipe needs EXACTLY the Sv or can use less... + * @return + */ + @Deprecated + public static boolean addBacterialVatRecipe(ItemStack[] aInputs, @Nonnull BioCulture aCulture, + @Nonnull FluidStack[] aFluidInputs, @Nonnull FluidStack[] aFluidOutputs, @Nonnegative int aDuration, + @Nonnegative int aEUt, Materials material, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + return BWRecipes.instance.addBacterialVatRecipe( + aInputs, + aCulture, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + material, + glasTier, + aSpecialValue, + exactSv); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java new file mode 100644 index 0000000000..b53638a77a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java @@ -0,0 +1,325 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import static cpw.mods.fml.common.registry.GameRegistry.findBlock; +import static gregtech.api.enums.Mods.IndustrialCraft2; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Objects; + +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.system.material.BW_NonMeta_MaterialItems; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Util; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_ModHandler; + +public final class BioVatLogicAdder { + + public static class RadioHatch { + + public static void runBasicItemIntegration() { + giveItemStackRadioHatchAbilites(ItemList.ThoriumCell_1.get(1), Materials.Thorium, 3); + giveItemStackRadioHatchAbilites(ItemList.ThoriumCell_2.get(1), Materials.Thorium, 6); + giveItemStackRadioHatchAbilites(ItemList.ThoriumCell_4.get(1), Materials.Thorium, 12); + + giveItemStackRadioHatchAbilites(ItemList.NaquadahCell_1.get(1), Materials.Naquadah, 3); + giveItemStackRadioHatchAbilites(ItemList.NaquadahCell_2.get(1), Materials.Naquadah, 6); + giveItemStackRadioHatchAbilites(ItemList.NaquadahCell_4.get(1), Materials.Naquadah, 12); + + giveItemStackRadioHatchAbilites(ItemList.Moxcell_1.get(1), Materials.Plutonium, 3); + giveItemStackRadioHatchAbilites(ItemList.Moxcell_2.get(1), Materials.Plutonium, 6); + giveItemStackRadioHatchAbilites(ItemList.Moxcell_4.get(1), Materials.Plutonium, 12); + + giveItemStackRadioHatchAbilites(ItemList.Uraniumcell_1.get(1), Materials.Uranium, 3); + giveItemStackRadioHatchAbilites(ItemList.Uraniumcell_2.get(1), Materials.Uranium, 6); + giveItemStackRadioHatchAbilites(ItemList.Uraniumcell_4.get(1), Materials.Uranium, 12); + + giveItemStackRadioHatchAbilites( + BW_NonMeta_MaterialItems.TiberiumCell_1.get(1), + WerkstoffLoader.Tiberium.getBridgeMaterial(), + 3); + giveItemStackRadioHatchAbilites( + BW_NonMeta_MaterialItems.TiberiumCell_2.get(1), + WerkstoffLoader.Tiberium.getBridgeMaterial(), + 6); + giveItemStackRadioHatchAbilites( + BW_NonMeta_MaterialItems.TiberiumCell_4.get(1), + WerkstoffLoader.Tiberium.getBridgeMaterial(), + 12); + + giveItemStackRadioHatchAbilites(BW_NonMeta_MaterialItems.TheCoreCell.get(1), Materials.Naquadah, 96); + + giveItemStackRadioHatchAbilites(ItemList.Depleted_Thorium_1.get(1), Materials.Thorium, 3, 10); + giveItemStackRadioHatchAbilites(ItemList.Depleted_Thorium_2.get(1), Materials.Thorium, 6, 10); + giveItemStackRadioHatchAbilites(ItemList.Depleted_Thorium_4.get(1), Materials.Thorium, 12, 10); + + giveItemStackRadioHatchAbilites(ItemList.Depleted_Naquadah_1.get(1), Materials.Naquadah, 3, 10); + giveItemStackRadioHatchAbilites(ItemList.Depleted_Naquadah_2.get(1), Materials.Naquadah, 6, 10); + giveItemStackRadioHatchAbilites(ItemList.Depleted_Naquadah_4.get(1), Materials.Naquadah, 12, 10); + + giveItemStackRadioHatchAbilites( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXSimpledepleted", 1), + Materials.Plutonium, + 3, + 10); + giveItemStackRadioHatchAbilites( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXDualdepleted", 1), + Materials.Plutonium, + 6, + 10); + giveItemStackRadioHatchAbilites( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXQuaddepleted", 1), + Materials.Plutonium, + 12, + 10); + + giveItemStackRadioHatchAbilites( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumSimpledepleted", 1), + Materials.Uranium, + 3, + 10); + giveItemStackRadioHatchAbilites( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumDualdepleted", 1), + Materials.Uranium, + 6, + 10); + giveItemStackRadioHatchAbilites( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumQuaddepleted", 1), + Materials.Uranium, + 12, + 10); + + giveItemStackRadioHatchAbilites( + BW_NonMeta_MaterialItems.Depleted_Tiberium_1.get(1), + WerkstoffLoader.Tiberium.getBridgeMaterial(), + 3, + 10); + giveItemStackRadioHatchAbilites( + BW_NonMeta_MaterialItems.Depleted_Tiberium_2.get(1), + WerkstoffLoader.Tiberium.getBridgeMaterial(), + 6, + 10); + giveItemStackRadioHatchAbilites( + BW_NonMeta_MaterialItems.Depleted_Tiberium_4.get(1), + WerkstoffLoader.Tiberium.getBridgeMaterial(), + 12, + 10); + + giveItemStackRadioHatchAbilites( + BW_NonMeta_MaterialItems.Depleted_TheCoreCell.get(1), + Materials.Naquadah, + 96, + 10); + + giveItemStackRadioHatchAbilites(ItemList.MNqCell_1.get(1), Materials.Naquadria, 3); + giveItemStackRadioHatchAbilites(ItemList.MNqCell_2.get(1), Materials.Naquadria, 6); + giveItemStackRadioHatchAbilites(ItemList.MNqCell_4.get(1), Materials.Naquadria, 12); + giveItemStackRadioHatchAbilites(ItemList.Depleted_MNq_1.get(1), Materials.Naquadria, 3, 10); + giveItemStackRadioHatchAbilites(ItemList.Depleted_MNq_2.get(1), Materials.Naquadria, 6, 10); + giveItemStackRadioHatchAbilites(ItemList.Depleted_MNq_4.get(1), Materials.Naquadria, 12, 10); + } + + private static final HashSet MaSv = new HashSet<>(); + private static final HashMap IsSv = new HashMap<>(); + private static final HashMap IsKg = new HashMap<>(); + private static final HashMap IsColor = new HashMap<>(); + + public static HashSet getMaSv() { + return RadioHatch.MaSv; + } + + public static HashMap getIsKg() { + return IsKg; + } + + public static HashMap getIsSv() { + return RadioHatch.IsSv; + } + + public static HashMap getIsColor() { + return IsColor; + } + + public static void setOverrideSvForMaterial(Materials m, int sv) { + MaSv.add(new BioVatLogicAdder.MaterialSvPair(m, sv)); + } + + public static void giveItemStackRadioHatchAbilites(ItemStack stack, int sv) { + IsSv.put(stack, sv); + } + + public static void giveItemStackRadioHatchAbilites(ItemStack stack, Materials materials) { + IsSv.put(stack, BW_Util.calculateSv(materials)); + } + + public static void giveItemStackRadioHatchAbilites(ItemStack stack, int sv, int kg) { + IsSv.put(stack, sv); + IsKg.put(stack, kg); + } + + public static void giveItemStackRadioHatchAbilites(ItemStack stack, Materials materials, int kg) { + giveItemStackRadioHatchAbilites(stack, BW_Util.calculateSv(materials), kg); + IsColor.put(stack, materials.getRGBA()); + } + + public static void giveItemStackRadioHatchAbilites(ItemStack stack, Materials materials, int kg, int divider) { + giveItemStackRadioHatchAbilites(stack, BW_Util.calculateSv(materials) / divider, kg); + IsColor.put(stack, materials.getRGBA()); + } + + public static void giveItemStackRadioHatchAbilites(ItemStack stack, int sv, int kg, short[] color) { + giveItemStackRadioHatchAbilites(stack, sv, kg); + IsColor.put(stack, color); + } + + public static int MaxSV = 150; + + public static int getMaxSv() { + int ret = MaxSV; + for (MaterialSvPair pair : RadioHatch.getMaSv()) { + if (pair.getSievert() > ret) ret = pair.getSievert(); + } + for (ItemStack is : RadioHatch.IsSv.keySet()) { + if (RadioHatch.IsSv.get(is) > ret) ret = RadioHatch.IsSv.get(is); + } + return ret; + } + } + + public static class BioVatGlass { + + private static final HashMap glasses = new HashMap<>(); + + /** + * @param sModname The modid owning the block + * @param sUnlocBlockName The name of the block itself + * @param meta The meta of the block + * @param tier the glasses Tier = Voltage tier (MIN 3) + * @return if the block was found in the Block registry + */ + public static boolean addCustomGlass(String sModname, String sUnlocBlockName, int meta, int tier) { + Block block = findBlock(sModname, sUnlocBlockName); + boolean ret = block != null; + if (ret) BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) meta), (byte) tier); + else new IllegalArgumentException( + "Block: " + sUnlocBlockName + " of the Mod: " + sModname + " was NOT found!").printStackTrace(); + block = null; + return ret; + } + + /** + * @param block the block to add + * @param meta the meta of the block (0-15) + * @param tier the glasses Tier = Voltage tier (MIN 3) + */ + public static void addCustomGlass(@Nonnull Block block, @Nonnegative int meta, @Nonnegative int tier) { + BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) meta), (byte) tier); + } + + /** + * @param block the block to add + * @param tier the glasses Tier = Voltage tier (MIN 3) + */ + public static void addCustomGlass(@Nonnull Block block, @Nonnegative int tier) { + BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) 0), (byte) tier); + } + + /** + * @param blockBytePair the block to add and its meta as a javafx.util Pair + * @param tier the glasses Tier = Voltage tier (MIN 3) + */ + public static void addCustomGlass(@Nonnull BlockMetaPair blockBytePair, @Nonnegative byte tier) { + BioVatGlass.glasses.put(blockBytePair, tier); + } + + public static HashMap getGlassMap() { + return BioVatGlass.glasses; + } + } + + public static class MaterialSvPair { + + final Materials materials; + final Integer sievert; + + public MaterialSvPair(Materials materials, Integer sievert) { + this.materials = materials; + this.sievert = sievert; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BioVatLogicAdder.MaterialSvPair that = (BioVatLogicAdder.MaterialSvPair) o; + return Objects.equals(this.getMaterials(), that.getMaterials()) + && Objects.equals(this.getSievert(), that.getSievert()); + } + + @Override + public int hashCode() { + return Objects.hash(this.getMaterials(), this.getSievert()); + } + + public Materials getMaterials() { + return this.materials; + } + + public Integer getSievert() { + return this.sievert; + } + } + + public static class BlockMetaPair { + + final Block block; + final Byte aByte; + + public BlockMetaPair(Block block, Byte aByte) { + this.block = block; + this.aByte = aByte; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BioVatLogicAdder.BlockMetaPair that = (BioVatLogicAdder.BlockMetaPair) o; + return Objects.equals(this.getBlock(), that.getBlock()) && Objects.equals(this.getaByte(), that.getaByte()); + } + + @Override + public int hashCode() { + return Objects.hash(this.getBlock(), this.getaByte()); + } + + public Block getBlock() { + return this.block; + } + + public Byte getaByte() { + return this.aByte; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java new file mode 100644 index 0000000000..eb4c2a0405 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java @@ -0,0 +1,211 @@ +package com.github.bartimaeusnek.bartworks.API; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static gregtech.api.enums.Mods.BartWorks; + +import java.util.ArrayList; +import java.util.List; +import java.util.PriorityQueue; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import net.minecraft.block.Block; + +import org.apache.commons.lang3.tuple.Pair; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.SetMultimap; +import com.google.common.collect.Table; +import com.gtnewhorizon.structurelib.structure.IStructureElement; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderState; +import cpw.mods.fml.common.registry.GameRegistry; + +/** + * API for bartworks borosilicate glass. + *

+ * You might have noticed this API does not expose any Block instance, but only IStructureElements. This is in case we + * add more glass blocks later, and we run out of meta id for only one block. + *

+ * IStructureElements returned from this class SHOULD NOT have its methods called before post init, or else you + * might end up with wrong autoplace hints. + */ +public class BorosilicateGlass { + + private static Block block, block2; + private static List> representatives; + private static SetMultimap> allLevels; + private static final Table allLevelsReverse = HashBasedTable.create(); + + private static boolean isValidTier(int tier) { + return tier > 0 && tier <= Byte.MAX_VALUE; + } + + private static Block getGlassBlock() { + if (block == null) { + block = GameRegistry.findBlock(BartWorks.ID, "BW_GlasBlocks"); + } + return block; + } + + private static Block getGlassBlock2() { + if (block2 == null) { + block2 = GameRegistry.findBlock(BartWorks.ID, "BW_GlasBlocks2"); + } + return block2; + } + + private static void doRegister(byte level, Block block, int meta, + SetMultimap> allLevels) { + allLevels.put(level, Pair.of(block, meta)); + allLevelsReverse.put(block, meta, level); + } + + private static SetMultimap> getAllLevels() { + if (allLevels == null) { + SetMultimap> ret = LinkedHashMultimap.create(); + Block block = getGlassBlock(); + doRegister((byte) 3, block, 0, ret); + doRegister((byte) 4, block, 1, ret); + doRegister((byte) 5, block, 12, ret); + doRegister((byte) 5, block, 2, ret); + doRegister((byte) 6, block, 3, ret); + doRegister((byte) 7, block, 4, ret); + doRegister((byte) 8, block, 5, ret); + for (int i = 6; i < 12; i++) { + doRegister((byte) 3, block, i, ret); + } + doRegister((byte) 9, block, 13, ret); + doRegister((byte) 10, block, 14, ret); + doRegister((byte) 11, block, 15, ret); + block = getGlassBlock2(); + doRegister((byte) 12, block, 0, ret); + allLevels = ret; + } + return allLevels; + } + + private static List> getRepresentatives() { + if (representatives == null) { + SetMultimap> allLevels = getAllLevels(); + ArrayList> ret = new ArrayList<>(); + for (Byte level : new PriorityQueue<>(allLevels.keySet())) { + ret.add( + allLevels.get(level) + .iterator() + .next()); + } + representatives = ret; + } + return representatives; + } + + private static Byte checkWithinBound(byte val, byte lo, byte hi) { + return val > hi || val < lo ? null : val; + } + + /** + * Register a new block as valid borosilicate glass with given tier (even if it doesn't contain boron at all) + * + * Does not support matching by more complex stuff like tile entity! + * + * Can only be called at INIT stage. + */ + public static void registerGlass(Block block, int meta, byte tier) { + if (Loader.instance() + .hasReachedState(LoaderState.POSTINITIALIZATION)) throw new IllegalStateException("register too late!"); + if (!Loader.instance() + .hasReachedState(LoaderState.INITIALIZATION)) throw new IllegalStateException("register too early!"); + if (!isValidTier(tier)) throw new IllegalArgumentException("not a valid tier: " + tier); + doRegister(tier, block, meta, getAllLevels()); + } + + /** + * Check if there is at least one type of boroglass in that tier. + */ + public static boolean hasGlassInTier(int tier) { + return getAllLevels().containsKey((byte) tier); + } + + /** + * Get a structure element for a certain tier of borosilicate glass. DOES NOT accept other glass like + * reinforced glass, magic mirror, vanilla glass, etc. unless these glass are explicitly registered as a + * borosilicate glass. + *

+ * Use this if you just want boroglass here and doesn't care what tier it is. + */ + public static IStructureElement ofBoroGlass(int tier) { + if (!hasGlassInTier(tier)) throw new IllegalArgumentException(); + return lazy(t -> { + Pair pair = getRepresentatives().get(tier - 3); + return ofBlockAdder((t1, block1, meta) -> getTier(block1, meta) == tier, pair.getKey(), pair.getValue()); + }); + } + + /** + * Get a structure element for any kind of borosilicate glass. DOES NOT accept other glass like reinforced + * glass, magic mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass. + *

+ * Use this if you just want boroglass here and doesn't care what tier it is. + */ + public static IStructureElement ofBoroGlassAnyTier() { + return lazy(t -> ofBlockAnyMeta(getGlassBlock())); + } + + /** + * Get a structure element for borosilicate glass. DOES NOT accept other glass like reinforced glass, magic + * mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass. + *

+ * This assumes you want all glass used to be of the same tier. + *

+ * NOTE: This will accept the basic boron glass (HV tier) as well. You might not want this. Use the other overload + * to filter this out. + * + * @param initialValue the value set before structure check started + */ + public static IStructureElement ofBoroGlass(byte initialValue, BiConsumer setter, + Function getter) { + return lazy( + t -> ofBlocksTiered(BorosilicateGlass::getTier, getRepresentatives(), initialValue, setter, getter)); + } + + /** + * Get a structure element for borosilicate glass. DOES NOT accept other glass like reinforced glass, magic + * mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass. + * + * @param initialValue the value set before structure check started + * @param minTier minimal accepted tier. inclusive. must be greater than 0. + * @param maxTier maximal accepted tier. inclusive. + */ + public static IStructureElement ofBoroGlass(byte initialValue, byte minTier, byte maxTier, + BiConsumer setter, Function getter) { + if (minTier > maxTier || minTier < 0) throw new IllegalArgumentException(); + return lazy( + t -> ofBlocksTiered( + (block1, meta) -> checkWithinBound(getTier(block1, meta), minTier, maxTier), + getRepresentatives().stream() + .skip(Math.max(minTier - 3, 0)) + .limit(maxTier - minTier + 1) + .collect(Collectors.toList()), + initialValue, + setter, + getter)); + } + + /** + * Get the tier of this borosilicate glass. DOES NOT consider other glass like reinforced glass, magic + * mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass. + * + * @return glass tier, or -1 if is not a borosilicate glass + */ + public static byte getTier(Block block, int meta) { + Byte ret = allLevelsReverse.get(block, meta); + return ret == null ? -1 : ret; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java new file mode 100644 index 0000000000..4a85029994 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +public interface INoiseGen { + + double getNoise(int x, int z); + + double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd); + + void setOctaves(int octaves); + + void setFrequency(double freq); + + void setSeed(long seed); + + void setAmplitude(double amplitude); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/IRadMaterial.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/IRadMaterial.java new file mode 100644 index 0000000000..9d2e2d7829 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/IRadMaterial.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import net.minecraft.item.ItemStack; + +public interface IRadMaterial { + + /** + * @return the amount of Radiation (0-150, commonly, higher values are possible but not recommended!) + */ + int getRadiationLevel(ItemStack aStack); + + /** + * @return 1 for stick, 2 for long rods, 3 for fuel rods + */ + byte getAmountOfMaterial(ItemStack aStack); + + /** + * @return the color of the material for display purposes + */ + short[] getColorForGUI(ItemStack aStack); + + /** + * @return the name of the material for display purposes + */ + String getNameForGUI(ItemStack aStack); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileAddsInformation.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileAddsInformation.java new file mode 100644 index 0000000000..d74263115b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileAddsInformation.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +public interface ITileAddsInformation { + + String[] getInfoData(); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileDropsContent.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileDropsContent.java new file mode 100644 index 0000000000..1f75115752 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileDropsContent.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import net.minecraft.inventory.ISidedInventory; + +public interface ITileDropsContent extends ISidedInventory { + + default int[] getDropSlots() { + return new int[] { 0 }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java new file mode 100644 index 0000000000..698c28fbf7 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface ITileHasDifferentTextureSides { + + IIcon[] texture = new IIcon[7]; + + @SideOnly(Side.CLIENT) + default IIcon getTextureForSide(ForgeDirection side, int meta) { + return texture[side.ordinal()]; + } + + @SideOnly(Side.CLIENT) + default IIcon getTextureForSide(int side, int meta) { + return this.getTextureForSide(ForgeDirection.values()[side], meta); + } + + @SideOnly(Side.CLIENT) + void registerBlockIcons(IIconRegister par1IconRegister); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/SideReference.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/SideReference.java new file mode 100644 index 0000000000..88ae5bf5c0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/SideReference.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import cpw.mods.fml.common.FMLCommonHandler; + +public class SideReference { + + public static class EffectiveSide { + + public static final boolean Server = FMLCommonHandler.instance() + .getEffectiveSide() + .isServer(); + public static final boolean Client = FMLCommonHandler.instance() + .getEffectiveSide() + .isClient(); + } + + public static class Side { + + public static final boolean Server = FMLCommonHandler.instance() + .getSide() + .isServer(); + public static final boolean Client = FMLCommonHandler.instance() + .getSide() + .isClient(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/VoidMinerDropAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/VoidMinerDropAdder.java new file mode 100644 index 0000000000..b83ce7d128 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/VoidMinerDropAdder.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import com.github.bartimaeusnek.crossmod.galacticgreg.VoidMinerUtility; + +import gregtech.api.interfaces.ISubTagContainer; + +public class VoidMinerDropAdder { + + public static void addDropsToDim(int dimID, ISubTagContainer material, float chance) { + VoidMinerUtility.addMaterialToDimensionList(dimID, material, chance); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAPI.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAPI.java new file mode 100644 index 0000000000..01c172382f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAPI.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; + +public final class WerkstoffAPI { + + @SuppressWarnings("rawtypes") + static Class w; + + static { + try { + w = Class.forName("com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + public static Werkstoff getWerkstoff(String aName) throws NoSuchFieldException, IllegalAccessException { + return (Werkstoff) w.getField(aName) + .get(null); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java new file mode 100644 index 0000000000..2cd29281f4 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import java.util.HashSet; + +public final class WerkstoffAdderRegistry { + + private static final HashSet toRun = new HashSet<>(); + + private WerkstoffAdderRegistry() {} + + public static void addWerkstoffAdder(Runnable adder) { + toRun.add(adder); + } + + public static void run() { + for (Runnable r : toRun) r.run(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java new file mode 100644 index 0000000000..620e9d65af --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java @@ -0,0 +1,61 @@ +package com.github.bartimaeusnek.bartworks.API.modularUI; + +import static com.github.bartimaeusnek.bartworks.MainMod.MOD_ID; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +public class BW_UITextures { + + public static final AdaptableUITexture BACKGROUND_BROWN = AdaptableUITexture + .of(MOD_ID, "GUI/background/brown", 176, 166, 3); + public static final UITexture BACKGROUND_CIRCUIT_PROGRAMMER = UITexture + .fullImage(MOD_ID, "GUI/background/circuit_programmer"); + + public static final AdaptableUITexture SLOT_BROWN = AdaptableUITexture.of(MOD_ID, "GUI/slot/brown", 18, 18, 1); + + public static final UITexture OVERLAY_SLOT_DISH = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/dish"); + public static final UITexture OVERLAY_SLOT_DNA_FLASK = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/dna_flask"); + public static final UITexture OVERLAY_SLOT_MODULE = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/module"); + public static final UITexture OVERLAY_SLOT_ROD = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/rod"); + public static final UITexture OVERLAY_SLOT_CROSS = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/cross"); + + public static final UITexture PROGRESSBAR_SIEVERT = UITexture.fullImage(MOD_ID, "GUI/progressbar/sievert"); + public static final UITexture PROGRESSBAR_STORED_EU_116 = UITexture + .fullImage(MOD_ID, "GUI/progressbar/stored_eu_116"); + public static final UITexture PROGRESSBAR_FUEL = UITexture.fullImage(MOD_ID, "GUI/progressbar/fuel"); + + public static final UITexture PICTURE_BW_LOGO_47X21 = UITexture.fullImage(MOD_ID, "GUI/picture/bw_logo_47x21"); + public static final UITexture PICTURE_SIEVERT_CONTAINER = UITexture + .fullImage(MOD_ID, "GUI/picture/sievert_container"); + public static final UITexture PICTURE_DECAY_TIME_CONTAINER = UITexture + .fullImage(MOD_ID, "GUI/picture/decay_time_container"); + public static final UITexture PICTURE_DECAY_TIME_INSIDE = UITexture + .fullImage(MOD_ID, "GUI/picture/decay_time_inside"); + public static final UITexture PICTURE_RADIATION = UITexture.fullImage(MOD_ID, "GUI/picture/radiation"); + public static final UITexture PICTURE_WINDMILL_EMPTY = UITexture.fullImage(MOD_ID, "GUI/picture/windmill_empty"); + public static final UITexture[] PICTURE_WINDMILL_ROTATING = IntStream.range(0, 4) + .mapToObj(i -> UITexture.partly(MOD_ID, "GUI/picture/windmill_rotating", 32, 128, 0, i * 32, 32, (i + 1) * 32)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture PICTURE_STORED_EU_FRAME = UITexture.fullImage(MOD_ID, "GUI/picture/stored_eu_frame"); + public static final UITexture PICTURE_RADIATION_SHUTTER_FRAME = UITexture + .fullImage(MOD_ID, "GUI/picture/radiation_shutter_frame"); + public static final AdaptableUITexture PICTURE_RADIATION_SHUTTER_INSIDE = AdaptableUITexture + .of(MOD_ID, "GUI/picture/radiation_shutter_inside", 51, 48, 1); + + public static final AdaptableUITexture TAB_TITLE_BROWN = AdaptableUITexture + .of(MOD_ID, "GUI/tab/title_brown", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_DARK_BROWN = AdaptableUITexture + .of(MOD_ID, "GUI/tab/title_dark_brown", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_ANGULAR_BROWN = AdaptableUITexture + .of(MOD_ID, "GUI/tab/title_angular_brown", 28, 28, 4); + + public static final UITexture OVERLAY_BUTTON_ASSEMBLER_MODE = UITexture + .fullImage(MOD_ID, "GUI/overlay_button/assembler_mode"); + public static final UITexture OVERLAY_BUTTON_LINE_MODE = UITexture + .fullImage(MOD_ID, "GUI/overlay_button/line_mode"); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/package-info.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/package-info.java new file mode 100644 index 0000000000..4bef7a0cad --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/package-info.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +@API(owner = Mods.Names.BART_WORKS, apiVersion = API_REFERENCE.VERSION, provides = "bartworks API") +package com.github.bartimaeusnek.bartworks.API; + +import cpw.mods.fml.common.API; +import gregtech.api.enums.Mods; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java new file mode 100644 index 0000000000..dfcf94115a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java @@ -0,0 +1,76 @@ +package com.github.bartimaeusnek.bartworks.API.recipe; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.util.BW_Util; + +public class BWNBTDependantCraftingRecipe implements IRecipe { + + ItemStack result; + Map charToStackMap = new HashMap<>(9, 1); + String[] shape; + + @SuppressWarnings({ "SuspiciousSystemArraycopy" }) + public BWNBTDependantCraftingRecipe(ItemStack result, Object... recipe) { + this.result = result; + this.shape = new String[3]; + System.arraycopy(recipe, 0, this.shape, 0, 3); + this.charToStackMap.put(' ', null); + for (int i = 3; i < recipe.length; i += 2) { + this.charToStackMap.put((char) recipe[i], ((ItemStack) recipe[i + 1]).copy()); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BWNBTDependantCraftingRecipe that)) return false; + + if (!Objects.equals(this.result, that.result) || !Objects.equals(this.charToStackMap, that.charToStackMap)) + return false; + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(this.shape, that.shape); + } + + @Override + public int hashCode() { + int result1 = this.result != null ? this.result.hashCode() : 0; + result1 = 31 * result1 + (this.charToStackMap != null ? this.charToStackMap.hashCode() : 0); + return 31 * result1 + Arrays.hashCode(this.shape); + } + + @Override + public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) { + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + ItemStack toCheck = p_77569_1_.getStackInRowAndColumn(y, x); + ItemStack ref = this.charToStackMap.get(this.shape[x].toCharArray()[y]); + if (!BW_Util.areStacksEqualOrNull(toCheck, ref)) return false; + } + } + return true; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) { + return this.result.copy(); + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return this.result; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BacterialVatFrontend.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BacterialVatFrontend.java new file mode 100644 index 0000000000..01cf2ecd32 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BacterialVatFrontend.java @@ -0,0 +1,92 @@ +package com.github.bartimaeusnek.bartworks.API.recipe; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_BioVat; +import com.gtnewhorizons.modularui.api.math.Alignment; + +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.GT_NEI_DefaultHandler; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class BacterialVatFrontend extends RecipeMapFrontend { + + public BacterialVatFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder, + neiPropertiesBuilder.neiSpecialInfoFormatter(new BacterialVatSpecialValueFormatter())); + } + + @Override + protected List handleNEIItemInputTooltip(List currentTip, + GT_NEI_DefaultHandler.FixedPositionedStack pStack) { + if (pStack.isFluid()) { + currentTip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("nei.biovat.input.tooltip")); + return currentTip; + } + return super.handleNEIItemInputTooltip(currentTip, pStack); + } + + @Override + protected List handleNEIItemOutputTooltip(List currentTip, + GT_NEI_DefaultHandler.FixedPositionedStack pStack) { + if (pStack.isFluid()) { + currentTip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("nei.biovat.output.tooltip")); + return currentTip; + } + return super.handleNEIItemOutputTooltip(currentTip, pStack); + } + + @Override + protected void drawNEIOverlayForInput(GT_NEI_DefaultHandler.FixedPositionedStack stack) { + drawFluidOverlay(stack); + } + + @Override + protected void drawNEIOverlayForOutput(GT_NEI_DefaultHandler.FixedPositionedStack stack) { + drawFluidOverlay(stack); + } + + private void drawFluidOverlay(GT_NEI_DefaultHandler.FixedPositionedStack stack) { + if (stack.isFluid()) { + drawNEIOverlayText( + "+", + stack, + colorOverride.getTextColorOrDefault("nei_overlay_yellow", 0xFDD835), + 0.5f, + true, + Alignment.TopRight); + return; + } + super.drawNEIOverlayForOutput(stack); + } + + private static class BacterialVatSpecialValueFormatter implements INEISpecialInfoFormatter { + + @Override + public List format(RecipeDisplayInfo recipeInfo) { + int[] tSpecialA = GT_TileEntity_BioVat.specialValueUnpack(recipeInfo.recipe.mSpecialValue); + String glassTier = StatCollector.translateToLocalFormatted("nei.biovat.0.name", tSpecialA[0]); + String sievert; + if (tSpecialA[2] == 1) { + sievert = StatCollector.translateToLocalFormatted("nei.biovat.1.name", tSpecialA[3]); + } else { + sievert = StatCollector.translateToLocalFormatted("nei.biovat.2.name", tSpecialA[3]); + } + return Arrays.asList(glassTier, sievert); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BartWorksRecipeMaps.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BartWorksRecipeMaps.java new file mode 100644 index 0000000000..281184893c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/BartWorksRecipeMaps.java @@ -0,0 +1,91 @@ +package com.github.bartimaeusnek.bartworks.API.recipe; + +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; + +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.recipe.maps.FuelBackend; +import gregtech.nei.formatter.FuelSpecialValueFormatter; + +public class BartWorksRecipeMaps { + + public static final RecipeMap bioLabRecipes = RecipeMapBuilder.of("bw.recipe.biolab") + .maxIO(6, 2, 1, 0) + .minInputs(1, 1) + .useSpecialSlot() + .slotOverlays((index, isFluid, isOutput, isSpecial) -> { + if (isSpecial) { + return BW_UITextures.OVERLAY_SLOT_MODULE; + } + if (isFluid) { + return GT_UITextures.OVERLAY_SLOT_VIAL_2; + } + if (!isOutput) { + switch (index) { + case 0: + return BW_UITextures.OVERLAY_SLOT_DISH; + case 1: + return BW_UITextures.OVERLAY_SLOT_DNA_FLASK; + case 2: + return GT_UITextures.OVERLAY_SLOT_CIRCUIT; + case 3: + return GT_UITextures.OVERLAY_SLOT_MOLECULAR_1; + case 4: + return GT_UITextures.OVERLAY_SLOT_MOLECULAR_2; + case 5: + return GT_UITextures.OVERLAY_SLOT_DATA_ORB; + } + } + return null; + }) + .progressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE) + .logo(BW_UITextures.PICTURE_BW_LOGO_47X21) + .logoSize(47, 21) + .logoPos(125, 3) + .disableRegisterNEI() + .build(); + public static final RecipeMap bacterialVatRecipes = RecipeMapBuilder.of("bw.recipe.BacteriaVat") + .maxIO(6, 2, 1, 1) + .minInputs(0, 1) + .useSpecialSlot() + .specialSlotSensitive() + .progressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE) + .frontend(BacterialVatFrontend::new) + .disableRegisterNEI() + .build(); + public static final RecipeMap acidGenFuels = RecipeMapBuilder.of("bw.fuels.acidgens", FuelBackend::new) + .maxIO(1, 1, 0, 0) + .neiSpecialInfoFormatter(FuelSpecialValueFormatter.INSTANCE) + .build(); + public static final RecipeMap circuitAssemblyLineRecipes = RecipeMapBuilder.of("bw.recipe.cal") + .maxIO(6, 1, 1, 0) + .minInputs(1, 1) + .useSpecialSlot() + .specialSlotSensitive() + .progressBar(GT_UITextures.PROGRESSBAR_CIRCUIT_ASSEMBLER) + .build(); + public static final RecipeMap radioHatchRecipes = RecipeMapBuilder.of("bw.recipe.radhatch") + .maxIO(1, 0, 0, 0) + .minInputs(1, 0) + .slotOverlays((index, isFluid, isOutput, isSpecial) -> BW_UITextures.OVERLAY_SLOT_ROD) + .logo(BW_UITextures.PICTURE_BW_LOGO_47X21) + .logoSize(47, 21) + .logoPos(118, 55) + .dontUseProgressBar() + .addSpecialTexture(74, 20, 29, 27, BW_UITextures.PICTURE_RADIATION) + .frontend(RadioHatchFrontend::new) + .build(); + public static final RecipeMap electricImplosionCompressorRecipes = RecipeMapBuilder + .of("gt.recipe.electricimplosioncompressor") + .maxIO(6, 2, 1, 1) + .slotOverlays( + (index, isFluid, isOutput, isSpecial) -> !isFluid && !isOutput ? GT_UITextures.OVERLAY_SLOT_IMPLOSION + : null) + .progressBar(GT_UITextures.PROGRESSBAR_COMPRESS) + .build(); + public static final RecipeMap htgrFakeRecipes = RecipeMapBuilder.of("bw.recipe.htgr") + .maxIO(1, 1, 0, 0) + .build(); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/DynamicGTRecipe.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/DynamicGTRecipe.java new file mode 100644 index 0000000000..d409d3ab26 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/DynamicGTRecipe.java @@ -0,0 +1,34 @@ +package com.github.bartimaeusnek.bartworks.API.recipe; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.MainMod; + +import gregtech.api.util.GT_Recipe; + +public class DynamicGTRecipe extends GT_Recipe { + + public DynamicGTRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, + int aSpecialValue, GT_Recipe originalRecipe) { + super( + aOptimize, + aInputs, + aOutputs, + aSpecialItems, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue); + if (originalRecipe != null) { + this.owners = new ArrayList<>(originalRecipe.owners); + this.stackTraces = new ArrayList<>(originalRecipe.stackTraces); + this.setOwner(MainMod.MOD_ID); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/RadioHatchFrontend.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/RadioHatchFrontend.java new file mode 100644 index 0000000000..a6cf4b180e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/recipe/RadioHatchFrontend.java @@ -0,0 +1,45 @@ +package com.github.bartimaeusnek.bartworks.API.recipe; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.util.StatCollector; + +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class RadioHatchFrontend extends RecipeMapFrontend { + + public RadioHatchFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super(uiPropertiesBuilder, neiPropertiesBuilder.neiSpecialInfoFormatter(new RadioHatchSpecialInfoFormatter())); + } + + @Override + protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) {} + + @Override + protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} + + private static class RadioHatchSpecialInfoFormatter implements INEISpecialInfoFormatter { + + @Override + public List format(RecipeDisplayInfo recipeInfo) { + int radioLevel = recipeInfo.recipe.mEUt; + int amount = recipeInfo.recipe.mDuration; + long time = recipeInfo.recipe.mSpecialValue; + return Arrays.asList( + StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.0", radioLevel), + StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.1", amount), + StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.2", time * amount / 20.0)); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/ASMUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/ASMUtils.java new file mode 100644 index 0000000000..725a0135a4 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/ASMUtils.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.ASM; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.objectweb.asm.tree.MethodNode; + +public class ASMUtils { + + public static String matchAny(String toCompare, String... args) { + for (String arg : args) { + if (toCompare.equalsIgnoreCase(arg)) return arg; + } + return ""; + } + + /** + * Call this Method twice, one time for the Descriptor and one time for the Name. + */ + public static boolean isCorrectMethod(MethodNode methodNode, String... args) { + for (String arg : args) { + if (methodNode.name.equalsIgnoreCase(arg) || methodNode.desc.equalsIgnoreCase(arg)) return true; + } + return false; + } + + public static boolean writeClassToDisk(byte[] towrite, String Classname, String Path) { + try { + if (Path.charAt(Path.length() - 1) == '/' || Path.charAt(Path.length() - 1) == '\\') + Path = Path.substring(0, Path.length() - 1); + OutputStream os = new FileOutputStream(new File(Path + '/' + Classname + ".class")); + os.write(towrite); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java new file mode 100644 index 0000000000..54598f9478 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.ASM; + +import static com.github.bartimaeusnek.bartworks.ASM.BWCoreTransformer.shouldTransform; +import static gregtech.api.enums.Mods.ExtraUtilities; +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.RWG; +import static gregtech.api.enums.Mods.Thaumcraft; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + +import cpw.mods.fml.common.DummyModContainer; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.ModMetadata; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; + +public class BWCore extends DummyModContainer { + + public static final String BWCORE_NAME = "BartWorks ASM Core"; + public static final Logger BWCORE_LOG = LogManager.getLogger(BWCore.BWCORE_NAME); + + public BWCore() { + super(new ModMetadata()); + ModMetadata metadata = this.getMetadata(); + metadata.modId = "BWCore"; + metadata.name = BWCore.BWCORE_NAME; + metadata.version = "0.0.1"; + metadata.authorList.add("bartimaeusnek"); + metadata.dependants = this.getDependants(); + metadata.parent = MainMod.MOD_ID; + } + + @Subscribe + public void preInit(FMLPreInitializationEvent event) { + shouldTransform[0] = ConfigHandler.enabledPatches[0]; + shouldTransform[1] = ConfigHandler.enabledPatches[1]; + shouldTransform[2] = ConfigHandler.enabledPatches[2]; + shouldTransform[3] = ConfigHandler.enabledPatches[3]; + BWCore.BWCORE_LOG.info("Extra Utilities found and ASM Patch enabled? " + shouldTransform[0]); + BWCore.BWCORE_LOG.info("Thaumcraft found and ASM Patch enabled? " + shouldTransform[2]); + } + + @Override + public List getDependants() { + List ret = new ArrayList<>(); + ret.add(new DefaultArtifactVersion(ExtraUtilities.ID, true)); + ret.add(new DefaultArtifactVersion(Thaumcraft.ID, true)); + ret.add(new DefaultArtifactVersion(GTPlusPlus.ID, true)); + ret.add(new DefaultArtifactVersion(RWG.ID, true)); + ret.add(new DefaultArtifactVersion(MainMod.MOD_ID, true)); + ret.add(new DefaultArtifactVersion(BartWorksCrossmod.MOD_ID, true)); + return ret; + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) { + bus.register(this); + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCorePlugin.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCorePlugin.java new file mode 100644 index 0000000000..f7fde1167d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCorePlugin.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.ASM; + +import java.io.File; +import java.util.ArrayList; +import java.util.Map; + +import net.minecraftforge.common.config.Configuration; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + +import cpw.mods.fml.relauncher.FMLInjectionData; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin; + +@IFMLLoadingPlugin.SortingIndex(Integer.MAX_VALUE) // Load as late as possible (after fastcraft/OptiFine). +@IFMLLoadingPlugin.MCVersion("1.7.10") +@IFMLLoadingPlugin.TransformerExclusions("com.github.bartimaeusnek.bartworks.ASM") +@IFMLLoadingPlugin.Name(BWCorePlugin.BWCORE_PLUGIN_NAME) +public class BWCorePlugin implements IFMLLoadingPlugin { + + public static final String BWCORE_PLUGIN_NAME = "BartWorks ASM Core Plugin"; + + public static File minecraftDir; + + public BWCorePlugin() { + // Injection Code taken from CodeChickenLib + if (BWCorePlugin.minecraftDir != null) return; // get called twice, once for IFMLCallHook + BWCorePlugin.minecraftDir = (File) FMLInjectionData.data()[6]; + // do all the configuration already now... + new ConfigHandler(new Configuration(new File(new File(BWCorePlugin.minecraftDir, "config"), "bartworks.cfg"))); + BWCoreTransformer.shouldTransform[2] = false; + } + + @Override + public String[] getASMTransformerClass() { + return new String[] { BWCoreTransformer.class.getName() }; + } + + @Override + public String getModContainerClass() { + return BWCore.class.getName(); + } + + @Override + public String getSetupClass() { + return null; + } + + @Override + @SuppressWarnings("rawtypes") + public void injectData(Map data) { + if (data.get("runtimeDeobfuscationEnabled") != null) { + BWCoreTransformer.obfs = (boolean) data.get("runtimeDeobfuscationEnabled"); + } + if (data.get("coremodList") != null) { + for (Object o : (ArrayList) data.get("coremodList")) { + if (o.toString() + .contains("MicdoodlePlugin")) { + BWCoreTransformer.shouldTransform[2] = ConfigHandler.enabledPatches[2]; + break; + } + } + } + } + + @Override + public String getAccessTransformerClass() { + return null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java new file mode 100644 index 0000000000..38a5a70d27 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.ASM; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.util.NonNullWrappedHashSet; +import com.github.bartimaeusnek.bartworks.util.accessprioritylist.AccessPriorityList; +import com.github.bartimaeusnek.bartworks.util.accessprioritylist.AccessPriorityListNode; + +public class BWCoreStaticReplacementMethodes { + + private static ThreadLocal> RECENTLYUSEDRECIPES = ThreadLocal + .withInitial(AccessPriorityList::new); + + public static void clearRecentlyUsedRecipes() { + // the easiest way to ensure the cache is flushed without causing synchronization overhead + // is to just replace the whole ThreadLocal instance. + RECENTLYUSEDRECIPES = ThreadLocal.withInitial(AccessPriorityList::new); + } + + public static ItemStack findCachedMatchingRecipe(InventoryCrafting inventoryCrafting, World world) { + int i = 0; + ItemStack itemstack = null; + ItemStack itemstack1 = null; + int j; + + for (j = 0; j < inventoryCrafting.getSizeInventory(); ++j) { + ItemStack itemstack2 = inventoryCrafting.getStackInSlot(j); + + if (itemstack2 != null) { + if (i == 0) itemstack = itemstack2; + + if (i == 1) itemstack1 = itemstack2; + + ++i; + } + } + + if (i == 2 && itemstack.getItem() == itemstack1.getItem() + && itemstack.stackSize == 1 + && itemstack1.stackSize == 1 + && itemstack.getItem() + .isRepairable()) { + Item item = itemstack.getItem(); + int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); + int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); + int l = j1 + k + item.getMaxDamage() * 5 / 100; + int i1 = item.getMaxDamage() - l; + + if (i1 < 0) i1 = 0; + + return new ItemStack(itemstack.getItem(), 1, i1); + + } + IRecipe iPossibleRecipe = null; + AccessPriorityList cache = RECENTLYUSEDRECIPES.get(); + Iterator> it = cache.nodeIterator(); + + while (it.hasNext()) { + AccessPriorityListNode recipeNode = it.next(); + iPossibleRecipe = recipeNode.getELEMENT(); + + if (!iPossibleRecipe.matches(inventoryCrafting, world)) continue; + + cache.addPrioToNode(recipeNode); + return iPossibleRecipe.getCraftingResult(inventoryCrafting); + } + + HashSet recipeSet = new NonNullWrappedHashSet<>(); + List recipeList = CraftingManager.getInstance() + .getRecipeList(); + + for (IRecipe r : recipeList) { + if (r.matches(inventoryCrafting, world)) recipeSet.add(r); + } + + Object[] arr = recipeSet.toArray(); + + if (arr.length == 0) return null; + + IRecipe recipe = (IRecipe) arr[0]; + ItemStack stack = recipe.getCraftingResult(inventoryCrafting); + + if (arr.length != 1) return stack; + + if (stack != null) cache.addLast(recipe); + + return stack; + } + + private BWCoreStaticReplacementMethodes() {} +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java new file mode 100644 index 0000000000..02835e39c2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.ASM; + +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACONST_NULL; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ARETURN; +import static org.objectweb.asm.Opcodes.GETFIELD; +import static org.objectweb.asm.Opcodes.ICONST_0; +import static org.objectweb.asm.Opcodes.IFNE; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; +import static org.objectweb.asm.Opcodes.IRETURN; +import static org.objectweb.asm.Opcodes.POP; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.JumpInsnNode; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.VarInsnNode; + +public class BWCoreTransformer implements IClassTransformer { + + public static final String[] DESCRIPTIONFORCONFIG = { "REMOVING RAIN FROM LAST MILLENNIUM (EXU)", + "REMOVING CREATURES FROM LAST MILLENNIUM (EXU)", "PATCHING THAUMCRAFT WAND PEDESTAL TO PREVENT VIS DUPLICATION", + "PATCHING CRAFTING MANAGER FOR CACHING RECIPES" }; + public static final String[] CLASSESBEINGTRANSFORMED = { + "com.rwtema.extrautils.worldgen.endoftime.WorldProviderEndOfTime", + "com.rwtema.extrautils.worldgen.endoftime.ChunkProviderEndOfTime", "thaumcraft.common.tiles.TileWandPedestal", + "net.minecraft.item.crafting.CraftingManager" }; + static boolean obfs; + + public static boolean[] shouldTransform = new boolean[BWCoreTransformer.CLASSESBEINGTRANSFORMED.length]; + + /** + * Made by DarkShaddow44 + */ + private static MethodNode transformThaumcraftWandPedestal(MethodNode method) { + InsnList nu = new InsnList(); + for (int j = 0; j < method.instructions.size(); j++) { + AbstractInsnNode instruction = method.instructions.get(j); + nu.add(instruction); + if (instruction.getOpcode() == INVOKEVIRTUAL) { + MethodInsnNode invokevirtual = (MethodInsnNode) instruction; + if ("addVis".equals(invokevirtual.name)) { + AbstractInsnNode beginning = method.instructions.get(j - 7); + LabelNode label = new LabelNode(); + nu.insertBefore(beginning, new VarInsnNode(ALOAD, 0)); + nu.insertBefore( + beginning, + new FieldInsnNode( + GETFIELD, + "thaumcraft/common/tiles/TileWandPedestal", + obfs ? "field_145850_b" : "worldObj", + "Lnet/minecraft/world/World;")); + nu.insertBefore( + beginning, + new FieldInsnNode( + GETFIELD, + "net/minecraft/world/World", + obfs ? "field_72995_K" : "isRemote", + "Z")); + nu.insertBefore(beginning, new JumpInsnNode(IFNE, label)); + nu.add(new InsnNode(POP)); + nu.add(label); + j++; // Skip actual Pop + } + } + } + method.instructions = nu; + return method; + } + + public static byte[] transform(int id, byte[] basicClass) { + if (!BWCoreTransformer.shouldTransform[id]) { + BWCore.BWCORE_LOG + .info("Patch: " + BWCoreTransformer.DESCRIPTIONFORCONFIG[id] + " is disabled, will not patch!"); + return basicClass; + } + + if (id < BWCoreTransformer.CLASSESBEINGTRANSFORMED.length) { + BWCore.BWCORE_LOG.info(BWCoreTransformer.DESCRIPTIONFORCONFIG[id]); + ClassReader classReader = new ClassReader(basicClass); + ClassNode classNode = new ClassNode(); + classReader.accept(classNode, ClassReader.SKIP_FRAMES); + List methods = classNode.methods; + scase: switch (id) { + case 0: { + BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEINGTRANSFORMED[id]); + String name_deObfs = "canDoRainSnowIce"; + + String dsc_deObfs = "(Lnet/minecraft/world/chunk/Chunk;)Z"; + for (int i = 0; i < methods.size(); i++) { + if (methods.get(i).name.equalsIgnoreCase(name_deObfs)) { + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Removing!"); + methods.remove(i); + break; + } + } + BWCore.BWCORE_LOG.info("Creating new " + name_deObfs + "!"); + MethodNode nu = new MethodNode(ACC_PUBLIC, name_deObfs, dsc_deObfs, null, new String[0]); + InsnList insnList = new InsnList(); + insnList.add(new InsnNode(ICONST_0)); + insnList.add(new InsnNode(IRETURN)); + nu.instructions = insnList; + nu.maxLocals = 1; + nu.maxStack = 1; + methods.add(nu); + break; + } + case 1: { + BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEINGTRANSFORMED[id]); + String name_deObfs = "getPossibleCreatures"; + String name_src = "func_73155_a"; + String name_Obfs = "a"; + String dsc_deObfs = "(Lnet/minecraft/entity/EnumCreatureType;III)Ljava/util/List;"; + String dsc_Obfs = "(Lsx;III)Ljava/util/List;"; + + for (int i = 0; i < methods.size(); i++) { + if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) + && ASMUtils.isCorrectMethod(methods.get(i), dsc_deObfs, dsc_Obfs)) { + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Patching!"); + MethodNode toPatch = methods.get(i); + InsnList insnList = new InsnList(); + insnList.add(new InsnNode(ACONST_NULL)); + insnList.add(new InsnNode(ARETURN)); + toPatch.instructions = insnList; + toPatch.maxStack = 1; + toPatch.maxLocals = 5; + methods.set(i, toPatch); + break scase; + } + } + } + case 2: { + BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEINGTRANSFORMED[id]); + String name_deObfs = "updateEntity"; + String name_src = "func_145845_h"; + String name_Obfs = "h"; + String dsc_universal = "()V"; + + for (int i = 0; i < methods.size(); i++) { + if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) + && ASMUtils.isCorrectMethod(methods.get(i), dsc_universal, dsc_universal)) { + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Patching!"); + methods.set(i, BWCoreTransformer.transformThaumcraftWandPedestal(methods.get(i))); + break scase; + } + } + } + case 3: { + BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEINGTRANSFORMED[id]); + String name_deObfs = "findMatchingRecipe"; + String name_Obfs = "a"; + String name_src = "func_82787_a"; + for (MethodNode toPatch : methods) { + if (ASMUtils.isCorrectMethod(toPatch, name_deObfs, name_Obfs, name_src)) { + toPatch.instructions = new InsnList(); + toPatch.instructions.add(new VarInsnNode(ALOAD, 1)); + toPatch.instructions.add(new VarInsnNode(ALOAD, 2)); + toPatch.instructions.add( + new MethodInsnNode( + INVOKESTATIC, + "com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes", + "findCachedMatchingRecipe", + "(Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Lnet/minecraft/item/ItemStack;", + false)); + toPatch.instructions.add(new InsnNode(ARETURN)); + toPatch.localVariables.clear(); + toPatch.maxStack = 2; + toPatch.maxLocals = 3; + break scase; + } + } + } + + default: { + BWCore.BWCORE_LOG.info("Could not find: " + BWCoreTransformer.CLASSESBEINGTRANSFORMED[id]); + return basicClass; + } + } + + classNode.methods = methods; + ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + classNode.accept(classWriter); + byte[] ret = classWriter.toByteArray(); + if (Arrays.hashCode(basicClass) == Arrays.hashCode(ret)) + BWCore.BWCORE_LOG.warn("Could not patch: " + BWCoreTransformer.CLASSESBEINGTRANSFORMED[id]); + return ret; + } + return basicClass; + } + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + for (int i = 0; i < BWCoreTransformer.CLASSESBEINGTRANSFORMED.length; i++) { + if (name.equalsIgnoreCase(BWCoreTransformer.CLASSESBEINGTRANSFORMED[i]) + || transformedName.equalsIgnoreCase(BWCoreTransformer.CLASSESBEINGTRANSFORMED[i])) + return BWCoreTransformer.transform(i, basicClass); + } + return basicClass; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java new file mode 100644 index 0000000000..c104d09f3a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.API.SideReference; + +import cpw.mods.fml.common.network.IGuiHandler; + +public class GuiHandler implements IGuiHandler { + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + if (!SideReference.Side.Client) return this.getServerGuiElement(ID, player, world, x, y, z); + return null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java new file mode 100644 index 0000000000..818b67d6fc --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks; + +import static com.github.bartimaeusnek.bartworks.common.loaders.BioRecipeLoader.runOnServerStarted; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.removeIC2Recipes; +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.Mods.BartWorks; +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.io.IOException; +import java.util.Map; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.github.bartimaeusnek.bartworks.API.API_ConfigValues; +import com.github.bartimaeusnek.bartworks.API.API_REFERENCE; +import com.github.bartimaeusnek.bartworks.API.BioObjectAdder; +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.ClientEventHandler.TooltipEventHandler; +import com.github.bartimaeusnek.bartworks.client.creativetabs.BioTab; +import com.github.bartimaeusnek.bartworks.client.creativetabs.GT2Tab; +import com.github.bartimaeusnek.bartworks.client.creativetabs.bartworksTab; +import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.loaders.ArtificialMicaLine; +import com.github.bartimaeusnek.bartworks.common.loaders.BeforeGTPreload; +import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.BioLabLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.common.loaders.LocalisationLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.RadioHatchMaterialLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.RecipeLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.RegisterServerCommands; +import com.github.bartimaeusnek.bartworks.common.loaders.StaticRecipeChangeLoaders; +import com.github.bartimaeusnek.bartworks.common.net.BW_Network; +import com.github.bartimaeusnek.bartworks.server.EventHandler.ServerEventHandler; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitPartLoader; +import com.github.bartimaeusnek.bartworks.system.material.GT_Enhancement.PlatinumSludgeOverHaul; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.DownTierLoader; +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.ResultWrongSievert; +import com.github.bartimaeusnek.bartworks.util.log.DebugLog; +import com.github.bartimaeusnek.crossmod.galacticgreg.VoidMinerUtility; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartedEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Mods; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GT_OreDictUnificator; + +@Mod(modid = MainMod.MOD_ID, name = MainMod.NAME, version = API_REFERENCE.VERSION, dependencies = """ + required-after:IC2;\ + required-after:gregtech;\ + after:berriespp;\ + after:tectech;\ + after:GalacticraftMars;\ + after:GalacticraftCore;\ + after:Forestry;\ + after:ProjRed|Illumination;\ + after:RandomThings;\ + before:miscutils;""") +public final class MainMod { + + public static final String NAME = "BartWorks"; + public static final String MOD_ID = Mods.Names.BART_WORKS; + public static final String APIVERSION = "11"; + public static final Logger LOGGER = LogManager.getLogger(MainMod.NAME); + public static final CreativeTabs GT2 = new GT2Tab("GT2C"); + public static final CreativeTabs BIO_TAB = new BioTab("BioTab"); + public static final CreativeTabs BWT = new bartworksTab(BartWorks.ID); + public static final IGuiHandler GH = new GuiHandler(); + + @Mod.Instance(MainMod.MOD_ID) + public static MainMod instance; + + public static BW_Network BW_Network_instance = new BW_Network(); + + public MainMod() { + GregTech_API.sBeforeGTPreload.add(new BeforeGTPreload()); + } + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent preinit) { + if (GTPlusPlus.isModLoaded()) { + MainMod.LOGGER.info("Found GT++, continuing"); + } + + if (API_ConfigValues.debugLog) { + try { + DebugLog.initDebugLog(preinit); + } catch (IOException e) { + MainMod.LOGGER.catching(e); + } + } + + WerkstoffLoader.setUp(); + + if (ConfigHandler.BioLab) { + BioCultureLoader.run(); + } + + Werkstoff.init(); + GregTech_API.sAfterGTPostload.add(new CircuitPartLoader()); + if (SideReference.Side.Client) { + GregTech_API.sBeforeGTLoad.add(new PrefixTextureLinker()); + } + + } + + @Mod.EventHandler + public void init(FMLInitializationEvent init) { + if (SideReference.Side.Client && ConfigHandler.tooltips) + MinecraftForge.EVENT_BUS.register(new TooltipEventHandler()); + ServerEventHandler serverEventHandler = new ServerEventHandler(); + if (SideReference.Side.Server) { + MinecraftForge.EVENT_BUS.register(serverEventHandler); + } + FMLCommonHandler.instance() + .bus() + .register(serverEventHandler); + if (ConfigHandler.BioLab) { + BioLabLoader.run(); + } + + WerkstoffLoader.runInit(); + + ItemRegistry.run(); + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent postinit) { + + RecipeLoader.run(); + + NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH); + if (ConfigHandler.BioLab) { + GTNHBlocks.run(); + for (Map.Entry pair : BioVatLogicAdder.BioVatGlass.getGlassMap() + .entrySet()) { + GT_OreDictUnificator.registerOre( + "blockGlass" + VN[pair.getValue()], + new ItemStack( + pair.getKey() + .getBlock(), + 1, + pair.getKey() + .getaByte())); + } + } + ArtificialMicaLine.runArtificialMicaRecipe(); + BioObjectAdder.regenerateBioFluids(); + + WerkstoffLoader.run(); + LocalisationLoader.localiseAll(); + + CheckRecipeResultRegistry.register(new ResultWrongSievert(0, ResultWrongSievert.NeededSievertType.EXACTLY)); + + RadioHatchMaterialLoader.run(); + } + + @Mod.EventHandler + public void onServerStarting(FMLServerStartingEvent event) { + RegisterServerCommands.registerAll(event); + } + + @Mod.EventHandler + public void onServerStarted(FMLServerStartedEvent event) { + MainMod.runOnPlayerJoined(ConfigHandler.classicMode, ConfigHandler.disableExtraGassesForEBF); + } + + @Mod.EventHandler + public void onModLoadingComplete(FMLLoadCompleteEvent event) { + removeIC2Recipes(); + StaticRecipeChangeLoaders.addElectricImplosionCompressorRecipes(); + PlatinumSludgeOverHaul.replacePureElements(); + + runOnServerStarted(); + StaticRecipeChangeLoaders.unificationRecipeEnforcer(); + VoidMinerUtility.generateDropMaps(); + } + + private static boolean recipesAdded; + + public static void runOnPlayerJoined(boolean classicMode, boolean disableExtraGasRecipes) { + OreDictHandler.adaptCacheForWorld(); + CircuitImprintLoader.run(); + BioVatLogicAdder.RadioHatch.runBasicItemIntegration(); + if (!recipesAdded) { + if (!disableExtraGasRecipes) StaticRecipeChangeLoaders.addEBFGasRecipes(); + + if (classicMode) DownTierLoader.run(); + + // StaticRecipeChangeLoaders.patchEBFMapForCircuitUnification(); + + recipesAdded = true; + } + + StaticRecipeChangeLoaders.fixEnergyRequirements(); + // StaticRecipeChangeLoaders.synchroniseCircuitUseMulti(); + + // Accept recipe map changes into Buffers + RecipeMap.ALL_RECIPE_MAPS.values() + .forEach( + map -> map.getBackend() + .reInit()); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java new file mode 100644 index 0000000000..969398df47 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.ClientEventHandler; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.util.Pair; + +class TooltipCache { + + private static final HashMap, char[]> cache = new HashMap<>(); + + static boolean put(ItemStack itemStack, List tooltip) { + Pair p = new Pair<>(Item.getIdFromItem(itemStack.getItem()), (short) itemStack.getItemDamage()); + if (TooltipCache.cache.containsKey(p) || tooltip.isEmpty()) { + return false; + } + StringBuilder sb = new StringBuilder(); + for (String s : tooltip) { + sb.append(s); + sb.append(System.lineSeparator()); + } + char[] rettype = sb.toString() + .toCharArray(); + return TooltipCache.cache.put(p, rettype) == rettype; + } + + static List getTooltip(ItemStack itemStack) { + Pair p = new Pair<>(Item.getIdFromItem(itemStack.getItem()), (short) itemStack.getItemDamage()); + char[] toTest = TooltipCache.cache.get(p); + if (toTest == null) { + return new ArrayList<>(); + } + return Arrays.asList(new String(toTest).split(System.lineSeparator())); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java new file mode 100644 index 0000000000..9f7fb64e4b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.ClientEventHandler; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_Blocks; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; + +@SideOnly(Side.CLIENT) +public class TooltipEventHandler { + + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void getTooltip(ItemTooltipEvent event) { + + if (event == null || event.itemStack == null || event.itemStack.getItem() == null) return; + + if (TooltipCache.getTooltip(event.itemStack) + .isEmpty()) { + ItemStack tmp = event.itemStack.copy(); + Pair abstractedStack = new Pair<>( + Item.getIdFromItem(tmp.getItem()), + (short) tmp.getItemDamage()); + List tooAdd = new ArrayList<>(); + if (ConfigHandler.sharedItemStackTooltip && OreDictHandler.getNonBWCache() + .contains(abstractedStack)) { + for (Pair pair : OreDictHandler.getNonBWCache()) { + if (pair.equals(abstractedStack)) { + GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); + if (UI == null) + UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); + if (UI != null) { + for (ModContainer modContainer : Loader.instance() + .getModList()) { + if (MainMod.MOD_ID.equals(UI.modId) || BartWorksCrossmod.MOD_ID.equals(UI.modId) + || "BWCore".equals(UI.modId)) break; + if (UI.modId.equals(modContainer.getModId())) { + tooAdd.add( + "Shared ItemStack between " + ChatColorHelper.DARKGREEN + + "BartWorks" + + ChatColorHelper.GRAY + + " and " + + ChatColorHelper.RED + + modContainer.getName()); + } + } + } else tooAdd.add( + "Shared ItemStack between " + ChatColorHelper.DARKGREEN + + "BartWorks" + + ChatColorHelper.GRAY + + " and another Mod, that doesn't use the ModContainer propperly!"); + } + } + } + + Block BLOCK = Block.getBlockFromItem(event.itemStack.getItem()); + if (BLOCK != null && BLOCK != Blocks.air) { + if (BLOCK instanceof BW_Blocks) { + TooltipCache.put(event.itemStack, tooAdd); + return; + } + BioVatLogicAdder.BlockMetaPair PAIR = new BioVatLogicAdder.BlockMetaPair( + BLOCK, + (byte) event.itemStack.getItemDamage()); + HashMap GLASSMAP = BioVatLogicAdder.BioVatGlass.getGlassMap(); + if (GLASSMAP.containsKey(PAIR)) { + int tier = GLASSMAP.get(PAIR); + tooAdd.add( + StatCollector.translateToLocal("tooltip.glas.0.name") + " " + + BW_ColorUtil.getColorForTier(tier) + + GT_Values.VN[tier] + + ChatColorHelper.RESET); + } else if (BLOCK.getMaterial() + .equals(Material.glass)) { + tooAdd.add( + StatCollector.translateToLocal("tooltip.glas.0.name") + " " + + BW_ColorUtil.getColorForTier(3) + + GT_Values.VN[3] + + ChatColorHelper.RESET); + } + } + + TooltipCache.put(event.itemStack, tooAdd); + event.toolTip.addAll(tooAdd); + } else { + event.toolTip.addAll(TooltipCache.getTooltip(event.itemStack)); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/BioTab.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/BioTab.java new file mode 100644 index 0000000000..8d3d457e06 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/BioTab.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; + +public class BioTab extends CreativeTabs { + + public BioTab(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return BioItemList.getPetriDish(null) + .getItem(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java new file mode 100644 index 0000000000..5a42164597 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; + +public class GT2Tab extends CreativeTabs { + + public GT2Tab(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ItemRegistry.TAB; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java new file mode 100644 index 0000000000..53be7436ce --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; + +public class bartworksTab extends CreativeTabs { + + public bartworksTab(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ItemRegistry.ROCKCUTTER_HV; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java new file mode 100644 index 0000000000..e2bb68b290 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.gui; + +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + +import com.github.bartimaeusnek.bartworks.MainMod; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.block.kineticgenerator.container.ContainerWindKineticGenerator; +import ic2.core.block.kineticgenerator.gui.GuiWindKineticGenerator; +import ic2.core.util.GuiTooltipHelper; + +@SideOnly(Side.CLIENT) +public class BW_GUIContainer_RotorBlock extends GuiWindKineticGenerator { + + public ContainerWindKineticGenerator container; + public String name; + + public BW_GUIContainer_RotorBlock(ContainerWindKineticGenerator container1) { + super(container1); + this.container = container1; + this.name = StatCollector.translateToLocal("tile.BWRotorBlock.0.name"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + this.fontRendererObj + .drawString(this.name, (this.xSize - this.fontRendererObj.getStringWidth(this.name)) / 2, 6, 2157374); + if (this.container.base.checkrotor()) { + if (!this.container.base.rotorspace()) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotorspace"), + 27, + 52, + 2157374); + } else if (this.container.base.checkrotor() && !this.container.base.guiisminWindStrength()) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.windweak1"), + 27, + 52, + 2157374); + } else { + this.fontRendererObj.drawString(this.container.base.getRotorhealth() + " %", 46, 52, 2157374); + if (this.container.base.guiisoverload()) { + GuiTooltipHelper.drawAreaTooltip( + mouseX - this.guiLeft, + mouseY - this.guiTop, + StatCollector.translateToLocal("ic2.WindKineticGenerator.error.overload"), + 44, + 27, + 79, + 52); + } + } + } else { + this.fontRendererObj + .drawString(StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotormiss"), 27, 52, 2157374); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor3f(0.5f, 0.25f, 0.07f); + this.mc.getTextureManager() + .bindTexture(new ResourceLocation(MainMod.MOD_ID, "textures/GUI/GUIPrimitiveKUBox.png")); + int j = (this.width - this.xSize) / 2; + int k = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); + if (this.container.base.guiisoverload() && this.container.base.checkrotor()) { + this.drawTexturedModalRect(j + 44, k + 20, 176, 0, 30, 26); + this.drawTexturedModalRect(j + 102, k + 20, 176, 0, 30, 26); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java new file mode 100644 index 0000000000..6bf5fd3fe1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java @@ -0,0 +1,112 @@ +package com.github.bartimaeusnek.bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; + +@SideOnly(Side.CLIENT) +public class BW_EICPistonVisualizer extends EntityFX { + + public BW_EICPistonVisualizer(World world, int x, int y, int z, int age) { + super(world, x, y, z); + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.particleMaxAge = age; + } + + @Override + public void onUpdate() { + if (this.particleAge++ >= this.particleMaxAge) this.setDead(); + } + + @Override + public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, + float p_70539_5_, float p_70539_6_, float p_70539_7_) { + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + + RenderBlocks.getInstance().blockAccess = this.worldObj; + RenderBlocks.getInstance() + .setRenderFromInside(false); + + // Look at nearby block for correct tiered block to use + Pair tieredBlock; + if (this.worldObj != null) { + int nX = (int) this.posX; + int nY = (int) this.posY + 1; + int nZ = (int) this.posZ; + Block neighborBlock = this.worldObj.getBlock(nX, nY, nZ); + int neighborMeta = this.worldObj.getBlockMetadata(nX, nY, nZ); + tieredBlock = Pair.of(neighborBlock, neighborMeta); + } else { + tieredBlock = Pair.of(GregTech_API.sBlockMetal5, 2); + } + + IIcon icon = tieredBlock.getKey() + .getIcon(0, tieredBlock.getValue()); + + double x = this.posX + 1; + double z = this.posZ; + + double f11 = x - interpPosX; + double f12 = this.posY - interpPosY; + double f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX - 1; + z = this.posZ; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX; + z = this.posZ + 1; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX; + z = this.posZ - 1; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + tessellator.setTranslation(0d, 0d, 0d); + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(true); + } + + @Override + public int getFXLayer() { + return 1; + } + + @Override + public boolean shouldRenderInPass(int pass) { + return pass == 2; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java new file mode 100644 index 0000000000..4c27a2a3f9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.renderer; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; + +import org.lwjgl.opengl.GL11; + +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_Meta_Items; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_Utility; +import gregtech.common.render.GT_RenderUtil; + +@SideOnly(Side.CLIENT) +public class BW_GT_ItemRenderer implements IItemRenderer { + + public BW_GT_ItemRenderer() { + for (BW_Meta_Items.BW_GT_MetaGen_Item_Hook tItem : BW_Meta_Items.BW_GT_MetaGen_Item_Hook.sInstances) { + MinecraftForgeClient.registerItemRenderer(tItem, this); + } + } + + @Override + public boolean handleRenderType(ItemStack aStack, IItemRenderer.ItemRenderType aType) { + if (!GT_Utility.isStackInvalid(aStack) && aStack.getItemDamage() >= 0) { + return aType == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON + || aType == IItemRenderer.ItemRenderType.INVENTORY + || aType == IItemRenderer.ItemRenderType.EQUIPPED + || aType == IItemRenderer.ItemRenderType.ENTITY; + } + return false; + } + + @Override + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType aType, ItemStack aStack, + IItemRenderer.ItemRendererHelper aHelper) { + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } + return aType == IItemRenderer.ItemRenderType.ENTITY; + } + + @Override + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Object... data) { + if (!GT_Utility.isStackInvalid(aStack)) { + short aMetaData = (short) aStack.getItemDamage(); + if (aMetaData >= 0) { + BW_Meta_Items.BW_GT_MetaGen_Item_Hook aItem = (BW_Meta_Items.BW_GT_MetaGen_Item_Hook) aStack.getItem(); + GL11.glEnable(3042); + if (type == IItemRenderer.ItemRenderType.ENTITY) { + if (RenderItem.renderInFrame) { + GL11.glScalef(0.85F, 0.85F, 0.85F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + GL11.glTranslated(-0.5D, -0.42D, 0.0D); + } + + GL11.glColor3f(1.0F, 1.0F, 1.0F); + IIcon tIcon = (IIcon) BW_Util.get2DCoordFrom1DArray(aMetaData, 0, 2, aItem.mIconList); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { + if (aMetaData < CircuitImprintLoader.reverseIDs) + GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + else { + for (int i = 0; i < 4; i++) { + GT_RenderUtil.renderItemIcon( + tIcon, + 0.0D + i * 2D, + 0.0D + i * 2D, + 10.0D + i * 2D, + 10.0D + i * 2D, + 0.001D, + 0.0F, + 0.0F, + -1.0F); + } + } + } else if (aMetaData < CircuitImprintLoader.reverseIDs) ItemRenderer.renderItemIn2D( + Tessellator.instance, + tIcon.getMaxU(), + tIcon.getMinV(), + tIcon.getMinU(), + tIcon.getMaxV(), + tIcon.getIconWidth(), + tIcon.getIconHeight(), + 0.0625F); + + IIcon tOverlay = (IIcon) BW_Util.get2DCoordFrom1DArray(aMetaData, 1, 2, aItem.mIconList); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + if (tOverlay != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { + GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D( + Tessellator.instance, + tOverlay.getMaxU(), + tOverlay.getMinV(), + tOverlay.getMinU(), + tOverlay.getMaxV(), + tOverlay.getIconWidth(), + tOverlay.getIconHeight(), + 0.0625F); + } + } + } + + GL11.glDisable(3042); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java new file mode 100644 index 0000000000..a082a44d31 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.IIconContainer; + +@SideOnly(Side.CLIENT) +public class BW_GT_Vanilla_Texture implements IIconContainer { + + IIcon packed; + + public BW_GT_Vanilla_Texture(Block block, ForgeDirection side) { + this.packed = block.getBlockTextureFromSide(side.flag); + } + + public BW_GT_Vanilla_Texture(Block block, int side) { + this.packed = block.getBlockTextureFromSide(side); + } + + public BW_GT_Vanilla_Texture(IIcon packed) { + this.packed = packed; + } + + @Override + public IIcon getIcon() { + return this.packed; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(this.packed.getIconName()); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java new file mode 100644 index 0000000000..7bb04e0c39 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.renderer; + +import static gregtech.common.render.GT_Renderer_Block.renderNegativeXFacing; +import static gregtech.common.render.GT_Renderer_Block.renderNegativeYFacing; +import static gregtech.common.render.GT_Renderer_Block.renderNegativeZFacing; +import static gregtech.common.render.GT_Renderer_Block.renderPositiveXFacing; +import static gregtech.common.render.GT_Renderer_Block.renderPositiveYFacing; +import static gregtech.common.render.GT_Renderer_Block.renderPositiveZFacing; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Block_TE; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Blocks; +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.GT_Mod; + +@ThreadSafeISBRH(perThread = true) +public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler { + + public static BW_Renderer_Block_Ores INSTANCE; + public static int renderID; + public static final float blockMin = 0.0F; + public static final float blockMax = 1.0F; + + public static void register() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + INSTANCE = new BW_Renderer_Block_Ores(); + RenderingRegistry.registerBlockHandler(INSTANCE); + } + + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int modelId, RenderBlocks aRenderer) { + BW_MetaGenerated_Block_TE tTileEntity = ((BW_MetaGenerated_Blocks) aBlock).getProperTileEntityForRendering(); + tTileEntity.mMetaData = (short) aMeta; + aRenderer.enableAO = false; + aRenderer.useInventoryTint = true; + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.DOWN), + true); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.UP), + true); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.NORTH), + true); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), + true); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.WEST), + true); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.EAST), + true); + aRenderer.setRenderBoundsFromBlock(aBlock); + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + aRenderer.useInventoryTint = false; + } + + // spotless:off + @Override + public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int modelId, RenderBlocks aRenderer) { + BW_MetaGenerated_Blocks tBlock = (BW_MetaGenerated_Blocks) aBlock; + if(tBlock == null) return false; + + BW_MetaGenerated_Block_TE fakeTileEntity = tBlock.getProperTileEntityForRendering(); // meh + if(fakeTileEntity == null) return false; + + BW_MetaGenerated_Block_TE actualTileEntity = (BW_MetaGenerated_Block_TE) aWorld.getTileEntity(aX, aY, aZ); + if(actualTileEntity == null) return false; + + fakeTileEntity.mMetaData = actualTileEntity.mMetaData; + aRenderer.useInventoryTint = false; + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion; + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.DOWN), true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.UP), true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.NORTH), true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.WEST), true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.EAST), true); + return true; + } + // spotless:on + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return renderID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java new file mode 100644 index 0000000000..ce87e4a68a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks2; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +@ThreadSafeISBRH(perThread = false) +public class RendererGlasBlock implements ISimpleBlockRenderingHandler { + + public static int renderID; + public static RendererGlasBlock INSTANCE; + + public static void register() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + INSTANCE = new RendererGlasBlock(); + RenderingRegistry.registerBlockHandler(INSTANCE); + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + Tessellator tessellator = Tessellator.instance; + block.setBlockBoundsForItemRender(); + renderer.setRenderBoundsFromBlock(block); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + // spotless:off + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + if (block instanceof BW_GlasBlocks) { + renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses, x, y, z); + renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, + ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f, + ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f, + ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f); + } + if (block instanceof BW_GlasBlocks2) { + renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses2, x, y, z); + renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, + ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f, + ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f, + ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f); + } + return true; + } + // spotless:on + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return RendererGlasBlock.renderID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java new file mode 100644 index 0000000000..7a12074e02 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.IFluidBlock; + +import com.github.bartimaeusnek.bartworks.common.blocks.BioFluidBlock; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_BioVat; +import com.github.bartimaeusnek.bartworks.util.Coords; +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +@ThreadSafeISBRH(perThread = false) +public class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler { + + private static final float LIGHT_Y_NEG = 0.5f; + private static final float LIGHT_Y_POS = 1f; + private static final float LIGHT_XZ_NEG = 0.8f; + private static final float LIGHT_XZ_POS = 0.6f; + private static final float THREE_QUARTERS_FILLED = 0.875f; + private static final double RENDER_OFFSET = 0.0010000000474974513; + + public static RendererSwitchingColorFluid instance; + + public static void register() { + instance = new RendererSwitchingColorFluid(); + } + + private float getFluidHeightAverage(float[] flow) { + float total = 0.0f; + int count = 0; + float end = 0.0f; + for (float aFlow : flow) { + if (aFlow >= RendererSwitchingColorFluid.THREE_QUARTERS_FILLED + && end != RendererSwitchingColorFluid.LIGHT_Y_POS) { + end = aFlow; + } + if (aFlow >= 0.0f) { + total += aFlow; + ++count; + } + } + if (end == 0.0f && count != 0) { + end = total / count; + } + return end; + } + + private float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block) { + + if (world.getBlock(x, y, z) == block) { + Block vOrigin = world.getBlock(x, y + 1, z); + if (vOrigin.getMaterial() + .isLiquid() || vOrigin instanceof IFluidBlock) { + return RendererSwitchingColorFluid.LIGHT_Y_POS; + } + if (world.getBlockMetadata(x, y, z) == block.getMaxRenderHeightMeta()) { + return RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; + } + } + return !world.getBlock(x, y, z) + .getMaterial() + .isSolid() && world.getBlock(x, y + 1, z) == block ? RendererSwitchingColorFluid.LIGHT_Y_POS + : block.getQuantaPercentage(world, x, y, z) * RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; + } + + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {} + + @SideOnly(Side.CLIENT) + public boolean renderWorldBlock(IBlockAccess iBlockAccess, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + if (!(block instanceof BioFluidBlock)) return false; + Tessellator tessellator = Tessellator.instance; + Coords blockat = new Coords( + x, + y, + z, + iBlockAccess.getTileEntity(x, y, z) + .getWorldObj().provider.dimensionId); + Integer rgb = GT_TileEntity_BioVat.staticColorMap.get(blockat); + + int r, g, b; + + if (rgb != null) { + r = rgb >> 16 & 0xFF; + g = rgb >> 8 & 0xFF; + b = rgb & 0xFF; + } else { + r = 0; + g = 0; + b = 255; + } + float red = r / 255f, green = g / 255f, blue = b / 255f; + + BlockFluidBase blockFluidBase = (BlockFluidBase) block; + boolean renderTop = iBlockAccess.getBlock(x, y + 1, z) != blockFluidBase; + boolean renderBottom = block.shouldSideBeRendered(iBlockAccess, x, y - 1, z, 0) + && iBlockAccess.getBlock(x, y - 1, z) != blockFluidBase; + boolean[] renderSides = { block.shouldSideBeRendered(iBlockAccess, x, y, z - 1, 2), + block.shouldSideBeRendered(iBlockAccess, x, y, z + 1, 3), + block.shouldSideBeRendered(iBlockAccess, x - 1, y, z, 4), + block.shouldSideBeRendered(iBlockAccess, x + 1, y, z, 5) }; + if (!renderTop && !renderBottom && !renderSides[0] && !renderSides[1] && !renderSides[2] && !renderSides[3]) { + return false; + } + boolean rendered = false; + float fluidHeightForRender = this.getFluidHeightForRender(iBlockAccess, x, y, z, blockFluidBase); + double heightNW, heightSW, heightSE, heightNE; + + if (fluidHeightForRender != RendererSwitchingColorFluid.LIGHT_Y_POS) { + float fluidHeightForRender1 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z - 1, blockFluidBase); + float fluidHeightForRender2 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z, blockFluidBase); + float fluidHeightForRender3 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z + 1, blockFluidBase); + float fluidHeightForRender4 = this.getFluidHeightForRender(iBlockAccess, x, y, z - 1, blockFluidBase); + float fluidHeightForRender5 = this.getFluidHeightForRender(iBlockAccess, x, y, z + 1, blockFluidBase); + float fluidHeightForRender6 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z - 1, blockFluidBase); + float fluidHeightForRender7 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z, blockFluidBase); + float fluidHeightForRender8 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z + 1, blockFluidBase); + heightNW = this.getFluidHeightAverage( + new float[] { fluidHeightForRender1, fluidHeightForRender2, fluidHeightForRender4, + fluidHeightForRender }); + heightSW = this.getFluidHeightAverage( + new float[] { fluidHeightForRender2, fluidHeightForRender3, fluidHeightForRender5, + fluidHeightForRender }); + heightSE = this.getFluidHeightAverage( + new float[] { fluidHeightForRender5, fluidHeightForRender7, fluidHeightForRender8, + fluidHeightForRender }); + heightNE = this.getFluidHeightAverage( + new float[] { fluidHeightForRender4, fluidHeightForRender6, fluidHeightForRender7, + fluidHeightForRender }); + } else { + heightNW = fluidHeightForRender; + heightSW = fluidHeightForRender; + heightSE = fluidHeightForRender; + heightNE = fluidHeightForRender; + } + + if (renderer.renderAllFaces || renderTop) { + rendered = true; + IIcon iconStill = this.getNullCheckedIiconOrFallbackTexture(); + float flowDir = (float) BlockFluidBase.getFlowDirection(iBlockAccess, x, y, z); + + heightNW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSE -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightNE -= RendererSwitchingColorFluid.RENDER_OFFSET; + + double dInterpolatedU, dInterpolatedV, dInterpolatedU2, dInterpolatedV2, dInterpolatedU3, dInterpolatedV3, + dInterpolatedU4, dInterpolatedV4; + + if (flowDir < -999.0f) { + dInterpolatedU = iconStill.getInterpolatedU(0.0); + dInterpolatedV = iconStill.getInterpolatedV(0.0); + dInterpolatedU2 = dInterpolatedU; + dInterpolatedV2 = iconStill.getInterpolatedV(16.0); + dInterpolatedU3 = iconStill.getInterpolatedU(16.0); + dInterpolatedV3 = dInterpolatedV2; + dInterpolatedU4 = dInterpolatedU3; + dInterpolatedV4 = dInterpolatedV; + } else { + float xFlow = MathHelper.sin(flowDir) * 0.25f, zFlow = MathHelper.cos(flowDir) * 0.25f; + dInterpolatedU = iconStill.getInterpolatedU(8.0f + (-zFlow - xFlow) * 16.0f); + dInterpolatedV = iconStill.getInterpolatedV(8.0f + (-zFlow + xFlow) * 16.0f); + dInterpolatedU2 = iconStill.getInterpolatedU(8.0f + (-zFlow + xFlow) * 16.0f); + dInterpolatedV2 = iconStill.getInterpolatedV(8.0f + (zFlow + xFlow) * 16.0f); + dInterpolatedU3 = iconStill.getInterpolatedU(8.0f + (zFlow + xFlow) * 16.0f); + dInterpolatedV3 = iconStill.getInterpolatedV(8.0f + (zFlow - xFlow) * 16.0f); + dInterpolatedU4 = iconStill.getInterpolatedU(8.0f + (zFlow - xFlow) * 16.0f); + dInterpolatedV4 = iconStill.getInterpolatedV(8.0f + (-zFlow - xFlow) * 16.0f); + } + + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x, y, z)); + tessellator.setColorOpaque_F( + RendererSwitchingColorFluid.LIGHT_Y_POS * red, + RendererSwitchingColorFluid.LIGHT_Y_POS * green, + RendererSwitchingColorFluid.LIGHT_Y_POS * blue); + + tessellator.addVertexWithUV(x, y + heightNW, z, dInterpolatedU, dInterpolatedV); + tessellator.addVertexWithUV(x, y + heightSW, z + 1, dInterpolatedU2, dInterpolatedV2); + tessellator.addVertexWithUV(x + 1, y + heightSE, z + 1, dInterpolatedU3, dInterpolatedV3); + tessellator.addVertexWithUV(x + 1, y + heightNE, z, dInterpolatedU4, dInterpolatedV4); + tessellator.addVertexWithUV(x, y + heightNW, z, dInterpolatedU, dInterpolatedV); + tessellator.addVertexWithUV(x + 1, y + heightNE, z, dInterpolatedU4, dInterpolatedV4); + tessellator.addVertexWithUV(x + 1, y + heightSE, z + 1, dInterpolatedU3, dInterpolatedV3); + tessellator.addVertexWithUV(x, y + heightSW, z + 1, dInterpolatedU2, dInterpolatedV2); + } + + if (renderer.renderAllFaces || renderBottom) { + rendered = true; + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x, y - 1, z)); + tessellator.setColorOpaque_F( + RendererSwitchingColorFluid.LIGHT_Y_NEG * red, + RendererSwitchingColorFluid.LIGHT_Y_NEG * green, + RendererSwitchingColorFluid.LIGHT_Y_NEG * blue); + renderer.renderFaceYNeg( + block, + x, + y + RendererSwitchingColorFluid.RENDER_OFFSET, + z, + this.getNullCheckedIiconOrFallbackTexture()); + } + + for (int side = 0; side < 4; ++side) { + int x2 = x, z2 = z; + + switch (side) { + case 0: + --z2; + break; + case 1: + ++z2; + break; + case 2: + --x2; + break; + case 3: + ++x2; + break; + default: + break; + } + + IIcon iconFlow = this.getNullCheckedIiconOrFallbackTexture(); + + if (renderer.renderAllFaces || renderSides[side]) { + rendered = true; + double dHeight1, dHeight2, dXcoord1, dXcoord2, dZcoord1, dZcoord2; + dZcoord2 = switch (side) { + case 0 -> { + dHeight1 = heightNW; + dHeight2 = heightNE; + dXcoord1 = x; + dXcoord2 = x + 1; + dZcoord1 = z + RendererSwitchingColorFluid.RENDER_OFFSET; + yield z + RendererSwitchingColorFluid.RENDER_OFFSET; + } + case 1 -> { + dHeight1 = heightSE; + dHeight2 = heightSW; + dXcoord1 = x + 1; + dXcoord2 = x; + dZcoord1 = z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + yield z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + } + case 2 -> { + dHeight1 = heightSW; + dHeight2 = heightNW; + dXcoord1 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z + 1; + yield z; + } + default -> { + dHeight1 = heightNE; + dHeight2 = heightSE; + dXcoord1 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z; + yield z + 1; + } + }; + float u1Flow = iconFlow.getInterpolatedU(0.0); + float u2Flow = iconFlow.getInterpolatedU(8.0); + float v1Flow = iconFlow.getInterpolatedV((1.0 - dHeight1) * 16.0 * 0.5); + float v2Flow = iconFlow.getInterpolatedV((1.0 - dHeight2) * 16.0 * 0.5); + float v3Flow = iconFlow.getInterpolatedV(8.0); + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x2, y, z2)); + float sideLighting; + if (side < 2) { + sideLighting = RendererSwitchingColorFluid.LIGHT_XZ_NEG; + } else { + sideLighting = RendererSwitchingColorFluid.LIGHT_XZ_POS; + } + tessellator.setColorOpaque_F( + RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * red, + RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * green, + RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * blue); + + tessellator.addVertexWithUV(dXcoord1, y + dHeight1, dZcoord1, u1Flow, v1Flow); + tessellator.addVertexWithUV(dXcoord2, y + dHeight2, dZcoord2, u2Flow, v2Flow); + tessellator.addVertexWithUV(dXcoord2, y, dZcoord2, u2Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord1, y, dZcoord1, u1Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord1, y + dHeight1, dZcoord1, u1Flow, v1Flow); + tessellator.addVertexWithUV(dXcoord1, y, dZcoord1, u1Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord2, y, dZcoord2, u2Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord2, y + dHeight2, dZcoord2, u2Flow, v2Flow); + } + } + renderer.renderMinY = 0.0; + renderer.renderMaxY = 1.0; + return rendered; + } + + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + + public int getRenderId() { + return FluidLoader.renderID; + } + + private IIcon getNullCheckedIiconOrFallbackTexture() { + return FluidLoader.autogenIIcon != null ? FluidLoader.autogenIIcon + : ((TextureMap) Minecraft.getMinecraft() + .getTextureManager() + .getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java new file mode 100644 index 0000000000..09df8f98f8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.textures; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; + +@SideOnly(Side.CLIENT) +public class PrefixTextureLinker implements Runnable { + + public static Map> texMap = new HashMap<>(); + public static Map> texMapBlocks = new HashMap<>(); + public static Map blockTexMap = new HashMap<>(); + + private static void fillBlockTexMap() { + blockTexMap.put(TextureSet.SET_QUARTZ, TextureSet.INDEX_block4); + Stream.of(OrePrefixes.blockCasing, OrePrefixes.blockCasingAdvanced) + .forEach(prefixes -> { + HashMap curr = new HashMap<>(); + Arrays.stream(TextureSet.class.getFields()) + .filter( + field -> field.getName() + .contains("SET")) + .forEach(SET -> { + try { + curr.put( + (TextureSet) SET.get(null), + new Textures.BlockIcons.CustomIcon( + "materialicons/" + SET.getName() + .substring(4) + "/" + prefixes)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + }); + texMapBlocks.put(prefixes, curr); + }); + } + + private static void fillItemTexMap() { + Arrays.stream(OrePrefixes.values()) + .filter( + prefixes -> prefixes != OrePrefixes.rod && prefixes.mTextureIndex == -1 + && Werkstoff.GenerationFeatures.getPrefixDataRaw(prefixes) != 0) + .forEach(prefixes -> { + HashMap curr = new HashMap<>(); + Arrays.stream(TextureSet.class.getFields()) + .filter( + field -> field.getName() + .contains("SET")) + .forEach(SET -> { + try { + curr.put( + (TextureSet) SET.get(null), + new Textures.ItemIcons.CustomIcon( + "materialicons/" + SET.getName() + .substring(4) + "/" + prefixes)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + }); + texMap.put(prefixes, curr); + }); + } + + @Override + public void run() { + fillItemTexMap(); + fillBlockTexMap(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java new file mode 100644 index 0000000000..1a00d16d85 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.MainMod; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; + +public class BW_Blocks extends Block { + + @SideOnly(Side.CLIENT) + protected IIcon[] texture; + + String[] textureNames; + protected String name; + + public BW_Blocks(String name, String[] texture) { + super(Material.anvil); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.name = name; + this.textureNames = texture; + this.setCreativeTab(MainMod.GT2); + GregTech_API.registerMachineBlock(this, -1); + } + + public BW_Blocks(String name, String[] texture, CreativeTabs tabs) { + super(Material.anvil); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.name = name; + this.textureNames = texture; + this.setCreativeTab(tabs); + GregTech_API.registerMachineBlock(this, -1); + } + + public BW_Blocks(String name, String[] texture, CreativeTabs tabs, Material material) { + super(material); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.name = name; + this.textureNames = texture; + this.setCreativeTab(tabs); + GregTech_API.registerMachineBlock(this, -1); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < this.textureNames.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public String getUnlocalizedName() { + return this.name; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java new file mode 100644 index 0000000000..c60f63129a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.renderer.RendererGlasBlock; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BW_GlasBlocks extends BW_Blocks { + + @SideOnly(Side.CLIENT) + private IIcon[] connectedTexture; + + private final boolean connectedTex; + private boolean fake; + private short[][] color = new short[this.textureNames.length][3]; + + public BW_GlasBlocks(String name, String[] texture, CreativeTabs tabs) { + super(name, texture, tabs, Material.glass); + this.connectedTex = false; + } + + public BW_GlasBlocks(String name, String[] texture, short[][] color, CreativeTabs tabs, boolean connectedTex, + boolean fake) { + super(name, texture, tabs, Material.glass); + this.connectedTex = connectedTex; + this.color = color; + this.fake = fake; + } + + public short[] getColor(int meta) { + return meta < this.texture.length ? this.color[meta] : this.color[0]; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (worldClient.getBlock(xCoord, yCoord, zCoord) instanceof BW_GlasBlocks) return false; + return super.shouldSideBeRendered(worldClient, xCoord, yCoord, zCoord, aSide); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + if (!this.connectedTex) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + return; + } + this.texture = new IIcon[this.textureNames.length]; + this.connectedTexture = new IIcon[16]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + String[] splitname = this.textureNames[0].split(":"); + for (int j = 0; j < 16; j++) { + this.connectedTexture[j] = par1IconRegister + .registerIcon(splitname[0] + ":connectedTex/" + splitname[1] + '/' + splitname[1] + '_' + j); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (!this.connectedTex) return super.getIcon(worldClient, xCoord, yCoord, zCoord, aSide); + + ForgeDirection dir = ForgeDirection.getOrientation(aSide); + byte sides = 0; + switch (dir) { + case UP: + case DOWN: { + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b1000); + break; + } + case EAST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b1000); + break; + } + case WEST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b1000); + break; + } + case NORTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b1000); + break; + } + case SOUTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BW_GlasBlocks) + sides = (byte) (sides | 0b1000); + break; + } + case UNKNOWN: + default: { + break; + } + } + return this.connectedTexture[sides]; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public int getRenderType() { + if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.renderID; + return 0; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java new file mode 100644 index 0000000000..4ef12dc30b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java @@ -0,0 +1,180 @@ +package com.github.bartimaeusnek.bartworks.common.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.renderer.RendererGlasBlock; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BW_GlasBlocks2 extends BW_Blocks { + + @SideOnly(Side.CLIENT) + private IIcon[] connectedTexture; + + private final boolean connectedTex; + private boolean fake; + private short[][] color = new short[this.textureNames.length][3]; + + public BW_GlasBlocks2(String name, String[] texture, CreativeTabs tabs) { + super(name, texture, tabs, Material.glass); + this.connectedTex = false; + } + + public BW_GlasBlocks2(String name, String[] texture, short[][] color, CreativeTabs tabs, boolean connectedTex, + boolean fake) { + super(name, texture, tabs, Material.glass); + this.connectedTex = connectedTex; + this.color = color; + this.fake = fake; + } + + public short[] getColor(int meta) { + return meta < this.texture.length ? this.color[meta] : this.color[0]; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (worldClient.getBlock(xCoord, yCoord, zCoord) instanceof BW_GlasBlocks2) return false; + return super.shouldSideBeRendered(worldClient, xCoord, yCoord, zCoord, aSide); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + if (!this.connectedTex) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + return; + } + this.texture = new IIcon[this.textureNames.length]; + this.connectedTexture = new IIcon[16]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + String[] splitname = this.textureNames[0].split(":"); + for (int j = 0; j < 16; j++) { + this.connectedTexture[j] = par1IconRegister.registerIcon( + splitname[0] + ":connectedTex/" + + "BoronSilicateGlassBlock" + + '/' + + "BoronSilicateGlassBlock" + + '_' + + j); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (!this.connectedTex) return super.getIcon(worldClient, xCoord, yCoord, zCoord, aSide); + + ForgeDirection dir = ForgeDirection.getOrientation(aSide); + byte sides = 0; + switch (dir) { + case UP: + case DOWN: { + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b1000); + break; + } + case EAST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b1000); + break; + } + case WEST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b1000); + break; + } + case NORTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b1000); + break; + } + case SOUTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BW_GlasBlocks2) + sides = (byte) (sides | 0b1000); + break; + } + case UNKNOWN: + default: { + break; + } + } + return this.connectedTexture[sides]; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public int getRenderType() { + if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.renderID; + return 0; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java new file mode 100644 index 0000000000..fb8e163ad1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.IFluidContainerItem; + +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileDropsContent; +import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +import com.gtnewhorizons.modularui.api.UIInfos; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.IHasGui; + +public class BW_TileEntityContainer extends BlockContainer implements ITileAddsInformation { + + protected Class tileEntity; + + public BW_TileEntityContainer(Material p_i45386_1_, Class tileEntity, String blockName) { + super(p_i45386_1_); + this.tileEntity = tileEntity; + this.setHardness(15.0F); + this.setResistance(30.0F); + this.setCreativeTab(MainMod.BWT); + this.setBlockName(blockName); + this.setBlockTextureName(MainMod.MOD_ID + ":" + blockName); + } + + @Override + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if (worldObj.isRemote) { + return false; + } + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof BW_TileEntity_HeatedWaterPump) { + if (player.getHeldItem() != null && (player.getHeldItem() + .getItem() + .equals(Items.bucket) + || player.getHeldItem() + .getItem() instanceof IFluidContainerItem) + && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false) != null) + if (player.getHeldItem() + .getItem() + .equals(Items.bucket) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false).amount == 1000) { + ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, true); + player.getHeldItem().stackSize--; + if (player.getHeldItem().stackSize <= 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + player.inventory.addItemStackToInventory(new ItemStack(Items.water_bucket)); + return true; + } + } + if (!player.isSneaking()) { + if (tile instanceof IHasGui) { + return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); + } + if (tile instanceof ITileWithModularUI) { + if (!worldObj.isRemote) { + UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); + } + return true; + } + } + return false; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IWrenchable tile2 && itemStack != null) { + int meta = itemStack.getItemDamage(); + world.setBlockMetadataWithNotify(x, y, z, meta, 2); + if (entity != null) { + int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; + switch (face) { + case 0: + tile2.setFacing((short) 2); + break; + case 1: + tile2.setFacing((short) 5); + break; + case 2: + tile2.setFacing((short) 3); + break; + case 3: + tile2.setFacing((short) 4); + break; + } + } + } + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity t = world.getTileEntity(x, y, z); + if (t instanceof ITileDropsContent) { + int[] dropSlots = ((ITileDropsContent) t).getDropSlots(); + for (int dropSlot : dropSlots) { + if (((ITileDropsContent) t).getStackInSlot(dropSlot) != null) world.spawnEntityInWorld( + new EntityItem(world, x, y, z, ((BW_TileEntity_HeatedWaterPump) t).getStackInSlot(dropSlot))); + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + if (!ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) return super.getIcon(side, meta); + try { + return ((ITileHasDifferentTextureSides) this.tileEntity.getConstructor() + .newInstance()).getTextureForSide(side, meta); + } catch (Exception e) { + e.printStackTrace(); + return super.getIcon(side, meta); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + if (ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) { + try { + ((ITileHasDifferentTextureSides) this.tileEntity.getConstructor() + .newInstance()).registerBlockIcons(par1IconRegister); + } catch (Exception e) { + e.printStackTrace(); + } + } else super.registerBlockIcons(par1IconRegister); + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + try { + return this.tileEntity.getConstructor() + .newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public String[] getInfoData() { + if (ITileAddsInformation.class.isAssignableFrom(this.tileEntity)) { + try { + return ((ITileAddsInformation) this.tileEntity.getConstructor() + .newInstance()).getInfoData(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return new String[0]; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_MachineBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_MachineBlock.java new file mode 100644 index 0000000000..0d1d9fd20b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_MachineBlock.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; + +public class BW_TileEntityContainer_MachineBlock extends BW_TileEntityContainer { + + public BW_TileEntityContainer_MachineBlock(Material p_i45386_1_, Class tileEntity, + String blockName) { + super(p_i45386_1_, tileEntity, blockName); + GregTech_API.registerMachineBlock(this, -1); + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java new file mode 100644 index 0000000000..852d8370ad --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.blocks; + +import java.util.List; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.gtnewhorizons.modularui.api.UIInfos; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.IHasGui; + +public class BW_TileEntityContainer_Multiple extends BlockContainer { + + protected final String[] textureNames; + protected final String name; + protected final Class[] tileEntityArray; + + @SideOnly(Side.CLIENT) + protected IIcon[] texture; + + public BW_TileEntityContainer_Multiple(Material p_i45386_1_, Class[] tileEntity, + String blockName, String[] textureNames, CreativeTabs tabs) { + super(p_i45386_1_); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.tileEntityArray = tileEntity; + this.name = blockName; + this.textureNames = textureNames; + this.setCreativeTab(tabs); + this.setBlockName(blockName); + this.setBlockTextureName(MainMod.MOD_ID + ":" + blockName); + } + + @Override + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if (worldObj.isRemote) { + return true; + } + if (!player.isSneaking()) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof IHasGui) { + return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); + } + if (tile instanceof ITileWithModularUI && !worldObj.isRemote) { + UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); + } + } + + return false; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IWrenchable tile2 && itemStack != null) { + int meta = itemStack.getItemDamage(); + world.setBlockMetadataWithNotify(x, y, z, meta, 2); + if (entity != null) { + int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; + switch (face) { + case 0: + tile2.setFacing((short) 2); + break; + case 1: + tile2.setFacing((short) 5); + break; + case 2: + tile2.setFacing((short) 3); + break; + case 3: + tile2.setFacing((short) 4); + break; + } + } + } + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < this.textureNames.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + try { + return this.tileEntityArray[meta].getConstructor() + .newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java new file mode 100644 index 0000000000..a5ad7625f9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.blocks; + +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BWTileEntityDimIDBridge; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BioFluidBlock extends BlockFluidBase implements ITileEntityProvider { + + public BioFluidBlock() { + super(FluidLoader.ff, Material.water); + this.setBlockName("BioFluidBlock"); + // this.setCreativeTab(MainMod.BioTab); + this.textureName = "gregtech:fluids/fluid.molten.autogenerated"; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + FluidLoader.autogenIIcon = this.blockIcon = reg.registerIcon(this.getTextureName()); + } + + @Override + public int getQuantaValue(IBlockAccess world, int x, int y, int z) { + return 0; + } + + @Override + public boolean canCollideCheck(int meta, boolean fullHit) { + return false; + } + + @Override + public int getMaxRenderHeightMeta() { + return 0; + } + + @Override + public int getRenderType() { + return FluidLoader.renderID; + } + + @Override + public FluidStack drain(World world, int x, int y, int z, boolean doDrain) { + return null; + } + + @Override + public boolean canDrain(World world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { + return FluidLoader.autogenIIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return FluidLoader.autogenIIcon; + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + return new BWTileEntityDimIDBridge(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java new file mode 100644 index 0000000000..0434a5d974 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.commands; + +import java.lang.reflect.Field; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + +public class ChangeConfig extends CommandBase { + + @Override + public String getCommandName() { + return "bwcfg"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwcfg "; + } + + @Override + @SuppressWarnings("rawtypes") + public void processCommand(ICommandSender sender, String[] args) { + try { + Field f = ConfigHandler.class.getField(args[0]); + Class c = f.getType(); + if (c.equals(int.class)) { + int l; + try { + l = Integer.parseInt(args[1]); + } catch (NumberFormatException e) { + sender.addChatMessage(new ChatComponentText("you need to enter a number!")); + return; + } + f.setInt(null, l); + } else if (c.equals(long.class)) { + long l; + try { + l = Long.parseLong(args[1]); + } catch (NumberFormatException e) { + sender.addChatMessage(new ChatComponentText("you need to enter a number!")); + return; + } + f.setLong(null, l); + } else if (c.equals(boolean.class)) { + if ("true".equalsIgnoreCase(args[1]) || "1".equalsIgnoreCase(args[1])) f.setBoolean(null, true); + else if ("false".equalsIgnoreCase(args[1]) || "0".equalsIgnoreCase(args[1])) f.setBoolean(null, false); + else { + sender.addChatMessage(new ChatComponentText("booleans need to be set to true or false")); + } + } + sender.addChatMessage(new ChatComponentText("Set " + args[0] + " to " + args[1])); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java new file mode 100644 index 0000000000..7afe07beb0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.commands; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import com.github.bartimaeusnek.bartworks.ASM.BWCoreStaticReplacementMethodes; + +public class ClearCraftingCache extends CommandBase { + + @Override + public String getCommandName() { + return "bwclr"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwclr"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + BWCoreStaticReplacementMethodes.clearRecentlyUsedRecipes(); + sender.addChatMessage(new ChatComponentText("Recipe Cache cleared ")); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java new file mode 100644 index 0000000000..341044c498 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.commands; + +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +public class GetWorkingDirectory extends CommandBase { + + @Override + public String getCommandName() { + return "bwgwd"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwgwd"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + sender.addChatMessage(new ChatComponentText(Minecraft.getMinecraft().mcDataDir.getAbsolutePath())); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java new file mode 100644 index 0000000000..dcd7caee97 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.commands; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.item.crafting.CraftingManager; + +public class PrintRecipeListToFile extends CommandBase { + + @Override + public String getCommandName() { + return "prltf"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "prltf "; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + File file = new File(args[0]); + try { + + BufferedWriter fw = new BufferedWriter(new FileWriter(file)); + CraftingManager.getInstance() + .getRecipeList() + .forEach(e -> { + try { + fw.write( + e.toString() + " = " + + e.getRecipeOutput() + .getDisplayName() + + "\n"); + } catch (IOException ex) { + ex.printStackTrace(); + } + }); + fw.flush(); + fw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java new file mode 100644 index 0000000000..5b76d6a163 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.commands; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +public class RunGC extends CommandBase { + + @Override + public String getCommandName() { + return "bwgc"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwgc"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + Runtime.getRuntime() + .gc(); + sender.addChatMessage(new ChatComponentText("Ran GC!")); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java new file mode 100644 index 0000000000..5b37a98e7e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.commands; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; + +import com.github.bartimaeusnek.bartworks.system.worldgen.MapGenRuins; + +public class SummonRuin extends CommandBase { + + @Override + public String getCommandName() { + return "SummonRuin"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "SummonRuin "; + } + + @Override + public void processCommand(ICommandSender iCommandSender, String[] args) { + try { + new MapGenRuins.RuinsBase().generate( + iCommandSender.getEntityWorld(), + iCommandSender.getEntityWorld().rand, + Integer.parseInt(args[0]), + 256, + Integer.parseInt(args[1])); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java new file mode 100644 index 0000000000..7c5a515b86 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -0,0 +1,334 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.configs; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import net.minecraftforge.common.config.Configuration; + +import com.github.bartimaeusnek.bartworks.API.API_ConfigValues; +import com.github.bartimaeusnek.bartworks.ASM.BWCoreTransformer; + +public class ConfigHandler { + + private static final int IDU = 10 * 8 + 5; + public static Configuration c; + + public static int IDOffset = 12600; + public static int megaMachinesMax = 256; + public static int mbWaterperSec = 150; + public static int ross128BID = -64; + public static int ross128BAID = -63; + public static int ross128btier = 3; + public static int ross128batier = 3; + public static int landerType = 3; + public static int ross128bRuinChance = 512; + public static int creativeScannerID; + public static int bioVatMaxParallelBonus = 1000; + public static int cutoffTier = 5; + public static int[][][] metasForTiers; + + public static long energyPerCell = 1000000L; + + public static boolean newStuff = true; + public static boolean BioLab = true; + public static boolean Ross128Enabled = true; + + public static boolean disableExtraGassesForEBF; + public static boolean disableMagicalForest; + public static boolean DEHPDirectSteam; + public static boolean teslastaff; + public static boolean classicMode; + + public static boolean GTppLogDisabler; + public static boolean tooltips = true; + public static boolean sharedItemStackTooltip = true; + public static boolean[] enabledPatches; + + public static byte maxTierRoss; + + public static boolean disableBoltedBlocksCasing = false; + public static boolean disableReboltedBlocksCasing = false; + + public static int pollutionHeatedWaterPumpSecond = 5; + public static int basePollutionMBFSecond = 400; + + public static Set voidMinerBlacklist = Collections.unmodifiableSet(new HashSet<>()); + + public static boolean disablePistonInEIC = false; + + private static final int[][] METAFORTIERS_ENERGY = { { 100, 101, 102, 105 }, { 1110, 1115, 1120, 1127 }, + { 1111, 12726, 1116, 1121, 1128 }, { 1112, 12727, 1117, 1122, 1129 }, { 12728, 1190, 1130, 12685 }, + { 1191, 1174, 695, 12686 }, }; + private static final int[][] METAFORTIERS_BUFFER = { { 5133, 5123 }, { 161, 171, 181, 191 }, { 162, 172, 182, 192 }, + { 163, 173, 183, 193 }, { 164, 174, 184, 194 }, { 165, 175, 185, 195 }, }; + private static final int[][] METAFORTIERS_CABLE = { { 5133, 5123 }, { 1210, 1230, 1250, 1270, 1290 }, + { 1310, 1330, 1350, 1370, 1390 }, { 1410, 1430, 1450, 1470, 1490 }, { 1510, 1530, 1550, 1570, 1590 }, + { 1650, 1670, 1690 }, }; + private static final int[][] METAFORTIERS_MACHINE = { + { 103, 104, 106, 107, 109, 110, 112, 113, 115, 116, 118, 119 }, + { 201, 211, 221, 231, 241, 251, 261, 271, 281, 291, 301, 311, 321, 331, 341, 351, 361, 371, 381, 391, 401, 411, + 421, 431, 441, 451, 461, 471, 481, 491, 501, 511, 521, 531, 541, 551, 561, 571, 581, 591, 601, 611, 621, + 631, 641, 651, 661, 671 }, + { 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 302, 312, 322, 332, 342, 352, 362, 372, 382, 392, 402, 412, + 422, 432, 442, 452, 462, 472, 482, 492, 502, 512, 522, 532, 542, 552, 562, 572, 582, 592, 602, 612, 622, + 632, 642, 652, 662, 672 }, + { 203, 213, 223, 233, 243, 253, 263, 273, 283, 293, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 403, 413, + 423, 433, 443, 453, 463, 473, 483, 493, 503, 513, 523, 533, 543, 553, 563, 573, 583, 593, 603, 613, 623, + 633, 643, 653, 663, 673 }, + { 204, 214, 224, 234, 244, 254, 264, 274, 284, 294, 304, 314, 324, 334, 344, 354, 364, 374, 384, 394, 404, 414, + 424, 434, 444, 454, 464, 474, 484, 494, 504, 514, 524, 534, 544, 554, 564, 574, 584, 594, 604, 614, 624, + 634, 644, 654, 664, 674 }, + { 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 405, 415, + 425, 435, 445, 455, 465, 475, 485, 495, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 605, 615, 625, + 635, 645, 655, 665, 675 }, }; + private static int[][][] defaultMetasForTiers = { METAFORTIERS_ENERGY, METAFORTIERS_BUFFER, METAFORTIERS_CABLE, + METAFORTIERS_MACHINE }; + private static final String[] VOLTAGE_NAMES = { "High Pressure Steam", "Low Voltage", "Medium Voltage", + "High Voltage", "Extreme Voltage", "Insane Voltage", "Ludicrous Voltage", "ZPM Voltage", "Ultimate Voltage", + "Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage", "Ultimate Mega Voltage", + "Ultimate Extended Mega Voltage", "Overpowered Voltage", "Maximum Voltage" }; + private static final String[] names = { "Generators", "Buffers", "Cables", "Machines" }; + + public ConfigHandler(Configuration C) { + ConfigHandler.c = C; + ConfigHandler.classicMode = ConfigHandler.c + .get( + "System", + "Enable Classic Mode", + false, + "Enables the classic Mode (all recipes in normal machines are doable in MV") + .getBoolean(false); + ConfigHandler.creativeScannerID = ConfigHandler.c + .get("System", "Creative Debug Scanner", 0, "ID for the Creative Debug Scanner Block") + .getInt(0); + + ConfigHandler.tooltips = ConfigHandler.c + .get("System", "BartWorksToolTips", true, "If you wish to enable extra tooltips") + .getBoolean(true); + ConfigHandler.sharedItemStackTooltip = ConfigHandler.c + .get( + "System", + "BartWorksSharedItemStackToolTips", + true, + "If you wish to enable \"Shared Item Stack\" tooltips") + .getBoolean(true); + + ConfigHandler.IDOffset = ConfigHandler.c + .get( + "System", + "ID Offset", + 12600, + "ID Offset for this mod. This Mod uses " + ConfigHandler.IDU + + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS") + .getInt(12600); + ConfigHandler.teslastaff = ConfigHandler.c + .get( + "System", + "Enable Teslastaff", + false, + "Enables the Teslastaff, an Item used to destroy Electric Armors") + .getBoolean(false); + ConfigHandler.BioLab = !ConfigHandler.c.get( + "System", + "Disable BioLab", + false, + "This switch disables the BioLab, BioVat etc. If you use GT5.08 or equivalent, this needs to be turned off!") + .getBoolean(false); + ConfigHandler.cutoffTier = ConfigHandler.c + .get( + "System", + "Tier to nerf circuits", + 5, + "This switch sets the lowest unnerfed Circuit Recipe Tier. -1 to disable it completely.", + -1, + VOLTAGE_NAMES.length) + .getInt(5); + ConfigHandler.cutoffTier = ConfigHandler.cutoffTier == -1 ? VOLTAGE_NAMES.length : ConfigHandler.cutoffTier; + ConfigHandler.disableExtraGassesForEBF = ConfigHandler.c + .get( + "System", + "Disable Extra Gases for EBF", + false, + "This switch disables extra gas recipes for the EBF, i.e. Xenon instead of Nitrogen") + .getBoolean(false); + ConfigHandler.disableBoltedBlocksCasing = ConfigHandler.c + .get("System", "Disable Bolted Casings", false, "This switch disable the generation of bolted casings") + .getBoolean(false); + ConfigHandler.disableReboltedBlocksCasing = ConfigHandler.c + .get("System", "Disable Rebolted Casings", false, "This switch disable the generation of rebolted casings") + .getBoolean(false); + + ConfigHandler.mbWaterperSec = ConfigHandler.c.get("Singleblocks", "mL Water per Sec for the StirlingPump", 150) + .getInt(150); + + ConfigHandler.energyPerCell = ConfigHandler.c + .get( + "Multiblocks", + "energyPerLESUCell", + 1000000, + "This will set Up the Energy per LESU Cell", + 1000000, + Integer.MAX_VALUE) + .getInt(1000000); + ConfigHandler.DEHPDirectSteam = ConfigHandler.c.get( + "Multiblocks", + "DEHP Direct Steam Mode", + false, + "This switch enables the Direct Steam Mode of the DEHP. If enabled it will take in Waterand output steam. If disabled it will Input IC2Coolant and output hot coolant") + .getBoolean(false); + ConfigHandler.megaMachinesMax = ConfigHandler.c + .get( + "Multiblocks", + "Mega Machines Maximum Recipes per Operation", + 256, + "This changes the Maximum Recipes per Operation to the specified Valure") + .getInt(256); + ConfigHandler.bioVatMaxParallelBonus = ConfigHandler.c + .get( + "Multiblocks", + "BioVat Maximum Bonus on Recipes", + 1000, + "This are the maximum parallel Operations the BioVat can do, when the output is half full.") + .getInt(1000); + ConfigHandler.voidMinerBlacklist = Collections.unmodifiableSet( + new HashSet<>( + Arrays.asList( + ConfigHandler.c.get( + "Multiblocks", + "Void Miner Blacklist", + new String[0], + "This is a blacklist for the Void Miner, blacklisted ores will not enter the drop prize pool. Please fill in the Unique Identifier of Ore and connect Damage with a colon, For example: gregtech:gt.blockores:32") + .getStringList()))); + ConfigHandler.disablePistonInEIC = ConfigHandler.c + .get( + "Multiblocks", + "Disable Electric Implosion Compressor piston", + false, + "This switch completely disables piston animation in Electric Implosion Compressor multiblock") + .getBoolean(false); + + ConfigHandler.pollutionHeatedWaterPumpSecond = ConfigHandler.c + .get( + "Pollution", + "Pollution produced per second by the water pump", + ConfigHandler.pollutionHeatedWaterPumpSecond, + "How much should the Simple Stirling Water Pump produce pollution per second") + .getInt(ConfigHandler.pollutionHeatedWaterPumpSecond); + ConfigHandler.basePollutionMBFSecond = ConfigHandler.c.get( + "Pollution", + "Pollution produced per tick by the MBF per ingot", + ConfigHandler.basePollutionMBFSecond, + "How much should the MBF produce pollution per tick per ingot. Then it'll be multiplied by the amount of ingots done in parallel") + .getInt(ConfigHandler.basePollutionMBFSecond); + + if (ConfigHandler.IDOffset == 0) { + ConfigHandler.IDOffset = 12600; + ConfigHandler.c + .get( + "System", + "ID Offset", + 12600, + "ID Offset for this mod. This Mod uses " + ConfigHandler.IDU + + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS") + .set(12600); + } + + ConfigHandler.GTppLogDisabler = ConfigHandler.c + .get("System", "Disable GT++ Logging", false, "Enables or Disables GT++ Logging.") + .getBoolean(false); + API_ConfigValues.debugLog = ConfigHandler.c + .get("System", "Enable Debug Log", false, "Enables or Disables the debug log.") + .getBoolean(false); + + for (int i = 0; i < BWCoreTransformer.CLASSESBEINGTRANSFORMED.length; i++) + BWCoreTransformer.shouldTransform[i] = ConfigHandler.c + .get( + "ASM fixes", + BWCoreTransformer.DESCRIPTIONFORCONFIG[i] + " in class: " + + BWCoreTransformer.CLASSESBEINGTRANSFORMED[i], + true) + .getBoolean(true); + + ConfigHandler.enabledPatches = new boolean[BWCoreTransformer.shouldTransform.length]; + ConfigHandler.enabledPatches = Arrays + .copyOf(BWCoreTransformer.shouldTransform, BWCoreTransformer.shouldTransform.length); + ConfigHandler.ross128BID = ConfigHandler.c + .get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b") + .getInt(-64); + ConfigHandler.ross128BAID = ConfigHandler.c + .get("CrossMod Interactions", "DimID - Ross128ba", -63, "The Dim ID for Ross128ba (Ross128b's Moon)") + .getInt(-63); + ConfigHandler.ross128btier = ConfigHandler.c + .get("CrossMod Interactions", "Rocket Tier - Ross128b", 3, "The Rocket Tier for Ross128b") + .getInt(3); + ConfigHandler.ross128batier = ConfigHandler.c + .get("CrossMod Interactions", "Rocket Tier - Ross128ba", 3, "The Rocket Tier for Ross128a") + .getInt(3); + ConfigHandler.ross128bRuinChance = ConfigHandler.c + .get("CrossMod Interactions", "Ruin Chance - Ross128b", 512, "Higher Values mean lesser Ruins.") + .getInt(512); + ConfigHandler.Ross128Enabled = ConfigHandler.c + .get( + "CrossMod Interactions", + "Galacticraft - Activate Ross128 System", + true, + "If the Ross128 System should be activated, DO NOT CHANGE AFTER WORLD GENERATION") + .getBoolean(true); + ConfigHandler.landerType = ConfigHandler.c + .get("CrossMod Interactions", "LanderType", 3, "1 = Moon Lander, 2 = Landing Balloons, 3 = Asteroid Lander") + .getInt(3); + ConfigHandler.disableMagicalForest = ConfigHandler.c + .get( + "CrossMod Interactions", + "Disable Magical Forest - Ross128b", + false, + "True disables the magical Forest Biome on Ross for more performance during World generation.") + .getBoolean(false); + + ConfigHandler.maxTierRoss = (byte) ConfigHandler.c + .get("Ross Ruin Metas", "A_Ruin Machine Tiers", 6, "", 0, VOLTAGE_NAMES.length) + .getInt(6); + ConfigHandler.metasForTiers = new int[4][maxTierRoss][]; + + for (int i = 0; i < 4; i++) { + if (maxTierRoss > ConfigHandler.defaultMetasForTiers[i].length) + ConfigHandler.defaultMetasForTiers[i] = new int[maxTierRoss][0]; + for (int j = 0; j < maxTierRoss; j++) ConfigHandler.metasForTiers[i][j] = ConfigHandler.c + .get( + "Ross Ruin Metas", + j + "_Ruin " + names[i] + " Tier " + VOLTAGE_NAMES[j], + ConfigHandler.defaultMetasForTiers[i][j]) + .getIntList(); + } + + ConfigHandler.setUpComments(); + + if (ConfigHandler.c.hasChanged()) ConfigHandler.c.save(); + } + + private static void setUpComments() { + ConfigHandler.c.addCustomCategoryComment("ASM fixes", "Disable ASM fixes here."); + ConfigHandler.c.addCustomCategoryComment("Singleblocks", "Singleblock Options can be set here."); + ConfigHandler.c.addCustomCategoryComment("Multiblocks", "Multiblock Options can be set here."); + ConfigHandler.c.addCustomCategoryComment("System", "Different System Settings can be set here."); + ConfigHandler.c.addCustomCategoryComment( + "CrossMod Interactions", + "CrossMod Interaction Settings can be set here. For Underground Fluid settings change the Gregtech.cfg!"); + ConfigHandler.c.addCustomCategoryComment("Ross Ruin Metas", "Ruin Metas and Tiers can be set here."); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java new file mode 100644 index 0000000000..f512e778bc --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_LanguageManager; + +public class BW_ItemBlocks extends ItemBlock { + + private final String mNoMobsToolTip = GT_LanguageManager + .addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + private final String mNoTileEntityToolTip = GT_LanguageManager + .addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + + public BW_ItemBlocks(Block par1) { + super(par1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(MainMod.GT2); + } + + @Override + public int getMetadata(int aMeta) { + return aMeta; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + byte tier = BorosilicateGlass.getTier(this.field_150939_a, aStack.getItemDamage()); + if (tier >= 0) { + aList.add( + StatCollector.translateToLocal("tooltip.glas.0.name") + " " + + BW_ColorUtil.getColorForTier(tier) + + GT_Values.VN[tier]); + } + if (this.field_150939_a instanceof ITileAddsInformation) { + aList.addAll(Arrays.asList(((ITileAddsInformation) this.field_150939_a).getInfoData())); + } + aList.add(this.mNoMobsToolTip); + if (!(this.field_150939_a instanceof ITileEntityProvider)) aList.add(this.mNoTileEntityToolTip); + + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + return this.field_150939_a.getIcon(0, stack.getItemDamage()); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return this.getIcon(stack, renderPass); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int p_77618_1_, int p_77618_2_) { + return this.field_150939_a.getIcon(0, p_77618_2_); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java new file mode 100644 index 0000000000..0b589bf53a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.WorldData; + +public class BW_SimpleWindMeter extends Item { + + public BW_SimpleWindMeter() { + this.maxStackSize = 1; + this.setMaxDamage(15); + this.setCreativeTab(MainMod.BWT); + this.hasSubtypes = false; + this.setUnlocalizedName("BW_SimpleWindMeter"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) { + this.itemIcon = register.registerIcon(MainMod.MOD_ID + ":BW_SimpleWindMeter"); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean p_77624_4_) { + super.addInformation(itemStack, entityPlayer, list, p_77624_4_); + list.add(StatCollector.translateToLocal("tooltip.windmeter.0.name")); + list.add( + StatCollector.translateToLocal("tooltip.windmeter.1.name") + " " + + (this.getMaxDamage() - this.getDamage(itemStack)) + + "/" + + this.getMaxDamage()); + list.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { + if (entityPlayer.worldObj.isRemote || world == null + || WorldData.get(world) == null + || WorldData.get(world).windSim == null) return itemStack; + + float windStrength = (float) WorldData.get(world).windSim.getWindAt(entityPlayer.posY); + String windS = windStrength < 1f ? StatCollector.translateToLocal("tooltip.windmeter.2.name") + : windStrength < 10f ? StatCollector.translateToLocal("tooltip.windmeter.3.name") + : windStrength < 20f ? StatCollector.translateToLocal("tooltip.windmeter.4.name") + : windStrength < 30f ? StatCollector.translateToLocal("tooltip.windmeter.5.name") + : windStrength < 50f ? StatCollector.translateToLocal("tooltip.windmeter.6.name") + : StatCollector.translateToLocal("tooltip.windmeter.7.name"); + entityPlayer.addChatMessage( + new ChatComponentText(StatCollector.translateToLocal("tooltip.windmeter.8.name") + " " + windS + ".")); + itemStack.damageItem(1, entityPlayer); + return itemStack; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java new file mode 100644 index 0000000000..f58ae8d6e7 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import static ic2.api.item.IKineticRotor.GearboxType.WATER; +import static ic2.api.item.IKineticRotor.GearboxType.WIND; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.IKineticRotor; +import ic2.core.block.kineticgenerator.gui.GuiWaterKineticGenerator; +import ic2.core.block.kineticgenerator.gui.GuiWindKineticGenerator; +import ic2.core.util.StackUtil; + +public class BW_Stonage_Rotors extends Item implements IKineticRotor { + + private final int[] DiaMinMax = new int[3]; + private final float eff; + private final IKineticRotor.GearboxType type; + private final ResourceLocation tex; + private final String itemTex; + private final int speed; + private final float mRotor; + private final int maxDamageEx; + private int dura; + + public BW_Stonage_Rotors(int diameter, float eff, int speed, float mRotor, int min, int max, int durability, + IKineticRotor.GearboxType type, ResourceLocation tex, String Name, String itemTex) { + this.DiaMinMax[0] = diameter; + this.DiaMinMax[1] = min; + this.DiaMinMax[2] = max; + this.eff = eff; + this.mRotor = mRotor; + this.speed = speed; + this.type = type; + this.tex = tex; + this.setMaxDamage(30000); + this.maxDamageEx = durability; + this.setUnlocalizedName(Name); + this.setCreativeTab(MainMod.BWT); + this.itemTex = itemTex; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(MainMod.MOD_ID + ":" + this.itemTex); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) { + info.add( + StatCollector.translateToLocalFormatted("ic2.itemrotor.wind.info", this.DiaMinMax[1], this.DiaMinMax[2])); + IKineticRotor.GearboxType type = null; + if (Minecraft.getMinecraft().currentScreen instanceof GuiWaterKineticGenerator) { + type = WATER; + } else if (Minecraft.getMinecraft().currentScreen instanceof GuiWindKineticGenerator) { + type = WIND; + } + info.add(StatCollector.translateToLocal("tooltip.rotor.0.name") + " " + this.DiaMinMax[0]); + info.add( + StatCollector.translateToLocal("tooltip.rotor.1.name") + " " + + (this.getMaxDamageEx() - this.getDamageOfStack(itemStack)) / 100 + + "/" + + this.getMaxDamageEx() / 100); + info.add(StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + this.eff); + info.add(StatCollector.translateToLocal("tooltip.rotor.3.name") + " " + this.speed); + info.add(StatCollector.translateToLocal("tooltip.rotor.4.name") + " " + this.mRotor); + if (type != null) { + info.add(StatCollector.translateToLocal("ic2.itemrotor.fitsin." + this.isAcceptedType(itemStack, type))); + } + info.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public int getDiameter(ItemStack itemStack) { + return this.DiaMinMax[0]; + } + + @Override + public ResourceLocation getRotorRenderTexture(ItemStack itemStack) { + return this.tex; + } + + @Override + public float getEfficiency(ItemStack itemStack) { + return this.eff; + } + + @Override + public int getMinWindStrength(ItemStack itemStack) { + return this.DiaMinMax[1]; + } + + @Override + public int getMaxWindStrength(ItemStack itemStack) { + return this.DiaMinMax[2]; + } + + @Override + public boolean isAcceptedType(ItemStack itemStack, IKineticRotor.GearboxType gearboxType) { + return gearboxType.equals(this.type); + } + + public int getSpeed() { + return this.speed; + } + + public float getmRotor() { + return this.mRotor; + } + + public void setDamageForStack(ItemStack stack, int advDmg) { + NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack); + nbtData.setInteger("DmgEx", advDmg); + if (this.maxDamageEx > 0) { + double p = (double) advDmg / (double) this.maxDamageEx; + int newDmg = (int) (stack.getMaxDamage() * p); + if (newDmg >= stack.getMaxDamage()) { + newDmg = stack.getMaxDamage() - 1; + } + stack.setItemDamage(newDmg); + this.dura = newDmg; + } + } + + public int getDamageOfStack(ItemStack stack) { + NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack); + this.dura = nbtData.getInteger("DmgEx"); + return this.dura; + } + + public int getMaxDamageEx() { + return this.maxDamageEx; + } + + public void damageItemStack(ItemStack stack, int Dmg) { + this.setDamageForStack(stack, this.getDamageOfStack(stack) + Dmg); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java new file mode 100644 index 0000000000..f0c746dd64 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.IItemWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.items.GT_Generic_Item; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem, IItemWithModularUI { + + private static final int COST_PER_USE = 100; + + public Circuit_Programmer() { + super("BWCircuitProgrammer", "Circuit Programmer", "Programs Integrated Circuits"); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setHasSubtypes(false); + this.setCreativeTab(MainMod.BWT); + GregTech_API.registerCircuitProgrammer( + s -> s.getItem() instanceof Circuit_Programmer && ElectricItem.manager.canUse(s, COST_PER_USE), + (s, p) -> { + ElectricItem.manager.use(s, COST_PER_USE, p); + return s; + }); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + if (aStack != null && aStack.getTagCompound() != null) aList.add( + StatCollector.translateToLocal("tooltip.cp.0.name") + " " + + (aStack.getTagCompound() + .getBoolean("HasChip") ? StatCollector.translateToLocal("tooltip.bw.yes.name") + : StatCollector.translateToLocal("tooltip.bw.no.name"))); + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (ElectricItem.manager.use(aStack, COST_PER_USE, aPlayer)) { + GT_UIInfos.openPlayerHeldItemUI(aPlayer); + } + return aStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + if (this.getChargedItem(itemStack) == this) { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aIconRegister) { + this.mIcon = aIconRegister.registerIcon("bartworks:CircuitProgrammer"); + } + + @Override + public int getTier(ItemStack var1) { + return 1; + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return 10000; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return GT_Values.V[1]; + } + + private static final String NBT_KEY_HAS_CHIP = "HasChip"; + private static final String NBT_KEY_CHIP_CONFIG = "ChipConfig"; + + @Override + public ModularWindow createWindow(UIBuildContext buildContext, ItemStack heldStack) { + ModularWindow.Builder builder = ModularWindow.builder(256, 166); + builder.setBackground(BW_UITextures.BACKGROUND_CIRCUIT_PROGRAMMER); + builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(86, 83), ModularUITextures.ITEM_SLOT); + + ItemStackHandler inventoryHandler = new ItemStackHandler(1) { + + @Override + public int getSlotLimit(int slot) { + return 1; + } + }; + SlotWidget circuitSlotWidget = new SlotWidget(new BaseSlot(inventoryHandler, 0) { + + @Override + public void putStack(ItemStack stack) { + if (Circuit_Programmer.this.isLVCircuit(stack)) { + stack = Circuit_Programmer.this.createRealCircuit(0); + } + ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(this.getSlotIndex(), stack); + this.onSlotChanged(); + } + }); + + ItemStack initialStack = null; + NBTTagCompound tag = heldStack.getTagCompound(); + if (tag != null && tag.getBoolean(NBT_KEY_HAS_CHIP)) { + initialStack = this.createRealCircuit(tag.getByte(NBT_KEY_CHIP_CONFIG)); + } + circuitSlotWidget.getMcSlot() + .putStack(initialStack); + + builder.widget(circuitSlotWidget.setChangeListener(widget -> { + ItemStack stack = widget.getMcSlot() + .getStack(); + ItemStack heldItem = widget.getContext() + .getPlayer() + .getHeldItem(); + NBTTagCompound tag2 = heldItem.getTagCompound(); + if (tag2 == null) { + tag2 = new NBTTagCompound(); + } + + if (stack != null) { + tag2.setBoolean(NBT_KEY_HAS_CHIP, true); + tag2.setByte(NBT_KEY_CHIP_CONFIG, (byte) stack.getItemDamage()); + } else { + tag2.setBoolean(NBT_KEY_HAS_CHIP, false); + } + heldItem.setTagCompound(tag2); + }) + .setFilter(stack -> this.isProgrammedCircuit(stack) || this.isLVCircuit(stack)) + .setBackground(ModularUITextures.ITEM_SLOT, GT_UITextures.OVERLAY_SLOT_INT_CIRCUIT) + .setPos(122, 60)); + + for (int i = 0; i < 24; i++) { + final int index = i; + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (circuitSlotWidget.getMcSlot() + .getHasStack() + && this.isProgrammedCircuit( + circuitSlotWidget.getMcSlot() + .getStack())) { + circuitSlotWidget.getMcSlot() + .putStack(this.createRealCircuit(index + 1)); + } + }) + .setPos(32 + i % 12 * 18, 21 + i / 12 * 18) + .setSize(18, 18)); + } + + return builder.build(); + } + + private ItemStack createRealCircuit(int config) { + return ItemList.Circuit_Integrated.getWithDamage(1, config); + } + + private boolean isProgrammedCircuit(ItemStack stack) { + return stack.getItem() + .equals( + GT_Utility.getIntegratedCircuit(0) + .getItem()); + } + + private boolean isLVCircuit(ItemStack stack) { + return BW_Util.checkStackAndPrefix(stack) + && OrePrefixes.circuit.equals(GT_OreDictUnificator.getAssociation(stack).mPrefix) + && GT_OreDictUnificator.getAssociation(stack).mMaterial.mMaterial.equals(Materials.Basic); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java new file mode 100644 index 0000000000..37ecfc61d2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.screen.IItemWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.items.GT_Generic_Item; + +public class GT_Destructopack_Item extends GT_Generic_Item implements IItemWithModularUI { + + public GT_Destructopack_Item() { + super("GT2Destructopack", "Destructopack", "Mobile Trash Bin"); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setHasSubtypes(false); + this.setCreativeTab(MainMod.GT2); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + GT_UIInfos.openPlayerHeldItemUI(aPlayer); + return aStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aIconRegister) { + this.mIcon = aIconRegister.registerIcon("bartworks:gt.GT2Destructopack"); + } + + @Override + public ModularWindow createWindow(UIBuildContext buildContext, ItemStack heldStack) { + ModularWindow.Builder builder = ModularWindow.builder(176, 166); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.bindPlayerInventory(buildContext.getPlayer()); + + builder.widget(new SlotWidget(new BaseSlot(new ItemStackHandler(), 0) { + + @Override + public void putStack(ItemStack stack) { + this.onSlotChanged(); + } + }).setBackground(ModularUITextures.ITEM_SLOT, BW_UITextures.OVERLAY_SLOT_CROSS) + .setPos(79, 16)) + .widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT) + .setSize(17, 17) + .setPos(152, 63)); + + return builder.build(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java new file mode 100644 index 0000000000..3a132dde22 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.google.common.collect.Sets; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class GT_Rockcutter_Item extends ItemTool implements IElectricItem { + + private static Set mineableBlocks = Sets + .newHashSet(Blocks.stone, Blocks.cobblestone, Blocks.sand, Blocks.clay); + private final int mCharge; + private final int mTransfer; + public int mTier; + + @SideOnly(Side.CLIENT) + private IIcon icon; + + private final int multi; + + public GT_Rockcutter_Item(int aTier) { + super(2 * aTier, Item.ToolMaterial.EMERALD, GT_Rockcutter_Item.mineableBlocks); + this.mTier = aTier; + this.multi = (int) Math.pow(10, this.mTier - 1); + GT_Rockcutter_Item.mineableBlocks = new HashSet<>(); + this.maxStackSize = 1; + this.mCharge = 10000 * this.multi; + this.mTransfer = (int) GT_Values.V[this.mTier]; + this.efficiencyOnProperMaterial = 2.0f * this.mTier; + this.setCreativeTab(MainMod.GT2); + this.setMaxDamage(27 + 10 * this.multi); + this.setNoRepair(); + this.setUnlocalizedName("GT_Rockcutter_Item_" + GT_Values.VN[this.mTier]); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(StatCollector.translateToLocal("tooltip.bw.tier.name") + " " + GT_Values.VN[this.mTier]); + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public void onUpdate(ItemStack aStack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) { + if (!ElectricItem.manager.canUse(aStack, 500 * this.multi)) { + if (aStack.isItemEnchanted()) { + aStack.getTagCompound() + .removeTag("ench"); + } + } else if (!aStack.isItemEnchanted()) { + aStack.addEnchantment(Enchantment.silkTouch, 3); + } + } + + @Override + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World p_77648_3_, int p_77648_4_, int p_77648_5_, + int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + ElectricItem.manager.use(aStack, 0, aPlayer); + return false; + } + + @Override + public boolean onBlockDestroyed(ItemStack var1, World var2, Block var3, int var4, int var5, int var6, + EntityLivingBase var7) { + ElectricItem.manager.use(var1, 0, var7); + if (ElectricItem.manager.canUse(var1, 500 * this.multi)) { + ElectricItem.manager.use(var1, 500 * this.multi, var7); + } else { + ElectricItem.manager.discharge(var1, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false); + } + return true; + } + + @Override + public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) { + return par1Block.getMaterial() + .equals(Material.glass) + || par1Block.getMaterial() + .equals(Material.clay) + || par1Block.getMaterial() + .equals(Material.packedIce) + || par1Block.getMaterial() + .equals(Material.ice) + || par1Block.getMaterial() + .equals(Material.sand) + || par1Block.getMaterial() + .equals(Material.ground) + || par1Block.getMaterial() + .equals(Material.rock) + || mineableBlocks.contains(par1Block); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + if (this.getChargedItem(itemStack) == this) { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); + } + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return this.mCharge; + } + + @Override + public int getTier(ItemStack itemStack) { + return this.mTier; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return this.mTransfer; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.icon = iconRegister.registerIcon("bartworks:GT_Rockcutter"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.icon; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java new file mode 100644 index 0000000000..6728a791e4 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.google.common.collect.Sets; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class GT_Teslastaff_Item extends ItemTool implements IElectricItem { + + private static final Set effective = Sets.newHashSet(Blocks.web); + private final double mCharge; + private final double mTransfer; + public int mTier; + + @SideOnly(Side.CLIENT) + private IIcon icon; + + public GT_Teslastaff_Item() { + super(0, Item.ToolMaterial.GOLD, GT_Teslastaff_Item.effective); + this.setCreativeTab(MainMod.GT2); + this.setNoRepair(); + this.mCharge = 10000000D; + this.mTransfer = 8192D; + this.mTier = 4; + this.setMaxStackSize(1); + this.setMaxDamage(27); + this.setUnlocalizedName("GT_Teslastaff_Item"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(StatCollector.translateToLocal("tooltip.teslastaff.0.name")); + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public boolean hitEntity(ItemStack aStack, EntityLivingBase aTarget, EntityLivingBase aPlayer) { + if (aTarget instanceof EntityLiving tTarget && ElectricItem.manager.canUse(aStack, 9000000)) { + ElectricItem.manager.use(aStack, 9000000, aPlayer); + for (int i = 1; i < 5; ++i) { + if (tTarget.getEquipmentInSlot(i) != null && tTarget.getEquipmentInSlot(i) + .getItem() instanceof IElectricItem) { + tTarget.setCurrentItemOrArmor(i, null); + } + } + } + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + if (this.getChargedItem(itemStack) == this) { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); + } + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return this.mCharge; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public int getTier(ItemStack itemStack) { + return this.mTier; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return this.mTransfer; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.icon = iconRegister.registerIcon("bartworks:GT_Teslastaff"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.icon; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java new file mode 100644 index 0000000000..a4712dc36a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.MainMod; + +public class LabModule extends SimpleSubItemClass { + + public LabModule(String[] tex) { + super(tex); + this.setCreativeTab(MainMod.BIO_TAB); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return "labModule." + super.getUnlocalizedName(stack); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + aList.add(StatCollector.translateToLocal("tooltip.labmodule.0.name")); + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java new file mode 100644 index 0000000000..cb5a65c13b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import static com.github.bartimaeusnek.bartworks.common.loaders.BioItemList.getAllDNASampleFlasks; +import static com.github.bartimaeusnek.bartworks.common.loaders.BioItemList.getAllPetriDishes; +import static com.github.bartimaeusnek.bartworks.common.loaders.BioItemList.getAllPlasmidCells; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BioCulture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LabParts extends SimpleSubItemClass { + + public LabParts(String[] tex) { + super(tex); + this.setCreativeTab(MainMod.BIO_TAB); + } + + @Override + public EnumRarity getRarity(ItemStack itemStack) { + + if (itemStack == null || itemStack.getTagCompound() == null) return EnumRarity.common; + + return switch (itemStack.getItemDamage()) { + case 0 -> BW_Util.getRarityFromByte( + itemStack.getTagCompound() + .getCompoundTag("DNA") + .getByte("Rarity")); + case 1, 2 -> BW_Util.getRarityFromByte( + itemStack.getTagCompound() + .getByte("Rarity")); + default -> EnumRarity.common; + }; + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int p_82790_2_) { + if (stack.getItemDamage() == 0 && stack.getTagCompound() != null + && stack.getTagCompound() + .getIntArray("Color") != null + && stack.getTagCompound() + .getIntArray("Color").length > 0) { + int[] rgb = stack.getTagCompound() + .getIntArray("Color"); + return BW_ColorUtil.getColorFromRGBArray(rgb); + } + return super.getColorFromItemStack(stack, p_82790_2_); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean b) { + if (itemStack == null) return; + + if (itemStack.getTagCompound() == null) { + switch (itemStack.getItemDamage()) { + case 0: + list.add(StatCollector.translateToLocal("tooltip.labparts.0.name")); + break; + case 1: + list.add(StatCollector.translateToLocal("tooltip.labparts.1.name")); + break; + case 2: + list.add(StatCollector.translateToLocal("tooltip.labparts.2.name")); + break; + case 3: + list.add(StatCollector.translateToLocal("tooltip.labparts.3.name")); + break; + case 4: + list.add(StatCollector.translateToLocal("tooltip.labparts.4.name")); + break; + default: + break; + } + super.addInformation(itemStack, entityPlayer, list, b); + return; + } + + BioCulture culture = BioCulture.getBioCulture( + itemStack.getTagCompound() + .getString("Name")); + + switch (itemStack.getItemDamage()) { + case 0: + list.add( + StatCollector.translateToLocal("tooltip.labparts.5.name") + " " + + itemStack.getTagCompound() + .getString("Name") + + (culture != null ? " (" + culture.getLocalisedName() + ")" : "")); + if (!itemStack.getTagCompound() + .getBoolean("Breedable")) { + list.add(StatCollector.translateToLocal("tooltip.labparts.6.name")); + } + break; + case 1: + list.add( + StatCollector.translateToLocal("tooltip.labparts.7.name") + " " + + itemStack.getTagCompound() + .getString("Name") + + (culture != null ? " (" + culture.getLocalisedName() + ")" : "")); + break; + case 2: + list.add( + StatCollector.translateToLocal("tooltip.labparts.8.name") + " " + + itemStack.getTagCompound() + .getString("Name") + + (culture != null ? " (" + culture.getLocalisedName() + ")" : "")); + break; + default: + break; + } + super.addInformation(itemStack, entityPlayer, list, b); + } + + @Override + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { + list.addAll(getAllPetriDishes()); + list.addAll(getAllDNASampleFlasks()); + list.addAll(getAllPlasmidCells()); + super.getSubItems(item, creativeTabs, list); + } + + @Override + public String getUnlocalizedName(ItemStack itemStack) { + if (itemStack.getItemDamage() == 0 && itemStack.getTagCompound() != null) + return "filled.item." + this.tex[itemStack.getItemDamage()].replace('/', '.'); + return super.getUnlocalizedName(itemStack); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java new file mode 100644 index 0000000000..e31e23d47c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SimpleIconItem extends Item { + + private final String tex; + + public SimpleIconItem(String tex) { + this.tex = tex; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon("bartworks:" + this.tex); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java new file mode 100644 index 0000000000..8d5b239a75 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SimpleSubItemClass extends Item { + + @SideOnly(Side.CLIENT) + protected IIcon[] itemIcon; + + String[] tex; + + public SimpleSubItemClass(String... tex) { + this.tex = tex; + this.hasSubtypes = true; + this.setCreativeTab(MainMod.BWT); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = new IIcon[this.tex.length]; + for (int i = 0; i < this.tex.length; i++) { + this.itemIcon[i] = iconRegister.registerIcon(MainMod.MOD_ID + ":" + this.tex[i]); + } + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { + for (int i = 0; i < this.tex.length; i++) { + p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int p_77617_1_) { + if (p_77617_1_ < this.tex.length) return this.itemIcon[p_77617_1_]; + return this.itemIcon[0]; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + if (stack.getItemDamage() < this.tex.length) return "item." + this.tex[stack.getItemDamage()].replace('/', '.'); + return "WrongDamageItemDestroyIt"; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ArtificialMicaLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ArtificialMicaLine.java new file mode 100644 index 0000000000..6268342cce --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ArtificialMicaLine.java @@ -0,0 +1,199 @@ +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.recipe.RecipeMaps.benderRecipes; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.COIL_HEAT; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.system.material.BW_GT_MaterialReference; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class ArtificialMicaLine { + + public static void runArtificialMicaRecipe() { + // Mg + O = MgO + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Magnesium.getDust(1)) + .itemOutputs(Materials.Magnesia.getDust(2)) + .fluidInputs(Materials.Oxygen.getGas(1000)) + .duration(2 * SECONDS) + .eut(8) + .addTo(UniversalChemical); + // Si + 6HF = H2SiF6 + 4H + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Silicon.getDust(1), Materials.Empty.getCells(4)) + .itemOutputs(Materials.Hydrogen.getCells(4)) + .fluidInputs(Materials.HydrofluoricAcid.getFluid(6000)) + .fluidOutputs(WerkstoffLoader.HexafluorosilicicAcid.getFluidOrGas(1000)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(UniversalChemical); + // K + Cl = KCl + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Potassium.getDust(1), GT_Utility.getIntegratedCircuit(2)) + .itemOutputs(Materials.RockSalt.getDust(2)) + .fluidInputs(Materials.Chlorine.getGas(1000)) + .duration(20 * TICKS) + .eut(8) + .addTo(UniversalChemical); + + // 2KCl + H2SiF6 = 2HCl + K2SiF6 + GT_Values.RA.stdBuilder() + .itemInputs(Materials.RockSalt.getDust(4)) + .itemOutputs(WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 9)) + .fluidInputs(WerkstoffLoader.HexafluorosilicicAcid.getFluidOrGas(1000)) + .fluidOutputs(Materials.HydrochloricAcid.getFluid(2000)) + .duration(1 * SECONDS) + .eut(8) + .addTo(mixerRecipes); + + // 2K + CO2 + O = K2CO3 + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Potassium.getDust(2), Materials.CarbonDioxide.getCells(1)) + .itemOutputs(WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 6), Materials.Empty.getCells(1)) + .fluidInputs(Materials.Oxygen.getGas(1000)) + .duration(2 * SECONDS) + .eut(8) + .addTo(UniversalChemical); + // K2O + CO2 = K2CO3 + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Potash.getDust(3), Materials.CarbonDioxide.getCells(1)) + .itemOutputs(WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 6), Materials.Empty.getCells(1)) + .duration(2 * SECONDS) + .eut(8) + .addTo(UniversalChemical); + + // 55Quartz Dust + 20K2SiF6 + 12Al2O3 + 4K2CO3 = 91Raw Fluorophlogopite Dust + GT_Values.RA.stdBuilder() + .itemInputs( + Materials.QuartzSand.getDust(55), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 20), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 12), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 4), + GT_Utility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 27)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + // 55Quartzite/Nether Quartz Dust + 20K2SiF6 + 57Al2O3 + 4K2CO3 = 136Raw Fluorophlogopite Dust + GT_Values.RA.stdBuilder() + .itemInputs( + Materials.Quartzite.getDust(55), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 20), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 57), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 4), + GT_Utility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 8)) + .fluidInputs() + .fluidOutputs() + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + Materials.NetherQuartz.getDust(55), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 20), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 57), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 4), + GT_Utility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 8)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + // 62Certus Quartz Dust + 10K2SiF6 + 12Al2O3 + 7K2CO3 = 91Raw Fluorophlogopite Dust + GT_Values.RA.stdBuilder() + .itemInputs( + Materials.CertusQuartz.getDust(62), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 10), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 12), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 7), + GT_Utility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 27)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + // MgO(s) = MgO(l) + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Magnesia.getDust(1)) + .fluidOutputs(Materials.Magnesia.getMolten(144)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(fluidExtractionRecipes); + + // 27Raw Fluorophlogopite Dust + 720MgO(l) = 4608Fluorophlogopite(l) + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 27)) + .itemOutputs(Materials.Glass.getDust(1)) + .fluidInputs(BW_GT_MaterialReference.Magnesia.getMolten(720)) + .fluidOutputs(WerkstoffLoader.HotFluorophlogopite.getFluidOrGas(4608)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_HV) + .metadata(COIL_HEAT, 1700) + .addTo(blastFurnaceRecipes); + + // 144Fluorophlogopite(l) = Fluorophlogopite + RecipeMaps.vacuumFreezerRecipes.addRecipe( + new GT_Recipe( + false, + new ItemStack[] { ItemList.Shape_Mold_Plate.get(0) }, + new ItemStack[] { WerkstoffLoader.Fluorophlogopite.get(OrePrefixes.plate, 1) }, + null, + null, + new FluidStack[] { WerkstoffLoader.HotFluorophlogopite.getFluidOrGas(144) }, + null, + 10, + 120, + 0)); + // Fluorophlogopite = 4Insulator Foil + if (NewHorizonsCoreMod.isModLoaded()) { + + GT_Values.RA.stdBuilder() + .itemInputs( + WerkstoffLoader.Fluorophlogopite.get(OrePrefixes.plate, 1), + GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(GT_ModHandler.getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 4)) + .duration(10 * TICKS) + .eut(600) + .addTo(benderRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java new file mode 100644 index 0000000000..88fab90aea --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static gregtech.api.enums.Mods.BartWorks; + +import java.lang.reflect.Field; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import ic2.core.Ic2Items; + +/** + * This class gets injected into GT via ASM! DO NOT CALL IT YOURSELF! + */ +public class BeforeGTPreload implements Runnable { + + private static boolean didrun; + + @Override + public void run() { + if (didrun) return; + // fixing BorosilicateGlass... -_-' + Materials.BorosilicateGlass + .add(SubTag.CRYSTAL, SubTag.NO_SMASHING, SubTag.NO_RECYCLING, SubTag.SMELTING_TO_FLUID); + + Field activeContainer = FieldUtils.getDeclaredField(LoadController.class, "activeContainer", true); + ModContainer bartworks = null; + ModContainer gregtech = Loader.instance() + .activeModContainer(); + boolean switchback = false; + LoadController modController = null; + if (!Loader.instance() + .activeModContainer() + .getModId() + .equals(BartWorks.ID)) { + Field fieldModController = FieldUtils.getDeclaredField(Loader.class, "modController", true); + try { + modController = (LoadController) fieldModController.get(Loader.instance()); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance() + .exitJava(-1, true); + } + + assert modController != null; + for (ModContainer mod : modController.getActiveModList()) { + if (mod.getModId() + .equals(BartWorks.ID)) { + bartworks = mod; + } + if (bartworks != null) break; + } + if (bartworks == null || gregtech == null) FMLCommonHandler.instance() + .exitJava(-1, true); + + try { + activeContainer.set(modController, bartworks); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance() + .exitJava(-1, true); + } + switchback = true; + } + + Block[] bw_glasses; + try { + bw_glasses = (Block[]) Class.forName("com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry") + .getField("bw_glasses") + .get(null); + GameRegistry.registerBlock(bw_glasses[0], BW_ItemBlocks.class, "BW_GlasBlocks"); + GameRegistry.registerBlock(bw_glasses[1], BW_ItemBlocks.class, "BW_GlasBlocks2"); + OreDictionary.registerOre("blockGlassHV", new ItemStack(Blocks.glass, 1, Short.MAX_VALUE)); + OreDictionary.registerOre("blockGlassHV", new ItemStack(bw_glasses[0], 1, 0)); + OreDictionary.registerOre("blockGlassEV", Ic2Items.reinforcedGlass); + OreDictionary.registerOre("blockGlassEV", new ItemStack(bw_glasses[0], 1, 1)); + OreDictionary.registerOre("blockGlassIV", new ItemStack(bw_glasses[0], 1, 12)); + OreDictionary.registerOre("blockGlassIV", new ItemStack(bw_glasses[0], 1, 2)); + OreDictionary.registerOre("blockGlassLuV", new ItemStack(bw_glasses[0], 1, 3)); + OreDictionary.registerOre("blockGlassZPM", new ItemStack(bw_glasses[0], 1, 4)); + OreDictionary.registerOre("blockGlassUV", new ItemStack(bw_glasses[0], 1, 5)); + OreDictionary.registerOre("blockGlassUHV", new ItemStack(bw_glasses[0], 1, 13)); + OreDictionary.registerOre("blockGlassUEV", new ItemStack(bw_glasses[0], 1, 14)); + OreDictionary.registerOre("blockGlassUIV", new ItemStack(bw_glasses[0], 1, 15)); + OreDictionary.registerOre("blockGlassUMV", new ItemStack(bw_glasses[1], 1, 0)); + } catch (IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) { + e.printStackTrace(); + FMLCommonHandler.instance() + .exitJava(-1, true); + } + if (switchback) { + try { + activeContainer.set(modController, gregtech); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance() + .exitJava(-1, true); + } + } + BeforeGTPreload.didrun = true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java new file mode 100644 index 0000000000..5bf9ff8185 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import java.awt.Color; + +import net.minecraft.item.EnumRarity; + +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import com.github.bartimaeusnek.bartworks.util.BioDNA; +import com.github.bartimaeusnek.bartworks.util.BioData; +import com.github.bartimaeusnek.bartworks.util.BioPlasmid; + +public class BioCultureLoader { + + public static final BioData BIO_DATA_BETA_LACMATASE = BioData + .createAndRegisterBioData("beta-Lactamase", EnumRarity.uncommon, 10000, 0); + private static final BioData BIO_DATA_YEAST = BioData + .createAndRegisterBioData("Saccharomyces cerevisiae", EnumRarity.common); + private static final BioDNA BIO_DNA_WHINE_YEAST = BioDNA + .createAndRegisterBioDNA("Saccharomyces cerevisiae var bayanus", EnumRarity.uncommon); + private static final BioDNA BIO_DNA_BEER_YEAST = BioDNA + .createAndRegisterBioDNA("Saccharomyces cerevisiae var cerevisiae", EnumRarity.uncommon); + private static final BioData eColiData = BioData + .createAndRegisterBioData("Escherichia koli", EnumRarity.uncommon, 10000, 0); + private static final BioDNA BIO_DNA_ANAEROBIC_OIL = BioDNA + .createAndRegisterBioDNA("Pseudomonas Veronii", EnumRarity.uncommon); + private static final BioData BIO_DATA_ANAEROBIC_OIL = BioData + .createAndRegisterBioData("Pseudomonas Veronii", EnumRarity.uncommon, 5000, 1); + public static BioCulture CommonYeast; + public static BioCulture WhineYeast; + public static BioCulture BeerYeast; + public static BioCulture rottenFleshBacteria; + public static BioCulture eColi; + public static BioCulture anaerobicOil; + public static BioCulture generalPurposeFermentingBacteria; + + public static void run() { + BioCultureLoader.CommonYeast = BioCulture.createAndRegisterBioCulture( + new Color(255, 248, 200), + "Saccharomyces cerevisiae", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_YEAST), + BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_YEAST), + true); + BioCultureLoader.WhineYeast = BioCulture.createAndRegisterBioCulture( + new Color(255, 248, 200), + "Saccharomyces cerevisiae var bayanus", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DNA_WHINE_YEAST), + BioCultureLoader.BIO_DNA_WHINE_YEAST, + EnumRarity.uncommon, + true); + BioCultureLoader.BeerYeast = BioCulture.createAndRegisterBioCulture( + new Color(255, 248, 200), + "Saccharomyces cerevisiae var cerevisiae", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DNA_BEER_YEAST), + BioCultureLoader.BIO_DNA_BEER_YEAST, + EnumRarity.uncommon, + true); + BioCultureLoader.rottenFleshBacteria = BioCulture.createAndRegisterBioCulture( + new Color(110, 40, 25), + "Escherichia cadaver", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_BETA_LACMATASE), + BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_BETA_LACMATASE), + false); + BioCultureLoader.eColi = BioCulture.createAndRegisterBioCulture( + new Color(149, 132, 75), + "Escherichia koli", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.eColiData), + BioDNA.convertDataToDNA(BioCultureLoader.eColiData), + true); + BioCultureLoader.anaerobicOil = BioCulture.createAndRegisterBioCulture( + new Color(0, 0, 0), + "Pseudomonas Veronii", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DNA_ANAEROBIC_OIL), + BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_ANAEROBIC_OIL), + true); + BioCultureLoader.generalPurposeFermentingBacteria = BioCulture.createAndRegisterBioCulture( + new Color(127, 69, 26), + "Saccharomyces escherichia", + BioCultureLoader.CommonYeast.getPlasmid(), + BioCultureLoader.eColi.getdDNA(), + EnumRarity.epic, + true); + + BioCultureLoader.CommonYeast.setLocalisedName("Common Yeast"); + BioCultureLoader.WhineYeast.setLocalisedName("Whine Yeast"); + BioCultureLoader.BeerYeast.setLocalisedName("Beer Yeast"); + BioCultureLoader.rottenFleshBacteria.setLocalisedName("Rotten Flesh Bacteria"); + BioCultureLoader.eColi.setLocalisedName("eColi Bacteria"); + BioCultureLoader.anaerobicOil.setLocalisedName("Anaerobic Oil Bacteria"); + BioCultureLoader.generalPurposeFermentingBacteria.setLocalisedName("General Purpose Fermenting Bacteria"); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java new file mode 100644 index 0000000000..8b86d4cd93 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import java.util.Collection; +import java.util.HashSet; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.items.LabModule; +import com.github.bartimaeusnek.bartworks.common.items.LabParts; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import com.github.bartimaeusnek.bartworks.util.BioDNA; +import com.github.bartimaeusnek.bartworks.util.BioData; +import com.github.bartimaeusnek.bartworks.util.BioPlasmid; + +import cpw.mods.fml.common.registry.GameRegistry; + +public class BioItemList { + + private BioItemList() {} + + private static final Item mItemBioLabParts = new LabModule( + new String[] { "DNAExtractionModule", "PCRThermoclyclingModule", "PlasmidSynthesisModule", + "TransformationModule", "ClonalCellularSynthesisModule" }); + public static final ItemStack[] mBioLabParts = { new ItemStack(BioItemList.mItemBioLabParts), + new ItemStack(BioItemList.mItemBioLabParts, 1, 1), new ItemStack(BioItemList.mItemBioLabParts, 1, 2), + new ItemStack(BioItemList.mItemBioLabParts, 1, 3), new ItemStack(BioItemList.mItemBioLabParts, 1, 4) }; + private static final Item vanillaBioLabParts = new LabParts( + new String[] { "petriDish", "DNASampleFlask", "PlasmidCell", "DetergentPowder", "Agarose", "IncubationModule", + "PlasmaMembrane" }); + + public static void registerBioItems() { + GameRegistry.registerItem(BioItemList.mItemBioLabParts, "BioLabModules"); + GameRegistry.registerItem(BioItemList.vanillaBioLabParts, "BioLabParts"); + } + + public static Collection getAllPetriDishes() { + HashSet ret = new HashSet<>(); + for (BioCulture Culture : BioCulture.BIO_CULTURE_ARRAY_LIST) { + ret.add(BioItemList.getPetriDish(Culture)); + } + return ret; + } + + public static Collection getAllDNASampleFlasks() { + HashSet ret = new HashSet<>(); + for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { + ret.add(BioItemList.getDNASampleFlask(BioDNA.convertDataToDNA(dna))); + } + return ret; + } + + public static Collection getAllPlasmidCells() { + HashSet ret = new HashSet<>(); + for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { + ret.add(BioItemList.getPlasmidCell(BioPlasmid.convertDataToPlasmid(dna))); + } + return ret; + } + + public static ItemStack getPetriDish(BioCulture Culture) { + if (Culture == null) return new ItemStack(BioItemList.vanillaBioLabParts); + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts); + ret.setTagCompound(BioCulture.getNBTTagFromCulture(Culture)); + return ret; + } + + public static ItemStack getDNASampleFlask(BioDNA dna) { + if (dna == null) return new ItemStack(BioItemList.vanillaBioLabParts, 1, 1); + + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts, 1, 1); + ret.setTagCompound(BioData.getNBTTagFromBioData(dna)); + return ret; + } + + public static ItemStack getPlasmidCell(BioPlasmid plasmid) { + if (plasmid == null) return new ItemStack(BioItemList.vanillaBioLabParts, 1, 2); + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts, 1, 2); + ret.setTagCompound(BioData.getNBTTagFromBioData(plasmid)); + return ret; + } + + /** + * 1 - Detergent Powder 2 - Agarose 3 - Incubation Module 4 - Plasma Membrane others are null + * + * @param selection see above + * @return the selected Item + */ + public static ItemStack getOther(int selection) { + if (selection < 1 || selection > 4) return null; + + return new ItemStack(BioItemList.vanillaBioLabParts, 1, 2 + selection); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java new file mode 100644 index 0000000000..28ad279e28 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +public class BioLabLoader { + + public static void run() { + FluidLoader.run(); + BioItemList.registerBioItems(); + BioRecipeLoader.run(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java new file mode 100644 index 0000000000..abed08eb5e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static gregtech.api.enums.Mods.CropsPlusPlus; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public class BioRecipeLoader { + + public static void run() { + registerWaterBasedBioLabIncubations(); + registerBacterialVatRecipes(); + } + + public static void registerWaterBasedBioLabIncubations() { + FluidStack[] easyFluids = { Materials.Water.getFluid(1000L), + FluidRegistry.getFluidStack("ic2distilledwater", 1000) }; + for (FluidStack fluidStack : easyFluids) { + + BWRecipes.instance.addBioLabRecipeIncubation( + new ItemStack(Items.rotten_flesh), + BioCultureLoader.rottenFleshBacteria, + new int[] { 3300 }, + new FluidStack[] { fluidStack }, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART); + + BWRecipes.instance.addBioLabRecipeIncubation( + new ItemStack(Items.fermented_spider_eye), + BioCultureLoader.eColi, + new int[] { 4500 }, + new FluidStack[] { fluidStack }, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Food_Dough.get(1L), + BioCultureLoader.CommonYeast, + new int[] { 7500 }, + new FluidStack[] { fluidStack }, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Food_Dough_Sugar.get(1L), + BioCultureLoader.WhineYeast, + new int[] { 2500 }, + new FluidStack[] { fluidStack }, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Bottle_Wine.get(1L), + BioCultureLoader.WhineYeast, + new int[] { 3300 }, + new FluidStack[] { fluidStack }, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Bottle_Beer.get(1L), + BioCultureLoader.BeerYeast, + new int[] { 2500 }, + new FluidStack[] { fluidStack }, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Bottle_Dark_Beer.get(1L), + BioCultureLoader.BeerYeast, + new int[] { 3300 }, + new FluidStack[] { fluidStack }, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART); + + BWRecipes.instance.addBioLabRecipeIncubation( + new ItemStack(Blocks.dirt), + BioCultureLoader.anaerobicOil, + new int[] { 100 }, + new FluidStack[] { fluidStack }, + 1500, + (int) TierEU.RECIPE_EV, + BW_Util.STANDART); + } + } + + public static void registerWaterBasedBacterialVatRecipes() { + FluidStack[] easyFluids = { Materials.Water.getFluid(1000L), + FluidRegistry.getFluidStack("ic2distilledwater", 1000) }; + for (FluidStack fluidStack : easyFluids) { + if (CropsPlusPlus.isModLoaded()) { + BWRecipes.instance.addBacterialVatRecipe( + new ItemStack[] { new ItemStack(Items.sugar, 64) }, + new FluidStack[] { new FluidStack(fluidStack, 100) }, + BioCultureLoader.CommonYeast, + new FluidStack[] { FluidRegistry.getFluidStack("potion.ghp", 1) }, + 350, + (int) TierEU.RECIPE_EV); + } + + BWRecipes.instance.addBacterialVatRecipe( + new ItemStack[] { ItemList.Crop_Drop_Grapes.get(16) }, + new FluidStack[] { new FluidStack(fluidStack, 100) }, + BioCultureLoader.WhineYeast, + new FluidStack[] { FluidRegistry.getFluidStack("potion.wine", 12) }, + 200, + (int) TierEU.RECIPE_MV); + + BWRecipes.instance.addBacterialVatRecipe( + new ItemStack[] { new ItemStack(Items.sugar, 4), ItemList.IC2_Hops.get(16L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wheat, 8L) }, + new FluidStack[] { new FluidStack(fluidStack, 100) }, + BioCultureLoader.BeerYeast, + new FluidStack[] { FluidRegistry.getFluidStack("potion.beer", 5) }, + 600, + (int) TierEU.RECIPE_LV); + BWRecipes.instance.addBacterialVatRecipe( + new ItemStack[] { ItemList.IC2_Hops.get(32L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wheat, 16L) }, + new FluidStack[] { new FluidStack(fluidStack, 100) }, + BioCultureLoader.BeerYeast, + new FluidStack[] { FluidRegistry.getFluidStack("potion.darkbeer", 10) }, + 600, + (int) TierEU.RECIPE_LV); + } + } + + public static void registerBacterialVatRecipes() { + registerWaterBasedBacterialVatRecipes(); + + BWRecipes.instance.addBacterialVatRecipe( + null, + new FluidStack[] { FluidRegistry.getFluidStack("potion.grapejuice", 100) }, + BioCultureLoader.WhineYeast, + new FluidStack[] { FluidRegistry.getFluidStack("potion.wine", 12) }, + 400, + (int) TierEU.RECIPE_LV); + + BWRecipes.instance.addBacterialVatRecipe( + null, + new FluidStack[] { Materials.FermentedBiomass.getFluid(10000) }, + BioCultureLoader.anaerobicOil, + new FluidStack[] { new FluidStack(FluidLoader.fulvicAcid, 1000) }, + 2748, + (int) TierEU.RECIPE_HV); + } + + public static void runOnServerStarted() { + RecipeMaps.fermentingRecipes.getAllRecipes() + .forEach( + recipe -> BWRecipes.instance.addBacterialVatRecipe( + new ItemStack[] { null }, + BioCultureLoader.generalPurposeFermentingBacteria, + recipe.mFluidInputs, + recipe.mFluidOutputs, + recipe.mDuration, + recipe.mEUt, + GT_Utility.getTier(recipe.mEUt))); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java new file mode 100644 index 0000000000..1a7e49aaa3 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java @@ -0,0 +1,213 @@ +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.Mods.Avaritia; +import static gregtech.api.enums.Mods.EternalSingularity; +import static gregtech.api.enums.Mods.GoodGenerator; +import static gregtech.api.enums.Mods.OpenComputers; +import static gregtech.api.enums.Mods.SuperSolarPanels; +import static gregtech.api.enums.Mods.UniversalSingularities; +import static gregtech.api.util.GT_ModHandler.getModItem; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; + +public class ElectricImplosionCompressorRecipes implements Runnable { + + private static void addElectricImplosionRecipe(final ItemStack[] inputItems, final FluidStack[] inputFluids, + final ItemStack[] outputItems, final FluidStack[] outputFluids, final int durationInTicks, + final int EUPerTick) { + BartWorksRecipeMaps.electricImplosionCompressorRecipes + .addRecipe(false, inputItems, outputItems, null, inputFluids, outputFluids, durationInTicks, EUPerTick, 1); + } + + private static final ItemStack[] circuits = { ItemList.Circuit_ExoticProcessor.get(1), + ItemList.Circuit_OpticalAssembly.get(1), ItemList.Circuit_Biowaresupercomputer.get(1), + ItemList.Circuit_Wetwaremainframe.get(1) }; + + @Override + public void run() { + // Custom electric implosion compressor recipes. Cannot be overclocked. + + if (EternalSingularity.isModLoaded()) { + + addElectricImplosionRecipe( + // IN. + new ItemStack[] { GT_Values.NI }, + new FluidStack[] { MaterialsUEVplus.SpaceTime.getMolten(72L) }, + // OUT. + new ItemStack[] { getModItem(EternalSingularity.ID, "eternal_singularity", 1L) }, + new FluidStack[] { GT_Values.NF }, + // Recipe stats. + 100 * 20, + (int) TierEU.RECIPE_UMV); + + if (UniversalSingularities.isModLoaded()) + // Raw Exposed Optical Chip + addElectricImplosionRecipe( + // IN. + new ItemStack[] { ItemList.Circuit_Silicon_Wafer7.get(1L), + // Fluxed Electrum Singularity. + getModItem(UniversalSingularities.ID, "universal.general.singularity", 1L, 20) }, + new FluidStack[] { GT_Values.NF }, + // OUT. + new ItemStack[] { ItemList.Circuit_Chip_Optical.get(16L) }, + new FluidStack[] { GT_Values.NF }, + 5 * 20, + (int) TierEU.RECIPE_UMV); + + } + + addElectricImplosionRecipe( + // IN. + new ItemStack[] { getModItem(GoodGenerator.ID, "highDensityPlutoniumNugget", 5L) }, + new FluidStack[] { Materials.Neutronium.getMolten(72L) }, + // OUT. + new ItemStack[] { getModItem(GoodGenerator.ID, "highDensityPlutonium", 1L) }, + new FluidStack[] { GT_Values.NF }, + // Recipe stats. + 1, + (int) TierEU.RECIPE_UEV); + + addElectricImplosionRecipe( + // IN. + new ItemStack[] { getModItem(GoodGenerator.ID, "highDensityUraniumNugget", 5L) }, + new FluidStack[] { Materials.Neutronium.getMolten(72L) }, + // OUT. + new ItemStack[] { getModItem(GoodGenerator.ID, "highDensityUranium", 1L) }, + new FluidStack[] { GT_Values.NF }, + // Recipe stats. + 1, + (int) TierEU.RECIPE_UEV); + + addElectricImplosionRecipe( + // IN. + new ItemStack[] { getModItem(GoodGenerator.ID, "highDensityThoriumNugget", 5L) }, + new FluidStack[] { Materials.Neutronium.getMolten(72L) }, + // OUT. + new ItemStack[] { getModItem(GoodGenerator.ID, "highDensityThorium", 1L) }, + new FluidStack[] { GT_Values.NF }, + // Recipe stats. + 1, + (int) TierEU.RECIPE_UEV); + + // Magneto material recipe for base fluid. + addElectricImplosionRecipe( + // IN. + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.WhiteDwarfMatter, 1L), + GT_OreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.Universium, 1L), + GT_OreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.BlackDwarfMatter, 1L) }, + new FluidStack[] { MaterialsUEVplus.RawStarMatter.getFluid(64 * 144L) }, + // OUT. + new ItemStack[] { GT_Values.NI }, + new FluidStack[] { MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(16 * 144L) }, + // Recipe stats. + 20 * 4, + (int) TierEU.RECIPE_UXV); + + // Infinity Catalyst + addElectricImplosionRecipe( + // IN. + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.dust, Materials.InfinityCatalyst, 64L), }, + new FluidStack[] { GT_Values.NF }, + // OUT. + new ItemStack[] { getModItem(Avaritia.ID, "Resource", 1L, 5) }, + new FluidStack[] { GT_Values.NF }, + // Recipe stats. + 1 * 1, + (int) TierEU.RECIPE_UIV); + + if (UniversalSingularities.isModLoaded()) { + // Fluxed Singularity + addElectricImplosionRecipe( + // IN. + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.block, Materials.ElectrumFlux, 16L), }, + new FluidStack[] { GT_Values.NF }, + // OUT. + new ItemStack[] { getModItem(UniversalSingularities.ID, "universal.general.singularity", 1L, 20) }, + new FluidStack[] { GT_Values.NF }, + // Recipe stats. + 1 * 1, + (int) TierEU.RECIPE_UIV); + + // Iron Singularity + addElectricImplosionRecipe( + // IN. + new ItemStack[] { GT_Values.NI }, + new FluidStack[] { Materials.Iron.getMolten(7296 * 9 * 144L) }, + // OUT. + new ItemStack[] { getModItem(Avaritia.ID, "Singularity", 1L, 0) }, + new FluidStack[] { GT_Values.NF }, + // Recipe stats. + 1 * 1, + (int) TierEU.RECIPE_UIV); + } + // MHDCSM V2 + addElectricImplosionRecipe( + // IN. + new ItemStack[] { MaterialsUEVplus.Eternity.getNanite(1), MaterialsUEVplus.Universium.getNanite(1) }, + new FluidStack[] { MaterialsUEVplus.RawStarMatter.getFluid(128 * 144L) }, + // OUT. + new ItemStack[] { GT_Values.NI }, + new FluidStack[] { MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(32 * 144L) }, + // Recipe stats. + 20 * 4, + (int) TierEU.RECIPE_MAX); + + this.addMagnetohydrodynamicallyConstrainedStarMatterPartRecipes(); + } + + private void addMagnetohydrodynamicallyConstrainedStarMatterPartRecipes() { + + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.frameGt, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.nugget, 9, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ingot, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plate, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plateDense, 1, 3); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stick, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.round, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.bolt, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.screw, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ring, 4, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.foil, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.itemCasing, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGtSmall, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.rotor, 1, 2); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stickLong, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.springSmall, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.spring, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGt, 1, 2); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.wireFine, 8, 1); + } + + private void addWhiteDwarfMagnetoEICRecipe(final OrePrefixes part, final int multiplier, + final int circuitMultiplier) { + + final int partFraction = (int) (144 * part.mMaterialAmount / M); + + for (ItemStack circuit : circuits) { + addElectricImplosionRecipe( + new ItemStack[] { circuit.splitStack(circuitMultiplier), + getModItem(SuperSolarPanels.ID, "solarsplitter", 1, 0), + getModItem(OpenComputers.ID, "hologram2", circuitMultiplier, 0), + GT_OreDictUnificator.get(part, MaterialsUEVplus.Eternity, multiplier), }, + new FluidStack[] { MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter + .getMolten((long) partFraction * multiplier) }, + new ItemStack[] { GT_OreDictUnificator + .get(part, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, multiplier) }, + new FluidStack[] { GT_Values.NF }, + (int) (multiplier * (20 * partFraction / 144.0)), + (int) TierEU.RECIPE_UXV); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java new file mode 100644 index 0000000000..809e52e6d1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.awt.Color; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.renderer.RendererGlasBlock; +import com.github.bartimaeusnek.bartworks.client.renderer.RendererSwitchingColorFluid; +import com.github.bartimaeusnek.bartworks.common.blocks.BioFluidBlock; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BWTileEntityDimIDBridge; +import com.github.bartimaeusnek.bartworks.util.BioCulture; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.FluidState; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.fluid.GT_FluidFactory; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Item_98; + +public class FluidLoader { + + public static IIcon autogenIIcon; + public static Fluid ff; + public static int renderID; + public static Block bioFluidBlock; + public static Fluid[] BioLabFluidMaterials; + public static ItemStack[] BioLabFluidCells; + + // OilProcessing chain + public static Fluid fulvicAcid, heatedfulvicAcid, Kerogen; + + public static void run() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + ff = new Fluid("BWfakeFluid"); + GregTech_API.sGTBlockIconload.add( + () -> ff.setIcons( + GregTech_API.sBlockIcons + .registerIcon(GregTech.getResourcePath("fluids", "fluid.molten.autogenerated")))); + fulvicAcid = createAndRegisterFluid("Fulvic Acid", new Color(20, 20, 20)); + heatedfulvicAcid = createAndRegisterFluid("Heated Fulvic Acid", new Color(40, 20, 20), 720); + Kerogen = createAndRegisterFluid("Kerogen", new Color(85, 85, 85)); + BioLabFluidMaterials = new Fluid[] { createAndRegisterFluid("FluorecentdDNA", new Color(125, 50, 170)), + createAndRegisterFluid("EnzymesSollution", new Color(240, 200, 125)), + createAndRegisterFluid("Penicillin", new Color(255, 255, 255)), + createAndRegisterFluid("Polymerase", new Color(110, 180, 110)) }; + + BioLabFluidCells = new ItemStack[BioLabFluidMaterials.length]; + + GT_MetaGenerated_Item_98.FluidCell[] fluidCells = { GT_MetaGenerated_Item_98.FluidCell.FLUORESCENT_DNA, + GT_MetaGenerated_Item_98.FluidCell.ENZYME_SOLUTION, GT_MetaGenerated_Item_98.FluidCell.PENICILLIN, + GT_MetaGenerated_Item_98.FluidCell.POLYMERASE, }; + for (int i = 0; i < fluidCells.length; i++) { + BioLabFluidCells[i] = fluidCells[i].get(); + } + + FluidStack dnaFluid = Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 100) + : Materials.Biomass.getFluid(100L); + for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { + if (B.isBreedable()) { + B.setFluid( + GT_FluidFactory.builder( + B.getName() + .replace(" ", "") + .toLowerCase() + "fluid") + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) B.getColor() + .getRed(), + (short) B.getColor() + .getBlue(), + (short) B.getColor() + .getGreen() }) + .withLocalizedName(B.getLocalisedName() + " Fluid") + .withStateAndTemperature(FluidState.LIQUID, 300) + .buildAndRegister() + .asFluid()); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(10)) + .fluidInputs(new FluidStack(B.getFluid(), 1000)) + .fluidOutputs(dnaFluid) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(centrifugeRecipes); + } + } + + bioFluidBlock = new BioFluidBlock(); + GameRegistry.registerBlock(bioFluidBlock, "coloredFluidBlock"); + GameRegistry.registerTileEntity(BWTileEntityDimIDBridge.class, "bwTEDimIDBridge"); + if (SideReference.Side.Client) { + RendererSwitchingColorFluid.register(); + RendererGlasBlock.register(); + } + } + + public static Fluid createAndRegisterFluid(String Name, Color color) { + return GT_FluidFactory.builder(Name) + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), + (short) color.getAlpha() }) + .withStateAndTemperature(FluidState.LIQUID, 300) + .buildAndRegister() + .asFluid(); + } + + public static Fluid createAndRegisterFluid(String Name, Color color, int temperature) { + return GT_FluidFactory.builder(Name) + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), + (short) color.getAlpha() }) + .withStateAndTemperature(FluidState.LIQUID, temperature) + .buildAndRegister() + .asFluid(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/GTNHBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/GTNHBlocks.java new file mode 100644 index 0000000000..329d73023f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/GTNHBlocks.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static gregtech.api.enums.Mods.BloodArsenal; +import static gregtech.api.enums.Mods.Botania; +import static gregtech.api.enums.Mods.Botany; +import static gregtech.api.enums.Mods.Chisel; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.ExtraUtilities; +import static gregtech.api.enums.Mods.GalaxySpace; +import static gregtech.api.enums.Mods.HardcoreEnderExpansion; +import static gregtech.api.enums.Mods.IndustrialCraft2; +import static gregtech.api.enums.Mods.Minecraft; +import static gregtech.api.enums.Mods.Natura; +import static gregtech.api.enums.Mods.Railcraft; +import static gregtech.api.enums.Mods.RandomThings; +import static gregtech.api.enums.Mods.TecTech; +import static gregtech.api.enums.Mods.TinkerConstruct; +import static gregtech.api.enums.Mods.Witchery; +import static gregtech.api.enums.Mods.ZTones; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; + +/** + * Autogenerated run file, script Created on Wed Jan 2 19:11:07 2019 by boubou_19 and bartimaeusnek Executed on + * 2019-01-03 02:08:43 modified by bartimaeusnek to only add blocks that mods are loaded modified by bartimaeusnek on + * 2020-03-22 00:20 to run statically modified by Quarri6343 on 2022-08-24 20:02 to add Botania Support + */ +public class GTNHBlocks { + + public static void run() { + for (int i = 0; i < 16; i++) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Minecraft.ID, "stained_glass", i, 3); + } + + BioVatLogicAdder.BioVatGlass.addCustomGlass(IndustrialCraft2.ID, "blockAlloyGlass", 0, 4); + + if (BloodArsenal.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(BloodArsenal.ID, "blood_stained_glass", 0, 3); + } + if (Botania.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Botania.ID, "manaGlass", 0, 4); + BioVatLogicAdder.BioVatGlass.addCustomGlass(Botania.ID, "elfGlass", 0, 5); + } + if (Botany.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Botany.ID, "stained", 0, 3); + } + + if (Chisel.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Chisel.ID, "glass2", 0, 3); + + for (int i = 0; i < 16; i++) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Chisel.ID, "glass", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass(Chisel.ID, "stained_glass_white", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass(Chisel.ID, "stained_glass_yellow", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass(Chisel.ID, "stained_glass_lightgray", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass(Chisel.ID, "stained_glass_brown", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass(Chisel.ID, "stained_glass_forestry", i, 3); + } + } + + if (EnderIO.isModLoaded()) { + for (int i = 0; i <= 5; ++i) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(EnderIO.ID, "blockFusedQuartz", i, 3); + } + } + + if (ExtraUtilities.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(ExtraUtilities.ID, "decorativeBlock1", 9, 3); + for (int i = 0; i < 12; ++i) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(ExtraUtilities.ID, "decorativeBlock2", i, 3); + } + + for (int i = 0; i < 6; ++i) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(ExtraUtilities.ID, "etherealglass", i, 3); + + } + } + + if (GalaxySpace.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(GalaxySpace.ID, "futureglass", 0, 3); + for (int i = 0; i < 16; i++) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(GalaxySpace.ID, "futureglasses", i, 3); + } + } + + if (HardcoreEnderExpansion.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(HardcoreEnderExpansion.ID, "laboratory_glass", 0, 3); + } + + if (IndustrialCraft2.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Minecraft.ID, "glass", 0, 3); + } + + if (Natura.isModLoaded()) { + for (int i = 0; i <= 1; ++i) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Natura.ID, "NetherGlass", i, 3); + } + } + + if (Railcraft.isModLoaded()) { + for (int i = 0; i < 16; i++) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Railcraft.ID, "glass", i, 3); + } + } + + if (RandomThings.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(RandomThings.ID, "spectreGlass", 0, 3); + } + + if (TinkerConstruct.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(TinkerConstruct.ID, "GlassBlock", 0, 3); + + for (int i = 0; i < 16; i++) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(TinkerConstruct.ID, "GlassBlock.StainedClear", i, 3); + } + } + + if (TecTech.isModLoaded()) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(TecTech.ID, "tile.quantumGlass", 0, 8); + } + + if (Witchery.isModLoaded()) { + for (int i = 0; i < 16; i++) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(Witchery.ID, "shadedglass", i, 3); + } + } + + if (ZTones.isModLoaded()) { + for (int i = 0; i < 16; i++) { + BioVatLogicAdder.BioVatGlass.addCustomGlass(ZTones.ID, "tile.glaxx", i, 3); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java new file mode 100644 index 0000000000..499686e6e0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java @@ -0,0 +1,453 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static com.github.bartimaeusnek.bartworks.MainMod.BWT; +import static com.github.bartimaeusnek.bartworks.MainMod.GT2; +import static gregtech.api.enums.Mods.GalactiGreg; +import static gregtech.api.enums.Mods.TecTech; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_Blocks; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks2; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer_MachineBlock; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; +import com.github.bartimaeusnek.bartworks.common.items.BW_SimpleWindMeter; +import com.github.bartimaeusnek.bartworks.common.items.BW_Stonage_Rotors; +import com.github.bartimaeusnek.bartworks.common.items.Circuit_Programmer; +import com.github.bartimaeusnek.bartworks.common.items.GT_Destructopack_Item; +import com.github.bartimaeusnek.bartworks.common.items.GT_Rockcutter_Item; +import com.github.bartimaeusnek.bartworks.common.items.GT_Teslastaff_Item; +import com.github.bartimaeusnek.bartworks.common.items.SimpleIconItem; +import com.github.bartimaeusnek.bartworks.common.items.SimpleSubItemClass; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_RotorBlock; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_ExperimentalFloodGate; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +import com.github.bartimaeusnek.bartworks.common.tileentities.debug.CreativeScanner; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_CircuitAssemblyLine; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_DEHP; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_THTR; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaBlastFurnace; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaChemicalReactor; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaDistillTower; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaOilCracker; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaVacuumFreezer; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_AcidGenerator; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_CompressedFluidHatch; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_Diode; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_EnergyDistributor; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_GiantOutputHatch; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_HumongousInputHatch; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.crossmod.galacticgreg.GT_TileEntity_VoidMiners; +import com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered.TT_MetaTileEntity_LowPowerLaserBox; +import com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered.TT_MetaTileEntity_LowPowerLaserDynamo; +import com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered.TT_MetaTileEntity_LowPowerLaserHatch; +import com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered.TT_MetaTileEntity_Pipe_Energy_LowPower; + +import cpw.mods.fml.common.registry.GameRegistry; +import fox.spiteful.avaritia.blocks.LudicrousBlocks; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import ic2.api.item.IKineticRotor; + +public class ItemRegistry { + + public static final Item DESTRUCTOPACK = new GT_Destructopack_Item(); + public static final Item TESLASTAFF = new GT_Teslastaff_Item(); + public static final Item ROCKCUTTER_LV = new GT_Rockcutter_Item(1); + public static final Item ROCKCUTTER_MV = new GT_Rockcutter_Item(2); + public static final Item ROCKCUTTER_HV = new GT_Rockcutter_Item(3); + public static final Item CIRCUIT_PROGRAMMER = new Circuit_Programmer(); + public static final Block ROTORBLOCK = new BW_TileEntityContainer_MachineBlock( + Material.wood, + BW_RotorBlock.class, + "BWRotorBlock"); + public static final Item LEATHER_ROTOR = new BW_Stonage_Rotors( + 7, + 0.15f, + 5, + 1.15f, + 1, + 50, + 10000000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorLeather.png"), + "BW_LeatherRotor", + "rotors/itemRotorLeather"); + public static final Item WOOL_ROTOR = new BW_Stonage_Rotors( + 7, + 0.18f, + 3, + 1.35f, + 1, + 50, + 9000000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorWool.png"), + "BW_WoolRotor", + "rotors/itemRotorWool"); + public static final Item PAPER_ROTOR = new BW_Stonage_Rotors( + 7, + 0.2f, + 12, + 0.9f, + 1, + 50, + 800000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorPaper.png"), + "BW_PaperRotor", + "rotors/itemRotorPaper"); + public static final Item COMBINED_ROTOR = new BW_Stonage_Rotors( + 9, + 0.22f, + 7, + 1.05f, + 1, + 50, + 6000000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorCombined.png"), + "BW_CombinedRotor", + "rotors/itemRotorCombined"); + public static final Item CRAFTING_PARTS = new SimpleSubItemClass( + "grindstone_top", + "grindstone_bottom", + "completed_grindstone", + "rotors/leatherParts", + "rotors/woolParts", + "rotors/paperParts", + "rotors/combinedParts"); + public static final Item TAB = new SimpleIconItem("GT2Coin"); + public static final Item WINDMETER = new BW_SimpleWindMeter(); + public static final Block PUMPBLOCK = new BW_TileEntityContainer( + Material.anvil, + BW_TileEntity_HeatedWaterPump.class, + "BWHeatedWaterPump"); + public static final Item PUMPPARTS = new SimpleSubItemClass("BWrawtube", "BWmotor"); + public static final Block EXPPUMP = new BW_TileEntityContainer( + Material.coral, + BW_TileEntity_ExperimentalFloodGate.class, + "ExpReversePump"); + + public static final Block bw_realglas = new BW_GlasBlocks( + "BW_GlasBlocks", + new String[] { MainMod.MOD_ID + ":BoronSilicateGlassBlock", + MainMod.MOD_ID + ":TitaniumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":TungstenSteelReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":LuVTierMaterialReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":IridiumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":OsmiumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock1", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock2", + MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock3", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock4", + MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock5", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock6", + MainMod.MOD_ID + ":ThoriumYttriumGlass", MainMod.MOD_ID + ":NeutroniumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":CosmicNeutroniumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":InfinityReinforcedBoronSilicateGlassBlock", }, + new short[][] { Materials.BorosilicateGlass.getRGBA(), Materials.Titanium.getRGBA(), + Materials.TungstenSteel.getRGBA(), Materials.Chrome.getRGBA(), Materials.Iridium.getRGBA(), + Materials.Osmium.getRGBA(), new short[] { 0xff, 0, 0 }, new short[] { 0, 0xff, 0 }, + new short[] { 0x80, 0, 0xff }, new short[] { 0xff, 0xff, 0 }, new short[] { 0, 0xff, 0x80 }, + new short[] { 0x80, 0x33, 0 }, WerkstoffLoader.YttriumOxide.getRGBA(), Materials.Neutronium.getRGBA(), + Materials.CosmicNeutronium.getRGBA(), new short[] { 0xda, 0xeb, 0xff }, }, + MainMod.BIO_TAB, + true, + false); + public static final Block bw_realglas2 = new BW_GlasBlocks2( + "BW_GlasBlocks2", + new String[] { MainMod.MOD_ID + ":TranscendentallyReinforcedBoronSilicateGlassBlock" }, + new short[][] { new short[] { 50, 50, 50 } }, + MainMod.BIO_TAB, + true, + false); + + public static final Block[] bw_glasses = { bw_realglas, bw_realglas2 }; + public static final Block bw_fake_glasses = new BW_GlasBlocks( + "BW_GlasBlocks", + new String[] { MainMod.MOD_ID + ":BoronSilicateGlassBlockRandlos" }, + null, + null, + true, + true); + public static final Block bw_fake_glasses2 = new BW_GlasBlocks2( + "BW_GlasBlocks2", + new String[] { MainMod.MOD_ID + ":BoronSilicateGlassBlockRandlos" }, + null, + null, + true, + true); + public static final Block[] BW_BLOCKS = { + new BW_Blocks( + "BW_ItemBlocks", + new String[] { MainMod.MOD_ID + ":EtchedLapisCell", MainMod.MOD_ID + ":PlatedLapisCell", }, + GT2), + new BW_Blocks("GT_LESU_CASING", new String[] { MainMod.MOD_ID + ":LESU_CELL", }, GT2), + new BW_Blocks( + "BW_Machinery_Casings", + new String[] { MainMod.MOD_ID + ":NickelFerriteBlocks", MainMod.MOD_ID + ":TransformerCoil", + // MainMod.MOD_ID+":DEHP_Casing", + // MainMod.MOD_ID+":DEHP_Casing_Base" + }, + BWT), }; + + public static ItemStack[] diode2A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] diode4A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] diode8A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] diode12A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] diode16A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] energyDistributor = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] acidGens = new ItemStack[3]; + public static ItemStack acidGensLV; + public static ItemStack[] megaMachines = new ItemStack[5]; + public static ItemStack dehp; + public static ItemStack[] voidminer = new ItemStack[3]; + public static ItemStack THTR; + public static ItemStack HTGR; + public static ItemStack eic; + public static ItemStack cal; + public static ItemStack compressedHatch; + public static ItemStack giantOutputHatch; + public static ItemStack humongousInputHatch; + + public static ItemStack[][][] TecTechLaserAdditions = new ItemStack[3][4][4]; + public static ItemStack TecTechPipeEnergyLowPower; + + public static void run() { + GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses, "BW_FakeGlasBlock"); + GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses2, "BW_FakeGlasBlocks2"); + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[2], BW_ItemBlocks.class, "BW_Machinery_Casings"); + GameRegistry.registerItem(ItemRegistry.LEATHER_ROTOR, "BW_LeatherRotor"); + GameRegistry.registerItem(ItemRegistry.WOOL_ROTOR, "BW_WoolRotor"); + GameRegistry.registerItem(ItemRegistry.PAPER_ROTOR, "BW_PaperRotor"); + GameRegistry.registerItem(ItemRegistry.COMBINED_ROTOR, "BW_CombinedRotor"); + GameRegistry.registerItem(ItemRegistry.CRAFTING_PARTS, "craftingParts"); + GameRegistry.registerTileEntity(BW_RotorBlock.class, "BWRotorBlockTE"); + GameRegistry.registerBlock(ItemRegistry.ROTORBLOCK, BW_ItemBlocks.class, "BWRotorBlock"); + GameRegistry.registerTileEntity(BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPumpTE"); + GameRegistry.registerBlock(ItemRegistry.PUMPBLOCK, BW_ItemBlocks.class, "BWHeatedWaterPumpBlock"); + GameRegistry.registerItem(ItemRegistry.PUMPPARTS, "BWPumpParts"); + GameRegistry.registerItem(ItemRegistry.WINDMETER, "BW_SimpleWindMeter"); + GameRegistry.registerTileEntity(BW_TileEntity_ExperimentalFloodGate.class, "BWExpReversePump"); + GameRegistry.registerBlock(ItemRegistry.EXPPUMP, BW_ItemBlocks.class, "BWExpReversePumpBlock"); + + // GT2 stuff + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[0], BW_ItemBlocks.class, "BW_ItemBlocks"); + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[1], BW_ItemBlocks.class, "GT_LESU_CASING"); + if (ConfigHandler.teslastaff) + GameRegistry.registerItem(ItemRegistry.TESLASTAFF, ItemRegistry.TESLASTAFF.getUnlocalizedName()); + + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_LV, ItemRegistry.ROCKCUTTER_LV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_MV, ItemRegistry.ROCKCUTTER_MV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_HV, ItemRegistry.ROCKCUTTER_HV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.TAB, "tabIconGT2"); + + if (ConfigHandler.creativeScannerID != 0) new CreativeScanner( + ConfigHandler.creativeScannerID, + "Creative Debug Scanner", + "Creative Debug Scanner", + 20); + ItemRegistry.eic = new GT_TileEntity_ElectricImplosionCompressor( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 6, + "ElectricImplosionCompressor", + "Electric Implosion Compressor").getStackForm(1L); + + // EIC depend on neutronium block to pass on structure updates + int bitmask = GregTech_API.sMachineIDs.getOrDefault(GregTech_API.sBlockMetal5, 0) | 1 << 2; + GregTech_API.registerMachineBlock(GregTech_API.sBlockMetal5, bitmask); + + // Also spacetime, transcendent metal, and universium + bitmask = GregTech_API.sMachineIDs.getOrDefault(GregTech_API.sBlockMetal9, 0) | 1 << 3 | 1 << 4 | 1 << 8; + GregTech_API.registerMachineBlock(GregTech_API.sBlockMetal9, bitmask); + + // Also infinity + bitmask = GregTech_API.sMachineIDs.getOrDefault(LudicrousBlocks.resource_block, 0) | 1 << 1; + GregTech_API.registerMachineBlock(LudicrousBlocks.resource_block, bitmask); + + ItemRegistry.THTR = new GT_TileEntity_THTR( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 5, + "THTR", + "Thorium High Temperature Reactor").getStackForm(1L); + GT_TileEntity_THTR.THTRMaterials.registeraTHR_Materials(); + ItemRegistry.HTGR = new GT_TileEntity_HTGR( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 15 + 48, + "HTGR", + "High Temperature Gas-cooled Reactor").getStackForm(1L); + GT_TileEntity_HTGR.HTGRMaterials.registeraTHR_Materials(); + + // ID ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 15 + 49 IS TAKEN !!! (12792) + + GT_OreDictUnificator + .add(OrePrefixes.block, Materials.BorosilicateGlass, new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)); + GT_OreDictUnificator + .registerOre(OrePrefixes.block, Materials.NickelZincFerrite, new ItemStack(ItemRegistry.BW_BLOCKS[2])); + for (int i = 0; i < GT_Values.VN.length - 1; i++) { + ItemRegistry.diode2A[i] = new GT_MetaTileEntity_Diode( + ConfigHandler.IDOffset + GT_Values.VN.length + 1 + i, + "diode" + "2A" + GT_Values.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 2A " + GT_Values.VN[i], + i).getStackForm(1L); + ItemRegistry.diode4A[i] = new GT_MetaTileEntity_Diode( + ConfigHandler.IDOffset + GT_Values.VN.length * 2 + 1 + i, + "diode" + "4A" + GT_Values.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 4A " + GT_Values.VN[i], + i).getStackForm(1L); + ItemRegistry.diode8A[i] = new GT_MetaTileEntity_Diode( + ConfigHandler.IDOffset + GT_Values.VN.length * 3 + 1 + i, + "diode" + "8A" + GT_Values.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 8A " + GT_Values.VN[i], + i).getStackForm(1L); + ItemRegistry.diode12A[i] = new GT_MetaTileEntity_Diode( + ConfigHandler.IDOffset + GT_Values.VN.length * 4 + 1 + i, + "diode" + "12A" + GT_Values.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 12A " + GT_Values.VN[i], + i).getStackForm(1L); + ItemRegistry.diode16A[i] = new GT_MetaTileEntity_Diode( + ConfigHandler.IDOffset + GT_Values.VN.length * 5 + 1 + i, + "diode" + "16A" + GT_Values.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 16A " + GT_Values.VN[i], + i).getStackForm(1L); + ItemRegistry.energyDistributor[i] = new GT_MetaTileEntity_EnergyDistributor( + ConfigHandler.IDOffset + 1 + i, + "energydistributor" + GT_Values.VN[i], + StatCollector.translateToLocal("tile.energydistributor.name") + " " + GT_Values.VN[i], + i).getStackForm(1L); + } + for (int i = 0; i < 3; i++) { + ItemRegistry.acidGens[i] = new GT_MetaTileEntity_AcidGenerator( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 - 2 + i, + "acidgenerator" + GT_Values.VN[i + 2], + StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GT_Values.VN[i + 2], + i + 2).getStackForm(1); + } + + ItemRegistry.acidGensLV = new GT_MetaTileEntity_AcidGenerator( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 65, + "acidgenerator" + GT_Values.VN[1], + StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GT_Values.VN[1], + +1).getStackForm(1L); + + ItemRegistry.dehp = new GT_TileEntity_DEHP( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 1, + 1, + "DEHP", + "Deep Earth Heating Pump").getStackForm(1L); + ItemRegistry.megaMachines[0] = new GT_TileEntity_MegaBlastFurnace( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 2, + "MegaBlastFurnace", + StatCollector.translateToLocal("tile.bw.mbf.name")).getStackForm(1L); + ItemRegistry.megaMachines[1] = new GT_TileEntity_MegaVacuumFreezer( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 3, + "MegaVacuumFreezer", + StatCollector.translateToLocal("tile.bw.mvf.name")).getStackForm(1L); + ItemRegistry.cal = new GT_TileEntity_CircuitAssemblyLine( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 7, + "CircuitAssemblyLine", + "Circuit Assembly Line").getStackForm(1L); + ItemRegistry.compressedHatch = new GT_MetaTileEntity_CompressedFluidHatch( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 8, + "CompressedFluidHatch", + "Liquid Air Fluid Hatch").getStackForm(1L); + ItemRegistry.giantOutputHatch = new GT_MetaTileEntity_GiantOutputHatch( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 9, + "GiantOutputHatch", + "Giant Output Hatch").getStackForm(1L); + ItemRegistry.humongousInputHatch = new GT_MetaTileEntity_HumongousInputHatch( + ConfigHandler.IDOffset + GT_Values.VN.length * 9 + 55, + "HumongousInputHatch", + "Humongous Input Hatch").getStackForm(1L); + ItemRegistry.megaMachines[2] = new GT_TileEntity_MegaDistillTower( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 10, + "MegaDistillationTower", + "Mega Distillation Tower").getStackForm(1L); + ItemRegistry.megaMachines[3] = new GT_TileEntity_MegaChemicalReactor( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 638, + "MegaChemicalReactor", + "Mega Chemical Reactor").getStackForm(1L); + ItemRegistry.megaMachines[4] = new GT_TileEntity_MegaOilCracker( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 639, + "MegaOilCracker", + "Mega Oil Cracker").getStackForm(1L); + + if (GalactiGreg.isModLoaded()) { + ItemRegistry.voidminer[2] = new GT_TileEntity_VoidMiners.VMUV( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 11, + "VoidMiner3", + "Void Miner III").getStackForm(1L); + ItemRegistry.voidminer[1] = new GT_TileEntity_VoidMiners.VMZPM( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 12, + "VoidMiner2", + "Void Miner II").getStackForm(1L); + ItemRegistry.voidminer[0] = new GT_TileEntity_VoidMiners.VMLUV( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 13, + "VoidMiner1", + "Void Miner I").getStackForm(1L); + } + if (TecTech.isModLoaded()) { + TecTechPipeEnergyLowPower = new TT_MetaTileEntity_Pipe_Energy_LowPower( + ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 14, + "pipe.lowpowerlaser", + "Low Power Laser Pipe").getStackForm(1L); + int startID = ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 15; + for (int amps = 32; amps <= 128; amps += 32) { + for (int tier = 4; tier < 8; tier++) { + TecTechLaserAdditions[0][amps / 32 - 1][tier - 4] = new TT_MetaTileEntity_LowPowerLaserBox( + startID, + GT_Values.VN[tier] + "_LPLaser_Converter_" + amps, + GT_Values.VN[tier] + " " + amps + "A/t" + " Low Power Laser Converter", + tier, + amps).getStackForm(1L); + startID++; + } + } + for (int amps = 32; amps <= 128; amps += 32) { + for (int tier = 4; tier < 8; tier++) { + TecTechLaserAdditions[1][amps / 32 - 1][tier - 4] = new TT_MetaTileEntity_LowPowerLaserHatch( + startID, + GT_Values.VN[tier] + "_LPLaser_Hatch_" + amps, + GT_Values.VN[tier] + " " + amps + "A/t" + " Low Power Laser Target Hatch", + tier, + amps).getStackForm(1L); + startID++; + } + } + for (int amps = 32; amps <= 128; amps += 32) { + for (int tier = 4; tier < 8; tier++) { + TecTechLaserAdditions[2][amps / 32 - 1][tier - 4] = new TT_MetaTileEntity_LowPowerLaserDynamo( + startID, + GT_Values.VN[tier] + "_LPLaser_Dynamo_" + amps, + GT_Values.VN[tier] + " " + amps + "A/t" + " Low Power Laser Source Hatch", + tier, + amps).getStackForm(1L); + startID++; + } + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LocalisationLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LocalisationLoader.java new file mode 100644 index 0000000000..020f89e703 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LocalisationLoader.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import gregtech.api.util.GT_LanguageManager; + +public class LocalisationLoader { + + private LocalisationLoader() {} + + private static void localiseTooltips() { + GT_LanguageManager + .addStringLocalization("metaitem.01.tooltip.purify.2", "Throw into Cauldron to get clean crushed Ore"); + GT_LanguageManager + .addStringLocalization("metaitem.01.tooltip.nqgen", "Can be used as Enriched Naquadah Fuel Substitute"); + } + + private static void localiseAchivements() { + GT_LanguageManager + .addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor", "Electric Implosions?"); + GT_LanguageManager.addStringLocalization( + "achievement.gt.blockmachines.electricimplosioncompressor.desc", + "Basically a giant Hammer that presses Stuff - No more TNT!"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.dehp", "Heat from below!"); + GT_LanguageManager + .addStringLocalization("achievement.gt.blockmachines.dehp.desc", "Get ALL the thermal energy!"); + GT_LanguageManager + .addStringLocalization("achievement.gt.blockmachines.circuitassemblyline", "Cheaper Circuits?"); + GT_LanguageManager.addStringLocalization( + "achievement.gt.blockmachines.circuitassemblyline.desc", + "Well, yes, but actually no..."); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.voidminer1", "Ores from deep below!"); + GT_LanguageManager + .addStringLocalization("achievement.gt.blockmachines.voidminer1.desc", "Is this some kind of Ex-Nihilo?"); + GT_LanguageManager.addStringLocalization( + "achievement.gt.blockmachines.voidminer2", + "Ores from deep below 2! Electric Boogaloo!"); + GT_LanguageManager + .addStringLocalization("achievement.gt.blockmachines.voidminer2.desc", "Ex-Nihilo, but faster!"); + GT_LanguageManager.addStringLocalization( + "achievement.gt.blockmachines.voidminer3", + "Ores from deep below 3! Trinity Ex-Nihilo"); + GT_LanguageManager + .addStringLocalization("achievement.gt.blockmachines.voidminer3.desc", "3x the trouble, 3x the fun!"); + } + + public static void localiseAll() { + localiseAchivements(); + localiseTooltips(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java new file mode 100644 index 0000000000..d141fe8b65 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java @@ -0,0 +1,224 @@ +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static gregtech.api.enums.Mods.IndustrialCraft2; + +import com.github.bartimaeusnek.bartworks.system.material.BW_NonMeta_MaterialItems; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; + +public class RadioHatchMaterialLoader { + + public static void run() { + + for (Werkstoff material : Werkstoff.werkstoffHashSet) { + if (material != null && material.getStats() + .isRadioactive()) { + int level = (int) material.getStats() + .getProtons(); + short[] rgba = material.getRGBA(); + if (material.hasItemType(OrePrefixes.stick)) + BWRecipes.instance.addRadHatch(material.get(OrePrefixes.stick), level, 1, rgba); + if (material.hasItemType(OrePrefixes.stickLong)) + BWRecipes.instance.addRadHatch(material.get(OrePrefixes.stickLong), level, 2, rgba); + } + } + + for (Materials material : Materials.getAll()) { + if (material == null || material.mElement == null) continue; + boolean validProton = material.getProtons() >= 83 && !material.equals(Materials.Tritanium) // No Tritanium + && !material.equals(Materials.Naquadah); // Naquadah needs spacial value + if (validProton) { + int level = (int) material.getProtons(); + short[] rgba = material.getRGBA(); + if (GT_OreDictUnificator.get(OrePrefixes.stick, material, 1) != null) BWRecipes.instance + .addRadHatch(GT_OreDictUnificator.get(OrePrefixes.stick, material, 1), level, 1, rgba); + if (GT_OreDictUnificator.get(OrePrefixes.stickLong, material, 1) != null) BWRecipes.instance + .addRadHatch(GT_OreDictUnificator.get(OrePrefixes.stickLong, material, 1), level, 2, rgba); + } + } + + Materials[] spacialMaterial = { Materials.Naquadah, Materials.NaquadahEnriched, Materials.Naquadria }; + int[] spacialValue = { 130, 140, 150 }; + + for (int i = 0; i < spacialMaterial.length; i++) { + if (GT_OreDictUnificator.get(OrePrefixes.stick, spacialMaterial[i], 1) != null) + BWRecipes.instance.addRadHatch( + GT_OreDictUnificator.get(OrePrefixes.stick, spacialMaterial[i], 1), + spacialValue[i], + 1, + spacialMaterial[i].mRGBa); + if (GT_OreDictUnificator.get(OrePrefixes.stickLong, spacialMaterial[i], 1) != null) + BWRecipes.instance.addRadHatch( + GT_OreDictUnificator.get(OrePrefixes.stickLong, spacialMaterial[i], 1), + spacialValue[i], + 2, + spacialMaterial[i].mRGBa); + } + + BWRecipes.instance.addRadHatch( + ItemList.ThoriumCell_1.get(1), + (int) Materials.Thorium.getProtons(), + 3, + Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.ThoriumCell_2.get(1), + (int) Materials.Thorium.getProtons(), + 6, + Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.ThoriumCell_4.get(1), + (int) Materials.Thorium.getProtons(), + 12, + Materials.Thorium.mRGBa); + + BWRecipes.instance.addRadHatch(ItemList.NaquadahCell_1.get(1), 140, 3, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.NaquadahCell_2.get(1), 140, 6, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.NaquadahCell_4.get(1), 140, 12, Materials.NaquadahEnriched.mRGBa); + + BWRecipes.instance.addRadHatch( + ItemList.Moxcell_1.get(1), + (int) Materials.Plutonium.getProtons(), + 3, + Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Moxcell_2.get(1), + (int) Materials.Plutonium.getProtons(), + 6, + Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Moxcell_4.get(1), + (int) Materials.Plutonium.getProtons(), + 12, + Materials.Plutonium.mRGBa); + + BWRecipes.instance.addRadHatch( + ItemList.Uraniumcell_1.get(1), + (int) Materials.Uranium.getProtons(), + 3, + Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Uraniumcell_2.get(1), + (int) Materials.Uranium.getProtons(), + 6, + Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Uraniumcell_4.get(1), + (int) Materials.Uranium.getProtons(), + 12, + Materials.Uranium.mRGBa); + + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.TiberiumCell_1.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons(), + 3, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.TiberiumCell_2.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons(), + 6, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.TiberiumCell_4.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons(), + 12, + WerkstoffLoader.Tiberium.getRGBA()); + + BWRecipes.instance + .addRadHatch(BW_NonMeta_MaterialItems.TheCoreCell.get(1), 140, 96, Materials.NaquadahEnriched.mRGBa); + + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Thorium_1.get(1), + (int) Materials.Thorium.getProtons() / 10, + 3, + Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Thorium_2.get(1), + (int) Materials.Thorium.getProtons() / 10, + 6, + Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Thorium_4.get(1), + (int) Materials.Thorium.getProtons() / 10, + 12, + Materials.Thorium.mRGBa); + + BWRecipes.instance + .addRadHatch(ItemList.Depleted_Naquadah_1.get(1), 140 / 10, 3, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance + .addRadHatch(ItemList.Depleted_Naquadah_2.get(1), 140 / 10, 6, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance + .addRadHatch(ItemList.Depleted_Naquadah_4.get(1), 140 / 10, 12, Materials.NaquadahEnriched.mRGBa); + + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXSimpledepleted", 1), + (int) Materials.Plutonium.getProtons() / 10, + 3, + Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXDualdepleted", 1), + (int) Materials.Plutonium.getProtons() / 10, + 6, + Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXQuaddepleted", 1), + (int) Materials.Plutonium.getProtons() / 10, + 12, + Materials.Plutonium.mRGBa); + + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumSimpledepleted", 1), + (int) Materials.Uranium.getProtons() / 10, + 3, + Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumDualdepleted", 1), + (int) Materials.Uranium.getProtons() / 10, + 6, + Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumQuaddepleted", 1), + (int) Materials.Uranium.getProtons() / 10, + 12, + Materials.Uranium.mRGBa); + + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.Depleted_Tiberium_1.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10, + 3, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.Depleted_Tiberium_2.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10, + 6, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.Depleted_Tiberium_4.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10, + 12, + WerkstoffLoader.Tiberium.getRGBA()); + + BWRecipes.instance + .addRadHatch(BW_NonMeta_MaterialItems.Depleted_TheCoreCell.get(1), 130 / 10, 96, Materials.Naquadah.mRGBa); + + BWRecipes.instance.addRadHatch(ItemList.MNqCell_1.get(1), 150, 3, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.MNqCell_2.get(1), 150, 6, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.MNqCell_4.get(1), 150, 12, Materials.Naquadria.mRGBa); + + BWRecipes.instance.addRadHatch(ItemList.Depleted_MNq_1.get(1), 150 / 10, 3, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.Depleted_MNq_2.get(1), 150 / 10, 6, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.Depleted_MNq_4.get(1), 150 / 10, 12, Materials.Naquadria.mRGBa); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java new file mode 100644 index 0000000000..c55561687b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.Assembler; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.AssemblyLine; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.Autoclave; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.Centrifuge; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.ChemicalBath; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.ChemicalReactor; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.CraftingRecipes; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.Electrolyzer; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.Extractor; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.FakeRecipes; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.FluidHeater; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.FluidSolidifier; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.FormingPress; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.LaserEngraver; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.Mixer; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.Pulverizer; +import com.github.bartimaeusnek.bartworks.common.loaders.recipes.PyrolyseOven; + +import gregtech.api.util.GT_ModHandler; + +public class RecipeLoader { + + public static final long BITSD = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE; + + public static void run() { + new Assembler().run(); + new AssemblyLine().run(); + new Autoclave().run(); + new Centrifuge().run(); + new ChemicalBath().run(); + new ChemicalReactor().run(); + new CraftingRecipes().run(); + new Electrolyzer().run(); + new Extractor().run(); + new FakeRecipes().run(); + new FluidHeater().run(); + new FluidSolidifier().run(); + new FormingPress().run(); + new LaserEngraver().run(); + new Mixer().run(); + new Pulverizer().run(); + new PyrolyseOven().run(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RegisterServerCommands.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RegisterServerCommands.java new file mode 100644 index 0000000000..615eed0c43 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RegisterServerCommands.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import com.github.bartimaeusnek.bartworks.common.commands.ChangeConfig; +import com.github.bartimaeusnek.bartworks.common.commands.ClearCraftingCache; +import com.github.bartimaeusnek.bartworks.common.commands.GetWorkingDirectory; +import com.github.bartimaeusnek.bartworks.common.commands.PrintRecipeListToFile; +import com.github.bartimaeusnek.bartworks.common.commands.RunGC; +import com.github.bartimaeusnek.bartworks.common.commands.SummonRuin; + +import cpw.mods.fml.common.event.FMLServerStartingEvent; + +public class RegisterServerCommands { + + public static void registerAll(FMLServerStartingEvent event) { + event.registerServerCommand(new SummonRuin()); + event.registerServerCommand(new ChangeConfig()); + event.registerServerCommand(new PrintRecipeListToFile()); + event.registerServerCommand(new ClearCraftingCache()); + event.registerServerCommand(new GetWorkingDirectory()); + event.registerServerCommand(new RunGC()); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java new file mode 100644 index 0000000000..6f50650484 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java @@ -0,0 +1,583 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.loaders; + +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.ANAEROBE_GAS; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.NOBLE_GAS; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.fluids; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.molten; +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.Mods.TinkerConstruct; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.StringUtils; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.API.recipe.DynamicGTRecipe; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.StreamUtils; +import com.github.bartimaeusnek.bartworks.util.log.DebugLog; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.google.common.collect.ArrayListMultimap; + +import cpw.mods.fml.common.registry.GameRegistry; +import gnu.trove.map.hash.TObjectDoubleHashMap; +import gregtech.api.enums.Element; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TierEU; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class StaticRecipeChangeLoaders { + + private static TObjectDoubleHashMap gtEbfGasRecipeTimeMultipliers = null; + private static TObjectDoubleHashMap gtEbfGasRecipeConsumptionMultipliers = null; + + public static final List whitelistForEBFNoGasRecipeDontCheckItemData = Arrays + .asList(GT_ModHandler.getModItem(TinkerConstruct.ID, "materials", 1L, 12) // Raw Aluminum -> Aluminium Ingot + // (coremod) + ); + + private StaticRecipeChangeLoaders() {} + + public static void addEBFGasRecipes() { + if (gtEbfGasRecipeTimeMultipliers == null) { + // For Werkstoff gases, use Werkstoff.Stats.setEbfGasRecipeTimeMultiplier + gtEbfGasRecipeTimeMultipliers = new TObjectDoubleHashMap<>(10, 0.5F, -1.0D); // keep default value as -1 + // Example to make Argon cut recipe times into a third of the original: + // gtEbfGasRecipeTimeMultipliers.put(Materials.Argon, 1.0D / 3.0D); + + gtEbfGasRecipeTimeMultipliers.put(Materials.Nitrogen, 1.0D); + gtEbfGasRecipeTimeMultipliers.put(Materials.Helium, 0.9D); + gtEbfGasRecipeTimeMultipliers.put(Materials.Argon, 0.8D); + gtEbfGasRecipeTimeMultipliers.put(Materials.Radon, 0.7D); + } + if (gtEbfGasRecipeConsumptionMultipliers == null) { + // For Werkstoff gases, use Werkstoff.Stats.setEbfGasRecipeConsumedAmountMultiplier + gtEbfGasRecipeConsumptionMultipliers = new TObjectDoubleHashMap<>(10, 0.5F, 1.0D); // keep default value as + // 1 + // Example to make Argon recipes use half the gas amount of the primary recipe (1000L->500L, 2000L->1000L + // etc.): + // gtEbfGasRecipeConsumptionMultipliers.put(Materials.Argon, 1.0D / 2.0D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Nitrogen, 1.0D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Helium, 1.0D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Argon, 0.85D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Radon, 0.7D); + } + ArrayListMultimap toChange = getRecipesToChange(NOBLE_GAS, ANAEROBE_GAS); + editRecipes(toChange, getNoGasItems(toChange)); + } + + public static void fixEnergyRequirements() { + RecipeMap.ALL_RECIPE_MAPS.values() + .stream() + .filter(StreamUtils::filterVisualMaps) + .forEach( + recipeMap -> recipeMap.getAllRecipes() + .parallelStream() + .forEach(gt_recipe -> { + for (int i = 0; i < VN.length - 1; i++) { + if (gt_recipe.mEUt > BW_Util.getMachineVoltageFromTier(i) + && gt_recipe.mEUt <= BW_Util.getTierVoltage(i)) { + gt_recipe.mEUt = BW_Util.getMachineVoltageFromTier(i); + } + } + })); + } + + public static void unificationRecipeEnforcer() { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + StaticRecipeChangeLoaders.runMaterialLinker(werkstoff); + if (werkstoff.getGenerationFeatures().enforceUnification) { + HashSet oreDictNames = new HashSet<>(werkstoff.getADDITIONAL_OREDICT()); + oreDictNames.add(werkstoff.getVarName()); + StaticRecipeChangeLoaders.runMoltenUnificationEnfocement(werkstoff); + StaticRecipeChangeLoaders.runUnficationDeleter(werkstoff); + for (String s : oreDictNames) for (OrePrefixes prefixes : OrePrefixes.values()) { + if (!werkstoff.hasItemType(prefixes)) continue; + String fullOreName = prefixes + s; + List ores = OreDictionary.getOres(fullOreName, false); + if (ores.size() <= 1) // empty or one entry, i.e. no unification needed + continue; + for (ItemStack toReplace : ores) { + ItemStack replacement = werkstoff.get(prefixes); + if (toReplace == null || GT_Utility.areStacksEqual(toReplace, replacement) + || replacement == null + || replacement.getItem() == null) continue; + for (RecipeMap map : RecipeMap.ALL_RECIPE_MAPS.values()) { + List toRemove = new ArrayList<>(); + nextRecipe: for (GT_Recipe recipe : map.getAllRecipes()) { + boolean removal = map.equals(RecipeMaps.fluidExtractionRecipes) + || map.equals(RecipeMaps.fluidSolidifierRecipes); + for (int i = 0; i < recipe.mInputs.length; i++) { + if (!GT_Utility.areStacksEqual(recipe.mInputs[i], toReplace)) continue; + if (removal) { + toRemove.add(recipe); + continue nextRecipe; + } + recipe.mInputs[i] = GT_Utility.copyAmount(recipe.mInputs[i].stackSize, replacement); + } + for (int i = 0; i < recipe.mOutputs.length; i++) { + if (!GT_Utility.areStacksEqual(recipe.mOutputs[i], toReplace)) continue; + if (removal) { + toRemove.add(recipe); + continue nextRecipe; + } + recipe.mOutputs[i] = GT_Utility + .copyAmount(recipe.mOutputs[i].stackSize, replacement); + } + if (recipe.mSpecialItems instanceof ItemStack specialItemStack) { + if (!GT_Utility.areStacksEqual(specialItemStack, toReplace)) continue; + if (removal) { + toRemove.add(recipe); + continue nextRecipe; + } + recipe.mSpecialItems = GT_Utility + .copyAmount(specialItemStack.stackSize, replacement); + } + } + map.getBackend() + .removeRecipes(toRemove); + } + } + } + } + } + } + + private static void runMoltenUnificationEnfocement(Werkstoff werkstoff) { + if (werkstoff.getGenerationFeatures().enforceUnification && werkstoff.hasItemType(OrePrefixes.cellMolten)) { + try { + FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(molten.get(werkstoff)), 144), + werkstoff.get(OrePrefixes.cellMolten), + Materials.Empty.getCells(1)); + Field f = GT_Utility.class.getDeclaredField("sFilledContainerToData"); + f.setAccessible(true); + @SuppressWarnings("unchecked") + Map sFilledContainerToData = (Map) f + .get(null); + Set> toremFilledContainerToData = new HashSet<>(); + ItemStack toReplace = null; + for (Map.Entry entry : sFilledContainerToData + .entrySet()) { + final String MODID = GameRegistry.findUniqueIdentifierFor(data.filledContainer.getItem()).modId; + if (MainMod.MOD_ID.equals(MODID) || BartWorksCrossmod.MOD_ID.equals(MODID)) continue; + if (entry.getValue().fluid.equals(data.fluid) + && !entry.getValue().filledContainer.equals(data.filledContainer)) { + toReplace = entry.getValue().filledContainer; + toremFilledContainerToData.add(entry); + } + } + sFilledContainerToData.entrySet() + .removeAll(toremFilledContainerToData); + Set toremRecipeList = new HashSet<>(); + if (toReplace != null) { + for (RecipeMap map : RecipeMap.ALL_RECIPE_MAPS.values()) { + toremRecipeList.clear(); + for (GT_Recipe recipe : map.getAllRecipes()) { + for (ItemStack mInput : recipe.mInputs) { + if (GT_Utility.areStacksEqual(mInput, toReplace)) { + toremRecipeList.add(recipe); + // recipe.mInputs[i] = data.filledContainer; + } + } + for (ItemStack mOutput : recipe.mOutputs) { + if (GT_Utility.areStacksEqual(mOutput, toReplace)) { + toremRecipeList.add(recipe); + // recipe.mOutputs[i] = data.filledContainer; + if (map == RecipeMaps.fluidCannerRecipes + && GT_Utility.areStacksEqual(mOutput, data.filledContainer) + && !recipe.mFluidInputs[0].equals(data.fluid)) { + toremRecipeList.add(recipe); + // recipe.mOutputs[i] = data.filledContainer; + } + } + } + if (recipe.mSpecialItems instanceof ItemStack + && GT_Utility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) { + toremRecipeList.add(recipe); + // recipe.mSpecialItems = data.filledContainer; + } + } + map.getBackend() + .removeRecipes(toremRecipeList); + } + } + GT_Utility.addFluidContainerData(data); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + } + } + + private static void runUnficationDeleter(Werkstoff werkstoff) { + if (werkstoff.getType() == Werkstoff.Types.ELEMENT && werkstoff.getBridgeMaterial() != null + && Element.get(werkstoff.getToolTip()) != Element._NULL) { + werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); + Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); + Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); + } + + for (OrePrefixes prefixes : OrePrefixes.values()) if (werkstoff.hasItemType(prefixes)) { + GT_OreDictUnificator.set(prefixes, werkstoff.getBridgeMaterial(), werkstoff.get(prefixes), true, true); + for (ItemStack stack : OreDictionary.getOres(prefixes + werkstoff.getVarName())) { + GT_OreDictUnificator.addAssociation(prefixes, werkstoff.getBridgeMaterial(), stack, false); + GT_OreDictUnificator.getAssociation(stack).mUnificationTarget = werkstoff.get(prefixes); + } + } + } + + private static void runMaterialLinker(Werkstoff werkstoff) { + if (werkstoff.getType() == Werkstoff.Types.ELEMENT && werkstoff.getBridgeMaterial() != null + && Element.get(werkstoff.getToolTip()) != Element._NULL) { + werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); + Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); + Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); + } + + for (OrePrefixes prefixes : OrePrefixes.values()) + if (werkstoff.hasItemType(prefixes) && werkstoff.getBridgeMaterial() != null) { + GT_OreDictUnificator.set(prefixes, werkstoff.getBridgeMaterial(), werkstoff.get(prefixes), true, true); + for (ItemStack stack : OreDictionary.getOres(prefixes + werkstoff.getVarName())) { + GT_OreDictUnificator.addAssociation(prefixes, werkstoff.getBridgeMaterial(), stack, false); + } + } + } + + /** + * Constructs a list of recipes to change by scanning all EBF recipes for uses of noble gases. + * + * @param GasTags list of gas tags to look out for in EBF recipes + * @return A multimap from the gas tag (noble and/or anaerobic) to all the recipes containing a gas with that tag + */ + private static ArrayListMultimap getRecipesToChange(SubTag... GasTags) { + ArrayListMultimap toAdd = ArrayListMultimap.create(); + for (GT_Recipe recipe : RecipeMaps.blastFurnaceRecipes.getAllRecipes()) { + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) { + Materials mat = getMaterialFromInputFluid(recipe); + if (mat != Materials._NULL) { + for (SubTag tag : GasTags) { + if (mat.contains(tag)) { + DebugLog.log( + "Found EBF Recipe to change, Output:" + + BW_Util.translateGTItemStack(recipe.mOutputs[0])); + toAdd.put(tag, recipe); + } + } + } + } + } + return toAdd; + } + + /** + * Scans EBF recipes for no-gas variants of the recipes present in base. Adds these recipes to the base multimap. + * + * @param base The recipe multimap to scan and modify + * @return Set of item outputs (recipe.mOutputs[0]) of the no-gas recipes + */ + private static HashSet getNoGasItems(ArrayListMultimap base) { + HashSet toAdd = new HashSet<>(); + ArrayListMultimap repToAdd = ArrayListMultimap.create(); + for (GT_Recipe recipe : RecipeMaps.blastFurnaceRecipes.getAllRecipes()) { + for (SubTag tag : base.keySet()) recipeLoop: for (GT_Recipe baseRe : base.get(tag)) { + if (recipe.mInputs.length == baseRe.mInputs.length && recipe.mOutputs.length == baseRe.mOutputs.length) + for (int i = 0; i < recipe.mInputs.length; i++) { + ItemStack tmpInput = recipe.mInputs[i]; + if ((recipe.mFluidInputs == null || recipe.mFluidInputs.length == 0) + && (whitelistForEBFNoGasRecipeDontCheckItemData.stream() + .anyMatch(s -> GT_Utility.areStacksEqual(s, tmpInput)) + || BW_Util.checkStackAndPrefix(recipe.mInputs[i]) + && BW_Util.checkStackAndPrefix(baseRe.mInputs[i]) + && GT_OreDictUnificator.getAssociation(recipe.mInputs[i]).mMaterial.mMaterial + .equals( + GT_OreDictUnificator.getAssociation(baseRe.mInputs[i]).mMaterial.mMaterial) + && GT_Utility.areStacksEqual(recipe.mOutputs[0], baseRe.mOutputs[0]))) { + toAdd.add(recipe.mOutputs[0]); + repToAdd.put(tag, recipe); + continue recipeLoop; + } + } + } + } + base.putAll(repToAdd); + return toAdd; + } + + private static int transformEBFGasRecipeTime(int originalDuration, long originalGasProtons, long newGasProtons) { + double protonTerm = originalGasProtons * (newGasProtons >= originalGasProtons ? 1.0D : 2.75D) - newGasProtons; + return Math.max(1, (int) (originalDuration / 200D * Math.max(200D + protonTerm, 1D))); + } + + private static int transformEBFGasRecipeTime(GT_Recipe recipe, Materials originalGas, Materials newGas) { + double newEbfMul = gtEbfGasRecipeTimeMultipliers.get(newGas); + double originalEbfMul = gtEbfGasRecipeTimeMultipliers.get(originalGas); + if (newEbfMul < 0.0D || originalEbfMul < 0.0D) { + return transformEBFGasRecipeTime(recipe.mDuration, originalGas.getProtons(), newGas.getProtons()); + } + return Math.max(1, (int) (recipe.mDuration * newEbfMul / originalEbfMul)); + } + + private static int transformEBFGasRecipeTime(GT_Recipe recipe, Materials originalGas, Werkstoff newGas) { + double newEbfMul = newGas.getStats() + .getEbfGasRecipeTimeMultiplier(); + double originalEbfMul = gtEbfGasRecipeTimeMultipliers.get(originalGas); + if (newEbfMul < 0.0D || originalEbfMul < 0.0D) { + return transformEBFGasRecipeTime( + recipe.mDuration, + originalGas.getProtons(), + newGas.getStats() + .getProtons()); + } + return Math.max(1, (int) (recipe.mDuration * newEbfMul / originalEbfMul)); + } + + private static int transformEBFNoGasRecipeTime(GT_Recipe recipe, Materials originalGas) { + return transformEBFGasRecipeTime(recipe.mDuration, originalGas.getProtons(), 0); + } + + private static void editEBFMaterialRecipes(SubTag GasTag, GT_Recipe recipe, Materials originalGas, + HashSet toAdd) { + for (Materials newGas : Materials.values()) { + if (newGas.contains(GasTag)) { + int time = transformEBFGasRecipeTime(recipe, originalGas, newGas); + int gasAmount = Math.max( + 1, + (int) Math.round(recipe.mFluidInputs[0].amount * gtEbfGasRecipeConsumptionMultipliers.get(newGas))); + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length == 1 + && recipe.mFluidInputs[0].isFluidEqual(newGas.getGas(0))) { + // preserve original recipe owner + toAdd.add( + new DynamicGTRecipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { newGas.getGas(gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue, + recipe)); + } else { + // new recipe + toAdd.add( + new GT_Recipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { newGas.getGas(gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue)); + } + } + } + } + + private static void editEBFWerkstoffRecipes(SubTag GasTag, GT_Recipe recipe, Materials originalGas, + HashSet toAdd) { + for (Werkstoff newGas : Werkstoff.werkstoffHashMap.values()) { + if (newGas.contains(GasTag)) { + int time = transformEBFGasRecipeTime(recipe, originalGas, newGas); + int gasAmount = Math.max( + 1, + (int) Math.round( + recipe.mFluidInputs[0].amount * newGas.getStats() + .getEbfGasRecipeConsumedAmountMultiplier())); + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length == 1 + && recipe.mFluidInputs[0] + .isFluidEqual(new FluidStack(Objects.requireNonNull(fluids.get(newGas)), 0))) { + // preserve original recipe owner + toAdd.add( + new DynamicGTRecipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { new FluidStack(Objects.requireNonNull(fluids.get(newGas)), gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue, + recipe)); + } else { + // new recipe + toAdd.add( + new GT_Recipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { new FluidStack(Objects.requireNonNull(fluids.get(newGas)), gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue)); + } + } + } + } + + private static void editEBFNoGasRecipes(GT_Recipe recipe, Materials originalGas, HashSet toAdd, + HashSet noGas) { + for (ItemStack is : noGas) { + byte circuitConfiguration = 1; + if (GT_Utility.areStacksEqual(is, recipe.mOutputs[0])) { + ArrayList inputs = new ArrayList<>(recipe.mInputs.length); + for (ItemStack stack : recipe.mInputs) + if (!GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(11), stack) + && !GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(14), stack) + && !GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(19), stack)) { + if (BW_Util.checkStackAndPrefix(stack)) circuitConfiguration = (byte) (OrePrefixes.dustSmall + .equals(GT_OreDictUnificator.getAssociation(stack).mPrefix) + ? 4 + : OrePrefixes.dustTiny.equals(GT_OreDictUnificator.getAssociation(stack).mPrefix) + ? 9 + : 1); + inputs.add(stack); + } + inputs.add(GT_Utility.getIntegratedCircuit(circuitConfiguration)); + toAdd.add( + new DynamicGTRecipe( + false, + inputs.toArray(new ItemStack[0]), + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + null, + recipe.mFluidOutputs, + transformEBFNoGasRecipeTime(recipe, originalGas), + recipe.mEUt, + recipe.mSpecialValue, + recipe)); + break; + } + } + } + + private static void removeDuplicateGasRecipes(HashSet toAdd) { + HashSet duplicates = new HashSet<>(); + for (GT_Recipe recipe : toAdd) { + for (GT_Recipe recipe2 : toAdd) { + if (recipe.mEUt != recipe2.mEUt || recipe.mDuration != recipe2.mDuration + || recipe.mSpecialValue != recipe2.mSpecialValue + || recipe == recipe2 + || recipe.mInputs.length != recipe2.mInputs.length + || recipe.mFluidInputs.length != recipe2.mFluidInputs.length) continue; + boolean isSame = true; + for (int i = 0; i < recipe.mInputs.length; i++) { + if (!GT_Utility.areStacksEqual(recipe.mInputs[i], recipe2.mInputs[i])) isSame = false; + } + for (int i = 0; i < recipe.mFluidInputs.length; i++) { + if (!GT_Utility.areFluidsEqual(recipe.mFluidInputs[i], recipe2.mFluidInputs[i])) isSame = false; + } + if (isSame) duplicates.add(recipe2); + } + } + toAdd.removeAll(duplicates); + } + + private static Materials getMaterialFromInputFluid(GT_Recipe recipe) { + String materialString = recipe.mFluidInputs[0].getFluid() + .getName(); + materialString = StringUtils.removeStart(materialString, "molten"); + materialString = StringUtils.removeStart(materialString, "fluid"); + materialString = StringUtils.capitalize(materialString); + return Materials.get(materialString); + } + + private static void editRecipes(ArrayListMultimap base, HashSet noGas) { + HashSet toAdd = new HashSet<>(); + + for (SubTag gasTag : base.keySet()) { + for (GT_Recipe recipe : base.get(gasTag)) { + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) { + Materials originalGas = getMaterialFromInputFluid(recipe); + if (originalGas != Materials._NULL) { + editEBFWerkstoffRecipes(gasTag, recipe, originalGas, toAdd); + editEBFMaterialRecipes(gasTag, recipe, originalGas, toAdd); + editEBFNoGasRecipes(recipe, originalGas, toAdd, noGas); + } + } + } + RecipeMaps.blastFurnaceRecipes.getBackend() + .removeRecipes(base.get(gasTag)); + } + + removeDuplicateGasRecipes(toAdd); + toAdd.forEach(RecipeMaps.blastFurnaceRecipes::add); + } + + public static void addElectricImplosionCompressorRecipes() { + RecipeMaps.implosionRecipes.getAllRecipes() + .stream() + .filter(e -> e.mInputs != null) + .forEach( + recipe -> BartWorksRecipeMaps.electricImplosionCompressorRecipes.addRecipe( + true, + Arrays.stream(recipe.mInputs) + .filter(e -> !StaticRecipeChangeLoaders.checkForExplosives(e)) + .distinct() + .toArray(ItemStack[]::new), + recipe.mOutputs, + null, + null, + null, + 1, + (int) TierEU.RECIPE_UEV, + 0)); + + // Custom EIC recipes. + new ElectricImplosionCompressorRecipes().run(); + } + + private static boolean checkForExplosives(ItemStack input) { + return GT_Utility.areStacksEqual(input, new ItemStack(Blocks.tnt)) + || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L)) + || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("dynamite", 1L)) + || GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L)); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java new file mode 100644 index 0000000000..8f152c00c7 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java @@ -0,0 +1,294 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.HOURS; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public class Assembler implements Runnable { + + @Override + public void run() { + Materials[] cables = { // Cable material used in the acid gen, diode and energy distributor below + Materials.Lead, // ULV + Materials.Tin, // LV + Materials.AnnealedCopper, // MV + Materials.Gold, // HV + Materials.Aluminium, // EV + Materials.Tungsten, // IV + Materials.VanadiumGallium, // LuV + Materials.Naquadah, // ZPM + Materials.NaquadahAlloy, // UV + Materials.SuperconductorUV // UHV + }; + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), + Materials.Lapis.getPlates(9), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2L), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1)) + .fluidInputs(FluidRegistry.getFluidStack("ic2coolant", 1000)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), + Materials.Lapis.getBlocks(8), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[1])) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(GregTech.ID, "gt.blockmachines", 64, 1000), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[0]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(GregTech.ID, "gt.blockmachines", 64, 1002), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[1]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(GregTech.ID, "gt.blockmachines", 64, 1126), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[2]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(GregTech.ID, "gt.blockmachines", 64, 1169), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[3]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(GregTech.ID, "gt.blockmachines", 64, 1160), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[4]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.AnnealedCopper, 64L), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[2], 1, 1)) + .fluidInputs(Materials.Plastic.getMolten(1152L)) + .duration(1 * TICKS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 1L), + Materials.Aluminium.getPlates(1), + ItemList.Circuit_Board_Plastic.get(1L), + ItemList.Battery_RE_LV_Lithium.get(1L)) + .itemOutputs(new ItemStack(ItemRegistry.CIRCUIT_PROGRAMMER)) + .fluidInputs(Materials.SolderingAlloy.getMolten(288L)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemList.Circuit_Parts_GlassFiber.get(32), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Electrum, 8), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.gemExquisite, 2)) + .itemOutputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + 1, + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage())) + .fluidInputs(Materials.Polytetrafluoroethylene.getMolten(72)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + + ItemStack[][] converters = ItemRegistry.TecTechLaserAdditions[0]; + ItemStack[][] input = ItemRegistry.TecTechLaserAdditions[1]; + ItemStack[][] dynamo = ItemRegistry.TecTechLaserAdditions[2]; + + ItemList[] emitters = { ItemList.Emitter_EV, ItemList.Emitter_IV, ItemList.Emitter_LuV, ItemList.Emitter_ZPM }; + + ItemList[] sensors = { ItemList.Sensor_EV, ItemList.Sensor_IV, ItemList.Sensor_LuV, ItemList.Sensor_ZPM }; + + OrePrefixes[] prefixes = { OrePrefixes.cableGt04, OrePrefixes.cableGt08, OrePrefixes.cableGt12, + OrePrefixes.cableGt16 }; + + for (int j = 0; j < 4; j++) { + for (int i = 0; i < 4; i++) { + ItemStack converter = converters[j][i]; + ItemStack eInput = input[j][i]; + ItemStack eDynamo = dynamo[j][i]; + long recipeConsumption; + switch (i) { + case 0: + recipeConsumption = TierEU.RECIPE_EV; + break; + case 1: + recipeConsumption = TierEU.RECIPE_IV; + break; + case 2: + recipeConsumption = TierEU.RECIPE_LuV; + break; + case 3: + recipeConsumption = TierEU.RECIPE_ZPM; + break; + default: + recipeConsumption = TierEU.RECIPE_EV; + break; + } + + int solderingAmount = Math.max(144 * i, 72) * (j + 1); + + GT_Values.RA.stdBuilder() + .itemInputs( + + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + ((j + 1) * 16), + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GT_OreDictUnificator.get(prefixes[j], cables[i + 4], 8), + emitters[i].get(2 * (j + 1)), + sensors[i].get(2 * (j + 1)), + ItemList.TRANSFORMERS[4 + i].get(2 * (j + 1))) + .itemOutputs(converter) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1)) * SECONDS) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + ((j + 1) * 16), + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GT_OreDictUnificator.get(prefixes[j], cables[i + 4], 8), + emitters[i].get(2 * (j + 1)), + sensors[i].get(2 * (j + 1)), + ItemList.TRANSFORMERS[4 + i].get(2 * (j + 1))) + .itemOutputs(converter) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1)) * SECONDS) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + (j + 1) * 16, + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GT_OreDictUnificator.get(prefixes[j], cables[i + 4], 8), + sensors[i].get(2 * (j + 1)), + ItemList.HATCHES_ENERGY[4 + i].get(2 * (j + 1))) + .itemOutputs(eInput) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1)) * SECONDS) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + (j + 1) * 16, + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GT_OreDictUnificator.get(prefixes[j], cables[i + 4], 8), + emitters[i].get(2 * (j + 1)), + ItemList.HATCHES_DYNAMO[4 + i].get(2 * (j + 1))) + .itemOutputs(eDynamo) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1) * SECONDS)) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + } + } + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemList.Hatch_Input_HV.get(64), + Materials.LiquidAir.getCells(1), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.compressedHatch.copy()) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Hatch_Output_HV.get(64), GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.giantOutputHatch.copy()) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Lead, 6), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.TungstenSteel, 1)) + .itemOutputs(new ItemStack(GregTech_API.sBlockCasings3, 1, 12)) + .fluidInputs(Materials.Concrete.getMolten(1296)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GregTech_API.sBlockCasings3, 1, 12), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Europium, 6), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Europium, 24)) + .itemOutputs(new ItemStack(GregTech_API.sBlockCasings8, 1, 5)) + .fluidInputs(Materials.Lead.getMolten(864)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(assemblerRecipes); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/AssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/AssemblyLine.java new file mode 100644 index 0000000000..538195362a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/AssemblyLine.java @@ -0,0 +1,85 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.enums.Mods.GalactiGreg; +import static gregtech.api.util.GT_RecipeBuilder.HOURS; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeConstants.AssemblyLine; +import static gregtech.api.util.GT_RecipeConstants.RESEARCH_ITEM; +import static gregtech.api.util.GT_RecipeConstants.RESEARCH_TIME; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; + +public class AssemblyLine implements Runnable { + + @Override + public void run() { + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, ItemList.Pump_IV.get(1L)) + .metadata(RESEARCH_TIME, 1 * HOURS) + .itemInputs( + ItemList.Pump_IV.get(16), + GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Ultimate, 32L), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.HSSE, 16L), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.HSSE, 16L), + ItemList.Field_Generator_LuV.get(8)) + .fluidInputs( + new FluidStack(solderIndalloy, 32 * 144), + Materials.Polytetrafluoroethylene.getMolten(32 * 144)) + .itemOutputs(ItemRegistry.dehp) + .eut(TierEU.RECIPE_LuV) + .duration(4 * MINUTES + 10 * SECONDS) + .addTo(AssemblyLine); + + if (GalactiGreg.isModLoaded()) { + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, ItemList.OreDrill4.get(1L)) + .metadata(RESEARCH_TIME, 25 * MINUTES + 36 * SECONDS) + .itemInputs( + ItemList.OreDrill4.get(1L), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Tritanium, 9L), + Materials.Europium.getPlates(3), + ItemList.Electric_Motor_LuV.get(9L), + ItemList.Sensor_LuV.get(9L), + ItemList.Field_Generator_LuV.get(9L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Europium, 36L)) + .fluidInputs(new FluidStack(solderIndalloy, 1440), WerkstoffLoader.Neon.getFluidOrGas(20000)) + .itemOutputs(ItemRegistry.voidminer[0].copy()) + .eut(TierEU.RECIPE_LuV) + .duration(5 * MINUTES) + .addTo(AssemblyLine); + } + + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, ItemList.Machine_LuV_CircuitAssembler.get(1L)) + .metadata(RESEARCH_TIME, 20 * MINUTES) + .itemInputs( + ItemList.Machine_LuV_CircuitAssembler.get(1L), + ItemList.Robot_Arm_LuV.get(4L), + ItemList.Electric_Motor_LuV.get(4L), + ItemList.Field_Generator_LuV.get(1L), + ItemList.Emitter_LuV.get(1L), + ItemList.Sensor_LuV.get(1L), + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.plate, 8)) + .fluidInputs(new FluidStack(solderIndalloy, 1440)) + .itemOutputs(ItemRegistry.cal.copy()) + .eut(TierEU.RECIPE_LuV) + .duration(20 * MINUTES) + .addTo(AssemblyLine); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Autoclave.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Autoclave.java new file mode 100644 index 0000000000..1793877df3 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Autoclave.java @@ -0,0 +1,41 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.autoclaveRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; + +public class Autoclave implements Runnable { + + @Override + public void run() { + Materials[] sterilizers = { Materials.Ammonia, Materials.Chlorine, Materials.Ethanol, Materials.Methanol }; + for (Materials used : sterilizers) { + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Circuit_Parts_PetriDish.get(1L)) + .itemOutputs(BioItemList.getPetriDish(null)) + .fluidInputs(used.getGas(10L) != null ? used.getGas(8L) : used.getFluid(16L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(autoclaveRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(Items.glass_bottle)) + .itemOutputs(BioItemList.getDNASampleFlask(null)) + .fluidInputs(used.getGas(10L) != null ? used.getGas(8L) : used.getFluid(16L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(autoclaveRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Centrifuge.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Centrifuge.java new file mode 100644 index 0000000000..e148376b01 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Centrifuge.java @@ -0,0 +1,144 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR.HTGRMaterials.MATERIALS_PER_FUEL; +import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR.HTGRMaterials.sHTGR_Fuel; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.util.Arrays; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_THTR; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_RecipeBuilder; +import gregtech.api.util.GT_Utility; + +public class Centrifuge implements Runnable { + + @Override + public void run() { + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Thorium.getDust(1)) + .itemOutputs( + Materials.Thorium.getDust(1), + Materials.Thorium.getDust(1), + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1), + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1), + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1)) + .outputChances(800, 375, 22, 22, 5) + .duration(8 * MINUTES + 20 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + ItemStack[] pellets = new ItemStack[6]; + Arrays.fill(pellets, new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 64, 4)); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 3), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(pellets) + .duration(40 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 5), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 64, 6)) + .duration(40 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 6)) + .itemOutputs(Materials.Lead.getDust(1)) + .outputChances(300) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + int i = 0; + for (GT_TileEntity_HTGR.HTGRMaterials.Fuel_ fuel : sHTGR_Fuel) { + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 3), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs( + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 64, i + 4), + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 64, i + 4), + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 64, i + 4), + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 64, i + 4)) + .duration(10 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 5), + GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 64, i + 6)) + .duration(2 * MINUTES + 30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GT_RecipeBuilder recipeBuilder = GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 6)) + .itemOutputs( + fuel.recycledItems[0], + fuel.recycledItems[1], + fuel.recycledItems[2], + fuel.recycledItems[3], + fuel.recycledItems[4]) + .outputChances(fuel.recycleChances); + if (fuel.recycledFluid != null) { + recipeBuilder.fluidOutputs(fuel.recycledFluid); + } + recipeBuilder.duration(1 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + i += MATERIALS_PER_FUEL; + } + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(BioItemList.getOther(4)) + .fluidInputs(new FluidStack(BioCultureLoader.eColi.getFluid(), 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[1], 10)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(17)) + .fluidInputs(new FluidStack(FluidLoader.BioLabFluidMaterials[1], 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[3], 250)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(17)) + .fluidInputs(new FluidStack(BioCultureLoader.CommonYeast.getFluid(), 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[2], 10)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(centrifugeRecipes); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalBath.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalBath.java new file mode 100644 index 0000000000..f1d9ddd236 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalBath.java @@ -0,0 +1,84 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.chemicalBathRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; + +public class ChemicalBath implements Runnable { + + @Override + public void run() { + + for (int i = 0; i < Dyes.dyeBrown.getSizeOfFluidList(); ++i) { + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 6)) + .fluidInputs(Dyes.dyeRed.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 7)) + .fluidInputs(Dyes.dyeGreen.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 8)) + .fluidInputs(Dyes.dyePurple.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 9)) + .fluidInputs(Dyes.dyeYellow.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 10)) + .fluidInputs(Dyes.dyeLime.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 11)) + .fluidInputs(Dyes.dyeBrown.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + } + + for (int i = 6; i < 11; i++) { + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, i)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .fluidInputs(Materials.Chlorine.getGas(50)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalReactor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalReactor.java new file mode 100644 index 0000000000..87aaf91f71 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/ChemicalReactor.java @@ -0,0 +1,29 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; + +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_Utility; + +public class ChemicalReactor implements Runnable { + + @Override + public void run() { + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(10)) + .fluidInputs(new FluidStack(FluidLoader.heatedfulvicAcid, 1000)) + .fluidOutputs(new FluidStack(FluidLoader.Kerogen, 1000)) + .duration(3 * SECONDS + 15 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(UniversalChemical); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java new file mode 100644 index 0000000000..17a5d5b025 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java @@ -0,0 +1,462 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.enums.Mods.IndustrialCraft2; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.common.loaders.RecipeLoader; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_BioVat; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_LESU; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ManualTrafo; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_Windmill; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_BioLab; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import ic2.core.Ic2Items; + +public class CraftingRecipes implements Runnable { + + @Override + public void run() { + + Materials[] cables = { // Cable material used in the acid gen, diode and energy distributor below + Materials.Lead, // ULV + Materials.Tin, // LV + Materials.AnnealedCopper, // MV + Materials.Gold, // HV + Materials.Aluminium, // EV + Materials.Tungsten, // IV + Materials.VanadiumGallium, // LuV + Materials.Naquadah, // ZPM + Materials.NaquadahAlloy, // UV + Materials.SuperconductorUV // UHV + }; + + ISubTagContainer[] hulls = { // Plate material used in the acid gen, diode and energy distributor below + Materials.WroughtIron, // ULV + Materials.Steel, // LV + Materials.Aluminium, // MV + Materials.StainlessSteel, // HV + Materials.Titanium, // EV + Materials.TungstenSteel, // IV + WerkstoffLoader.LuVTierMaterial, // LuV + Materials.Iridium, // ZPM + Materials.Osmium, // UV + Materials.Naquadah // UHV + }; + + ItemStack[] bats = { ItemList.Battery_Hull_LV.get(1L), ItemList.Battery_Hull_MV.get(1L), + ItemList.Battery_Hull_HV.get(1L) }; + ItemStack[] chreac = { ItemList.Machine_MV_ChemicalReactor.get(1L), ItemList.Machine_HV_ChemicalReactor.get(1L), + ItemList.Machine_EV_ChemicalReactor.get(1L) }; + + GT_ModHandler.addCraftingRecipe( + new GT_TileEntity_LESU(ConfigHandler.IDOffset, "LESU", "L.E.S.U.").getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "CDC", "SBS", "CFC", 'C', "circuitAdvanced", 'D', ItemList.Cover_Screen.get(1L), 'S', + GT_OreDictUnificator.get(OrePrefixes.cableGt12, Materials.Platinum, 1L), 'B', + new ItemStack(ItemRegistry.BW_BLOCKS[1]), 'F', ItemList.Field_Generator_HV.get(1L) }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.DESTRUCTOPACK), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "CPC", "PLP", "CPC", 'C', "circuitAdvanced", 'P', + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Aluminium, 1L), 'L', + new ItemStack(Items.lava_bucket) }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.DESTRUCTOPACK), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "CPC", "PLP", "CPC", 'C', "circuitAdvanced", 'P', + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Steel, 1L), 'L', + new ItemStack(Items.lava_bucket) }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROCKCUTTER_MV), + RecipeLoader.BITSD, + new Object[] { "DS ", "DP ", "DCB", 'D', GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Diamond, 1L), + 'S', GT_OreDictUnificator.get(OrePrefixes.stick, Materials.TungstenSteel, 1L), 'P', + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 1L), 'C', "circuitGood", 'B', + ItemList.IC2_AdvBattery.get(1L) }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROCKCUTTER_LV), + RecipeLoader.BITSD, + new Object[] { "DS ", "DP ", "DCB", 'D', GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Diamond, 1L), + 'S', GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Titanium, 1L), 'P', + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), 'C', "circuitBasic", 'B', + ItemList.IC2_ReBattery.get(1L) }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROCKCUTTER_HV), + RecipeLoader.BITSD, + new Object[] { "DS ", "DP ", "DCB", 'D', GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Diamond, 1L), + 'S', GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Iridium, 1L), 'P', + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 1L), 'C', "circuitAdvanced", 'B', + ItemList.IC2_EnergyCrystal.get(1L) }); + + if (ConfigHandler.teslastaff) { + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.TESLASTAFF), + RecipeLoader.BITSD, + new Object[] { "BO ", "OP ", " P", 'O', + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUHV, 1L), 'B', + ItemList.Energy_LapotronicOrb.get(1L), 'P', "plateAlloyIridium", }); + } + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PUMPPARTS, 1, 0), // tube + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { " fG", " G ", "G ", 'G', ItemList.Circuit_Parts_Glass_Tube.get(1L) }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PUMPPARTS, 1, 1), // motor + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "GLP", "LSd", "PfT", 'G', + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Steel, 1L), 'L', + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Steel, 1L), 'S', + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 1L), 'P', new ItemStack(Blocks.piston), + 'T', new ItemStack(ItemRegistry.PUMPPARTS, 1, 0) }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PUMPBLOCK, 1, 0), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "IPI", "PMP", "ISI", 'I', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iron, 1L), + 'P', GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Wood, 1L), 'M', + new ItemStack(ItemRegistry.PUMPPARTS, 1, 1), 'S', Ic2Items.ironFurnace }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.WINDMETER), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "SWF", "Sf ", "Ss ", 'S', "stickWood", 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE), + 'F', new ItemStack(Items.string), }); + + for (int i = 0; i < 3; i++) { + Materials cable = cables[i + 2]; + ItemStack machinehull = ItemList.MACHINE_HULLS[i + 2].get(1L); + GT_ModHandler.addCraftingRecipe( + ItemRegistry.acidGens[i], + RecipeLoader.BITSD, + new Object[] { "HRH", "HCH", "HKH", 'H', bats[i], 'K', + GT_OreDictUnificator.get(OrePrefixes.cableGt01, cable, 1L), 'C', machinehull, 'R', chreac[i] }); + } + + GT_ModHandler.addCraftingRecipe( + ItemRegistry.acidGensLV, + RecipeLoader.BITSD, + new Object[] { "HRH", "KCK", "HKH", 'H', ItemList.Battery_Hull_LV.get(1L), 'K', + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Tin, 1L), 'C', ItemList.Hull_LV.get(1L), 'R', + ItemList.Machine_LV_ChemicalReactor.get(1L), }); + + for (int i = 0; i < 9; i++) { + try { + Materials cable = cables[i]; + ItemStack hull = hulls[i] instanceof Materials + ? GT_OreDictUnificator.get(OrePrefixes.plate, hulls[i], 1L) + : ((Werkstoff) hulls[i]).get(OrePrefixes.plate); + ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); + + GT_ModHandler.addCraftingRecipe( + ItemRegistry.energyDistributor[i], + RecipeLoader.BITSD, + new Object[] { "PWP", "WCW", "PWP", 'W', GT_OreDictUnificator.get(OrePrefixes.wireGt16, cable, 1L), + 'P', hull, 'C', machinehull }); + GT_ModHandler.addCraftingRecipe( + ItemRegistry.diode12A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GT_OreDictUnificator.get(OrePrefixes.cableGt12, cable, 1L), 'P', hull, 'C', machinehull }); + GT_ModHandler.addCraftingRecipe( + ItemRegistry.diode8A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GT_OreDictUnificator.get(OrePrefixes.cableGt08, cable, 1L), 'P', hull, 'C', machinehull }); + GT_ModHandler.addCraftingRecipe( + ItemRegistry.diode4A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GT_OreDictUnificator.get(OrePrefixes.cableGt04, cable, 1L), 'P', hull, 'C', machinehull }); + GT_ModHandler.addCraftingRecipe( + ItemRegistry.diode2A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GT_OreDictUnificator.get(OrePrefixes.cableGt02, cable, 1L), 'P', hull, 'C', machinehull }); + GT_ModHandler.addCraftingRecipe( + ItemRegistry.diode16A[i], + RecipeLoader.BITSD, + new Object[] { "WHW", "DCD", "PDP", 'H', OrePrefixes.componentCircuit.get(Materials.Inductor), 'D', + OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GT_OreDictUnificator.get(OrePrefixes.wireGt16, cable, 1L), 'P', hull, 'C', machinehull }); + + } catch (ArrayIndexOutOfBoundsException ignored) { + + } + + } + + String[] stones = { "stone", "stoneSmooth" }; + String[] granites = { "blockGranite", "stoneGranite", "Granite", "granite" }; + for (String granite : granites) { + for (String stone : stones) { + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "SSS", "DfD", " h ", 'S', stone, 'D', + new ItemStack(GregTech_API.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hDf", "SSS", 'S', stone, 'D', + new ItemStack(GregTech_API.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "SSS", "DfD", " h ", 'S', stone, 'D', granite, }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hDf", "SSS", 'S', stone, 'D', granite, }); + } + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 2), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "STS", "h f", "SBS", 'S', granite, 'T', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), + 'B', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), }); + } + + GT_ModHandler.addCraftingRecipe( + new GT_TileEntity_ManualTrafo( + ConfigHandler.IDOffset + GT_Values.VN.length * 6 + 1, + "bw.manualtrafo", + StatCollector.translateToLocal("tile.manutrafo.name")).getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "SCS", "CHC", "ZCZ", 'S', + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Titanium, 1L), 'C', + new ItemStack(ItemRegistry.BW_BLOCKS[2]), 'H', ItemList.Hull_HV.get(1L), 'Z', "circuitAdvanced" }); + + GT_ModHandler.addCraftingRecipe( + new GT_TileEntity_Windmill( + ConfigHandler.IDOffset + GT_Values.VN.length * 6 + 2, + "bw.windmill", + StatCollector.translateToLocal("tile.bw.windmill.name")).getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "BHB", "WGW", "BWB", 'B', new ItemStack(Blocks.brick_block), 'W', + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), 'H', new ItemStack(Blocks.hopper), + 'G', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 2), }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 2), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "STS", "h f", "SBS", 'S', + new ItemStack(GregTech_API.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), 'T', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), 'B', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WLs", "WLh", "WLf", 'L', new ItemStack(Items.leather), 'W', "logWood", }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WLs", "WLh", "WLf", 'L', new ItemStack(Blocks.carpet), 'W', "logWood", }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WLs", "WLh", "WLf", 'L', new ItemStack(Items.paper), 'W', "logWood", }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'Z', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'E', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'Z', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'D', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'D', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.LEATHER_ROTOR), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'W', + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.WOOL_ROTOR), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'W', + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PAPER_ROTOR), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), 'W', + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.COMBINED_ROTOR), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), 'W', + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROTORBLOCK), + RecipeLoader.BITSD, + new Object[] { "WRW", "RGR", "WRW", 'R', GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Iron, 1L), + 'W', "plankWood", 'G', GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + + GT_ModHandler.addCraftingRecipe( + ItemRegistry.THTR, + RecipeLoader.BITSD, + new Object[] { "BZB", "BRB", "BZB", 'B', new ItemStack(GregTech_API.sBlockCasings3, 1, 12), 'R', + GT_ModHandler.getModItem(IndustrialCraft2.ID, "blockGenerator", 1, 5), 'Z', "circuitUltimate" }); + + GT_ModHandler.addCraftingRecipe( + ItemRegistry.HTGR, + RecipeLoader.BITSD, + new Object[] { "BZB", "BRB", "BZB", 'B', new ItemStack(GregTech_API.sBlockCasings8, 1, 5), 'R', + GT_ModHandler.getModItem(IndustrialCraft2.ID, "blockGenerator", 1, 5), 'Z', "circuitSuperconductor" }); + + // DNAExtractionModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[0], + RecipeLoader.BITSD, + new Object[] { "TET", "CFC", "TST", 'T', + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), 'E', ItemList.Emitter_EV.get(1L), + 'C', GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Aluminium, 1L), 'S', + ItemList.Sensor_EV.get(1L), 'F', ItemList.Field_Generator_EV.get(1L) }); + + // PCRThermoclyclingModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[1], + RecipeLoader.BITSD, + new Object[] { "NEN", "CFC", "NSN", 'N', + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Nichrome, 1L), 'E', + ItemList.Emitter_EV.get(1L), 'C', + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Aluminium, 1L), 'S', + ItemList.Sensor_EV.get(1L), 'F', ItemList.Field_Generator_EV.get(1L) }); + + // PlasmidSynthesisModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[2], + RecipeLoader.BITSD, + new Object[] { "SFE", "CPC", "NFN", 'N', + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Nichrome, 1L), 'C', "circuit" + Materials.Data, + 'F', ItemList.Field_Generator_EV.get(1L), 'E', ItemList.Emitter_EV.get(1L), 'S', + ItemList.Sensor_EV.get(1L), 'P', + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), }); + // TransformationModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[3], + RecipeLoader.BITSD, + new Object[] { "SFE", "CPC", "NFN", 'N', + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 1L), 'C', + "circuit" + Materials.Master, 'F', ItemList.Field_Generator_LuV.get(1L), 'E', + ItemList.Emitter_LuV.get(1L), 'S', ItemList.Sensor_LuV.get(1L), 'P', + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.plate, 1), }); + + // ClonalCellularSynthesisModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[4], + RecipeLoader.BITSD, + new Object[] { "FEF", "CPC", "FSF", 'N', + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 1L), 'C', + "circuit" + Materials.Master, 'F', ItemList.Field_Generator_LuV.get(1L), 'E', + ItemList.Emitter_LuV.get(1L), 'S', ItemList.Sensor_LuV.get(1L), 'P', + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.plate, 1), }); + + GT_ModHandler.addCraftingRecipe( + new GT_TileEntity_BioVat( + ConfigHandler.IDOffset + GT_Values.VN.length * 7, + "bw.biovat", + StatCollector.translateToLocal("tile.biovat.name")).getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "GCG", "KHK", "GCG", 'G', new ItemStack(ItemRegistry.bw_glasses[0], 1, 1), 'C', + "circuit" + Materials.Data, 'K', GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Silver, 1L), + 'H', ItemList.MACHINE_HULLS[3].get(1L) }); + + ItemStack[] Pistons2 = { ItemList.Electric_Piston_HV.get(1L), ItemList.Electric_Piston_EV.get(1L), + ItemList.Electric_Piston_IV.get(1L), ItemList.Electric_Piston_LuV.get(1L), + ItemList.Electric_Piston_ZPM.get(1L), ItemList.Electric_Piston_UV.get(1L) }; + ItemStack[] BioLab2 = new ItemStack[GT_Values.VN.length - 3]; + ItemStack[] RadioHatch2 = new ItemStack[GT_Values.VN.length - 3]; + Materials[] cables2 = { Materials.Gold, Materials.Aluminium, Materials.Tungsten, Materials.VanadiumGallium, + Materials.Naquadah, Materials.NaquadahAlloy, Materials.SuperconductorUHV }; + Materials[] hulls2 = { Materials.StainlessSteel, Materials.Titanium, Materials.TungstenSteel, Materials.Chrome, + Materials.Iridium, Materials.Osmium, Materials.Naquadah }; + Materials[] wireMat2 = { Materials.Kanthal, Materials.Nichrome, Materials.TungstenSteel, Materials.Naquadah, + Materials.NaquadahAlloy, Materials.SuperconductorUHV }; + Materials[] circuits2 = { Materials.Advanced, Materials.Data, Materials.Elite, Materials.Master, + Materials.Ultimate, Materials.SuperconductorUHV }; + + for (int i = 3; i < GT_Values.VN.length - 1; i++) { + // 12625 + BioLab2[i - 3] = new GT_MetaTileEntity_BioLab( + ConfigHandler.IDOffset + GT_Values.VN.length * 6 + i, + "bw.biolab" + GT_Values.VN[i], + GT_Values.VN[i] + " " + StatCollector.translateToLocal("tile.biolab.name"), + i).getStackForm(1L); + RadioHatch2[i - 3] = new GT_MetaTileEntity_RadioHatch( + ConfigHandler.IDOffset + GT_Values.VN.length * 7 - 2 + i, + "bw.radiohatch" + GT_Values.VN[i], + GT_Values.VN[i] + " " + StatCollector.translateToLocal("tile.radiohatch.name"), + i).getStackForm(1L); + try { + ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); + GT_ModHandler.addCraftingRecipe( + BioLab2[i - 3], + RecipeLoader.BITSD, + new Object[] { "PFP", "WCW", "OGO", 'F', + GT_OreDictUnificator.get(OrePrefixes.frameGt, hulls2[i - 3], 1L), 'W', + GT_OreDictUnificator.get(OrePrefixes.wireGt01, wireMat2[i - 3], 1L), 'P', + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Polytetrafluoroethylene, 1L), 'O', + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Polystyrene, 1L), 'G', + "circuit" + circuits2[i - 3], 'C', machinehull }); + GT_ModHandler.addCraftingRecipe( + RadioHatch2[i - 3], + RecipeLoader.BITSD, + new Object[] { "DPD", "DCD", "DKD", 'D', + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Lead, 1L), 'C', machinehull, 'K', + GT_OreDictUnificator.get(OrePrefixes.cableGt08, cables2[i - 3], 1L), 'P', Pistons2[i - 3] }); + } catch (ArrayIndexOutOfBoundsException ignored) { + + } + } + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Electrolyzer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Electrolyzer.java new file mode 100644 index 0000000000..9502d4eff3 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Electrolyzer.java @@ -0,0 +1,152 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.electrolyzerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; + +public class Electrolyzer implements Runnable { + + // TODO: fix the chemical balance issues there are below + @Override + public void run() { + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Forsterit.get(OrePrefixes.dust, 7)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Magnesium, 2L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 1L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(10 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.RedZircon.get(OrePrefixes.dust, 6)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(OrePrefixes.dust, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 1L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(90) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Fayalit.get(OrePrefixes.dust, 7)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 2L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 1L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(16 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Prasiolite.get(OrePrefixes.dust, 16)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 5L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 1L)) + .duration(29 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Hedenbergit.get(OrePrefixes.dust, 10)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Calcium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 2L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(15 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.FuchsitAL.get(OrePrefixes.dust, 21), ItemList.Cell_Empty.get(2)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Potassium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Aluminiumoxide, 3L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 3L), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 2)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(19 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.FuchsitCR.get(OrePrefixes.dust, 21), ItemList.Cell_Empty.get(2)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Potassium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Chrome, 3L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 3L), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 2)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(23 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.VanadioOxyDravit.get(OrePrefixes.dust, 53), ItemList.Cell_Empty.get(3)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Vanadium, 3L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Magnalium, 6L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 3)) + .fluidOutputs(Materials.Oxygen.getGas(19000L)) + .duration(35 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.ChromoAluminoPovondrait.get(OrePrefixes.dust, 53), ItemList.Cell_Empty.get(3)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Chrome, 3L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Magnalium, 6L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 3)) + .fluidOutputs(Materials.Oxygen.getGas(19000L)) + .duration(36 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.FluorBuergerit.get(OrePrefixes.dust, 50), ItemList.Cell_Empty.get(3)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 3L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Aluminiumoxide, 6L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Fluorine, 3)) + .fluidOutputs(Materials.Oxygen.getGas(6000L)) + .duration(36 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Olenit.get(OrePrefixes.dust, 51), ItemList.Cell_Empty.get(1)) + .itemOutputs( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Aluminiumoxide, 9L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 1)) + .fluidOutputs(Materials.Oxygen.getGas(1000L)) + .duration(39 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Extractor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Extractor.java new file mode 100644 index 0000000000..9b304de837 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Extractor.java @@ -0,0 +1,45 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.enums.Mods.CropLoadCore; +import static gregtech.api.recipe.RecipeMaps.extractorRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import com.github.bartimaeusnek.bartworks.util.BW_Util; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.TierEU; + +public class Extractor implements Runnable { + + @Override + public void run() { + List oreCropVine = OreDictionary.getOres("cropVine", false); + if (CropLoadCore.isModLoaded() && !oreCropVine.isEmpty()) { + for (ItemStack stack : oreCropVine) { + + GT_Values.RA.stdBuilder() + .itemInputs(BW_Util.setStackSize(stack, 12)) + .itemOutputs(BioItemList.getOther(1)) + .duration(25 * SECONDS) + .eut((int) TierEU.RECIPE_HV) + .addTo(extractorRecipes); + + } + } + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Circuit_Chip_Stemcell.get(1L)) + .itemOutputs(BioItemList.getOther(4)) + .duration(25 * SECONDS) + .eut((int) TierEU.RECIPE_LuV) + .addTo(extractorRecipes); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FakeRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FakeRecipes.java new file mode 100644 index 0000000000..1df03d10f2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FakeRecipes.java @@ -0,0 +1,11 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR; + +public class FakeRecipes implements Runnable { + + @Override + public void run() { + GT_TileEntity_HTGR.HTGRMaterials.register_fake_THR_Recipes(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidHeater.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidHeater.java new file mode 100644 index 0000000000..3d27c55038 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidHeater.java @@ -0,0 +1,27 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.fluidHeaterRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_Utility; + +public class FluidHeater implements Runnable { + + @Override + public void run() { + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(10)) + .fluidInputs(new FluidStack(FluidLoader.fulvicAcid, 1000)) + .fluidOutputs(new FluidStack(FluidLoader.heatedfulvicAcid, 1000)) + .duration(4 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(fluidHeaterRecipes); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidSolidifier.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidSolidifier.java new file mode 100644 index 0000000000..4991370f44 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FluidSolidifier.java @@ -0,0 +1,103 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.TierEU; + +public class FluidSolidifier implements Runnable { + + @Override + public void run() { + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(Blocks.lapis_block)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0)) + .fluidInputs(Materials.Iron.getMolten(1296L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 1)) + .fluidInputs(Materials.Titanium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 2)) + .fluidInputs(Materials.TungstenSteel.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 3)) + .fluidInputs(WerkstoffLoader.LuVTierMaterial.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 4)) + .fluidInputs(Materials.Iridium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 5)) + .fluidInputs(Materials.Osmium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_ZPM) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 13)) + .fluidInputs(Materials.Neutronium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 14)) + .fluidInputs(Materials.CosmicNeutronium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UHV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 15)) + .fluidInputs(Materials.Infinity.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UEV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[1], 1, 0)) + .fluidInputs(MaterialsUEVplus.TranscendentMetal.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UIV) + .addTo(fluidSolidifierRecipes); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FormingPress.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FormingPress.java new file mode 100644 index 0000000000..bdeb24af9e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/FormingPress.java @@ -0,0 +1,77 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR.HTGRMaterials.MATERIALS_PER_FUEL; +import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR.HTGRMaterials.sHTGR_Fuel; +import static gregtech.api.recipe.RecipeMaps.formingPressRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_THTR; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; + +public class FormingPress implements Runnable { + + @Override + public void run() { + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials), Materials.Graphite.getDust(64)) + .itemOutputs(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 1)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 1), + Materials.Silicon.getDust(64)) + .itemOutputs(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 2)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 2), + Materials.Graphite.getDust(64)) + .itemOutputs(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 3)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + int i = 0; + for (GT_TileEntity_HTGR.HTGRMaterials.Fuel_ fuel : sHTGR_Fuel) { + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i), + Materials.Carbon.getDust(64)) + .itemOutputs(new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 1)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 1), + Materials.Silicon.getDust(64)) + .itemOutputs(new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 2)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 2), + Materials.Graphite.getDust(64)) + .itemOutputs(new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 3)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + i += MATERIALS_PER_FUEL; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/LaserEngraver.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/LaserEngraver.java new file mode 100644 index 0000000000..59c84d0f7c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/LaserEngraver.java @@ -0,0 +1,28 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_Utility; + +public class LaserEngraver implements Runnable { + + @Override + public void run() { + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(Items.emerald), GT_Utility.getIntegratedCircuit(17)) + .itemOutputs(BioItemList.getPlasmidCell(null)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(laserEngraverRecipes); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Mixer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Mixer.java new file mode 100644 index 0000000000..d69b4278ef --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Mixer.java @@ -0,0 +1,65 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR.HTGRMaterials.MATERIALS_PER_FUEL; +import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR.HTGRMaterials.sHTGR_Fuel; +import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_HTGR; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_THTR; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public class Mixer implements Runnable { + + @Override + public void run() { + GT_Values.RA.stdBuilder() + .itemInputs( + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 10), + Materials.Uranium235.getDust(1), + GT_Utility.getIntegratedCircuit(2)) + .itemOutputs(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + int i = 0; + for (GT_TileEntity_HTGR.HTGRMaterials.Fuel_ fuel : sHTGR_Fuel) { + GT_Values.RA.stdBuilder() + .itemInputs(fuel.mainItem, fuel.secondaryItem, GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + i += MATERIALS_PER_FUEL; + } + + if (Gendustry.isModLoaded()) { + GT_Values.RA.stdBuilder() + .itemInputs( + GT_Utility.getIntegratedCircuit(17), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Radon, 1L)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(FluidRegistry.getFluidStack("liquiddna", 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[0], 2000)) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(mixerRecipes); + } + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Pulverizer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Pulverizer.java new file mode 100644 index 0000000000..4dbcc45708 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Pulverizer.java @@ -0,0 +1,98 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; + +public class Pulverizer implements Runnable { + + @Override + public void run() { + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 1)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Titanium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 2)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.TungstenSteel.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 3)) + .itemOutputs( + Materials.BorosilicateGlass.getDust(9), + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.dust, 8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 4)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Iridium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_ZPM) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 5)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Osmium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UV) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 13)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Neutronium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UHV) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 14)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.CosmicNeutronium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UEV) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 15)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Infinity.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UIV) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[1], 1, 0)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), MaterialsUEVplus.TranscendentMetal.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UMV) + .addTo(maceratorRecipes); + + for (int i = 6; i < 11; i++) { + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, i)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/PyrolyseOven.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/PyrolyseOven.java new file mode 100644 index 0000000000..c810c323d9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/PyrolyseOven.java @@ -0,0 +1,24 @@ +package com.github.bartimaeusnek.bartworks.common.loaders.recipes; + +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; + +public class PyrolyseOven implements Runnable { + + @Override + public void run() { + GT_Values.RA.addPyrolyseRecipe( + Materials.Wood.getDust(10), + new FluidStack(FluidLoader.Kerogen, 1000), + 10, + null, + Materials.Oil.getFluid(1000), + 105, + (int) TierEU.RECIPE_HV); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java new file mode 100644 index 0000000000..b5e002ef29 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.net; + +import java.util.EnumMap; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; + +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.server.FMLServerHandler; +import gregtech.api.enums.GT_Values; +import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; +import gregtech.api.net.IGT_NetworkHandler; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.MessageToMessageCodec; + +/* + * Original GT File slightly Modified + */ +@SuppressWarnings("deprecation") +@ChannelHandler.Sharable +public class BW_Network extends MessageToMessageCodec implements IGT_NetworkHandler { + + private final EnumMap mChannel; + private final GT_Packet_New[] mSubChannels; + + public BW_Network() { + this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", this, new BW_Network.HandlerShared()); + this.mSubChannels = new GT_Packet_New[] { new RendererPacket(), new CircuitProgrammerPacket(), + new MetaBlockPacket(), new OreDictCachePacket(), new ServerJoinedPackage(), new EICPacket() }; + } + + @Override + protected void encode(ChannelHandlerContext aContext, GT_Packet_New aPacket, List aOutput) + throws Exception { + aOutput.add( + new FMLProxyPacket( + Unpooled.buffer() + .writeByte(aPacket.getPacketID()) + .writeBytes(aPacket.encode()) + .copy(), + aContext.channel() + .attr(NetworkRegistry.FML_CHANNEL) + .get())); + } + + @Override + protected void decode(ChannelHandlerContext aContext, FMLProxyPacket aPacket, List aOutput) + throws Exception { + ByteArrayDataInput aData = ByteStreams.newDataInput( + aPacket.payload() + .array()); + aOutput.add(this.mSubChannels[aData.readByte()].decode(aData)); + } + + @Override + public void sendToPlayer(@Nonnull GT_Packet aPacket, @Nonnull EntityPlayerMP aPlayer) { + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.PLAYER); + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) + .set(aPlayer); + this.mChannel.get(Side.SERVER) + .writeAndFlush(aPacket); + } + + public void sendToAllPlayersinWorld(@Nonnull GT_Packet aPacket, World world) { + for (String name : FMLServerHandler.instance() + .getServer() + .getAllUsernames()) { + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.PLAYER); + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) + .set(world.getPlayerEntityByName(name)); + this.mChannel.get(Side.SERVER) + .writeAndFlush(aPacket); + } + } + + @Override + public void sendToAllAround(@Nonnull GT_Packet aPacket, NetworkRegistry.TargetPoint aPosition) { + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) + .set(aPosition); + this.mChannel.get(Side.SERVER) + .writeAndFlush(aPacket); + } + + @Override + public void sendToServer(@Nonnull GT_Packet aPacket) { + this.mChannel.get(Side.CLIENT) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.TOSERVER); + this.mChannel.get(Side.CLIENT) + .writeAndFlush(aPacket); + } + + @Override + public void sendPacketToAllPlayersInRange(World aWorld, @Nonnull GT_Packet aPacket, int aX, int aZ) { + if (!aWorld.isRemote) { + + for (Object tObject : aWorld.playerEntities) { + if (!(tObject instanceof EntityPlayerMP tPlayer)) { + break; + } + + Chunk tChunk = aWorld.getChunkFromBlockCoords(aX, aZ); + if (tPlayer.getServerForPlayer() + .getPlayerManager() + .isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { + this.sendToPlayer(aPacket, tPlayer); + } + } + } + } + + @Sharable + static final class HandlerShared extends SimpleChannelInboundHandler { + + HandlerShared() {} + + @Override + protected void channelRead0(ChannelHandlerContext ctx, GT_Packet_New aPacket) throws Exception { + EntityPlayer aPlayer = GT_Values.GT.getThePlayer(); + aPacket.process(aPlayer == null ? null : GT_Values.GT.getThePlayer().worldObj); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java new file mode 100644 index 0000000000..c47b834157 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.net; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +import com.github.bartimaeusnek.bartworks.common.items.Circuit_Programmer; +import com.google.common.io.ByteArrayDataInput; + +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; + +public class CircuitProgrammerPacket extends GT_Packet_New { + + private int dimID, playerID; + private byte chipCfg; + private boolean hasChip; + + public CircuitProgrammerPacket() { + super(true); + } + + public CircuitProgrammerPacket(int dimID, int playerID, boolean hasChip, byte chipCfg) { + super(false); + this.dimID = dimID; + this.playerID = playerID; + this.hasChip = hasChip; + this.chipCfg = chipCfg; + } + + @Override + public byte getPacketID() { + return 1; + } + + @Override + public void encode(ByteBuf aOut) { + aOut.writeInt(this.dimID) + .writeInt(this.playerID) + .writeByte(this.hasChip ? this.chipCfg : -1); + } + + @Override + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { + return new CircuitProgrammerPacket( + byteArrayDataInput.readInt(), + byteArrayDataInput.readInt(), + byteArrayDataInput.readByte() > -1, + byteArrayDataInput.readByte()); + } + + @Override + public void process(IBlockAccess iBlockAccess) { + World w = DimensionManager.getWorld(this.dimID); + if (w != null && w.getEntityByID(this.playerID) instanceof EntityPlayer) { + ItemStack stack = ((EntityPlayer) w.getEntityByID(this.playerID)).getHeldItem(); + if (stack != null && stack.stackSize > 0) { + Item item = stack.getItem(); + if (item instanceof Circuit_Programmer) { + NBTTagCompound nbt = stack.getTagCompound(); + nbt.setBoolean("HasChip", this.hasChip); + if (this.hasChip) nbt.setByte("ChipConfig", this.chipCfg); + stack.setTagCompound(nbt); + ((EntityPlayer) w.getEntityByID(this.playerID)).inventory.setInventorySlotContents( + ((EntityPlayer) w.getEntityByID(this.playerID)).inventory.currentItem, + stack); + } + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java new file mode 100644 index 0000000000..621cc3fe4f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java @@ -0,0 +1,60 @@ +package com.github.bartimaeusnek.bartworks.common.net; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor; +import com.github.bartimaeusnek.bartworks.util.Coords; +import com.google.common.io.ByteArrayDataInput; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; + +public class EICPacket extends GT_Packet_New { + + private Coords coords; + private boolean bool; + + public EICPacket() { + super(true); + } + + public EICPacket(Coords coords, boolean bool) { + super(false); + this.coords = coords; + this.bool = bool; + } + + @Override + public byte getPacketID() { + return 5; + } + + @Override + public void encode(ByteBuf aOut) { + aOut.writeInt(this.coords.x); + aOut.writeInt(this.coords.y); + aOut.writeInt(this.coords.z); + aOut.writeBoolean(this.bool); + } + + @Override + public GT_Packet_New decode(ByteArrayDataInput aData) { + return new EICPacket(new Coords(aData.readInt(), aData.readInt(), aData.readInt()), aData.readBoolean()); + } + + @Override + public void process(IBlockAccess aWorld) { + if (SideReference.Side.Client) { + TileEntity te = aWorld.getTileEntity(this.coords.x, this.coords.y, this.coords.z); + if (!(te instanceof IGregTechTileEntity)) return; + IMetaTileEntity mte = ((IGregTechTileEntity) te).getMetaTileEntity(); + if (!(mte instanceof GT_TileEntity_ElectricImplosionCompressor)) return; + if (this.bool && !((IGregTechTileEntity) te).hasMufflerUpgrade()) + ((IGregTechTileEntity) te).addMufflerUpgrade(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java new file mode 100644 index 0000000000..6b555014ed --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.net; + +import java.nio.ByteBuffer; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Block_TE; +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; +import com.google.common.io.ByteArrayDataInput; + +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; + +public class MetaBlockPacket extends GT_Packet_New { + + int x; + short y; + int z; + short meta; + + public MetaBlockPacket(int x, int y, int z, int meta) { + super(false); + this.x = x; + this.y = (short) y; + this.z = z; + this.meta = (short) meta; + } + + public MetaBlockPacket() { + super(true); + } + + @Override + public byte getPacketID() { + return 2; + } + + @Override + public void encode(ByteBuf aOut) { + int hash = MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(12) + .putInt(this.x) + .putInt(this.z) + .putShort(this.y) + .putShort(this.meta) + .array(), + 0, + 12, + 31); + aOut.writeInt(this.x) + .writeInt(this.z) + .writeShort(this.y) + .writeShort(this.meta) + .writeInt(hash); + } + + @Override + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { + this.x = byteArrayDataInput.readInt(); + this.z = byteArrayDataInput.readInt(); + this.y = byteArrayDataInput.readShort(); + this.meta = byteArrayDataInput.readShort(); + MetaBlockPacket todecode = new MetaBlockPacket(this.x, this.y, this.z, this.meta); + if (byteArrayDataInput.readInt() != MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(12) + .putInt(this.x) + .putInt(this.z) + .putShort(this.y) + .putShort(this.meta) + .array(), + 0, + 12, + 31)) { + MainMod.LOGGER.error("PACKET HASH DOES NOT MATCH!"); + return null; + } + return todecode; + } + + @Override + public void process(IBlockAccess iBlockAccess) { + if (iBlockAccess != null) { + TileEntity tTileEntity = iBlockAccess.getTileEntity(this.x, this.y, this.z); + if (tTileEntity instanceof BW_MetaGenerated_Block_TE) { + ((BW_MetaGenerated_Block_TE) tTileEntity).mMetaData = this.meta; + } + if (iBlockAccess instanceof World && ((World) iBlockAccess).isRemote) { + ((World) iBlockAccess).markBlockForUpdate(this.x, this.y, this.z); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java new file mode 100644 index 0000000000..c488273d73 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.net; + +import java.util.HashSet; + +import net.minecraft.world.IBlockAccess; + +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.google.common.io.ByteArrayDataInput; + +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; + +public class OreDictCachePacket extends GT_Packet_New { + + private HashSet> hashSet = new HashSet<>(); + + public OreDictCachePacket() { + super(true); + } + + public OreDictCachePacket(HashSet> set) { + super(false); + this.hashSet = set; + } + + @Override + public byte getPacketID() { + return 3; + } + + @Override + public void encode(ByteBuf aOut) { + int size = this.hashSet.size(); + aOut.writeInt(size); + for (Pair p : this.hashSet) { + aOut.writeInt(p.getKey()) + .writeShort(p.getValue()); + } + } + + @Override + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { + int size = byteArrayDataInput.readInt(); + for (int i = 0; i < size; i++) { + this.hashSet.add(new Pair<>(byteArrayDataInput.readInt(), byteArrayDataInput.readShort())); + } + return new OreDictCachePacket(this.hashSet); + } + + @Override + public void process(IBlockAccess iBlockAccess) { + OreDictHandler.getNonBWCache() + .clear(); + OreDictHandler.getNonBWCache() + .addAll(this.hashSet); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java new file mode 100644 index 0000000000..436413fa14 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.net; + +import net.minecraft.world.IBlockAccess; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_BioVat; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.Coords; +import com.google.common.io.ByteArrayDataInput; + +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; + +public class RendererPacket extends GT_Packet_New { + + private Coords coords; + private int integer; + private byte removal; + + public RendererPacket() { + super(true); + } + + public RendererPacket(Coords coords, int integer, boolean removal) { + super(false); + this.coords = coords; + this.integer = integer; + this.removal = (byte) (removal ? 1 : 0); + } + + @Override + public byte getPacketID() { + return 0; + } + + @Override + public void encode(ByteBuf aOut) { + byte r = (byte) (this.integer >> 16 & 0xFF); + byte g = (byte) (this.integer >> 8 & 0xFF); + byte b = (byte) (this.integer & 0xFF); + byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + + this.coords.z % 25 + + this.coords.wID % 25 + + this.integer % 25 + + this.removal); + aOut.writeInt(this.coords.x) + .writeShort(this.coords.y) + .writeInt(this.coords.z) + .writeInt(this.coords.wID) + .writeByte(r) + .writeByte(g) + .writeByte(b) + .writeByte(this.removal) + .writeByte(checksum); + } + + @Override + public GT_Packet_New decode(ByteArrayDataInput dataInput) { + this.coords = new Coords(dataInput.readInt(), dataInput.readShort(), dataInput.readInt(), dataInput.readInt()); + this.integer = BW_ColorUtil + .getColorFromRGBArray(new int[] { dataInput.readByte(), dataInput.readByte(), dataInput.readByte() }); + this.removal = dataInput.readByte(); + + byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + + this.coords.z % 25 + + this.coords.wID % 25 + + this.integer % 25 + + this.removal); + + if (checksum != dataInput.readByte()) { + MainMod.LOGGER.error("BW Packet was corrupted or modified!"); + return null; + } + + return new RendererPacket(this.coords, this.integer, this.removal == 1); + } + + @Override + public void process(IBlockAccess iBlockAccess) { + if (SideReference.Side.Client) { + if (this.removal == 0) GT_TileEntity_BioVat.staticColorMap.put(this.coords, this.integer); + else GT_TileEntity_BioVat.staticColorMap.remove(this.coords); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java new file mode 100644 index 0000000000..091802683d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.net; + +import net.minecraft.world.IBlockAccess; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.google.common.io.ByteArrayDataInput; + +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; + +public class ServerJoinedPackage extends GT_Packet_New { + + private byte config; + + ServerJoinedPackage() { + super(true); + } + + public ServerJoinedPackage(Object obj) { + super(false); + this.config = (byte) (ConfigHandler.classicMode && ConfigHandler.disableExtraGassesForEBF ? 3 + : ConfigHandler.classicMode ? 2 : ConfigHandler.disableExtraGassesForEBF ? 1 : 0); + } + + @Override + public byte getPacketID() { + return 4; + } + + @Override + public void encode(ByteBuf aOut) { + aOut.writeByte(this.config); + } + + @Override + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { + this.config = byteArrayDataInput.readByte(); + return this; + } + + @Override + public void process(IBlockAccess iBlockAccess) { + boolean gas = (this.config & 1) != 0; + boolean classic = (this.config & 0b10) != 0; + MainMod.runOnPlayerJoined(classic, gas); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BWTileEntityDimIDBridge.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BWTileEntityDimIDBridge.java new file mode 100644 index 0000000000..bb0c0cf319 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BWTileEntityDimIDBridge.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.classic; + +import net.minecraft.tileentity.TileEntity; + +public class BWTileEntityDimIDBridge extends TileEntity { + + @Override + public boolean canUpdate() { + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java new file mode 100644 index 0000000000..5db8989d0c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.classic; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; + +import com.github.bartimaeusnek.bartworks.client.gui.BW_GUIContainer_RotorBlock; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.block.kineticgenerator.container.ContainerWindKineticGenerator; +import ic2.core.block.kineticgenerator.tileentity.TileEntityWindKineticGenerator; + +public class BW_RotorBlock extends TileEntityWindKineticGenerator { + + public int getGrindPower() { + return super.getKuOutput(); + } + + @Override + public int getKuOutput() { + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) { + return new BW_GUIContainer_RotorBlock(new ContainerWindKineticGenerator(entityPlayer, this)); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java new file mode 100644 index 0000000000..79bedfa1b8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.classic; + +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.WEST; + +import java.util.Comparator; +import java.util.PriorityQueue; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.TileFluidHandler; + +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.util.Coords; + +public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implements ITileAddsInformation { + + private static final ForgeDirection[] allowed_directions = { DOWN, WEST, EAST, SOUTH, NORTH }; + private PriorityQueue breadthFirstQueue = new PriorityQueue<>(Comparator.comparingInt(x -> x.y)); + private boolean wasInited = false; + + public BW_TileEntity_ExperimentalFloodGate() { + this.tank.setCapacity(64000); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return fluid.canBePlacedInWorld(); + } + + public void initEntity() { + if (this.wasInited) return; + this.breadthFirstQueue.add(new Coords(this.xCoord, this.yCoord, this.zCoord)); + this.wasInited = true; + } + + @Override + public void updateEntity() { + this.initEntity(); + Coords current = this.breadthFirstQueue.poll(); + if (current == null) return; + this.setFluidBlock(current); + for (ForgeDirection allowed_direction : allowed_directions) { + this.addBlockToQueue(current, allowed_direction); + } + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); + tag.setBoolean("init", this.wasInited); + + int[] x = new int[this.breadthFirstQueue.size()]; + int[] y = new int[this.breadthFirstQueue.size()]; + int[] z = new int[this.breadthFirstQueue.size()]; + Coords[] arr = this.breadthFirstQueue.toArray(new Coords[0]); + + for (int i = 0; i < this.breadthFirstQueue.size(); i++) { + x[i] = arr[i].x; + y[i] = arr[i].y; + z[i] = arr[i].z; + } + + tag.setIntArray("queueX", x); + tag.setIntArray("queueY", y); + tag.setIntArray("queueZ", z); + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + this.wasInited = tag.getBoolean("init"); + int[] x = tag.getIntArray("queueX"); + int[] y = tag.getIntArray("queueY"); + int[] z = tag.getIntArray("queueZ"); + for (int i = 0; i < x.length; i++) { + this.breadthFirstQueue.add(new Coords(x[i], y[i], z[i])); + } + } + + private void setFluidBlock(Coords current) { + if (!this.checkForAir(current) || this.tank.drain(1000, false) == null + || this.tank.drain(1000, false).amount != 1000) return; + FluidStack stack = this.tank.drain(1000, true); + this.worldObj.setBlock( + current.x, + current.y, + current.z, + stack.getFluid() + .getBlock(), + 0, + 2); + } + + private void addBlockToQueue(Coords current, ForgeDirection allowed_direction) { + Coords side = current.getCoordsFromSide(allowed_direction); + if (this.checkForAir(side)) this.breadthFirstQueue.add(side); + } + + private boolean checkForAir(Coords coords) { + return this.worldObj.isAirBlock(coords.x, coords.y, coords.z); + } + + @Override + public String[] getInfoData() { + return new String[] { "Experimental Machine to fill Holes with Fluids" }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java new file mode 100644 index 0000000000..faccfc4738 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java @@ -0,0 +1,374 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.classic; + +import java.util.Arrays; +import java.util.Optional; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileDropsContent; +import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.InvWrapper; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; + +public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDropsContent, IFluidHandler, IFluidTank, + ITileWithModularUI, ITileAddsInformation, ITileHasDifferentTextureSides { + + public static final int FUELSLOT = 0; + public static final Fluid WATER = FluidRegistry.WATER; + public ItemStack fuelstack; + public FluidStack outputstack = new FluidStack(FluidRegistry.WATER, 0); + public int fuel; + public byte tick; + public int maxfuel; + public ItemStack fakestack = new ItemStack(Blocks.water); + + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound subItemStack = new NBTTagCompound(); + if (this.fuelstack != null) { + this.fuelstack.writeToNBT(subItemStack); + } + compound.setTag("ItemStack", subItemStack); + NBTTagCompound subFluidStack = new NBTTagCompound(); + this.outputstack.writeToNBT(subFluidStack); + compound.setTag("FluidStack", subFluidStack); + compound.setInteger("fuel", this.fuel); + compound.setInteger("maxfuel", this.maxfuel); + compound.setByte("tick", this.tick); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + this.tick = compound.getByte("tick"); + this.fuel = compound.getInteger("fuel"); + this.maxfuel = compound.getInteger("maxfuel"); + this.outputstack = FluidStack.loadFluidStackFromNBT(compound.getCompoundTag("FluidStack")); + if (!compound.getCompoundTag("ItemStack") + .equals(new NBTTagCompound())) + this.fuelstack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ItemStack")); + super.readFromNBT(compound); + } + + private boolean checkPreUpdate() { + return (this.fuelstack == null || this.fuelstack.stackSize <= 0) && this.fuel <= 0; + } + + private void fixUnderlflow() { + if (this.fuel < 0) this.fuel = 0; + } + + private void handleRefuel() { + if (this.fuelstack != null && this.fuel == 0) { + this.fuel = this.maxfuel = TileEntityFurnace.getItemBurnTime(this.fuelstack); + --this.fuelstack.stackSize; + if (this.fuelstack.stackSize <= 0) this.fuelstack = null; + } + } + + private void handleWaterGeneration() { + if (this.fuel > 0) { + ++this.tick; + --this.fuel; + if (this.tick % 20 == 0) { + if (this.outputstack.amount <= 8000 - ConfigHandler.mbWaterperSec) + this.outputstack.amount += ConfigHandler.mbWaterperSec; + this.tick = 0; + } + } + } + + @Override + public void updateEntity() { + if (this.worldObj.isRemote) return; + + this.pushWaterToAdjacentTiles(); + this.fakestack.setStackDisplayName(this.outputstack.amount + "L Water"); + if (this.checkPreUpdate()) return; + + this.fixUnderlflow(); + this.handleRefuel(); + this.handleWaterGeneration(); + this.causePollution(); + } + + private void pushWaterToAdjacentTiles() { + Arrays.stream(ForgeDirection.values(), 0, 6) // All but Unknown + .forEach( + direction -> Optional + .ofNullable( + this.worldObj.getTileEntity( + this.xCoord + direction.offsetX, + this.yCoord + direction.offsetY, + this.zCoord + direction.offsetZ)) + .ifPresent(te -> { + if (te instanceof IFluidHandler tank) { + if (tank.canFill(direction.getOpposite(), this.outputstack.getFluid())) { + int drainage = tank.fill(direction.getOpposite(), this.outputstack, false); + if (drainage > 0) { + tank.fill(direction.getOpposite(), this.outputstack, true); + this.drain(drainage, true); + } + } + } else if (te instanceof IFluidTank tank) { + int drainage = tank.fill(this.outputstack, false); + if (drainage > 0) { + tank.fill(this.outputstack, true); + this.drain(drainage, true); + } + } + })); + } + + private void causePollution() { + Optional.ofNullable(this.worldObj) + .ifPresent(e -> { + if (e.getTotalWorldTime() % 20 == 0) { + Optional.ofNullable(e.getChunkFromBlockCoords(this.xCoord, this.zCoord)) + .ifPresent(c -> GT_Pollution.addPollution(c, ConfigHandler.pollutionHeatedWaterPumpSecond)); + } + }); + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0 }; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return TileEntityFurnace.getItemBurnTime(p_102007_2_) > 0; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 2; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + if (slotIn == 0) return this.fuelstack; + return this.fakestack; + } + + @Override + public ItemStack decrStackSize(int slot, int ammount) { + if (slot != BW_TileEntity_HeatedWaterPump.FUELSLOT || this.fuelstack == null + || ammount > this.fuelstack.stackSize) return null; + + return this.fuelstack.splitStack(ammount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int index) { + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + if (slot == BW_TileEntity_HeatedWaterPump.FUELSLOT) this.fuelstack = stack; + else this.fakestack = stack; + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + return TileEntityFurnace.getItemBurnTime(stack) > 0 && index == BW_TileEntity_HeatedWaterPump.FUELSLOT; + } + + @Override + public FluidStack getFluid() { + return this.outputstack.amount > 0 ? this.outputstack : null; + } + + @Override + public int getFluidAmount() { + return this.outputstack.amount; + } + + @Override + public int getCapacity() { + return 8000; + } + + @Override + public FluidTankInfo getInfo() { + return new FluidTankInfo(this); + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + int actualdrain = maxDrain; + if (actualdrain > this.outputstack.amount) actualdrain = this.outputstack.amount; + FluidStack ret = new FluidStack(BW_TileEntity_HeatedWaterPump.WATER, actualdrain); + if (ret.amount == 0) ret = null; + if (doDrain) { + this.outputstack.amount -= actualdrain; + FluidEvent.fireEvent( + new FluidEvent.FluidDrainingEvent( + this.outputstack, + this.getWorldObj(), + this.xCoord, + this.yCoord, + this.zCoord, + this, + actualdrain)); + } + return ret; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (resource != null && resource.getFluid() == BW_TileEntity_HeatedWaterPump.WATER + && this.drain(resource.amount, false) != null) return this.drain(resource.amount, doDrain); + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return this.drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return fluid == null || fluid == BW_TileEntity_HeatedWaterPump.WATER; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { this.getInfo() }; + } + + @Override + public String[] getInfoData() { + return new String[] { + StatCollector.translateToLocal("tooltip.tile.waterpump.0.name") + " " + + GT_Utility.formatNumbers(ConfigHandler.mbWaterperSec) + + String.format( + StatCollector.translateToLocal("tooltip.tile.waterpump.1.name"), + ConfigHandler.pollutionHeatedWaterPumpSecond), + StatCollector.translateToLocal("tooltip.tile.waterpump.2.name") }; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + ITileHasDifferentTextureSides.texture[ForgeDirection.UP.ordinal()] = par1IconRegister + .registerIcon(MainMod.MOD_ID + ":heatedWaterPumpTop"); + ITileHasDifferentTextureSides.texture[ForgeDirection.DOWN.ordinal()] = par1IconRegister + .registerIcon(MainMod.MOD_ID + ":heatedWaterPumpDown"); + for (int i = 2; i < 7; i++) { + ITileHasDifferentTextureSides.texture[i] = par1IconRegister + .registerIcon(MainMod.MOD_ID + ":heatedWaterPumpSide"); + } + } + + @Override + public ModularWindow createWindow(UIBuildContext buildContext) { + ModularWindow.Builder builder = ModularWindow.builder(176, 166); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.bindPlayerInventory(buildContext.getPlayer()); + final IItemHandlerModifiable invWrapper = new InvWrapper(this); + + builder.widget( + new SlotWidget(invWrapper, 0).setFilter(stack -> TileEntityFurnace.getItemBurnTime(stack) > 0) + .setPos(55, 52)) + .widget( + SlotWidget.phantom(invWrapper, 1) + .disableInteraction() + .setPos(85, 32)) + .widget( + new ProgressBar().setProgress(() -> (float) this.fuel / this.maxfuel) + .setTexture(BW_UITextures.PROGRESSBAR_FUEL, 14) + .setDirection(ProgressBar.Direction.UP) + .setPos(56, 36) + .setSize(14, 14)); + + return builder.build(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java new file mode 100644 index 0000000000..0dc888c663 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.classic; + +import java.util.ArrayList; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +import gregtech.api.util.GT_Utility; + +public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank, IFluidHandler { + + final ArrayList INTERNALTANKS = new ArrayList<>(); + + int selectedTank; + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return this.fill(resource, doFill); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return this.drain(from, resource != null ? resource.amount : 0, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return this.drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + boolean ret = false; + for (FluidStack stack : this.INTERNALTANKS) { + ret = GT_Utility.areFluidsEqual(stack, new FluidStack(fluid, 0)); + if (ret) { + this.selectedTank = this.INTERNALTANKS.indexOf(stack); + break; + } + } + return ret; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[0]; + } + + @Override + public FluidStack getFluid() { + if (this.INTERNALTANKS.get(this.selectedTank) == null || this.INTERNALTANKS.get(this.selectedTank).amount == 0) + if (this.selectedTank > 0) this.selectedTank = this.INTERNALTANKS.size() - 1; + return this.INTERNALTANKS.get(this.selectedTank); + } + + @Override + public int getFluidAmount() { + return this.INTERNALTANKS.get(this.selectedTank) != null ? this.INTERNALTANKS.get(this.selectedTank).amount : 0; + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + + NBTTagList lInternalTank = new NBTTagList(); + + for (FluidStack internaltank : this.INTERNALTANKS) { + if (internaltank != null) { + NBTTagCompound entry = new NBTTagCompound(); + entry.setString( + "FluidName", + internaltank.getFluid() + .getName()); + entry.setInteger("Ammount", internaltank.amount); + entry.setTag("FluidTag", internaltank.tag); + lInternalTank.appendTag(entry); + } + } + compound.setTag("InternalTank", lInternalTank); + } + + @Override + public int getCapacity() { + return Integer.MAX_VALUE; + } + + @Override + public FluidTankInfo getInfo() { + return null; + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + if (this.worldObj.isRemote || resource == null || resource.amount == 0) return 0; + + if (!doFill) return resource.amount; + + int id = 0; + + if (this.canDrain(null, resource.getFluid())) { + for (FluidStack stack : this.INTERNALTANKS) if (GT_Utility.areFluidsEqual(stack, resource)) { + this.INTERNALTANKS.get(id = this.INTERNALTANKS.indexOf(stack)).amount += resource.amount; + this.selectedTank = id; + } + } else { + this.INTERNALTANKS.add(resource); + id = this.INTERNALTANKS.size() - 1; + this.selectedTank = id; + } + return this.INTERNALTANKS.get(id).amount; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + + FluidStack outputstack = this.INTERNALTANKS.get(this.selectedTank); + if (this.worldObj.isRemote || maxDrain == 0 || this.getFluid() == null || outputstack == null) return null; + + int actualdrain = maxDrain; + if (actualdrain > outputstack.amount) actualdrain = outputstack.amount; + FluidStack ret = new FluidStack(outputstack.getFluid(), actualdrain); + if (ret.amount == 0) ret = null; + if (doDrain) { + outputstack.amount -= actualdrain; + FluidEvent.fireEvent( + new FluidEvent.FluidDrainingEvent( + outputstack, + this.getWorldObj(), + this.xCoord, + this.yCoord, + this.zCoord, + this, + actualdrain)); + } + return ret; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/debug/CreativeScanner.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/debug/CreativeScanner.java new file mode 100644 index 0000000000..2dcc69377e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/debug/CreativeScanner.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.debug; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Scanner; + +public class CreativeScanner extends GT_MetaTileEntity_Scanner { + + public CreativeScanner(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public CreativeScanner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new CreativeScanner(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.setEUVar(this.maxEUStore()); + this.mProgresstime = this.mMaxProgresstime; + super.onPostTick(aBaseMetaTileEntity, aTick); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java new file mode 100644 index 0000000000..a7d8ea9db8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java @@ -0,0 +1,836 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.github.bartimaeusnek.bartworks.util.BW_Util.ofGlassTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; +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.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + +import javax.annotation.Nullable; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.items.LabParts; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.net.RendererPacket; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import com.github.bartimaeusnek.bartworks.util.Coords; +import com.github.bartimaeusnek.bartworks.util.MathUtils; +import com.github.bartimaeusnek.bartworks.util.ResultWrongSievert; +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.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_ParallelHelper; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_BioVat extends GT_MetaTileEntity_EnhancedMultiBlockBase { + + public static final HashMap staticColorMap = new HashMap<>(); + + private static final byte TIMERDIVIDER = 20; + + private final HashSet playerMPHashSet = new HashSet<>(); + private final ArrayList mRadHatches = new ArrayList<>(); + private int height = 1; + private Fluid mFluid = FluidRegistry.LAVA; + private BioCulture mCulture; + private ItemStack mStack; + private boolean needsVisualUpdate = true; + private byte mGlassTier; + private int mSievert; + private int mNeededSievert; + private int mCasing = 0; + private int mExpectedMultiplier = 0; + private int mTimes = 0; + private boolean isVisibleFluid = false; + + public GT_TileEntity_BioVat(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_BioVat(String aName) { + super(aName); + } + + private static final int CASING_INDEX = 49; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { "ccccc", "ccccc", "ccccc", "ccccc", "ccccc" }, + { "ggggg", "gaaag", "gaaag", "gaaag", "ggggg" }, { "ggggg", "gaaag", "gaaag", "gaaag", "ggggg" }, + { "cc~cc", "ccccc", "ccccc", "ccccc", "ccccc" }, })) + .addElement( + 'c', + ofChain( + ofHatchAdder(GT_TileEntity_BioVat::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_BioVat::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_BioVat::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_BioVat::addRadiationInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_BioVat::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(e -> e.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1)))) + .addElement('a', ofChain(isAir(), ofBlockAnyMeta(FluidLoader.bioFluidBlock))) + .addElement( + 'g', + ofGlassTiered((byte) 1, (byte) 127, (byte) 0, (te, v) -> te.mGlassTier = v, te -> te.mGlassTier, 1)) + .build(); + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Bacterial Vat") + .addInfo("Controller block for the Bacterial Vat") + .addInfo("For maximum efficiency boost keep the Output Hatch always half filled!") + .addSeparator() + .beginStructureBlock(5, 4, 5, false) + .addController("Front bottom center") + .addCasingInfoMin("Clean Stainless Steel Casings", 19, false) + .addOtherStructurePart("Glass", "Hollow two middle layers", 2) + .addStructureInfo("The glass can be any glass, i.e. Tinkers Construct Clear Glass") + .addStructureInfo("Some Recipes need more advanced Glass Types") + .addMaintenanceHatch("Any casing", 1) + .addOtherStructurePart("Radio Hatch", "Any casing", 1) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addInputHatch("Any casing", 1) + .addOutputHatch("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + public static int[] specialValueUnpack(int aSpecialValue) { + int[] ret = new int[4]; + ret[0] = aSpecialValue & 0xF; // = glass tier + ret[1] = aSpecialValue >>> 4 & 0b11; // = special value + ret[2] = aSpecialValue >>> 6 & 0b1; // boolean exact svt | 1 = true | 0 = false + ret[3] = aSpecialValue >>> 7 & Integer.MAX_VALUE; // = sievert + return ret; + } + + private int getInputCapacity() { + return this.mInputHatches.stream() + .mapToInt(GT_MetaTileEntity_Hatch_Input::getCapacity) + .sum(); + } + + private int getOutputCapacity() { + return this.mOutputHatches.stream() + .mapToInt(GT_MetaTileEntity_Hatch_Output::getCapacity) + .sum(); + } + + @Override + public int getCapacity() { + int ret = 0; + ret += this.getInputCapacity(); + // ret += getOutputCapacity(); + return ret; + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return super.fill(resource, doFill); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public RecipeMap getRecipeMap() { + return BartWorksRecipeMaps.bacterialVatRecipes; + } + + /** + * Calculates the expected output multiplier based on the output hatch + * + * @param recipeFluidOutput the recipe fluid output + * @param needEqual if the recipeFluidOutput should be equal to the fluid in the output hatch + * @return the expected output multiplier + */ + private int getExpectedMultiplier(@Nullable FluidStack recipeFluidOutput, boolean needEqual) { + FluidStack storedFluidOutputs = this.getStoredFluidOutputs(); + if (storedFluidOutputs == null) return 1; + if (!needEqual || storedFluidOutputs.isFluidEqual(recipeFluidOutput)) { + return this.calcMod(storedFluidOutputs.amount) + 1; + } + return 1; + } + + private int calcMod(double x) { + double y = this.getOutputCapacity() / 2D, z = ConfigHandler.bioVatMaxParallelBonus; + + int ret = MathUtils.ceilInt((-1D / y * Math.pow(x - y, 2D) + y) / y * z); + return MathUtils.clamp(1, ret, ConfigHandler.bioVatMaxParallelBonus); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (!BW_Util.areStacksEqualOrNull( + (ItemStack) recipe.mSpecialItems, + GT_TileEntity_BioVat.this.getControllerSlot())) return CheckRecipeResultRegistry.NO_RECIPE; + int[] conditions = GT_TileEntity_BioVat.specialValueUnpack(recipe.mSpecialValue); + GT_TileEntity_BioVat.this.mNeededSievert = conditions[3]; + + if (GT_TileEntity_BioVat.this.mGlassTier < conditions[0]) { + return CheckRecipeResultRegistry.insufficientMachineTier(conditions[0]); + } + + if (conditions[2] == 0) { + if (GT_TileEntity_BioVat.this.mSievert < GT_TileEntity_BioVat.this.mNeededSievert) { + return ResultWrongSievert.insufficientSievert(GT_TileEntity_BioVat.this.mNeededSievert); + } + } else if (GT_TileEntity_BioVat.this.mSievert != conditions[3]) { + return ResultWrongSievert.wrongSievert(conditions[3]); + } + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected GT_ParallelHelper createParallelHelper(@NotNull GT_Recipe recipe) { + return super.createParallelHelper(recipeWithMultiplier(recipe, inputFluids)); + } + }; + } + + protected GT_Recipe recipeWithMultiplier(GT_Recipe recipe, FluidStack[] fluidInputs) { + GT_Recipe tRecipe = recipe.copy(); + int multiplier = getExpectedMultiplier(recipe.getFluidOutput(0), true); + mExpectedMultiplier = multiplier; + // Calculate max multiplier limited by input fluids + long fluidAmount = 0; + for (FluidStack fluid : fluidInputs) { + if (recipe.mFluidInputs[0].isFluidEqual(fluid)) { + fluidAmount += fluid.amount; + } + } + multiplier = (int) Math.min(multiplier, fluidAmount / recipe.mFluidInputs[0].amount); + // In case multiplier is 0 + multiplier = Math.max(multiplier, 1); + mTimes = multiplier; + tRecipe.mFluidInputs[0].amount *= multiplier; + tRecipe.mFluidOutputs[0].amount *= multiplier; + return tRecipe; + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setSpecialSlotItem(this.getControllerSlot()); + } + + public FluidStack getStoredFluidOutputs() { + // Only one output Hatch + assert this.mOutputHatches.size() == 1; + return this.mOutputHatches.get(0) + .getFluid(); + } + + private boolean addRadiationInputToMachineList(IGregTechTileEntity aTileEntity, int CasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null || !(aMetaTileEntity instanceof GT_MetaTileEntity_RadioHatch)) { + return false; + } else { + ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(CasingIndex); + return this.mRadHatches.add((GT_MetaTileEntity_RadioHatch) aMetaTileEntity); + } + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + this.mRadHatches.clear(); + this.mGlassTier = 0; + this.mCasing = 0; + + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 2, 3, 0)) return false; + + return this.mCasing >= 19 && this.mRadHatches.size() <= 1 + && this.mOutputHatches.size() == 1 + && this.mMaintenanceHatches.size() == 1 + && this.mInputHatches.size() > 0 + && this.mEnergyHatches.size() > 0; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + private void sendAllRequiredRendererPackets() { + int height = this.reCalculateHeight(); + if (this.mFluid != null && height > 1 && this.reCalculateFluidAmmount() > 0) { + for (int x = -1; x < 2; x++) for (int y = 1; y < height; y++) + for (int z = -1; z < 2; z++) this.sendPackagesOrRenewRenderer(x, y, z, this.mCulture); + } + } + + private void sendPackagesOrRenewRenderer(int x, int y, int z, BioCulture lCulture) { + int xDir = this.getXDir(); + int zDir = this.getZDir(); + + GT_TileEntity_BioVat.staticColorMap.remove( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId)); + GT_TileEntity_BioVat.staticColorMap.put( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB()); + + if (SideReference.Side.Server) { + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity() + .getWorld(), + new RendererPacket( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(), + true), + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity() + .getWorld(), + new RendererPacket( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(), + false), + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + } + this.needsVisualUpdate = true; + } + + private void check_Chunk() { + World aWorld = this.getBaseMetaTileEntity() + .getWorld(); + if (!aWorld.isRemote) { + + for (Object tObject : aWorld.playerEntities) { + if (!(tObject instanceof EntityPlayerMP tPlayer)) { + break; + } + Chunk tChunk = aWorld.getChunkFromBlockCoords( + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + if (tPlayer.getServerForPlayer() + .getPlayerManager() + .isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { + if (!this.playerMPHashSet.contains(tPlayer)) { + this.playerMPHashSet.add(tPlayer); + this.sendAllRequiredRendererPackets(); + } + } else { + this.playerMPHashSet.remove(tPlayer); + } + } + } + } + + private void placeFluid() { + this.isVisibleFluid = true; + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.height = this.reCalculateHeight(); + if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) for (int x = -1; x < 2; x++) { + for (int y = 0; y < this.height; y++) { + for (int z = -1; z < 2; z++) { + if (this.getBaseMetaTileEntity() + .getWorld() + .getBlock( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()) + .equals(Blocks.air)) + this.getBaseMetaTileEntity() + .getWorld() + .setBlock( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + FluidLoader.bioFluidBlock); + } + } + } + } + + private void removeFluid(int xDir, int zDir) { + this.isVisibleFluid = false; + + for (int x = -1; x < 2; x++) { + for (int y = 1; y < 3; y++) { + for (int z = -1; z < 2; z++) { + if (this.getBaseMetaTileEntity() + .getWorld() + .getBlock( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()) + .equals(FluidLoader.bioFluidBlock)) + this.getBaseMetaTileEntity() + .getWorld() + .setBlockToAir( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()); + GT_TileEntity_BioVat.staticColorMap.remove( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId); + } + } + } + } + + private int reCalculateFluidAmmount() { + return this.getStoredFluids() + .stream() + .mapToInt(fluidStack -> fluidStack.amount) + .sum(); + } + + private int reCalculateHeight() { + return this.reCalculateFluidAmmount() > this.getCapacity() / 4 - 1 + ? this.reCalculateFluidAmmount() >= this.getCapacity() / 2 ? 3 : 2 + : 1; + } + + public void doAllVisualThings() { + if (this.getBaseMetaTileEntity() + .isServerSide()) { + if (this.mMachine) { + ItemStack aStack = this.mInventory[1]; + BioCulture lCulture = null; + int xDir = this.getXDir(); + int zDir = this.getZDir(); + + if (this.getBaseMetaTileEntity() + .getTimer() % 200 == 0) { + this.check_Chunk(); + } + + if (this.needsVisualUpdate && this.getBaseMetaTileEntity() + .getTimer() % GT_TileEntity_BioVat.TIMERDIVIDER == 0) { + for (int x = -1; x < 2; x++) + for (int y = 1; y < 3; y++) for (int z = -1; z < 2; z++) this.getBaseMetaTileEntity() + .getWorld() + .setBlockToAir( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()); + } + + this.height = this.reCalculateHeight(); + if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) { + if (!BW_Util.areStacksEqualOrNull(aStack, this.mStack) + || this.needsVisualUpdate && this.getBaseMetaTileEntity() + .getTimer() % GT_TileEntity_BioVat.TIMERDIVIDER == 1) { + for (int x = -1; x < 2; x++) { + for (int y = 1; y < this.height; y++) { + for (int z = -1; z < 2; z++) { + if (aStack == null + || aStack.getItem() instanceof LabParts && aStack.getItemDamage() == 0) { + if (this.mCulture == null || aStack == null + || aStack.getTagCompound() == null + || this.mCulture.getID() != aStack.getTagCompound() + .getInteger("ID")) { + lCulture = aStack == null || aStack.getTagCompound() == null ? null + : BioCulture.getBioCulture( + aStack.getTagCompound() + .getString("Name")); + this.sendPackagesOrRenewRenderer(x, y, z, lCulture); + } + } + } + } + } + this.mStack = aStack; + this.mCulture = lCulture; + } + if (this.needsVisualUpdate && this.getBaseMetaTileEntity() + .getTimer() % GT_TileEntity_BioVat.TIMERDIVIDER == 1) { + if (this.getBaseMetaTileEntity() + .isClientSide()) new Throwable().printStackTrace(); + this.placeFluid(); + this.needsVisualUpdate = false; + } + } + } else { + this.onRemoval(); + } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.height != this.reCalculateHeight()) this.needsVisualUpdate = true; + this.doAllVisualThings(); + if (this.getBaseMetaTileEntity() + .isServerSide() && this.mRadHatches.size() == 1) { + this.mSievert = this.mRadHatches.get(0) + .getSievert(); + if (this.getBaseMetaTileEntity() + .isActive() && this.mNeededSievert > this.mSievert) this.mOutputFluids = null; + } + if (aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime <= 0) { + this.mTimes = 0; + this.mMaxProgresstime = 0; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mFluidHeight", this.height); + if (this.mCulture != null && !this.mCulture.getName() + .isEmpty()) aNBT.setString("mCulture", this.mCulture.getName()); + else if ((this.mCulture == null || this.mCulture.getName() + .isEmpty()) && !aNBT.getString("mCulture") + .isEmpty()) { + aNBT.removeTag("mCulture"); + } + if (this.mFluid != null) aNBT.setString("mFluid", this.mFluid.getName()); + aNBT.setInteger("mSievert", this.mSievert); + aNBT.setInteger("mNeededSievert", this.mNeededSievert); + aNBT.setBoolean("isVisibleFluid", this.isVisibleFluid); + super.saveNBTData(aNBT); + } + + @Override + public void onRemoval() { + if (this.isVisibleFluid) { + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.removeFluid(xDir, zDir); + this.sendRenderPackets(xDir, zDir); + } else if (this.getBaseMetaTileEntity() + .getWorld() + .getWorldTime() % 20 == 7) { + this.sendRenderPackets(); + } + + super.onRemoval(); + } + + private int getXDir() { + return this.getBaseMetaTileEntity() + .getBackFacing().offsetX * 2; + } + + private int getZDir() { + return this.getBaseMetaTileEntity() + .getBackFacing().offsetZ * 2; + } + + private void sendRenderPackets() { + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.sendRenderPackets(xDir, zDir); + } + + private void sendRenderPackets(int xDir, int zDir) { + if (SideReference.Side.Server) { + for (int x = -1; x < 2; x++) { + for (int y = 1; y < 3; y++) { + for (int z = -1; z < 2; z++) { + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity() + .getWorld(), + new RendererPacket( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + this.mCulture == null ? BioCulture.NULLCULTURE.getColorRGB() + : this.mCulture.getColorRGB(), + true), + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + } + } + } + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.height = aNBT.getInteger("mFluidHeight"); + this.mCulture = BioCulture.getBioCulture(aNBT.getString("mCulture")); + if (!aNBT.getString("mFluid") + .isEmpty()) this.mFluid = FluidRegistry.getFluid(aNBT.getString("mFluid")); + this.mSievert = aNBT.getInteger("mSievert"); + this.mNeededSievert = aNBT.getInteger("mNeededSievert"); + super.loadNBTData(aNBT); + this.isVisibleFluid = aNBT.getBoolean("isVisibleFluid"); + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_BioVat(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 3, 0); + } + + @Override + public String[] getInfoData() { + final String[] baseInfoData = super.getInfoData(); + final String[] infoData = new String[baseInfoData.length + 2]; + System.arraycopy(baseInfoData, 0, infoData, 0, baseInfoData.length); + // See https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11923 + // here we must check the machine is well-formed as otherwise getExpectedMultiplier might error out! + infoData[infoData.length - 2] = StatCollector.translateToLocal("BW.infoData.BioVat.expectedProduction") + ": " + + EnumChatFormatting.GREEN + + (this.mMachine + ? (this.mMaxProgresstime <= 0 ? this.getExpectedMultiplier(null, false) : this.mExpectedMultiplier) + * 100 + : -1) + + EnumChatFormatting.RESET + + " %"; + infoData[infoData.length - 1] = StatCollector.translateToLocal("BW.infoData.BioVat.production") + ": " + + EnumChatFormatting.GREEN + + (this.mMaxProgresstime <= 0 ? 0 : this.mTimes) * 100 + + EnumChatFormatting.RESET + + " %"; + return infoData; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + batchMode = !batchMode; + if (batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java new file mode 100644 index 0000000000..1f85ea0167 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java @@ -0,0 +1,641 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static com.github.bartimaeusnek.bartworks.util.BW_Util.ofGlassTieredMixed; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.enums.GT_HatchElement.InputBus; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_HatchElement.OutputBus; +import static gregtech.api.enums.SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_Meta_Items; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class GT_TileEntity_CircuitAssemblyLine extends + GT_MetaTileEntity_EnhancedMultiBlockBase implements ISurvivalConstructable { + + private static final int CASING_INDEX = 16; + + private static final String STRUCTURE_PIECE_FIRST = "first"; + private static final String STRUCTURE_PIECE_NEXT = "next"; + private static final String STRUCTURE_PIECE_NEXT_HINT = "next_hint"; + private static final String STRUCTURE_PIECE_LAST = "last"; + + private static final int MINIMUM_CIRCUIT_ASSEMBLER_LENGTH = 5; + protected static final String IMPRINT_KEY = "Type"; + protected static final String LENGTH_KEY = "Length"; + protected static final String RUNNING_MODE_KEY = "RunningMode"; + + private int length; + private int mode; + private String imprintedItemName; + private ItemStack imprintedStack; + + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_FIRST, + transpose(new String[][] { { "~", "G", "G" }, { "g", "l", "g" }, { "b", "i", "b" }, })) + .addShape( + STRUCTURE_PIECE_NEXT, + transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "I", "b" }, })) + .addShape( + STRUCTURE_PIECE_NEXT_HINT, + transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "i", "b" }, })) + .addShape( + STRUCTURE_PIECE_LAST, + transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "o", "b" }, })) + .addElement( + 'G', + buildHatchAdder(GT_TileEntity_CircuitAssemblyLine.class).atLeast(Energy) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTech_API.sBlockCasings3, 10)) + .addElement('g', ofGlassTieredMixed((byte) 4, (byte) 127, 5)) + .addElement('l', ofBlock(GregTech_API.sBlockCasings2, 5)) // assembling line casings + .addElement( + 'b', + buildHatchAdder(GT_TileEntity_CircuitAssemblyLine.class).atLeast(InputHatch, Maintenance) + .casingIndex(CASING_INDEX) + .dot(2) + .disallowOnly(ForgeDirection.EAST, ForgeDirection.WEST) + .buildAndChain(GregTech_API.sBlockCasings2, 0)) + .addElement('i', InputBus.newAny(CASING_INDEX, 3, ForgeDirection.DOWN)) + .addElement( + 'I', + buildHatchAdder(GT_TileEntity_CircuitAssemblyLine.class).atLeast(InputHatch, InputBus, OutputBus) + .casingIndex(CASING_INDEX) + .dot(2) + .disallowOnly(ForgeDirection.EAST, ForgeDirection.WEST) + .buildAndChain(GregTech_API.sBlockCasings2, 0)) + .addElement('o', OutputBus.newAny(CASING_INDEX, 2, ForgeDirection.DOWN)) + .build(); + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Circuit Assembler/Circuit Assembly Line") + .addInfo("Controller block for the Circuit Assembly Line") + .addInfo("Change Mode with Screwdriver") + .addInfo("Does not lose efficiency when overclocked") + .addInfo( + "---------" + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("chat.cal.mode.0") + + EnumChatFormatting.GRAY + + "--------") + .addInfo("Imprint this machine with a Circuit Imprint,") + .addInfo("by putting the imprint in the controller") + .addInfo("Every Circuit Assembly Line can only be imprinted ONCE") + .addInfo( + "---------" + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("chat.cal.mode.1") + + EnumChatFormatting.GRAY + + "--------") + .addInfo( + "Does Circuit Assembler recipes, Minimum Length: " + EnumChatFormatting.RED + + MINIMUM_CIRCUIT_ASSEMBLER_LENGTH + + EnumChatFormatting.GRAY) + .addInfo("Recipe tier in Circuit Assembler mode is at most Energy Hatch tier - 1.") + .addInfo("This mode supports Crafting Input Buffer/Bus and allows bus separation") + .addInfo("") + .addSeparator() + .addInfo(BW_Tooltip_Reference.TT_BLUEPRINT) + .beginVariableStructureBlock(2, 7, 3, 3, 3, 3, false) + .addStructureInfo("From Bottom to Top, Left to Right") + .addStructureInfo( + "Layer 1 - Solid Steel Machine Casing, Input bus (Last Output bus), Solid Steel Machine Casing") + .addStructureInfo("Layer 2 - EV+ Tier Glass, Assembling Line Casing, EV+ Tier Glass") + .addStructureInfo("Layer 3 - Grate Machine Casing") + .addStructureInfo("Up to 7 repeating slices, last is Output Bus") + .addController("Layer 3 first slice front") + .addOtherStructurePart( + "1x " + StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch"), + "Any layer 3 casing", + 1) + .addInputHatch("Any layer 1 casing", 2) + .addInputBus("As specified on layer 1", 3, 4) + .addOutputBus("As specified in final slice on layer 1", 4) + .addOtherStructurePart("EV+ Tier Glass", "As specified on layer 2", 5) + .addMaintenanceHatch("Any layer 1 casing", 2) + .toolTipFinisher(ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + return tt; + } + + public String getTypeForDisplay() { + + if (this.type.equals(new NBTTagCompound())) return ""; + return GT_LanguageManager.getTranslation( + GT_LanguageManager.getTranslateableItemStackName(CircuitImprintLoader.getStackFromTag(this.type))); + } + + private NBTTagCompound type = new NBTTagCompound(); + + public GT_TileEntity_CircuitAssemblyLine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private GT_TileEntity_CircuitAssemblyLine(String aName) { + super(aName); + } + + private boolean imprintMachine(ItemStack itemStack) { + if (!this.type.equals(new NBTTagCompound())) return true; + if (!GT_Utility.isStackValid(itemStack)) return false; + if (itemStack.getItem() instanceof BW_Meta_Items.BW_GT_MetaGenCircuits && itemStack.getItemDamage() == 0 + && itemStack.getTagCompound() != null + && this.type.equals(new NBTTagCompound())) { + this.type = itemStack.getTagCompound(); + this.mInventory[1] = null; + this.getBaseMetaTileEntity() + .issueBlockUpdate(); + return true; + } + return false; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient(IC2_MACHINES_MAGNETIZER_LOOP, 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.type = aNBT.getCompoundTag(IMPRINT_KEY); + this.imprintedItemName = this.type == null ? "" + : GT_LanguageManager.getTranslateableItemStackName(ItemStack.loadItemStackFromNBT(this.type)); + mode = aNBT.getInteger(RUNNING_MODE_KEY); + length = aNBT.getInteger(LENGTH_KEY); + super.loadNBTData(aNBT); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (!this.type.equals(new NBTTagCompound())) aNBT.setTag(IMPRINT_KEY, this.type); + aNBT.setInteger(RUNNING_MODE_KEY, mode); + aNBT.setInteger(LENGTH_KEY, length); + super.saveNBTData(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + if (!this.type.equals(new NBTTagCompound())) aNBT.setTag(IMPRINT_KEY, this.type); + aNBT.setInteger(RUNNING_MODE_KEY, mode); + aNBT.setInteger(LENGTH_KEY, length); + super.saveNBTData(aNBT); + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (getBaseMetaTileEntity().isServerSide()) { + this.mode = (this.mode + 1) % 2; + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("chat.cal.mode." + this.mode)); + } + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + public RecipeMap getRecipeMap() { + if (this.mode == 0) return BartWorksRecipeMaps.circuitAssemblyLineRecipes; + return RecipeMaps.circuitAssemblerRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(BartWorksRecipeMaps.circuitAssemblyLineRecipes, RecipeMaps.circuitAssemblerRecipes); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Override + @Nonnull + protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + // limit CA mode recipes to hatch tier - 1 + if (GT_TileEntity_CircuitAssemblyLine.this.mode == 1 + && recipe.mEUt > GT_TileEntity_CircuitAssemblyLine.this.getMaxInputVoltage() / 4) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + }.enablePerfectOverclock(); + } + + @NotNull + @Override + public CheckRecipeResult checkProcessing() { + if (mode == 0) { + if (this.type.equals(new NBTTagCompound()) && !this.imprintMachine(this.getControllerSlot())) + return SimpleCheckRecipeResult.ofFailure("no_imprint"); + if (this.imprintedItemName == null || this.imprintedStack == null) { + this.imprintedStack = new ItemStack(BW_Meta_Items.getNEWCIRCUITS(), 1, 0); + this.imprintedStack.setTagCompound(this.type); + this.imprintedItemName = GT_LanguageManager.getTranslateableItemStackName(this.imprintedStack); + } + } else if (length < MINIMUM_CIRCUIT_ASSEMBLER_LENGTH) { + return SimpleCheckRecipeResult.ofFailure("not_enough_length"); + } + + return super.checkProcessing(); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setSpecialSlotItem(this.imprintedStack); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; + } + + @Override + public ArrayList getStoredInputs() { + if (mode == 0) { + ArrayList rList = new ArrayList<>(); + for (GT_MetaTileEntity_Hatch_InputBus tHatch : filterValidMTEs(mInputBusses)) { + tHatch.mRecipeMap = this.getRecipeMap(); + for (int i = 0; i < tHatch.getBaseMetaTileEntity() + .getSizeInventory(); i++) { + if (tHatch.getBaseMetaTileEntity() + .getStackInSlot(i) != null) { + rList.add( + tHatch.getBaseMetaTileEntity() + .getStackInSlot(i)); + break; + } + } + } + return rList; + } + + return super.getStoredInputs(); + } + + @Override + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } else { + return false; + } + } + + @Override + public boolean addInputHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null || !(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input)) { + return false; + } else { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_CircuitAssemblyLine(this.mName); + } + + private String[] infoDataBuffer; + + @Override + public String[] getInfoData() { + if (this.infoDataBuffer != null) return this.infoDataBuffer; + + String[] oldInfo = super.getInfoData(); + this.infoDataBuffer = new String[oldInfo.length + 1]; + System.arraycopy(oldInfo, 0, this.infoDataBuffer, 0, oldInfo.length); + this.infoDataBuffer[oldInfo.length] = StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + + EnumChatFormatting.YELLOW + + this.getTypeForDisplay(); + return this.infoDataBuffer; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + if (!this.checkPiece(STRUCTURE_PIECE_FIRST, 0, 0, 0)) { + return false; + } + return this.checkMachine(true) || this.checkMachine(false); + } + + private boolean checkMachine(boolean leftToRight) { + + for (int i = 1; i < 7; ++i) { + if (!this.checkPiece(STRUCTURE_PIECE_NEXT, leftToRight ? -i : i, 0, 0)) { + return false; + } + length = i + 1; + + if (!this.mOutputBusses.isEmpty()) { + return this.mEnergyHatches.size() == 1 && this.mMaintenanceHatches.size() == 1; + } + } + + return false; + } + + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTURE_PIECE_FIRST, stackSize, hintsOnly, 0, 0, 0); + int tLength = Math.min(stackSize.stackSize + 1, 7); + + for (int i = 1; i < tLength; ++i) { + this.buildPiece(STRUCTURE_PIECE_NEXT, stackSize, hintsOnly, -i, 0, 0); + } + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + int built; + built = survivialBuildPiece(STRUCTURE_PIECE_FIRST, stackSize, 0, 0, 0, elementBudget, env, false, true); + if (built >= 0) return built; + int tLength = Math.min(stackSize.stackSize + 1, 7); + + for (int i = 1; i < tLength - 1; ++i) { + built = survivialBuildPiece( + STRUCTURE_PIECE_NEXT_HINT, + stackSize, + -i, + 0, + 0, + elementBudget, + env, + false, + true); + if (built >= 0) return built; + } + return survivialBuildPiece( + STRUCTURE_PIECE_LAST, + stackSize, + -(tLength - 1), + 0, + 0, + elementBudget, + env, + false, + true); + } + + @Override + public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { + if (stack.hasTagCompound() && stack.stackTagCompound.hasKey(IMPRINT_KEY)) { + tooltip.add( + StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + + EnumChatFormatting.YELLOW + + StatCollector.translateToLocal( + GT_LanguageManager.getTranslateableItemStackName( + ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("Type"))))); + } + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder + .widget(new FakeSyncWidget.StringSyncer(() -> this.imprintedItemName, val -> this.imprintedItemName = val)); + builder.widget( + new CycleButtonWidget().setToggle(() -> mode == 1, val -> mode = val ? 1 : 0) + .setTextureGetter( + state -> state == 1 ? BW_UITextures.OVERLAY_BUTTON_ASSEMBLER_MODE + : BW_UITextures.OVERLAY_BUTTON_LINE_MODE) + .setBackground(GT_UITextures.BUTTON_STANDARD) + .setPos(80, 91) + .setSize(16, 16) + .dynamicTooltip( + () -> Collections.singletonList(StatCollector.translateToLocal("chat.cal.mode." + mode))) + .setUpdateTooltipEveryTick(true) + .setTooltipShowUpDelay(TOOLTIP_DELAY)); + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) { + if (mode == 0) return false; + inputSeparation = !inputSeparation; + GT_Utility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + return true; + } else { + batchMode = !batchMode; + if (batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + } + + @Override + public boolean supportsInputSeparation() { + return mode != 0; + } + + @Override + public boolean isInputSeparationEnabled() { + return mode == 1 && super.isInputSeparationEnabled(); + } + + @Override + public boolean isRecipeLockingEnabled() { + return this.mode == 0 && this.imprintedItemName != null && !"".equals(this.imprintedItemName); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + currenttip.add( + EnumChatFormatting.GREEN + + StatCollector.translateToLocal("chat.cal.mode." + tag.getInteger(RUNNING_MODE_KEY))); + if (tag.hasKey("ImprintedWith") && tag.getInteger(RUNNING_MODE_KEY) == 0) currenttip.add( + StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + + EnumChatFormatting.YELLOW + + tag.getString("ImprintedWith")); + + } + + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + super.getWailaNBTData(player, tile, tag, world, x, y, z); + String imprintedWith = this.getTypeForDisplay(); + if (!imprintedWith.isEmpty()) tag.setString("ImprintedWith", imprintedWith); + tag.setInteger(RUNNING_MODE_KEY, mode); + } + + @Override + protected boolean supportsCraftingMEBuffer() { + return mode != 0; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java new file mode 100644 index 0000000000..f394089fb0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static gregtech.api.enums.GT_Values.VN; + +import java.lang.reflect.Field; +import java.util.Arrays; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase; +import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; + +public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { + + private static float nulearHeatMod = 2f; + private byte mMode; + private byte mTier; + + public GT_TileEntity_DEHP(int aID, int tier, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + this.mTier = (byte) tier; + } + + public GT_TileEntity_DEHP(String aName, byte mTier) { + super(aName); + this.mTier = mTier; + } + + @Override + @SuppressWarnings("rawtypes") + public void onConfigLoad(GT_Config aConfig) { + try { + Class c = TileEntityNuclearReactorElectric.class; + Field f = c.getDeclaredField("huOutputModifier"); + f.setAccessible(true); + GT_TileEntity_DEHP.nulearHeatMod = f.getFloat(f); + } catch (SecurityException | IllegalArgumentException | ExceptionInInitializerError | NullPointerException + | IllegalAccessException | NoSuchFieldException e) { + e.printStackTrace(); + } + super.onConfigLoad(aConfig); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mTier", this.mTier); + aNBT.setByte("mMode", this.mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mTier = aNBT.getByte("mTier"); + this.mMode = aNBT.getByte("mMode"); + super.loadNBTData(aNBT); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_DEHP(this.mName, this.mTier); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + String casings = this.getCasingBlockItem() + .get(0) + .getDisplayName(); + tt.addMachineType("Geothermal Heat Pump") + .addInfo("Consumes " + GT_Values.V[this.mTier + 2] + "EU/t") + .addInfo("Has 4 Modes, use the Screwdriver to change them:"); + if (ConfigHandler.DEHPDirectSteam) { + tt.addInfo("0 Idle, 1 Steam, 2 Superheated Steam (requires Distilled Water), 3 Retract") + .addInfo("Explodes when it runs out of Water/Distilled Water") + .addInfo( + "Converts " + (long) (this.mTier * 1200 * 20) + + "L/s Water(minus 10% per Maintenance Problem) to Steam") + .addInfo( + "Converts " + (long) (this.mTier * 600 * 20) + + "L/s Distilled Water(minus 10% per Maintenance Problem) to SuperheatedSteam"); + + } else { + tt.addInfo("0 Idle, 1 & 2 Coolant Heating Mode (no Difference between them), 3 Retract") + .addInfo("Explodes when it runs out of Coolant") + .addInfo( + "Heats up " + (long) (this.mTier * 24 * (double) GT_TileEntity_DEHP.nulearHeatMod) * 20 + + "L/s Coolant(minus 10% per Maintenance Problem)"); + } + tt.addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addOtherStructurePart(casings, "form the 3x1x3 Base") + .addOtherStructurePart(casings, "1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart( + this.getFrameMaterial().mName + " Frame Boxes", + "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[this.getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes, optional, any base casing") + .addInputHatch("Any base casing") + .addOutputHatch("Any base casing") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_HeatProof; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.Tungsten; + } + + @Override + protected int getCasingTextureIndex() { + return 11; + } + + @Override + protected int getMinTier() { + return 2 + this.mTier; + } + + @Override + protected boolean checkHatches() { + return !this.mMaintenanceHatches.isEmpty() && !this.mOutputHatches.isEmpty() && !this.mInputHatches.isEmpty(); + } + + private long getFluidFromHatches(Fluid f) { + long ret = 0; + for (GT_MetaTileEntity_Hatch_Input ih : this.mInputHatches) { + if (ih.getFluid() + .getFluid() + .equals(f)) ret += ih.getFluidAmount(); + } + return ret; + } + + private long getWaterFromHatches(boolean onlyDistilled) { + Fluid toConsume1 = FluidRegistry.WATER; + Fluid toConsume2 = GT_ModHandler.getDistilledWater(1L) + .getFluid(); + if (onlyDistilled) toConsume1 = toConsume2; + long ret = 0; + for (GT_MetaTileEntity_Hatch_Input ih : this.mInputHatches) { + if (ih.getFluid() + .getFluid() + .equals(toConsume1) + || ih.getFluid() + .getFluid() + .equals(toConsume2)) + ret += ih.getFluidAmount(); + } + return ret; + } + + @Override + protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, + int yHead, int oldYHead) { + if (this.mMode != 3) { + this.isPickingPipes = false; + try { + Field workState = this.getClass() + .getField("workState"); + workState.setInt(this, 0); + } catch (NoSuchFieldError | NoSuchFieldException | IllegalAccessException ignored) {} + return true; + } + return super.workingUpward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.getBaseMetaTileEntity() + .getWorld().isRemote) return; + ++this.mMode; + if (this.mMode >= 4) this.mMode = 0; + GT_Utility.sendChatToPlayer(aPlayer, "Mode: " + this.mMode); + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, + int yHead, int oldYHead) { + if (this.mMode == 3) { + this.isPickingPipes = true; + try { + Field workState = this.getClass() + .getSuperclass() + .getDeclaredField("workState"); + workState.setInt(this, 2); + } catch (NoSuchFieldError | NoSuchFieldException | IllegalAccessException ignored) {} + return true; + } + + if (this.tryLowerPipeState(false) == 0) { + return true; + } + if (this.waitForPipes()) { + return false; + } + if (this.mMode == 0) { + this.mMode = 1; + } + if (ConfigHandler.DEHPDirectSteam) { + if (this.mMode == 1) { + long steamProduced = this.mTier * 600 * 2L * this.mEfficiency / 10000L; + long waterConsume = (steamProduced + 160) / 160; + + if (this.getWaterFromHatches(false) - waterConsume > 0) { + this.consumeFluid(FluidRegistry.WATER, waterConsume); + this.addOutput(GT_ModHandler.getSteam(steamProduced)); + } else { + this.explodeMultiblock(); + return false; + } + } else if (this.mMode == 2) { + long steamProduced = this.mTier * 300 * 2L * this.mEfficiency / 10000L; + long waterConsume = (steamProduced + 160) / 160; + + if (this.getWaterFromHatches(true) - waterConsume > 0) { + this.consumeFluid( + GT_ModHandler.getDistilledWater(1) + .getFluid(), + waterConsume); + this.addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", (int) steamProduced)); + } else { + this.explodeMultiblock(); + return false; + } + } + } else if (this.mMode == 1 || this.mMode == 2) { + long coolantConverted = (long) (this.mTier * 24 + * (double) GT_TileEntity_DEHP.nulearHeatMod + * this.mEfficiency + / 10000L); + if (this.getFluidFromHatches(FluidRegistry.getFluid("ic2coolant")) - coolantConverted > 0) { + this.consumeFluid(FluidRegistry.getFluid("ic2coolant"), coolantConverted); + this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", (int) coolantConverted)); + } else { + this.explodeMultiblock(); + return false; + } + } + return true; + } + + private boolean consumeFluid(Fluid fluid, long ammount) { + if (ammount > Integer.MAX_VALUE) { + int[] tmp = new int[(int) (ammount / Integer.MAX_VALUE)]; + Arrays.fill(tmp, (int) (ammount / Integer.MAX_VALUE)); + for (int i = 0; i < tmp.length; i++) { + for (GT_MetaTileEntity_Hatch_Input ih : this.mInputHatches) { + if (fluid.equals(FluidRegistry.WATER) ? ih.getFluid() + .getFluid() + .equals(fluid) + || ih.getFluid() + .getFluid() + .equals( + GT_ModHandler.getDistilledWater(1) + .getFluid()) + : ih.getFluid() + .getFluid() + .equals(fluid)) + tmp[i] -= ih.drain((int) ammount, true).amount; + if (tmp[i] <= 0) break; + } + } + + return tmp[tmp.length - 1] <= 0; + } + + long tmp = ammount; + for (GT_MetaTileEntity_Hatch_Input ih : this.mInputHatches) { + if (fluid.equals(FluidRegistry.WATER) ? ih.getFluid() + .getFluid() + .equals(fluid) + || ih.getFluid() + .getFluid() + .equals( + GT_ModHandler.getDistilledWater(1) + .getFluid()) + : ih.getFluid() + .getFluid() + .equals(fluid)) + tmp -= ih.drain((int) ammount, true).amount; + if (tmp <= 0) return true; + } + return false; + } + + @Override + protected void setElectricityStats() { + try { + this.mEUt = this.isPickingPipes ? 60 : Math.toIntExact(GT_Values.V[this.getMinTier()]); + } catch (ArithmeticException e) { + e.printStackTrace(); + this.mEUt = Integer.MAX_VALUE - 7; + } + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + this.mEfficiency = this.getCurrentEfficiency(null); + this.mEfficiencyIncrease = 10000; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java new file mode 100644 index 0000000000..cb2140d62b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java @@ -0,0 +1,550 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry.BW_BLOCKS; +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.client.renderer.BW_EICPistonVisualizer; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.net.EICPacket; +import com.github.bartimaeusnek.bartworks.util.Coords; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.ITierConverter; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureUtility; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fox.spiteful.avaritia.blocks.LudicrousBlocks; +import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; +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.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_ElectricImplosionCompressor + extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase + implements ISurvivalConstructable { + + private static final boolean pistonEnabled = !ConfigHandler.disablePistonInEIC; + private Boolean piston = true; + private static final SoundResource sound = SoundResource.RANDOM_EXPLODE; + private final ArrayList chunkCoordinates = new ArrayList<>(5); + private int mBlockTier = 0; + private int mCasing; + + public GT_TileEntity_ElectricImplosionCompressor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_ElectricImplosionCompressor(String aName) { + super(aName); + } + + private static final int CASING_INDEX = 16; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { "ccc", "cec", "ccc" }, { "ttt", "tft", "ttt" }, { "ttt", "tft", "ttt" }, + { "nnn", "nnn", "nnn" }, { "nNn", "NNN", "nNn" }, { "nnn", "nnn", "nnn" }, { "t~t", "tft", "ttt" }, + { "ttt", "tft", "ttt" }, { "CCC", "CeC", "CCC" }, })) + .addElement('c', ofChain(ofBlock(GregTech_API.sBlockCasings2, 0), ofBlock(GregTech_API.sBlockCasings3, 4))) + .addElement('t', ofBlock(BW_BLOCKS[2], 1)) + .addElement('f', ofBlock(BW_BLOCKS[2], 0)) + .addElement( + 'n', + StructureUtility.ofBlocksTiered( + tieredBlockConverter(), + getAllBlockTiers(), + 0, + GT_TileEntity_ElectricImplosionCompressor::setBlockTier, + GT_TileEntity_ElectricImplosionCompressor::getBlockTier)) + .addElement( + 'C', + buildHatchAdder(GT_TileEntity_ElectricImplosionCompressor.class) + .atLeast(InputBus, OutputBus, Maintenance, InputHatch, OutputHatch) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings2, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings3, 4)))) + .addElement( + 'e', + buildHatchAdder(GT_TileEntity_ElectricImplosionCompressor.class).atLeast(Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(2) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings2, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings3, 4)))) + .addElement('N', new IStructureElement<>() { + + // Much of this based on StructureUtility.ofBlocksTiered + private final List> tiers = getAllBlockTiers(); + + @Override + public boolean check(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z) { + if (!te.piston && !world.isAirBlock(x, y, z)) return false; + if (te.piston) { + Block candidate = world.getBlock(x, y, z); + int candidateMeta = world.getBlockMetadata(x, y, z); + return getTierOfBlock(candidate, candidateMeta) != -1; + } + return true; + } + + private Pair getTier(ItemStack trigger) { + return this.tiers.get(Math.min(Math.max(trigger.stackSize, 1), this.tiers.size()) - 1); + } + + @Override + public boolean spawnHint(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z, + ItemStack itemStack) { + Pair tier = this.getTier(itemStack); + if (te.piston) StructureLibAPI.hintParticle(world, x, y, z, tier.getKey(), tier.getValue()); + return true; + } + + @Override + public boolean placeBlock(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z, + ItemStack itemStack) { + Pair tier = this.getTier(itemStack); + if (te.piston) world.setBlock(x, y, z, tier.getKey(), tier.getValue(), 3); + else world.setBlockToAir(x, y, z); + return true; + } + + @Override + public BlocksToPlace getBlocksToPlace(GT_TileEntity_ElectricImplosionCompressor t, World world, int x, + int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { + return BlocksToPlace.createEmpty(); + } + + @Override + public PlaceResult survivalPlaceBlock(GT_TileEntity_ElectricImplosionCompressor t, World world, int x, + int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { + return isAir().survivalPlaceBlock(t, world, x, y, z, trigger, env); + } + }) + .build(); + + public static List> getAllBlockTiers() { + return new ArrayList<>() { + + private static final long serialVersionUID = 8171991663102417651L; + + { + this.add(Pair.of(GregTech_API.sBlockMetal5, 2)); + this.add(Pair.of(LudicrousBlocks.resource_block, 1)); + this.add(Pair.of(GregTech_API.sBlockMetal9, 4)); + this.add(Pair.of(GregTech_API.sBlockMetal9, 3)); + this.add(Pair.of(GregTech_API.sBlockMetal9, 8)); + } + + }; + } + + public static ITierConverter tieredBlockConverter() { + return GT_TileEntity_ElectricImplosionCompressor::getTierOfBlock; + } + + private static int getTierOfBlock(Block block, int meta) { + if (block == null) { + return -1; + } + if (block == GregTech_API.sBlockMetal5 && meta == 2) { + return 1; // Neutronium + } + if (block == LudicrousBlocks.resource_block && meta == 1) { + return 2; // Infinity + } + if (block == GregTech_API.sBlockMetal9) { + return switch (meta) { + case 4 -> 3; // Transcendent Metal + case 3 -> 4; // SpaceTime + case 8 -> 5; // Universium + default -> -1; + }; + } + return -1; + } + + private void setBlockTier(int tier) { + this.mBlockTier = tier; + } + + private int getBlockTier() { + return this.mBlockTier; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Implosion Compressor") + .addInfo("Explosions are fun") + .addInfo("Controller block for the Electric Implosion Compressor") + .addInfo("Uses electricity instead of Explosives") + .addInfo("Can parallel up to 4^(Tier - 1)") + .addInfo("Tier is determined by containment block") + .addInfo("Valid blocks: Neutronium, Infinity, Transcendent Metal, Spacetime, Universium") + .addInfo("Minimum allowed energy hatch tier is one below recipe tier") + .addInfo("Supports " + TT + " energy hatches") + .addSeparator() + .beginStructureBlock(3, 9, 3, false) + .addController("Front 3rd layer center") + .addCasingInfoMin("Solid Steel Machine Casing", 8, false) + .addStructureInfo("Casings can be replaced with Explosion Warning Signs") + .addOtherStructurePart("Transformer-Winding Blocks", "Outer layer 2,3,7,8") + .addOtherStructurePart("Nickel-Zinc-Ferrite Blocks", "Inner layer 2,3,7,8") + .addOtherStructurePart("Containment Blocks", "Layer 4,5,6") + .addMaintenanceHatch("Any bottom casing", 1) + .addInputBus("Any bottom casing", 1) + .addInputHatch("Any bottom casing", 1) + .addOutputBus("Any bottom casing", 1) + .addEnergyHatch("Bottom middle and/or top middle", 2) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public RecipeMap getRecipeMap() { + return BartWorksRecipeMaps.electricImplosionCompressorRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + long voltage = GT_TileEntity_ElectricImplosionCompressor.this.getAverageInputVoltage(); + // Only allow a minimum of T-1 energy hatch + if (recipe.mEUt > voltage * 4) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { + // For overclocking we'll allow all power to be used + return super.createOverclockCalculator(recipe) + .setEUt(GT_TileEntity_ElectricImplosionCompressor.this.getMaxInputEu()) + .setAmperage(1); + } + }.setMaxParallelSupplier(() -> (int) Math.pow(4, Math.max(this.mBlockTier - 1, 0))); + } + + private void updateChunkCoordinates() { + this.chunkCoordinates.clear(); + + for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) { + if (Math.abs(x) != 1 || Math.abs(z) != 1) { + int[] abc = { x, -2, z + 1 }; + int[] xyz = { 0, 0, 0 }; + this.getExtendedFacing() + .getWorldOffset(abc, xyz); + xyz[0] += this.getBaseMetaTileEntity() + .getXCoord(); + xyz[1] += this.getBaseMetaTileEntity() + .getYCoord(); + xyz[2] += this.getBaseMetaTileEntity() + .getZCoord(); + this.chunkCoordinates.add(new ChunkCoordinates(xyz[0], xyz[1], xyz[2])); + } + } + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + this.updateChunkCoordinates(); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (pistonEnabled && aBaseMetaTileEntity.isActive() && aTick % 20 == 0) { + if (aBaseMetaTileEntity.isClientSide()) this.animatePiston(aBaseMetaTileEntity); + else if (aBaseMetaTileEntity.hasMufflerUpgrade()) MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + aBaseMetaTileEntity.getWorld(), + new EICPacket( + new Coords( + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()), + true), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getZCoord()); + } + } + + @Override + public void setExtendedFacing(ExtendedFacing newExtendedFacing) { + super.setExtendedFacing(newExtendedFacing); // Will call stopMachine + + this.updateChunkCoordinates(); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public void stopMachine() { + this.resetPiston(this.mBlockTier); + super.stopMachine(); + } + + private void resetPiston(int tier) { + if (!pistonEnabled) return; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (!aBaseMetaTileEntity.isServerSide()) return; + if (!this.piston) { + List> tiers = getAllBlockTiers(); + Pair tieredBlock = tiers.get(Math.min(tier, tiers.size()) - 1); + this.chunkCoordinates.forEach(c -> { + // Don't replace real blocks in case user has placed something (e.g. tier upgrade) + if (aBaseMetaTileEntity.getWorld() + .isAirBlock(c.posX, c.posY, c.posZ)) { + aBaseMetaTileEntity.getWorld() + .setBlock(c.posX, c.posY, c.posZ, tieredBlock.getKey(), tieredBlock.getValue(), 3); + } + }); + this.piston = !this.piston; + } + } + + private void activatePiston() { + if (!pistonEnabled) return; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (!aBaseMetaTileEntity.isServerSide()) return; + if (this.piston) { + this.chunkCoordinates.forEach( + c -> aBaseMetaTileEntity.getWorld() + .setBlockToAir(c.posX, c.posY, c.posZ)); + this.piston = !this.piston; + } + } + + private void animatePiston(IGregTechTileEntity aBaseMetaTileEntity) { + if (!aBaseMetaTileEntity.getWorld().isRemote) return; + + if (!this.getBaseMetaTileEntity() + .hasMufflerUpgrade()) + GT_Utility.doSoundAtClient( + sound, + 10, + 1f, + 1f, + this.chunkCoordinates.get(0).posX, + this.chunkCoordinates.get(0).posY, + this.chunkCoordinates.get(0).posZ); + this.spawnVisualPistonBlocks( + aBaseMetaTileEntity.getWorld(), + this.chunkCoordinates.get(2).posX, + this.chunkCoordinates.get(2).posY, + this.chunkCoordinates.get(2).posZ, + 10); + } + + @SideOnly(Side.CLIENT) + private void spawnVisualPistonBlocks(World world, int x, int y, int z, int age) { + BW_EICPistonVisualizer pistonVisualizer = new BW_EICPistonVisualizer(world, x, y, z, age); + Minecraft.getMinecraft().effectRenderer.addEffect(pistonVisualizer); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("piston", this.piston); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("piston")) this.piston = aNBT.getBoolean("piston"); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + int pistonTier = this.mBlockTier; + this.mCasing = 0; + int mMaxHatchTier = 0; + this.setBlockTier(0); + boolean isOK = this.checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0); + + List energyHatches = this.getExoticAndNormalEnergyHatchList(); + for (GT_MetaTileEntity_Hatch hatch : energyHatches) { + mMaxHatchTier = Math.max(mMaxHatchTier, hatch.mTier); + } + + isOK = isOK && this.mMaintenanceHatches.size() == 1 && energyHatches.size() >= 1; + if (isOK) { + this.activatePiston(); + return true; + } + this.resetPiston(pistonTier); + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_ElectricImplosionCompressor(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 1, 6, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 6, 0, elementBudget, env, false, true); + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + batchMode = !batchMode; + if (batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java new file mode 100644 index 0000000000..a5ed5a69b7 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java @@ -0,0 +1,614 @@ +/* + * Copyright (C) 2022 kuba6000 This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_VIA_BARTWORKS; +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_Values.AuthorKuba; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.common.items.SimpleSubItemClass; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.MathUtils; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_HTGR extends GT_MetaTileEntity_EnhancedMultiBlockBase { + + private static final int BASECASINGINDEX = 181; + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " BBBBBBB ", " BBBBBBBBB ", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", + "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", " BBBBBBBBB ", " BBBBBBB " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " bbb~bbb ", " bbbbbbbbb ", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", + "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", " bbbbbbbbb ", " bbbbbbb " }, })) + .addElement('c', onElementPass(x -> x.mCasing++, ofBlock(GregTech_API.sBlockCasings8, 5))) + .addElement( + 'b', + ofChain( + ofHatchAdder(GT_TileEntity_HTGR::addOutputToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(GT_TileEntity_HTGR::addMaintenanceToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(GT_TileEntity_HTGR::addEnergyInputToMachineList, BASECASINGINDEX, 1), + onElementPass(x -> x.mCasing++, ofBlock(GregTech_API.sBlockCasings8, 5)))) + .addElement( + 'B', + ofChain( + ofHatchAdder(GT_TileEntity_HTGR::addInputToMachineList, BASECASINGINDEX, 2), + onElementPass(x -> x.mCasing++, ofBlock(GregTech_API.sBlockCasings8, 5)))) + // ofHatchAdderOptional(GT_TileEntity_HTGR::addInputToMachineList, BASECASINGINDEX, 2, + // GregTech_API.sBlockCasings8, 5)) + .build(); + + private static final int HELIUM_NEEDED = 730000; + public static final int powerUsage = (int) TierEU.RECIPE_LuV; + private static final int maxcapacity = 720000; + private static final int mincapacity = maxcapacity / 10; + private int HeliumSupply; + private int fueltype = -1, fuelsupply = 0; + private boolean empty; + private int emptyticksnodiff = 0; + private int coolanttaking = 0; + private int mCasing = 0; + + public GT_TileEntity_HTGR(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private GT_TileEntity_HTGR(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Breeder Reactor") + .addInfo("Controller block for the High Temperature Gas-cooled Reactor (HTGR)") + .addInfo(AuthorKuba) + .addInfo("You can clear internal buffer by changing the mode with a screwdriver") + .addInfo("Needs a constant supply of coolant while running") + .addInfo("Needs at least 72k Fuel pebbles to start operation (can hold up to 720k pebbles)") + .addInfo("Consumes up to 2.5% of total Fuel Pellets per Operation depending on efficiency") + .addInfo("Efficiency is calculated exponentially depending on the amount of pebbles in the internal buffer") + .addInfo("and affects total recipe time (at 100% eff, -50% total recipe time") + .addInfo( + "Reactor will take 4 000L/s of coolant multiplied by efficiency and by fuel coolant value (check tooltips)") + .addInfo("Uses " + GT_Utility.formatNumbers(powerUsage) + " EU/t") + .addInfo("One Operation takes 1 hour") + .addSeparator() + .beginStructureBlock(11, 12, 11, true) + .addController("Front bottom center") + .addCasingInfoMin("Europium Reinforced Radiation Proof Casings", 500, false) + .addStructureInfo("Corners and the 2 touching blocks are air (cylindric)") + .addInputBus("Any top layer casing", 2) + .addInputHatch("Any top layer casing", 2) + .addOutputBus("Any bottom layer casing", 1) + .addOutputHatch("Any bottom layer casing", 1) + .addEnergyHatch("Any bottom layer casing", 1) + .addMaintenanceHatch("Any bottom layer casing", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_VIA_BARTWORKS.apply(ChatColorHelper.GOLD + "kuba6000")); + return tt; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece("main", stackSize, hintsOnly, 5, 11, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + this.mCasing = 0; + return this.checkPiece("main", 5, 11, 0) && this.mCasing >= 500 + && this.mMaintenanceHatches.size() == 1 + && this.mInputHatches.size() > 0 + && this.mOutputHatches.size() > 0 + && this.mInputBusses.size() > 0 + && this.mOutputBusses.size() > 0 + && this.mEnergyHatches.size() > 0; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.HeliumSupply = aNBT.getInteger("HeliumSupply"); + this.fueltype = aNBT.getInteger("fueltype"); + this.fuelsupply = aNBT.getInteger("fuelsupply"); + this.empty = aNBT.getBoolean("EmptyMode"); + this.coolanttaking = aNBT.getInteger("coolanttaking"); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("HeliumSupply", this.HeliumSupply); + aNBT.setInteger("fueltype", this.fueltype); + aNBT.setInteger("fuelsupply", this.fuelsupply); + aNBT.setBoolean("EmptyMode", this.empty); + aNBT.setInteger("coolanttaking", this.coolanttaking); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && !this.empty) { + boolean updateneeded = false; + if (this.HeliumSupply < GT_TileEntity_HTGR.HELIUM_NEEDED) { + for (FluidStack fluidStack : this.getStoredFluids()) { + if (fluidStack.isFluidEqual(Materials.Helium.getGas(1))) { + int toget = Math.min(GT_TileEntity_HTGR.HELIUM_NEEDED - this.HeliumSupply, fluidStack.amount); + fluidStack.amount -= toget; + this.HeliumSupply += toget; + updateneeded = true; + } + } + } + if (this.fuelsupply < maxcapacity) { + this.startRecipeProcessing(); + for (ItemStack itemStack : this.getStoredInputs()) { + int type = -1; + if (itemStack == null || itemStack.getItem() != HTGRMaterials.aHTGR_Materials) continue; + int damage = HTGRMaterials.aHTGR_Materials.getDamage(itemStack); + if ((damage + 1) % HTGRMaterials.MATERIALS_PER_FUEL != HTGRMaterials.USABLE_FUEL_INDEX + 1) + continue; // is fuel + type = damage / HTGRMaterials.MATERIALS_PER_FUEL; + if (this.fueltype == -1) this.fueltype = type; + if (this.fueltype != type) continue; + int toget = Math.min(maxcapacity - this.fuelsupply, itemStack.stackSize); + this.fuelsupply += toget; + itemStack.stackSize -= toget; + updateneeded = true; + } + this.endRecipeProcessing(); + } + if (updateneeded) this.updateSlots(); + } + } + + @Override + public RecipeMap getRecipeMap() { + // Only for visual + return BartWorksRecipeMaps.htgrFakeRecipes; + } + + @Override + protected boolean filtersFluid() { + return false; + } + + @Override + public boolean checkRecipe(ItemStack controllerStack) { + + if (this.empty) { + if (this.HeliumSupply > 0 || this.fuelsupply > 0) { + this.mEfficiency = 10000; + this.mMaxProgresstime = 100; + return true; + } + return false; + } + if (this.HeliumSupply < GT_TileEntity_HTGR.HELIUM_NEEDED || this.fuelsupply < mincapacity) return false; + + double eff = Math.min(Math.pow((double) this.fuelsupply / (double) mincapacity, 2D), 100D) / 100D + - (this.getIdealStatus() - this.getRepairStatus()) / 10D; + + if (eff <= 0) return false; + + int toReduce = MathUtils.floorInt(this.fuelsupply * 0.025D * eff); + + final int originalToReduce = toReduce; + int burnedballs = toReduce / 64; + if (burnedballs > 0) toReduce -= burnedballs * 64; + + int meta = this.fueltype * HTGRMaterials.MATERIALS_PER_FUEL + HTGRMaterials.BURNED_OUT_FUEL_INDEX; + + ItemStack[] toOutput = { new ItemStack(HTGRMaterials.aHTGR_Materials, burnedballs, meta), + new ItemStack(HTGRMaterials.aHTGR_Materials, toReduce, meta + 1) }; + if (!this.canOutputAll(toOutput)) return false; + + this.fuelsupply -= originalToReduce; + this.mOutputItems = toOutput; + + // this.updateSlots(); // not needed ? + + this.coolanttaking = (int) (4000D * (this.fueltype * 0.5D + 1) * eff); + + this.mEfficiency = (int) (eff * 10000D); + this.mEfficiencyIncrease = 0; + this.mEUt = -powerUsage; + this.mMaxProgresstime = (int) (72000 * (1d - eff / 2d)); + return true; + } + + private int runningtick = 0; + + @Override + public boolean onRunningTick(ItemStack aStack) { + this.runningtick++; + + if (this.empty) { + if (this.emptyticksnodiff > 20 && this.emptyticksnodiff % 20 != 0) { + this.emptyticksnodiff++; + return true; + } + if (this.HeliumSupply > 0) { + this.addOutput(Materials.Helium.getGas(this.HeliumSupply)); + this.HeliumSupply = 0; + } + if (this.fuelsupply > 0) { + ItemStack iStack = new ItemStack( + HTGRMaterials.aHTGR_Materials, + this.fuelsupply, + HTGRMaterials.MATERIALS_PER_FUEL * this.fueltype + HTGRMaterials.USABLE_FUEL_INDEX); + boolean storedAll = false; + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : filterValidMTEs(mOutputBusses)) { + if (tHatch.storeAll(iStack)) { + storedAll = true; + break; + } + } + if (!storedAll) { + if (this.fuelsupply == iStack.stackSize) this.emptyticksnodiff++; + else { + this.fuelsupply = iStack.stackSize; + this.emptyticksnodiff = 0; + } + } else { + this.fuelsupply = 0; + this.fueltype = -1; + this.coolanttaking = 0; + } + } + return true; + } + // USE DA POWAH + if (!this.drainEnergyInput(-this.mEUt)) { + this.criticalStopMachine(); + return false; + } + + if (this.runningtick % 20 == 0) { + int takecoolant = this.coolanttaking; + int drainedamount = 0; + + for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { + FluidStack drained = tHatch.drain(takecoolant, true); + takecoolant -= drained.amount; + drainedamount += drained.amount; + if (takecoolant <= 0) break; + } + } + + if (drainedamount > 0) this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); + + this.updateSlots(); + + if (takecoolant > 0) this.stopMachine(); + } + + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_HTGR(this.mName); + } + + @Override + public String[] getInfoData() { + return new String[] { "Mode:", this.empty ? "Emptying" : "Normal", "Progress:", + GT_Utility.formatNumbers(this.mProgresstime / 20) + "s / " + + GT_Utility.formatNumbers(this.mMaxProgresstime / 20) + + "s", + "Fuel type:", + this.fueltype == -1 ? "NONE" : "TRISO (" + HTGRMaterials.sHTGR_Fuel[this.fueltype].sEnglish + ")", + "Fuel amount:", GT_Utility.formatNumbers(this.fuelsupply) + " pcs.", "Helium-Level:", + GT_Utility.formatNumbers(this.HeliumSupply) + "L / " + + GT_Utility.formatNumbers(GT_TileEntity_HTGR.HELIUM_NEEDED) + + "L", + "Coolant:", GT_Utility.formatNumbers(this.coolanttaking) + "L/s", "Problems:", + String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, + ForgeDirection forgeDirection, int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == forgeDirection) { + if (aActive) return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_HTGR.BASECASINGINDEX), TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_HTGR.BASECASINGINDEX), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_HTGR.BASECASINGINDEX) }; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mMaxProgresstime > 0) { + GT_Utility.sendChatToPlayer(aPlayer, "HTGR mode cannot be changed while the machine is running."); + return; + } + this.empty = !this.empty; + GT_Utility.sendChatToPlayer( + aPlayer, + "HTGR is now running in " + (this.empty ? "emptying mode." : "normal Operation")); + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + public static class HTGRMaterials { + + private static class CustomHTGRSimpleSubItemClass extends SimpleSubItemClass { + + HashMap tooltip = null; + + public CustomHTGRSimpleSubItemClass(HashMap tooltip, String... tex) { + super(tex); + this.tooltip = tooltip; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + if (this.tooltip.containsKey(this.getDamage(p_77624_1_))) + aList.add(this.tooltip.get(this.getDamage(p_77624_1_))); + aList.add("Material for High Temperature Gas-cooled Reactor"); + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + } + } + + private static class Base_ { + + public String sName; + public String sEnglish; + + public Base_(String a, String b) { + this.sName = a; + this.sEnglish = b; + } + } + + public static class Fuel_ { + + public String sName; + public String sEnglish; + public ItemStack mainItem; + public ItemStack secondaryItem; + public ItemStack[] recycledItems = { GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, + GT_Values.NI }; + public FluidStack recycledFluid; + public int[] recycleChances; + public String tooltip; + + public Fuel_(String sName, String sEnglish, ItemStack mainItem, ItemStack secondaryItem, + FluidStack recycledFluid, ItemStack[] recycledItems, int[] recycleChances, String tooltip) { + this.sName = sName; + this.sEnglish = sEnglish; + this.mainItem = mainItem; + this.secondaryItem = secondaryItem; + this.recycledFluid = recycledFluid; + System.arraycopy(recycledItems, 0, this.recycledItems, 0, recycledItems.length); + this.recycleChances = recycleChances; + this.tooltip = tooltip; + } + } + + private static class LangEntry_ { + + public String sName; + public String sEnglish; + + public LangEntry_(String a, String b) { + this.sName = a; + this.sEnglish = b; + } + } + + public static final Base_[] sHTGR_Bases = { new Base_("HTGRFuelMixture", "HTGR fuel mixture"), + new Base_("BISOPebbleCompound", "BISO pebble compound"), + new Base_("TRISOPebbleCompound", "TRISO pebble compound"), new Base_("TRISOBall", "TRISO ball"), + new Base_("TRISOPebble", "TRISO pebble"), new Base_("BurnedOutTRISOBall", "Burned out TRISO Ball"), + new Base_("BurnedOutTRISOPebble", "Burned out TRISO Pebble"), }; + public static final int MATERIALS_PER_FUEL = sHTGR_Bases.length; + static final int USABLE_FUEL_INDEX = 4; + static final int BURNED_OUT_FUEL_INDEX = 5; + public static final Fuel_[] sHTGR_Fuel = { new Fuel_( + "Thorium", + "Thorium", + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 64), + Materials.Uranium235.getDust(4), + GT_Values.NF, + new ItemStack[] { Materials.Silicon.getDust(1), Materials.Graphite.getDust(1), Materials.Carbon.getDust(1), + Materials.Lutetium.getDust(1), WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1) }, + new int[] { 9900 / 4, 9900 / 4, 9900 / 4, 9900 / 4, 162 / 4 }, + "Multiplies coolant by 1"), + new Fuel_( + "Uranium", + "Uranium", + Materials.Uranium.getDust(64), + Materials.Uranium235.getDust(8), + FluidRegistry.getFluidStack("krypton", 4), + new ItemStack[] { Materials.Silicon.getDust(1), Materials.Graphite.getDust(1), + Materials.Carbon.getDust(1), Materials.Lead.getDust(1), Materials.Uranium.getDust(1) }, + new int[] { 9900 / 4, 9900 / 4, 9900 / 4, 5000 / 4, 5000 / 4 }, + "Multiplies coolant by 1.5"), + new Fuel_( + "Plutonium", + "Plutonium", + Materials.Plutonium.getDust(64), + Materials.Plutonium241.getDust(4), + FluidRegistry.getFluidStack("xenon", 4), + new ItemStack[] { Materials.Silicon.getDust(1), Materials.Graphite.getDust(1), + Materials.Carbon.getDust(1), Materials.Lead.getDust(1), Materials.Plutonium.getDust(1) }, + new int[] { 9900 / 4, 9900 / 4, 9900 / 4, 5000 / 4, 5000 / 4 }, + "Multiplies coolant by 2"), }; + public static final CustomHTGRSimpleSubItemClass aHTGR_Materials; + static final ArrayList aHTGR_Localizations = new ArrayList<>(); + + static { + String[] sHTGR_Materials = new String[sHTGR_Bases.length * sHTGR_Fuel.length]; + HashMap tooltip = new HashMap<>(); + int i = 0; + for (Fuel_ fuel : sHTGR_Fuel) for (Base_ base : sHTGR_Bases) { + sHTGR_Materials[i] = "HTGR" + base.sName + fuel.sName; + aHTGR_Localizations.add( + new LangEntry_("item." + sHTGR_Materials[i] + ".name", base.sEnglish + " (" + fuel.sEnglish + ")")); + if ((i + 1) % MATERIALS_PER_FUEL == USABLE_FUEL_INDEX + 1 && fuel.tooltip != null + && !fuel.tooltip.isEmpty()) tooltip.put(i, fuel.tooltip); + i++; + } + aHTGR_Materials = new CustomHTGRSimpleSubItemClass(tooltip, sHTGR_Materials); + } + + public static void registeraTHR_Materials() { + for (LangEntry_ iName : aHTGR_Localizations) + GT_LanguageManager.addStringLocalization(iName.sName, iName.sEnglish); + GameRegistry.registerItem(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, "bw.HTGRMaterials"); + } + + public static void register_fake_THR_Recipes() { + + int i = 0; + for (@SuppressWarnings("unused") + Fuel_ fuel : sHTGR_Fuel) { + + BartWorksRecipeMaps.htgrFakeRecipes.addFakeRecipe( + false, + new ItemStack[] { new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 64, i + 4) }, + new ItemStack[] { new ItemStack(GT_TileEntity_HTGR.HTGRMaterials.aHTGR_Materials, 1, i + 5) }, + null, + null, + null, + 72000, + powerUsage, + 0); + + i += MATERIALS_PER_FUEL; + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java new file mode 100644 index 0000000000..5a2c3ba382 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java @@ -0,0 +1,598 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.Collections; + +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.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.ConnectedBlocksChecker; +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { + + private static final byte TEXID_SIDE = 0; + private static final byte TEXID_CHARGING = 1; + private static final byte TEXID_IDLE = 2; + private static final byte TEXID_EMPTY = 3; + private static final IIcon[] iIcons = new IIcon[4]; + private static final IIconContainer[] iIconContainers = new IIconContainer[4]; + private static final ITexture[][] iTextures = new ITexture[4][1]; + public ConnectedBlocksChecker connectedcells; + public final ItemStack[] circuits = new ItemStack[5]; + private final ItemStackHandler circuitsInventoryHandler = new ItemStackHandler(this.circuits) { + + @Override + public int getSlotLimit(int slot) { + return 1; + } + }; + private long mStorage; + + protected static final NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public GT_TileEntity_LESU(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + this.mStorage = ConfigHandler.energyPerCell; + } + + public GT_TileEntity_LESU(String aName) { + super(aName); + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public long maxEUStore() { + return this.mStorage >= Long.MAX_VALUE - 1 || this.mStorage < 0 ? Long.MAX_VALUE - 1 : this.mStorage; + } + + @Override + public long maxAmperesIn() { + int ret = 0; + for (int i = 0; i < 5; ++i) if (this.circuits[i] != null && this.circuits[i].getItem() + .equals( + GT_Utility.getIntegratedCircuit(0) + .getItem())) + ret += this.circuits[i].getItemDamage(); + return ret > 0 ? ret : 1; + } + + @Override + public long maxAmperesOut() { + return this.maxAmperesIn(); + } + + @Override + public long maxEUInput() { + + for (int i = 1; i < GT_Values.V.length; i++) { + if (this.maxEUOutput() <= GT_Values.V[i] && this.maxEUOutput() > GT_Values.V[i - 1]) + return Math.min(GT_Values.V[i], 32768L); + } + + return 8; + } + + @Override + public long maxEUOutput() { + return Math.min(Math.max(this.mStorage / ConfigHandler.energyPerCell, 1L), 32768L); + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 1; + } + + @Override + public int dechargerSlotStartIndex() { + return 1; + } + + @Override + public int dechargerSlotCount() { + return 1; + } + + @Override + public boolean isTeleporterCompatible() { + return true; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_LESU(this.mName); + } + + @Override + public String[] getDescription() { + ArrayList e = new ArrayList<>(); + String[] dsc = StatCollector.translateToLocal("tooltip.tile.lesu.0.name") + .split(";"); + Collections.addAll(e, dsc); + e.add( + StatCollector.translateToLocal("tooltip.tile.lesu.1.name") + " " + + GT_Utility.formatNumbers(ConfigHandler.energyPerCell) + + "EU"); + dsc = StatCollector.translateToLocal("tooltip.tile.lesu.2.name") + .split(";"); + Collections.addAll(e, dsc); + e.add(ChatColorHelper.RED + StatCollector.translateToLocal("tooltip.tile.lesu.3.name")); + e.add(BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + return e.toArray(new String[0]); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + + for (int i = 0; i < GT_TileEntity_LESU.iTextures.length; i++) { + GT_TileEntity_LESU.iIcons[i] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":LESU_CASING_" + i); + int finalI = i; + GT_TileEntity_LESU.iIconContainers[i] = new IIconContainer() { + + @Override + public IIcon getIcon() { + return GT_TileEntity_LESU.iIcons[finalI]; + } + + @Override + public IIcon getOverlayIcon() { + return GT_TileEntity_LESU.iIcons[finalI]; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(MainMod.MOD_ID + ":LESU_CASING_" + finalI); + } + }; + } + } + + public boolean isClientSide() { + if (this.getWorld() != null) return this.getWorld().isRemote ? FMLCommonHandler.instance() + .getSide() == Side.CLIENT + : FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + return FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + + ITexture[] ret = {}; + + if (this.isClientSide()) { + + for (int i = 0; i < GT_TileEntity_LESU.iTextures.length; i++) { + GT_TileEntity_LESU.iTextures[i][0] = TextureFactory + .of(GT_TileEntity_LESU.iIconContainers[i], Dyes.getModulation(0, Dyes.MACHINE_METAL.mRGBa)); + } + + if (side == facing && this.getBaseMetaTileEntity() + .getUniversalEnergyStored() <= 0) ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_EMPTY]; + else if (side == facing && !aActive) ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_IDLE]; + else if (side == facing && aActive) ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_CHARGING]; + else ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_SIDE]; + } + + return ret; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return true; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return true; + } + + @Override + public int getSizeInventory() { + return 6; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + if (slotIn > 1) return this.circuits[slotIn - 2]; + return this.mInventory[slotIn]; + } + + @Override + public void setInventorySlotContents(int index, ItemStack stack) { + if (index < 2) this.mInventory[index] = stack; + else this.circuits[index - 2] = stack; + } + + @Override + public String getInventoryName() { + return "L.E.S.U."; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + + return switch (index) { + case 0, 1 -> true; + default -> stack != null && stack.getItem() + .equals( + GT_Utility.getIntegratedCircuit(0) + .getItem()); + }; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + this.checkMachine(aBaseMetaTileEntity, null); + super.onFirstTick(aBaseMetaTileEntity); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + this.mMaxProgresstime = 1; + if (aTick % 20 == 0) this.checkMachine(aBaseMetaTileEntity, null); + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + } + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + this.mMaxProgresstime = 1; + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setIntArray("customCircuitInv", GT_Utility.stacksToIntArray(this.circuits)); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + int[] stacks = aNBT.getIntArray("customCircuitInv"); + for (int i = 0; i < stacks.length; i++) { + this.circuits[i] = GT_Utility.intToStack(stacks[i]); + } + super.loadNBTData(aNBT); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + long startingTime = System.nanoTime(); + this.connectedcells = new ConnectedBlocksChecker(); + this.connectedcells.get_connected( + aBaseMetaTileEntity.getWorld(), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + ItemRegistry.BW_BLOCKS[1]); + + if (this.connectedcells.get_meta_of_sideblocks( + aBaseMetaTileEntity.getWorld(), + this.getBaseMetaTileEntity() + .getMetaTileID(), + new int[] { aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord() }, + true)) { + this.getBaseMetaTileEntity() + .disableWorking(); + this.getBaseMetaTileEntity() + .setActive(false); + this.mStorage = 0; + this.mMaxProgresstime = 0; + this.mProgresstime = 0; + return false; + } + + this.mEfficiency = this.getMaxEfficiency(null); + this.mStorage = ConfigHandler.energyPerCell * this.connectedcells.hashset.size() >= Long.MAX_VALUE - 1 + || ConfigHandler.energyPerCell * this.connectedcells.hashset.size() < 0 ? Long.MAX_VALUE - 1 + : ConfigHandler.energyPerCell * this.connectedcells.hashset.size(); + this.mMaxProgresstime = 1; + this.mProgresstime = 0; + + this.mCrowbar = true; + this.mHardHammer = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mSolderingTool = true; + this.mWrench = true; + + this.getBaseMetaTileEntity() + .enableWorking(); + this.getBaseMetaTileEntity() + .setActive(true); + + long finishedTime = System.nanoTime(); + // System.out.println("LESU LookUp: "+((finishedTime - startingTime) / 1000000)+"ms"); + if (finishedTime - startingTime > 5000000) MainMod.LOGGER.warn( + "LESU LookUp took longer than 5ms!(" + (finishedTime - startingTime) + + "ns / " + + (finishedTime - startingTime) / 1000000 + + "ms) Owner:" + + this.getBaseMetaTileEntity() + .getOwnerName() + + " Check at x:" + + this.getBaseMetaTileEntity() + .getXCoord() + + " y:" + + this.getBaseMetaTileEntity() + .getYCoord() + + " z:" + + this.getBaseMetaTileEntity() + .getZCoord() + + " DIM-ID: " + + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + public World getWorld() { + return this.getBaseMetaTileEntity() + .getWorld(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(105, 51)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 4) + .setSize(118, 67)) + .widget(new SlotWidget(new BaseSlot(this.inventoryHandler, 1) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }).setBackground( + this.getGUITextureSet() + .getItemSlot(), + GT_UITextures.OVERLAY_SLOT_IN) + .setPos(127, 13)) + .widget(new SlotWidget(new BaseSlot(this.inventoryHandler, 0) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }).setBackground( + this.getGUITextureSet() + .getItemSlot(), + GT_UITextures.OVERLAY_SLOT_CHARGER) + .setPos(127, 49)); + for (int i = 0; i < 4; i++) { + builder.widget( + new SlotWidget(this.circuitsInventoryHandler, i).setBackground( + this.getGUITextureSet() + .getItemSlot(), + GT_UITextures.OVERLAY_SLOT_INT_CIRCUIT) + .setPos(151, 4 + i * 18)); + } + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + this.drawTexts(screenElements); + builder.widget(screenElements); + + builder.widget( + new DrawableWidget().setDrawable(BW_UITextures.PICTURE_STORED_EU_FRAME) + .setPos(7, 72) + .setSize(118, 7)) + .widget( + new ProgressBar().setProgress( + () -> (float) this.getBaseMetaTileEntity() + .getStoredEU() / this.getBaseMetaTileEntity() + .getEUCapacity()) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(BW_UITextures.PROGRESSBAR_STORED_EU_116, 116) + .setPos(8, 73) + .setSize(116, 5)); + } + + private long clientEU; + private long clientMaxEU; + private long clientMaxIn; + private long clientMaxOut; + private long clientAmps; + + private void drawTexts(DynamicPositionedColumn screenElements) { + screenElements.setSpace(0) + .setPos(11, 8); + + screenElements.widget( + new TextWidget().setStringSupplier(() -> "EU: " + numberFormat.format(this.clientEU)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getStoredEU(), + val -> clientEU = val)) + .widget( + new TextWidget().setStringSupplier(() -> "MAX: " + numberFormat.format(clientMaxEU)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .isActive() + ? this.getBaseMetaTileEntity() + .getOutputVoltage() * ConfigHandler.energyPerCell + : 0, + val -> clientMaxEU = val)) + .widget( + new TextWidget().setStringSupplier(() -> "MAX EU/t IN: " + numberFormat.format(clientMaxIn)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getInputVoltage(), + val -> clientMaxIn = val)) + .widget( + new TextWidget().setStringSupplier(() -> "EU/t OUT: " + numberFormat.format(clientMaxOut)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getOutputVoltage(), + val -> clientMaxOut = val)) + .widget( + new TextWidget().setStringSupplier(() -> "AMP/t IN/OUT: " + numberFormat.format(clientAmps)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getInputAmperage(), + val -> clientAmps = val)) + .widget( + new TextWidget(Text.localised("tooltip.LESU.0.name")).setDefaultColor(Color.YELLOW.getRGB()) + .setEnabled(widget -> this.maxEUStore() >= Long.MAX_VALUE - 1)) + .widget( + new TextWidget(Text.localised("tooltip.LESU.1.name")).setDefaultColor(Color.RED.getRGB()) + .setEnabled( + widget -> !this.getBaseMetaTileEntity() + .isActive())); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java new file mode 100644 index 0000000000..b481429411 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry.BW_BLOCKS; +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + +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; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_EnhancedMultiBlockBase { + + private byte mode; + private int mTiers; + private boolean upstep = true; + + public GT_TileEntity_ManualTrafo(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_ManualTrafo(String aName) { + super(aName); + } + + private static final int CASING_INDEX = 2; + private static final String STRUCTURE_PIECE_BASE = "base"; + private static final String STRUCTURE_PIECE_LAYER = "layer"; + private static final String STRUCTURE_PIECE_TOP = "top"; + private static final String STRUCTURE_PIECE_TAP_LAYER = "taplayer"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { { "b~b", "bbb", "bbb" } })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] { { "ttt", "tft", "ttt" } })) + .addShape(STRUCTURE_PIECE_TOP, transpose(new String[][] { { "ooo", "ooo", "ooo" } })) + .addShape( + STRUCTURE_PIECE_TAP_LAYER, + transpose(new String[][] { { " TTT ", "TtttT", "TtftT", "TtttT", " TTT " } })) + .addElement( + 'b', + ofChain( + ofHatchAdder(GT_TileEntity_ManualTrafo::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_ManualTrafo::addMaintenanceToMachineList, CASING_INDEX, 1), + ofBlock(GregTech_API.sBlockCasings1, 2))) + .addElement( + 'o', + ofHatchAdderOptional( + GT_TileEntity_ManualTrafo::addDynamoToMachineList, + CASING_INDEX, + 2, + GregTech_API.sBlockCasings1, + 2)) + .addElement('t', ofBlock(BW_BLOCKS[2], 1)) + .addElement('f', ofBlock(BW_BLOCKS[2], 0)) + .addElement('T', new IStructureElementNoPlacement() { + + @Override + public boolean check(GT_TileEntity_ManualTrafo te, World world, int x, int y, int z) { + if (world.isAirBlock(x, y, z)) return true; + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity == null || !(tileEntity instanceof IGregTechTileEntity)) return true; + IMetaTileEntity mte = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); + if (mte instanceof GT_MetaTileEntity_Hatch_Dynamo || mte instanceof GT_MetaTileEntity_Hatch_Energy) { + int intier = te.mEnergyHatches.get(0).mTier; + if (((GT_MetaTileEntity_TieredMachineBlock) mte).mTier + == intier + (te.upstep ? te.mTiers : -te.mTiers)) { + te.addToMachineList((IGregTechTileEntity) tileEntity, CASING_INDEX); + return true; + } + return false; + } + return true; + } + + @Override + public boolean spawnHint(GT_TileEntity_ManualTrafo te, World world, int x, int y, int z, + ItemStack itemStack) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 2 /* aDots: 3 */); + return true; + } + }) + .build(); + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Transformer") + .addInfo("Controller block for the Manual Trafo") + .addInfo("Operates in 4 diffrent modes:") + .addInfo("Mode 1: Circuit 0 in controller: Direct-Upstep") + .addInfo("Mode 2: Circuit 1 in controller: Direct-Downstep") + .addInfo("Mode 3: Circuit 2 in controller: Tapped-Upstep (currently disabled)") + .addInfo("Mode 4: Circuit 2 in controller: Tapped-Downstep (currently disabled)") + .addSeparator() + .beginVariableStructureBlock(3, 3, 3, 10, 3, 3, false) + .addController("Front bottom center") + .addCasingInfoMin("MV Machine Casing", 0, false) + .addOtherStructurePart("Transformer-Winding Blocks", "1 Layer for each tier transformed") + .addOtherStructurePart("Nickel-Zinc-Ferrite Blocks", "Middle of Transformer-Winding Blocks") + .addMaintenanceHatch("Any bottom layer casing", 1) + .addEnergyHatch("Any bottom layer casing", 1) + .addDynamoHatch("Any top layer casing", 2) + .addStructureInfo("---------TAPPED MODE---------") + .addEnergyHatch("Touching Transformer-Winding Blocks", 3) + .addDynamoHatch("Touching Transformer-Winding Blocks", 3) + .addStructureInfo("Hatches touching Transformer-Winding Blocks must be tiered from bottom to top") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!this.getBaseMetaTileEntity() + .isAllowedToWork()) this.stopMachine(); + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (!this.getBaseMetaTileEntity() + .isAllowedToWork()) { + this.stopMachine(); + return false; + } + + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + + if (this.getBaseMetaTileEntity() + .getTimer() % 40 == 0) if (this.mEfficiency < this.getMaxEfficiency(null)) this.mEfficiency += 100; + else this.mEfficiency = this.getMaxEfficiency(null); + + if (this.mode > 1) { + return false; // this.onRunningTickTabbedMode(); Tapped mode is disable + } + + return this.drainEnergyInput(this.getInputTier() * 2 * this.mEnergyHatches.size()) && this.addEnergyOutput( + this.getInputTier() * 2 * this.mEnergyHatches.size() * this.mEfficiency / this.getMaxEfficiency(null)); + } + + public boolean onRunningTickTabbedMode() { + boolean ret = false; + for (GT_MetaTileEntity_Hatch_Dynamo E : this.mDynamoHatches) { + for (GT_MetaTileEntity_Hatch_Energy I : this.mEnergyHatches) { + + long vtt = I.getEUVar() >= V[E.mTier] / 2 && E.getEUVar() < E.maxEUStore() ? I.getEUVar() : 0; + + if (vtt == 0) continue; + + long vtp = E.getEUVar() + vtt; + long avt = Math.min(vtp, E.maxEUStore()); + E.setEUVar(avt); + I.setEUVar(I.getEUVar() - vtt); + ret = true; + } + } + return ret; + } + + @Override + public long getInputTier() { + if (this.mEnergyHatches.size() > 0) return GT_Utility.getTier( + this.mEnergyHatches.get(0) + .getBaseMetaTileEntity() + .getInputVoltage()); + return 0L; + } + + @Override + public long getOutputTier() { + if (this.mDynamoHatches.size() > 0) return GT_Utility.getTier( + this.mDynamoHatches.get(0) + .getBaseMetaTileEntity() + .getOutputVoltage()); + return 0L; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + + if (!this.getBaseMetaTileEntity() + .isAllowedToWork()) { + this.stopMachine(); + return false; + } + if (itemStack == null || !itemStack.getUnlocalizedName() + .startsWith("gt.integrated_circuit")) this.mode = 0; + else this.mode = (byte) Math.min(3, itemStack.getItemDamage()); + this.upstep = this.mode % 2 == 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + this.mEfficiency = Math.max(this.mEfficiency, 100); + return this.upstep ? this.getOutputTier() - this.getInputTier() == this.mTiers + : this.getInputTier() - this.getOutputTier() == this.mTiers; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + + if (itemStack == null || !itemStack.getUnlocalizedName() + .startsWith("gt.integrated_circuit")) this.mode = 0; + else this.mode = (byte) Math.min(3, itemStack.getItemDamage()); + + this.upstep = this.mode % 2 == 0; + boolean tapmode = this.mode > 1; + + if (!this.checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0) || this.mEnergyHatches.size() == 0) return false; + + byte intier = this.mEnergyHatches.get(0).mTier; + for (GT_MetaTileEntity_Hatch_Energy in : this.mEnergyHatches) if (in.mTier != intier) return false; + + int mHeight; + for (mHeight = 1; mHeight <= 8; mHeight++) { + if (tapmode) { + this.mTiers = mHeight; + if (!this.checkPiece(STRUCTURE_PIECE_TAP_LAYER, 2, mHeight, 1)) break; + } else if (!this.checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) break; + } + if (!this.checkPiece(STRUCTURE_PIECE_TOP, 1, mHeight, 0)) return false; + this.mTiers = mHeight - 1; + + if (this.mDynamoHatches.size() == 0 || this.mMaintenanceHatches.size() != 1 || this.mTiers == 0) return false; + + byte outtier = this.mDynamoHatches.get(0).mTier; + for (GT_MetaTileEntity_Hatch_Dynamo out : this.mDynamoHatches) { + if (out.mTier != outtier) return false; + } + + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return true; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_ManualTrafo(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound ntag) { + super.saveNBTData(ntag); + ntag.setInteger("mTiers", this.mTiers); + ntag.setByte("mMode", this.mode); + ntag.setBoolean("upstep", this.upstep); + } + + @Override + public void loadNBTData(NBTTagCompound ntag) { + super.loadNBTData(ntag); + this.mTiers = ntag.getInteger("mTiers"); + this.mode = ntag.getByte("mMode"); + this.upstep = ntag.getBoolean("upstep"); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + if (this.mInventory[1] == null || !this.mInventory[1].getUnlocalizedName() + .startsWith("gt.integrated_circuit")) this.mode = 0; + else this.mode = (byte) Math.min(3, this.mInventory[1].getItemDamage()); + int mHeight = Math.min(itemStack.stackSize, 8); + boolean tapmode = this.mode > 1; + this.buildPiece(STRUCTURE_PIECE_BASE, itemStack, b, 1, 0, 0); + for (int i = 0; i < mHeight; i++) { + if (tapmode) this.buildPiece(STRUCTURE_PIECE_TAP_LAYER, itemStack, b, 2, i + 1, 1); + else this.buildPiece(STRUCTURE_PIECE_LAYER, itemStack, b, 1, i + 1, 0); + } + this.buildPiece(STRUCTURE_PIECE_TOP, itemStack, b, 1, mHeight + 1, 0); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java new file mode 100644 index 0000000000..e7a2b090c9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java @@ -0,0 +1,413 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +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.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.items.SimpleSubItemClass; +import com.github.bartimaeusnek.bartworks.util.MathUtils; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_THTR extends GT_MetaTileEntity_EnhancedMultiBlockBase { + + private static final int BASECASINGINDEX = 44; + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " BBBBBBB ", " BBBBBBBBB ", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", + "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", " BBBBBBBBB ", " BBBBBBB " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " bbb~bbb ", " bbbbbbbbb ", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", + "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", " bbbbbbbbb ", " bbbbbbb " }, })) + .addElement('c', onElementPass(x -> x.mCasing++, ofBlock(GregTech_API.sBlockCasings3, 12))) + .addElement( + 'b', + ofChain( + ofHatchAdder(GT_TileEntity_THTR::addOutputToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(GT_TileEntity_THTR::addMaintenanceToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(GT_TileEntity_THTR::addEnergyInputToMachineList, BASECASINGINDEX, 1), + onElementPass(x -> x.mCasing++, ofBlock(GregTech_API.sBlockCasings3, 12)))) + .addElement( + 'B', + ofChain( + ofHatchAdder(GT_TileEntity_THTR::addInputToMachineList, BASECASINGINDEX, 2), + onElementPass(x -> x.mCasing++, ofBlock(GregTech_API.sBlockCasings3, 12)))) + // ofHatchAdderOptional(GT_TileEntity_THTR::addInputToMachineList, BASECASINGINDEX, 2, + // GregTech_API.sBlockCasings3, 12)) + .build(); + + private static final int HELIUM_NEEDED = 730000; + private static final int powerUsage = (int) TierEU.RECIPE_IV / 2; + private static final int maxcapacity = 675000; + private static final int mincapacity = 100000; + private int HeliumSupply; + private int fuelsupply; + private boolean empty; + private int coolanttaking = 0; + private int mCasing = 0; + + public GT_TileEntity_THTR(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private GT_TileEntity_THTR(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("High Temperature Reactor") + .addInfo("Controller block for the Thorium High Temperature Reactor (THTR)") + .addInfo("Needs to be primed with " + GT_Utility.formatNumbers(HELIUM_NEEDED) + " of helium") + .addInfo("Needs a constant supply of coolant while running") + .addInfo("Needs at least 100k Fuel pebbles to start operation (can hold up to 675k pebbles)") + .addInfo("Consumes up to 0.5% of total Fuel Pellets per Operation depending on efficiency") + .addInfo("Efficiency decreases exponentially if the internal buffer is not completely filled") + .addInfo("Reactor will take 4 800L/t of coolant multiplied by efficiency") + .addInfo("Uses " + GT_Utility.formatNumbers(powerUsage) + " EU/t") + .addInfo("One Operation takes 9 hours") + .addSeparator() + .beginStructureBlock(11, 12, 11, true) + .addController("Front bottom center") + .addCasingInfoMin("Radiation Proof Casings", 500, false) + .addStructureInfo("Corners and the 2 touching blocks are air (cylindric)") + .addInputBus("Any top layer casing", 2) + .addInputHatch("Any top layer casing", 2) + .addOutputBus("Any bottom layer casing", 1) + .addOutputHatch("Any bottom layer casing", 1) + .addEnergyHatch("Any bottom layer casing", 1) + .addMaintenanceHatch("Any bottom layer casing", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 5, 11, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + this.mCasing = 0; + return this.checkPiece(STRUCTURE_PIECE_MAIN, 5, 11, 0) && this.mCasing >= 500 + && this.mMaintenanceHatches.size() == 1 + && this.mInputHatches.size() > 0 + && this.mOutputHatches.size() > 0 + && this.mInputBusses.size() > 0 + && this.mOutputBusses.size() > 0 + && this.mEnergyHatches.size() > 0; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.HeliumSupply = aNBT.getInteger("HeliumSupply"); + this.fuelsupply = aNBT.getInteger("fuelsupply"); + this.coolanttaking = aNBT.getInteger("coolanttaking"); + this.empty = aNBT.getBoolean("EmptyMode"); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("HeliumSupply", this.HeliumSupply); + aNBT.setInteger("fuelsupply", this.fuelsupply); + aNBT.setInteger("coolanttaking", this.coolanttaking); + aNBT.setBoolean("EmptyMode", this.empty); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && !this.empty) { + if (this.HeliumSupply < GT_TileEntity_THTR.HELIUM_NEEDED) { + for (FluidStack fluidStack : this.getStoredFluids()) { + if (fluidStack.isFluidEqual(Materials.Helium.getGas(1))) { + int toget = Math.min(GT_TileEntity_THTR.HELIUM_NEEDED - this.HeliumSupply, fluidStack.amount); + fluidStack.amount -= toget; + this.HeliumSupply += toget; + if (GT_TileEntity_THTR.HELIUM_NEEDED == this.HeliumSupply && fluidStack.amount == 0) + fluidStack = null; + } + } + } + if (this.fuelsupply < maxcapacity) { + this.startRecipeProcessing(); + for (ItemStack itemStack : this.getStoredInputs()) { + if (GT_Utility.areStacksEqual( + itemStack, + new ItemStack(THTRMaterials.aTHTR_Materials, 1, THTRMaterials.MATERIAL_FUEL_INDEX))) { + int toget = Math.min(maxcapacity - this.fuelsupply, itemStack.stackSize); + if (toget == 0) continue; + itemStack.stackSize -= toget; + this.fuelsupply += toget; + } + } + this.endRecipeProcessing(); + this.updateSlots(); + } + } + } + + @Override + public boolean checkRecipe(ItemStack controllerStack) { + + if (this.empty) { + if (this.HeliumSupply > 0 || this.fuelsupply > 0) { + this.mEfficiency = 10000; + this.mMaxProgresstime = 100; + return true; + } + return false; + } + if (this.HeliumSupply < GT_TileEntity_THTR.HELIUM_NEEDED || this.fuelsupply < mincapacity) return false; + + double eff = Math + .min(Math.pow((this.fuelsupply - mincapacity) / ((maxcapacity - mincapacity) / 10D), 2D) + 1, 100D) / 100D + - (this.getIdealStatus() - this.getRepairStatus()) / 10D; + if (eff <= 0D) return false; + + int toReduce = MathUtils.floorInt(this.fuelsupply * 0.005D * eff); + + final int originalToReduce = toReduce; + int burnedballs = toReduce / 64; + if (burnedballs > 0) toReduce -= burnedballs * 64; + + int meta = THTRMaterials.MATERIAL_USED_FUEL_INDEX; + + ItemStack[] toOutput = { new ItemStack(THTRMaterials.aTHTR_Materials, burnedballs, meta), + new ItemStack(THTRMaterials.aTHTR_Materials, toReduce, meta + 1) }; + if (!this.canOutputAll(toOutput)) return false; + + this.fuelsupply -= originalToReduce; + this.mOutputItems = toOutput; + + // this.updateSlots(); not needed ? + + this.coolanttaking = (int) (4800D * eff); + this.mEfficiency = (int) (eff * 10000D); + this.mEUt = -powerUsage; + this.mMaxProgresstime = 648000; + return true; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + + if (this.empty) { + this.addOutput(Materials.Helium.getGas(this.HeliumSupply)); + this.addOutput( + new ItemStack(THTRMaterials.aTHTR_Materials, this.fuelsupply, THTRMaterials.MATERIAL_FUEL_INDEX)); + this.HeliumSupply = 0; + this.fuelsupply = 0; + this.updateSlots(); + return true; + } + + if (!super.onRunningTick(aStack)) return false; + + int takecoolant = this.coolanttaking; + int drainedamount = 0; + + for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { + FluidStack drained = tHatch.drain(takecoolant, true); + takecoolant -= drained.amount; + drainedamount += drained.amount; + if (takecoolant <= 0) break; + } + } + + if (drainedamount > 0) this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); + + this.updateSlots(); + + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_THTR(this.mName); + } + + @Override + public String[] getInfoData() { + return new String[] { "Progress:", + GT_Utility.formatNumbers(this.mProgresstime / 20) + "secs /" + + GT_Utility.formatNumbers(this.mMaxProgresstime / 20) + + "secs", + "TRISO-Pebbles:", + GT_Utility.formatNumbers(this.fuelsupply) + "pcs. / " + GT_Utility.formatNumbers(this.fuelsupply) + "psc.", + "Helium-Level:", + GT_Utility.formatNumbers(this.HeliumSupply) + "L / " + + GT_Utility.formatNumbers(GT_TileEntity_THTR.HELIUM_NEEDED) + + "L", + "Coolant/t:", GT_Utility.formatNumbers(this.mProgresstime == 0 ? 0 : this.coolanttaking) + "L/t", + "Problems:", String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_THTR.BASECASINGINDEX), TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_THTR.BASECASINGINDEX), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(GT_TileEntity_THTR.BASECASINGINDEX) }; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mMaxProgresstime > 0) { + GT_Utility.sendChatToPlayer(aPlayer, "THTR mode cannot be changed while the machine is running."); + return; + } + this.empty = !this.empty; + GT_Utility.sendChatToPlayer( + aPlayer, + "THTR is now running in " + (this.empty ? "emptying mode." : "normal Operation")); + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + public static class THTRMaterials { + + public static final SimpleSubItemClass aTHTR_Materials = new SimpleSubItemClass( + "BISOPelletCompound", // 0 + "BISOPelletBall", // 1 + "TRISOPelletCompound", // 2 + "TRISOPelletBall", // 3 + "TRISOPellet", // 4 + "BurnedOutTRISOPelletBall", // 5 + "BurnedOutTRISOPellet" // 6 + ); + public static final int MATERIAL_FUEL_INDEX = 4; + public static final int MATERIAL_USED_FUEL_INDEX = 5; + + public static void registeraTHR_Materials() { + GameRegistry.registerItem(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, "bw.THTRMaterials"); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java new file mode 100644 index 0000000000..a1e1f1fd46 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java @@ -0,0 +1,641 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofTileAdder; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_Values.V; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.items.BW_Stonage_Rotors; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_RotorBlock; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IGetTitleColor; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +public class GT_TileEntity_Windmill extends GT_MetaTileEntity_EnhancedMultiBlockBase + implements ISurvivalConstructable, IGetTitleColor { + + private static final IIcon[] iIcons = new IIcon[2]; + private static final IIconContainer[] iIconContainers = new IIconContainer[2]; + private static final ITexture[] iTextures = new ITexture[3]; + + private BW_RotorBlock rotorBlock; + private int mDoor = 0; + private int mHardenedClay = 0; + private int mMulti = 16; + + public GT_TileEntity_Windmill(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private GT_TileEntity_Windmill(String aName) { + super(aName); + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { " ", " ", " ", " p ", " ", " ", " " }, + { " ", " ", " ppp ", " p p ", " ppp ", " ", " " }, + { " ", " ppppp ", " p p ", " p p ", " p p ", " ppppp ", " " }, + { " ppppp ", "p p", "p p", "p p", "p p", "p p", " ppppp " }, + { " ppspp ", "p p", "p p", "p p", "p p", "p p", " ppppp " }, + { " ppppp ", "p p", "p p", "p p", "p p", "p p", " ppppp " }, + { " ", " ppppp ", " p p ", " p p ", " p p ", " ppppp ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " bb~bb ", "bbbbbbb", "bbbbbbb", "bbbbbbb", "bbbbbbb", "bbbbbbb", " bbbbb " }, })) + .addElement('p', ofBlockAnyMeta(Blocks.planks)) + .addElement( + 'c', + ofChain( + onElementPass(t -> t.mHardenedClay++, ofBlock(Blocks.hardened_clay, 0)), + ofTileAdder(GT_TileEntity_Windmill::addDispenserToOutputSet, Blocks.hardened_clay, 0), + onElementPass(t -> t.mDoor++, new IStructureElementNoPlacement() { + + private final IStructureElement delegate = ofBlock(Blocks.wooden_door, 0); + + @Override + public boolean check(GT_TileEntity_Windmill gt_tileEntity_windmill, World world, int x, int y, + int z) { + return this.delegate.check(gt_tileEntity_windmill, world, x, y, z); + } + + @Override + public boolean spawnHint(GT_TileEntity_Windmill gt_tileEntity_windmill, World world, int x, int y, + int z, ItemStack trigger) { + return this.delegate.spawnHint(gt_tileEntity_windmill, world, x, y, z, trigger); + } + }))) + .addElement('b', ofBlock(Blocks.brick_block, 0)) + .addElement('s', new IStructureElement() { + + @Override + public boolean check(GT_TileEntity_Windmill t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return t.setRotorBlock(tileEntity); + } + + @Override + public boolean spawnHint(GT_TileEntity_Windmill t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 0); + return true; + } + + @Override + public boolean placeBlock(GT_TileEntity_Windmill gt_tileEntity_windmill, World world, int x, int y, int z, + ItemStack trigger) { + return false; + } + + @Override + public BlocksToPlace getBlocksToPlace(GT_TileEntity_Windmill gt_tileEntity_windmill, World world, int x, + int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { + return BlocksToPlace.create(new ItemStack(ItemRegistry.ROTORBLOCK)); + } + }) + .build(); + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Windmill") + .addInfo("Controller block for the Windmill") + .addInfo("A primitive Grinder powered by Kinetic energy") + .addInfo("Speed and output will be affected by wind speed, recipe and rotor") + .addInfo("Please use the Primitive Rotor") + .addInfo("Macerates 16 items at a time") + .addInfo("The structure is too complex!") + .addInfo("Follow the StructureLib hologram projector to build the main structure.") + .addSeparator() + .beginStructureBlock(7, 12, 7, false) + .addController("Front bottom center") + .addCasingInfoMin("Hardened Clay block", 40, false) + .addOtherStructurePart("Dispenser", "Any Hardened Clay block") + .addOtherStructurePart("0-1 Wooden door", "Any Hardened Clay block") + .addStructureHint("Primitive Kinetic Shaftbox", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + private final Set tileEntityDispensers = new HashSet<>(); + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mMaxProgresstime > 0) this.mProgresstime += this.rotorBlock.getGrindPower(); + if (!this.rotorBlock.rotorSlot.isEmpty()) this.setRotorDamage(this.rotorBlock, this.rotorBlock.getGrindPower()); + return this.rotorBlock.getGrindPower() > 0; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return true; + } + + @Override + public boolean doRandomMaintenanceDamage() { + return true; + } + + private float[] multiplierRecipe(ItemStack itemStack) { + // will return max and min value of the multiplier, the average of these is used to calculate the multiplier. + final Item item = itemStack.getItem(); + if (item == Items.wheat) { + return new float[] { 1.13f, 1.5f }; + } + final Block block = Block.getBlockFromItem(item); + if (item == Items.bone || block == Blocks.glowstone || block == Blocks.pumpkin) { + return new float[] { 0.8f, 1f }; + } + if (block == Blocks.gravel || block == Blocks.cobblestone + || block == Blocks.stone + || block == Blocks.sandstone + || block == Blocks.clay + || block == Blocks.hardened_clay + || block == Blocks.stained_hardened_clay + || block == Blocks.wool + || block == Blocks.netherrack + || block == Blocks.log + || block == Blocks.log2) { + return new float[] { 1f, 1.5f }; + } + final ItemData association = GT_OreDictUnificator.getAssociation(itemStack); + final OrePrefixes prefix = association == null ? null : association.mPrefix; + if (prefix == null || association.mMaterial == null + || association.mMaterial.mMaterial == null + || association.mMaterial.mMaterial.getDust(1) == null) { + return new float[] { 1f, 1f }; + } + if (OrePrefixes.ore == prefix || OrePrefixes.oreNetherrack == prefix + || OrePrefixes.oreEndstone == prefix + || OrePrefixes.oreBlackgranite == prefix + || OrePrefixes.oreRedgranite == prefix + || OrePrefixes.oreMarble == prefix + || OrePrefixes.oreBasalt == prefix) { + return new float[] { 0.5f, 1f }; + } + if (OrePrefixes.stone == prefix || OrePrefixes.stoneBricks == prefix + || OrePrefixes.stoneChiseled == prefix + || OrePrefixes.stoneCobble == prefix + || OrePrefixes.stoneCracked == prefix + || OrePrefixes.stoneMossy == prefix + || OrePrefixes.stoneMossyBricks == prefix + || OrePrefixes.stoneSmooth == prefix + || OrePrefixes.cobblestone == prefix) { + return new float[] { 1f, 1.5f }; + } + return new float[] { 1f, 1f }; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + if (itemStack == null || itemStack.getItem() == null) return false; + + if (this.mOutputItems == null) this.mOutputItems = new ItemStack[2]; + + GT_Recipe tRecipe = RecipeMaps.maceratorRecipes + .findRecipe(this.getBaseMetaTileEntity(), false, false, V[1], null, itemStack); + if (tRecipe == null) { + return false; + } + + if (tRecipe.getOutput(0) != null) { + // Decrease input stack by appropriate amount (Not always 1) + for (int i = 0; i < this.mMulti; i++) { + if (!tRecipe.isRecipeInputEqual(true, null, itemStack)) { + this.mMulti = i; + break; + } + } + this.updateSlots(); + this.mOutputItems[0] = tRecipe.getOutput(0); + float[] mRecipe = this.multiplierRecipe(itemStack); + float multiper = Math.min( + mRecipe[1], + Math.max( + mRecipe[0], + 2f * (float) Math.sqrt((float) 1 / (this.rotorBlock.getWindStrength() + 1)) + * this.OutputMultiplier(this.rotorBlock) + * (mRecipe[0] + mRecipe[1]))); + int amount = (int) Math.floor(multiper * (this.mOutputItems[0].stackSize * this.mMulti)); + + // Split ItemStack --by gtpp + List splitStacks = new ArrayList<>(); + while (amount > this.mOutputItems[0].getMaxStackSize()) { + ItemStack tmp = this.mOutputItems[0].copy(); + tmp.stackSize = this.mOutputItems[0].getMaxStackSize(); + amount -= this.mOutputItems[0].getMaxStackSize(); + splitStacks.add(tmp); + } + ItemStack tmp = this.mOutputItems[0].copy(); + tmp.stackSize = amount; + splitStacks.add(tmp); + this.mOutputItems = splitStacks.toArray(new ItemStack[splitStacks.size()]); + } + this.mMaxProgresstime = tRecipe.mDuration * 2 * 100 * this.mMulti / this.getSpeed(this.rotorBlock); + this.mMulti = 16; + return true; + } + + @Override + public void stopMachine() { + this.getBaseMetaTileEntity() + .disableWorking(); + } + + public boolean addDispenserToOutputSet(TileEntity aTileEntity) { + if (aTileEntity instanceof TileEntityDispenser) { + this.tileEntityDispensers.add((TileEntityDispenser) aTileEntity); + return true; + } + return false; + } + + public boolean setRotorBlock(TileEntity aTileEntity) { + if (aTileEntity instanceof BW_RotorBlock) { + this.rotorBlock = (BW_RotorBlock) aTileEntity; + return true; + } + return false; + } + + @Override + public boolean addOutput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + + for (TileEntityDispenser tHatch : this.tileEntityDispensers) { + for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getStackInSlot(i) == null || GT_Utility.areStacksEqual(tHatch.getStackInSlot(i), aStack) + && aStack.stackSize + tHatch.getStackInSlot(i).stackSize <= 64) { + if (GT_Utility.areStacksEqual(tHatch.getStackInSlot(i), aStack)) { + ItemStack merge = tHatch.getStackInSlot(i) + .copy(); + merge.stackSize = aStack.stackSize + tHatch.getStackInSlot(i).stackSize; + tHatch.setInventorySlotContents(i, merge); + } else { + tHatch.setInventorySlotContents(i, aStack.copy()); + } + + if (GT_Utility.areStacksEqual(tHatch.getStackInSlot(i), aStack)) { + aStack = null; + return true; + } + tHatch.setInventorySlotContents(i, null); + aStack = null; + return false; + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + + this.tileEntityDispensers.clear(); + this.mDoor = 0; + this.mHardenedClay = 0; + + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 3, 11, 0) || this.tileEntityDispensers.isEmpty() + || this.mDoor > 2 + || this.mHardenedClay < 40) return false; + + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + + return true; + } + + @Override + public int getCurrentEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public void updateSlots() { + if (this.mInventory[1] != null && this.mInventory[1].stackSize <= 0) { + this.mInventory[1] = null; + } + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_Windmill(this.mName); + } + + @Override + public String[] getInfoData() { + return new String[] { "Progress:", + this.mProgresstime + " Grindings of " + this.mMaxProgresstime + " needed Grindings", "GrindPower:", + this.rotorBlock.getGrindPower() + "KU/t" }; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + GT_TileEntity_Windmill.iIcons[0] = Blocks.brick_block.getIcon(0, 0); + GT_TileEntity_Windmill.iIconContainers[0] = new IIconContainer() { + + @Override + public IIcon getIcon() { + return GT_TileEntity_Windmill.iIcons[0]; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation("brick"); + } + }; + + GT_TileEntity_Windmill.iIcons[1] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":windmill_top"); + GT_TileEntity_Windmill.iIconContainers[1] = new IIconContainer() { + + @Override + public IIcon getIcon() { + return GT_TileEntity_Windmill.iIcons[1]; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(MainMod.MOD_ID + ":windmill_top"); + } + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + + ITexture[] ret = new ITexture[6]; + + if (this.isClientSide()) { + + if (facing == side || side == ForgeDirection.DOWN) { + GT_TileEntity_Windmill.iTextures[0] = TextureFactory.of(GT_TileEntity_Windmill.iIconContainers[0]); + Arrays.fill(ret, GT_TileEntity_Windmill.iTextures[0]); + } else if (side == ForgeDirection.UP) { + GT_TileEntity_Windmill.iTextures[1] = TextureFactory.of(GT_TileEntity_Windmill.iIconContainers[1]); + Arrays.fill(ret, GT_TileEntity_Windmill.iTextures[1]); + } else { + GT_TileEntity_Windmill.iTextures[2] = TextureFactory.of(Textures.BlockIcons.COVER_WOOD_PLATE); + Arrays.fill(ret, GT_TileEntity_Windmill.iTextures[2]); + } + } + return ret; + } + + public boolean isClientSide() { + if (this.getBaseMetaTileEntity() + .getWorld() != null) + return this.getBaseMetaTileEntity() + .getWorld().isRemote + ? FMLCommonHandler.instance() + .getSide() == Side.CLIENT + : FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + return FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 3, 11, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 11, 0, elementBudget, env, false, true); + } + + public float OutputMultiplier(BW_RotorBlock rotorBlock) { + try { + return ((BW_Stonage_Rotors) rotorBlock.rotorSlot.get() + .getItem()).getmRotor(); + } catch (Exception e) { + return 1f; + } + } + + public int getSpeed(BW_RotorBlock rotorBlock) { + try { + return ((BW_Stonage_Rotors) rotorBlock.rotorSlot.get() + .getItem()).getSpeed(); + } catch (Exception e) { + return 1; + } + } + + public void setRotorDamage(BW_RotorBlock rotorBlock, int damage) { + try { + ((BW_Stonage_Rotors) rotorBlock.rotorSlot.get() + .getItem()).damageItemStack(rotorBlock.rotorSlot.get(), damage); + } catch (Exception e) { + rotorBlock.rotorSlot.damage(damage, false); + } + } + + @Override + public GUITextureSet getGUITextureSet() { + return new GUITextureSet().setMainBackground(BW_UITextures.BACKGROUND_BROWN) + .setItemSlot(BW_UITextures.SLOT_BROWN) + .setTitleTab( + BW_UITextures.TAB_TITLE_BROWN, + BW_UITextures.TAB_TITLE_DARK_BROWN, + BW_UITextures.TAB_TITLE_ANGULAR_BROWN); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(BW_UITextures.PICTURE_BW_LOGO_47X21) + .setSize(47, 21) + .setPos(123, 59)); + } + + @Override + public int getTitleColor() { + return this.COLOR_TITLE_WHITE.get(); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new SlotWidget(this.inventoryHandler, 1).setBackground( + this.getGUITextureSet() + .getItemSlot()) + .setPos(59, 35)) + .widget(new DrawableWidget() { + + private static final int DIVIDER = 125; + + @Override + public void onScreenUpdate() { + super.onScreenUpdate(); + if (GT_TileEntity_Windmill.this.mMaxProgresstime > 0) { + if (System.currentTimeMillis() / DIVIDER % 40 == 30) + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[3]); + else if (System.currentTimeMillis() / DIVIDER % 40 == 20) + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[2]); + else if (System.currentTimeMillis() / DIVIDER % 40 == 10) + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[1]); + else if (System.currentTimeMillis() / DIVIDER % 40 == 0) + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[0]); + } else { + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_EMPTY); + } + } + }.setDrawable(BW_UITextures.PICTURE_WINDMILL_EMPTY) + .setPos(85, 27) + .setSize(32, 32)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> this.mMaxProgresstime, val -> this.mMaxProgresstime = val)) + .widget( + new ItemDrawable( + () -> this.mMachine && !this.getBaseMetaTileEntity() + .isActive() + ? GT_MetaGenerated_Tool_01.INSTANCE + .getToolWithStats(GT_MetaGenerated_Tool_01.SOFTMALLET, 1, null, null, null) + : null).asWidget() + .setPos(66, 66)) + .widget( + new FakeSyncWidget.BooleanSyncer( + () -> this.getBaseMetaTileEntity() + .isActive(), + val -> this.getBaseMetaTileEntity() + .setActive(val))) + .widget( + new TextWidget(GT_Utility.trans("138", "Incomplete Structure.")) + .setDefaultColor(this.COLOR_TEXT_WHITE.get()) + .setMaxWidth(150) + .setEnabled(widget -> !this.mMachine) + .setPos(92, 22)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> this.mMachine, val -> this.mMachine = val)); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java new file mode 100644 index 0000000000..c8ea85d182 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +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.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_Utility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Arrays; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +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.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlockBase + implements ISurvivalConstructable { + + private static final int CASING_INDEX = 11; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape("main", createShape()) + .addElement('=', StructureElementAirNoHint.getInstance()) + .addElement( + 't', + buildHatchAdder(GT_TileEntity_MegaBlastFurnace.class) + .atLeast( + OutputHatch.withAdder(GT_TileEntity_MegaBlastFurnace::addOutputHatchToTopList) + .withCount(t -> t.mPollutionOutputHatches.size())) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTech_API.sBlockCasings1, CASING_INDEX)) + .addElement('m', Muffler.newAny(CASING_INDEX, 2)) + .addElement( + 'C', + withChannel( + "coil", + ofCoil(GT_TileEntity_MegaBlastFurnace::setCoilLevel, GT_TileEntity_MegaBlastFurnace::getCoilLevel))) + .addElement( + 'g', + withChannel( + "glass", + BorosilicateGlass + .ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier))) + .addElement( + 'b', + buildHatchAdder(GT_TileEntity_MegaBlastFurnace.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTech_API.sBlockCasings1, CASING_INDEX)) + .build(); + + private static String[][] createShape() { + String[][] raw = new String[20][]; + + raw[0] = new String[15]; + String topCasing = "ttttttttttttttt"; + String middleTopCasing = "tttttttmttttttt"; + raw[0][0] = topCasing; + for (int i = 1; i < 15; i++) { + raw[0][i] = topCasing; + } + raw[0][7] = middleTopCasing; + + raw[1] = new String[15]; + String allGlass = "ggggggggggggggg"; + String allCoil = "gCCCCCCCCCCCCCg"; + String middleLine = "gC===========Cg"; + raw[1][0] = allGlass; + raw[1][1] = allCoil; + raw[1][13] = allCoil; + raw[1][14] = allGlass; + for (int i = 2; i < 13; i++) { + raw[1][i] = middleLine; + } + for (int i = 2; i < 19; i++) { + raw[i] = raw[1]; + } + String bottomCasing = "bbbbbbbbbbbbbbb"; + raw[19] = new String[15]; + for (int i = 0; i < 15; i++) { + raw[19][i] = bottomCasing; + } + + raw[17] = Arrays.copyOf(raw[17], raw[17].length); + raw[17][0] = "ggggggg~ggggggg"; + + return transpose(raw); + } + + private HeatingCoilLevel mCoilLevel; + protected final ArrayList mPollutionOutputHatches = new ArrayList<>(); + protected final FluidStack[] pollutionFluidStacks = { Materials.CarbonDioxide.getGas(1000), + Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000) }; + private int mHeatingCapacity; + private byte glassTier; + private final static int polPtick = ConfigHandler.basePollutionMBFSecond / 20 * ConfigHandler.megaMachinesMax; + + public GT_TileEntity_MegaBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_MegaBlastFurnace(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_MegaBlastFurnace(this.mName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Blast Furnace") + .addInfo("Controller block for the Mega Blast Furnace") + .addInfo("You can use some fluids to reduce recipe time. Place the circuit in the Input Bus") + .addInfo("Each 900K over the min. Heat required reduces power consumption by 5% (multiplicatively)") + .addInfo("Each 1800K over the min. Heat allows for an overclock to be upgraded to a perfect overclock.") + .addInfo("That means the EBF will reduce recipe time by a factor 4 instead of 2 (giving 100% efficiency).") + .addInfo("Additionally gives +100K for every tier past MV") + .addPollutionAmount(20 * this.getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(15, 20, 15, true) + .addController("3rd layer center") + .addCasingInfoRange("Heat Proof Machine Casing", 0, 279, false) + .addOtherStructurePart("864x Heating Coils", "Inner 13x18x13 (Hollow)") + .addOtherStructurePart("1007x Borosilicate Glass", "Outer 15x18x15") + .addStructureInfo("The glass tier limits the Energy Input tier") + .addEnergyHatch("Any bottom layer casing") + .addMaintenanceHatch("Any bottom layer casing") + .addMufflerHatch("Top middle") + .addInputBus("Any bottom layer casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("Gasses, Any top layer casing") + .addStructureInfo("Recovery amount scales with Muffler Hatch tier") + .addOutputHatch("Platline fluids, Any bottom layer casing") + .addStructureHint("This Mega Multiblock is too big to have its structure hologram displayed fully.") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.glassTier = aNBT.getByte("glasTier"); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + this.inputSeparation = aNBT.getBoolean("isBussesSeparate"); + } + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) { + this.inputSeparation = !this.inputSeparation; + GT_Utility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + this.inputSeparation); + return true; + } + this.batchMode = !this.batchMode; + if (this.batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[0][CASING_INDEX] }; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("glasTier", this.glassTier); + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return polPtick; + } + + public boolean addOutputHatchToTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mPollutionOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + return false; + } + + @Override + protected String[] getExtendedInfoData() { + return new String[] { StatCollector.translateToLocal("GT5U.EBF.heat") + ": " + + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(this.mHeatingCapacity) + + EnumChatFormatting.RESET + + " K" }; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) { + return super.createOverclockCalculator(recipe).setRecipeHeat(recipe.mSpecialValue) + .setMachineHeat(GT_TileEntity_MegaBlastFurnace.this.mHeatingCapacity) + .setHeatOC(true) + .setHeatDiscount(true); + } + + @Override + protected @Nonnull CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + return recipe.mSpecialValue <= GT_TileEntity_MegaBlastFurnace.this.mHeatingCapacity + ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + }.setMaxParallel(ConfigHandler.megaMachinesMax); + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece("main", stackSize, hintsOnly, 7, 17, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + this.glassTier = 0; + this.setCoilLevel(HeatingCoilLevel.None); + return this.survivialBuildPiece("main", stackSize, 7, 17, 0, realBudget, source, actor, false, true); + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + this.mCoilLevel = aCoilLevel; + } + + public HeatingCoilLevel getCoilLevel() { + return this.mCoilLevel; + } + + @Override + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack tLiquid = aLiquid.copy(); + boolean isOutputPollution = false; + for (FluidStack pollutionFluidStack : this.pollutionFluidStacks) { + if (!tLiquid.isFluidEqual(pollutionFluidStack)) continue; + + isOutputPollution = true; + break; + } + ArrayList tOutputHatches; + if (isOutputPollution) { + tOutputHatches = this.mPollutionOutputHatches; + int pollutionReduction = 0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) { + pollutionReduction = 100 - tHatch.calculatePollutionReduction(100); + break; + } + tLiquid.amount = tLiquid.amount * pollutionReduction / 100; + } else { + tOutputHatches = this.mOutputHatches; + } + return dumpFluid(tOutputHatches, tLiquid, true) || dumpFluid(tOutputHatches, tLiquid, false); + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + this.mHeatingCapacity = 0; + this.glassTier = 0; + + this.setCoilLevel(HeatingCoilLevel.None); + + this.mPollutionOutputHatches.clear(); + + if (!this.checkPiece("main", 7, 17, 0) || this.getCoilLevel() == HeatingCoilLevel.None + || this.mMaintenanceHatches.size() != 1) return false; + + if (this.glassTier < 8) { + for (int i = 0; i < this.mExoticEnergyHatches.size(); ++i) { + GT_MetaTileEntity_Hatch hatch = this.mExoticEnergyHatches.get(i); + if (hatch.getConnectionType() == GT_MetaTileEntity_Hatch.ConnectionType.LASER) { + return false; + } + if (this.glassTier < hatch.mTier) { + return false; + } + } + for (int i = 0; i < this.mEnergyHatches.size(); ++i) { + if (this.glassTier < this.mEnergyHatches.get(i).mTier) { + return false; + } + } + } + + this.mHeatingCapacity = (int) this.getCoilLevel() + .getHeat() + 100 * (BW_Util.getTier(this.getMaxInputEu()) - 2); + + return true; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.blastFurnaceRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -2; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java new file mode 100644 index 0000000000..4b11f8d500 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_MegaChemicalReactor + extends GT_TileEntity_MegaMultiBlockBase implements ISurvivalConstructable { + + private byte glassTier; + + public GT_TileEntity_MegaChemicalReactor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_MegaChemicalReactor(String aName) { + super(aName); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Chemical Reactor") + .addInfo("Controller block for the Chemical Reactor") + .addInfo("What molecule do you want to synthesize") + .addInfo("Or you want to replace something in this molecule") + .addInfo("The structure is too complex!") + .addInfo("Follow the Structure Lib hologram projector to build the main structure.") + .addSeparator() + .beginStructureBlock(5, 5, 9, false) + .addController("Front center") + .addStructureInfo("46x Chemically Inert Machine Casing (minimum)") + .addStructureInfo("7x Fusion Coil Block") + .addStructureInfo("28x PTFE Pipe Casing") + .addStructureInfo("64x Borosilicate Glass Block (any tier)") + .addStructureInfo("The glass tier limits the Energy Input tier") + .addEnergyHatch("Hint block ", 3) + .addMaintenanceHatch("Hint block ", 2) + .addInputHatch("Hint block ", 1) + .addInputBus("Hint block ", 1) + .addOutputBus("Hint block ", 1) + .addOutputHatch("Hint block ", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_TileEntity_MegaChemicalReactor(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { casingTexturePages[1][48], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[1][48], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[1][48] }; + } + + @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.multiblockChemicalReactorRecipes; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + inputSeparation = !inputSeparation; + GT_Utility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + this.batchMode = !this.batchMode; + if (this.batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().enablePerfectOverclock() + .setMaxParallel(ConfigHandler.megaMachinesMax); + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 2, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 2, 2, 0, realBudget, source, actor, false, true); + } + // -------------- TEC TECH COMPAT ---------------- + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.glassTier = 0; + + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 0) || this.mMaintenanceHatches.size() != 1) return false; + + if (this.glassTier < 8) { + for (int i = 0; i < this.mExoticEnergyHatches.size(); ++i) { + GT_MetaTileEntity_Hatch hatch = this.mExoticEnergyHatches.get(i); + if (hatch.getConnectionType() == GT_MetaTileEntity_Hatch.ConnectionType.LASER) { + return false; + } + if (this.glassTier < hatch.mTier) { + return false; + } + } + for (int i = 0; i < this.mEnergyHatches.size(); ++i) { + if (this.glassTier < this.mEnergyHatches.get(i).mTier) { + return false; + } + } + } + + return true; + } + + private static final int CASING_INDEX = 176; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { "ttttt", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "ttttt" }, + { "tgggt", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", "teeet" }, + { "tg~gt", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", "teret" }, + { "tgggt", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", "teeet" }, + { "ttttt", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "ttttt" }, })) + .addElement('p', ofBlock(GregTech_API.sBlockCasings8, 1)) + .addElement('t', ofBlock(GregTech_API.sBlockCasings8, 0)) + .addElement( + 'd', + buildHatchAdder(GT_TileEntity_MegaChemicalReactor.class) + .atLeast(InputBus, InputHatch, OutputBus, OutputHatch) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTech_API.sBlockCasings8, 0)) + .addElement('r', Maintenance.newAny(CASING_INDEX, 2)) + .addElement( + 'e', + buildHatchAdder(GT_TileEntity_MegaChemicalReactor.class) + .atLeast(Energy.or(ExoticEnergy), InputHatch, InputBus, OutputHatch, OutputBus) + .casingIndex(CASING_INDEX) + .dot(3) + .buildAndChain(GregTech_API.sBlockCasings8, 0)) + .addElement('c', ofChain(ofBlock(GregTech_API.sBlockCasings4, 7), ofBlock(GregTech_API.sBlockCasings5, 13))) + .addElement( + 'g', + BorosilicateGlass + .ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier)) + .build(); + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java new file mode 100644 index 0000000000..80bc644e9e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +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.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + +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; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElementCheckOnly; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.fluid.IFluidStore; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Output_ME; + +public class GT_TileEntity_MegaDistillTower extends GT_TileEntity_MegaMultiBlockBase + implements ISurvivalConstructable { + + protected static final int CASING_INDEX = 49; + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "top"; + private static final IStructureDefinition STRUCTURE_DEFINITION; + + static { + IHatchElement layeredOutputHatch = OutputHatch + .withCount(GT_TileEntity_MegaDistillTower::getCurrentLayerOutputHatchCount) + .withAdder(GT_TileEntity_MegaDistillTower::addLayerOutputHatch); + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + STRUCTURE_PIECE_BASE, + transpose( + new String[][] { { "bbbbbbb~bbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", + "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", + "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", + "bbbbbbbbbbbbbbb" }, })) + .addShape( + STRUCTURE_PIECE_LAYER, + transpose( + new String[][] { + { "lllllllllllllll", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", + "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", + "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", + "lcccccccccccccl", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, })) + .addShape( + STRUCTURE_PIECE_TOP_HINT, + transpose( + new String[][] { + { "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", + "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", + "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", + "lllllllllllllll", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, })) + .addElement('=', StructureElementAirNoHint.getInstance()) + .addElement( + 'b', + buildHatchAdder(GT_TileEntity_MegaDistillTower.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain( + onElementPass( + GT_TileEntity_MegaDistillTower::onCasingFound, + ofBlock(GregTech_API.sBlockCasings4, 1)))) + .addElement( + 'l', + buildHatchAdder(GT_TileEntity_MegaDistillTower.class) + .atLeast(layeredOutputHatch, Maintenance, Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain( + onElementPass( + GT_TileEntity_MegaDistillTower::onCasingFound, + ofBlock(GregTech_API.sBlockCasings4, 1)))) + .addElement('c', (IStructureElementCheckOnly) (t, world, x, y, z) -> { + if (world.isAirBlock(x, y, z)) { + if (t.mTopState < 1) { + t.mTopState = 0; + return true; + } + // definitely top - cannot be air + return false; + } + // from here on we must be looking at a top layer, since it's not air + if (t.mTopState == 0) + // must be air but failed, so no + return false; + t.mTopState = 1; + // hatch adder + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof IGregTechTileEntity entity && t.addLayerOutputHatch(entity, CASING_INDEX)) { + t.onTopLayerFound(false); + return true; + } + // block adder + if (world.getBlock(x, y, z) == GregTech_API.sBlockCasings4 && world.getBlockMetadata(x, y, z) == 1) { + t.onTopLayerFound(true); + return true; + } + return false; + }) + .build(); + } + + protected final List> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; + + // -1 => maybe top, maybe not, 0 => definitely not top, 1 => definitely top + private int mTopState = -1; + + public GT_TileEntity_MegaDistillTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private GT_TileEntity_MegaDistillTower(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_TileEntity_MegaDistillTower(this.mName); + } + + protected void onCasingFound() { + this.mCasing++; + } + + protected int getCurrentLayerOutputHatchCount() { + return this.mOutputHatchesByLayer.size() < this.mHeight || this.mHeight <= 0 ? 0 + : this.mOutputHatchesByLayer.get(this.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 (this.mOutputHatchesByLayer.size() < this.mHeight) this.mOutputHatchesByLayer.add(new ArrayList<>()); + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); + tHatch.updateTexture(aBaseCasingIndex); + return this.mOutputHatchesByLayer.get(this.mHeight - 1) + .add(tHatch); + } + + protected void onTopLayerFound(boolean aIsCasing) { + this.mTopLayerFound = true; + if (aIsCasing) this.onCasingFound(); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.distillationTowerRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Distillery") + .addInfo("Controller block for the Distillation Tower") + .addInfo("Fluids are only put out at the correct height") + .addInfo("The correct height equals the slot number in the NEI recipe") + .addSeparator() + .beginVariableStructureBlock(15, 15, 16, 56, 15, 15, true) + .addController("Front bottom") + .addOtherStructurePart("Clean Stainless Steel Machine Casing", "15 x h - 5 (minimum)") + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("2-11x Output Hatches (One per Output Layer except bottom layer)") + .addStructureInfo("An \"Output Layer\" consists of 5 layers!") + .addStructureHint("The interior of this Mega Multiblock's hologram is empty, it should be all air.") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + this.mOutputHatchesByLayer.forEach(List::clear); + this.mHeight = 1; + this.mTopLayerFound = false; + this.mTopState = -1; + + // check base + if (!this.checkPiece(STRUCTURE_PIECE_BASE, 7, 0, 0)) return false; + + // check each layer + while (this.mHeight < 12) { + if (!checkPiece(STRUCTURE_PIECE_LAYER, 7, mHeight * 5, 0)) { + return false; + } + if (this.mOutputHatchesByLayer.size() < this.mHeight || this.mOutputHatchesByLayer.get(this.mHeight - 1) + .isEmpty()) + // layer without output hatch + return false; + if (mTopLayerFound) { + break; + } + this.mTopState = -1; + // not top + this.mHeight++; + } + + // validate final invariants... + return this.mCasing >= 75 * this.mHeight + 10 && this.mHeight >= 2 + && this.mTopLayerFound + && this.mMaintenanceHatches.size() == 1; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 7, 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++) { + this.buildPiece(STRUCTURE_PIECE_LAYER, stackSize, hintsOnly, 7, 5 * i, 0); + } + this.buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 7, 5 * (tTotalHeight - 1), 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + this.mHeight = 0; + int built = this + .survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 7, 0, 0, realBudget, 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++) { + this.mHeight = i; + built = this.survivialBuildPiece( + STRUCTURE_PIECE_LAYER, + stackSize, + 7, + 5 * this.mHeight, + 0, + realBudget, + source, + actor, + false, + true); + if (built >= 0) return built; + } + this.mHeight = tTotalHeight - 1; + return this.survivialBuildPiece( + STRUCTURE_PIECE_TOP_HINT, + stackSize, + 7, + 5 * this.mHeight, + 0, + realBudget, + source, + actor, + false, + true); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + this.batchMode = !this.batchMode; + if (this.batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallel(ConfigHandler.megaMachinesMax); + } + + @Override + public boolean canDumpFluidToME() { + + // All fluids can be dumped to ME only if each layer contains a ME Output Hatch. + for (List tLayerOutputHatches : this.mOutputHatchesByLayer) { + + boolean foundMEHatch = false; + + for (IFluidStore tHatch : tLayerOutputHatches) { + if (tHatch instanceof GT_MetaTileEntity_Hatch_Output_ME) { + foundMEHatch = true; + break; + } + } + + // Exit if we didn't find a valid hatch on this layer. + if (!foundMEHatch) { + return false; + } + } + + return true; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length && i < this.mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i].copy(); + if (!dumpFluid(this.mOutputHatchesByLayer.get(i), tStack, true)) + dumpFluid(this.mOutputHatchesByLayer.get(i), tStack, false); + } + } + + @Override + public List getFluidOutputSlots(FluidStack[] toOutput) { + return this.getFluidOutputSlotsByLayer(toOutput, this.mOutputHatchesByLayer); + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java new file mode 100644 index 0000000000..223ef65f77 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java @@ -0,0 +1,223 @@ +package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; + +import static gregtech.api.util.GT_Utility.filterValidMTEs; + +import java.util.Arrays; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureElement; + +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.util.GT_Utility; + +public abstract class GT_TileEntity_MegaMultiBlockBase> + extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase { + + protected GT_TileEntity_MegaMultiBlockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_MegaMultiBlockBase(String aName) { + super(aName); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + // Migration code + if (aNBT.hasKey("lEUt")) { + this.lEUt = aNBT.getLong("lEUt"); + } + } + + protected String[] getExtendedInfoData() { + return new String[0]; + } + + protected long[] getCurrentInfoData() { + long storedEnergy = 0, maxEnergy = 0; + for (GT_MetaTileEntity_Hatch hatch : this.getExoticAndNormalEnergyHatchList()) { + storedEnergy += hatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += hatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + return new long[] { storedEnergy, maxEnergy }; + } + + @Override + public String[] getInfoData() { + int mPollutionReduction = 0; + + for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) { + mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); + } + + long[] ttHatches = this.getCurrentInfoData(); + long storedEnergy = ttHatches[0]; + long maxEnergy = ttHatches[1]; + + for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + long nominalV = this.getMaxInputEu(); + String tName = BW_Util.getTierNameFromVoltage(nominalV); + if ("MAX+".equals(tName)) tName = EnumChatFormatting.OBFUSCATED + "MAX+"; + + String[] extendedInfo = this.getExtendedInfoData(); + + String[] baseInfo = { + StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(this.mProgresstime / 20) + + EnumChatFormatting.RESET + + " s / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.mMaxProgresstime / 20) + + EnumChatFormatting.RESET + + " s", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + + EnumChatFormatting.RED + + GT_Utility.formatNumbers(-this.lEUt) + + EnumChatFormatting.RESET + + " EU/t", + StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getMaxInputVoltage()) + + EnumChatFormatting.RESET + + " EU/t(*" + + GT_Utility.formatNumbers(this.getMaxInputAmps()) + + "A) = " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(nominalV) + + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tName + + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + + EnumChatFormatting.RED + + (this.getIdealStatus() - this.getRepairStatus()) + + EnumChatFormatting.RESET + + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + + ": " + + EnumChatFormatting.YELLOW + + this.mEfficiency / 100.0F + + EnumChatFormatting.RESET + + " %", + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + + mPollutionReduction + + EnumChatFormatting.RESET + + " %" }; + + String[] combinedInfo = Arrays.copyOf(baseInfo, baseInfo.length + extendedInfo.length + 1); + + System.arraycopy(extendedInfo, 0, combinedInfo, baseInfo.length, extendedInfo.length); + + combinedInfo[combinedInfo.length - 1] = BW_Tooltip_Reference.BW; + + return combinedInfo; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(this.getMaxInputEu()); + logic.setAvailableAmperage(1); + } + + protected static class StructureElementAirNoHint implements IStructureElement { + + private static final StructureElementAirNoHint INSTANCE = new StructureElementAirNoHint<>(); + + @SuppressWarnings("unchecked") + public static IStructureElement getInstance() { + return (IStructureElement) INSTANCE; + } + + private StructureElementAirNoHint() {} + + @Override + public boolean check(T o, World world, int x, int y, int z) { + return world.isAirBlock(x, y, z); + } + + @Override + public boolean spawnHint(T o, World world, int x, int y, int z, ItemStack trigger) { + if (world.blockExists(x, y, z) && !world.isAirBlock(x, y, z)) + // hint if this is obstructed. in case *someone* ever finish the transparent rendering + StructureLibAPI + .hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), StructureLibAPI.HINT_BLOCK_META_AIR); + return true; + } + + @Override + public boolean placeBlock(T o, World world, int x, int y, int z, ItemStack trigger) { + world.setBlockToAir(x, y, z); + return true; + } + + @Override + public BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + return BlocksToPlace.createEmpty(); + } + + @Override + public PlaceResult survivalPlaceBlock(T o, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + if (this.check(o, world, x, y, z)) return PlaceResult.SKIP; + if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, env.getActor())) return PlaceResult.REJECT; + world.setBlock(x, y, z, Blocks.air, 0, 2); + return PlaceResult.ACCEPT; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java new file mode 100644 index 0000000000..40ec9f814b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java @@ -0,0 +1,459 @@ +/* + * Copyright (c) 2022 SKYCATV587 Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The + * above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +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.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_Utility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.maps.OilCrackerBackend; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Input_ME; +import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; + +public class GT_TileEntity_MegaOilCracker extends GT_TileEntity_MegaMultiBlockBase + implements ISurvivalConstructable { + + private static final int CASING_INDEX = 49; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " p p ", "ppgggggggggpp", " pgggggggggp ", " pgggpppgggp ", " pgggpMpgggp ", + " pgggpppgggp ", " pgggggggggp ", "ppgggggggggpp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " g c c c c g ", " g c c c c g ", + " g c c c c g ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " p c c p ", " p c c c c p ", + " p c c p ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " p c c c c p ", " l c c c c r ", + " p c c c c p ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " p c c p ", " p c c c c p ", + " p c c p ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " g c c c c g ", " g c c c c g ", + " g c c c c g ", " g c c c c g ", "pgggggggggggp", " p p " }, + { "ppmmmm~mmmmpp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", + "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppmmmmmmmmmpp" }, })) + .addElement( + 'c', + withChannel( + "coil", + ofCoil(GT_TileEntity_MegaOilCracker::setCoilLevel, GT_TileEntity_MegaOilCracker::getCoilLevel))) + + .addElement('p', ofBlock(GregTech_API.sBlockCasings4, 1)) + .addElement( + 'l', + InputHatch.withAdder(GT_TileEntity_MegaOilCracker::addLeftHatchToMachineList) + .newAny(CASING_INDEX, 2)) + .addElement( + 'r', + OutputHatch.withAdder(GT_TileEntity_MegaOilCracker::addRightHatchToMachineList) + .newAny(CASING_INDEX, 3)) + .addElement( + 'm', + buildHatchAdder(GT_TileEntity_MegaOilCracker.class).atLeast(Energy.or(ExoticEnergy), Maintenance, InputBus) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTech_API.sBlockCasings4, 1)) + .addElement( + 'M', + InputHatch.withAdder(GT_TileEntity_MegaOilCracker::addMiddleInputToMachineList) + .newAny(CASING_INDEX, 4)) + .addElement( + 'g', + withChannel( + "glass", + BorosilicateGlass + .ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier))) + .build(); + private byte glassTier; + private HeatingCoilLevel heatLevel; + protected final List mMiddleInputHatches = new ArrayList<>(); + protected int mInputOnSide = -1; + protected int mOutputOnSide = -1; + + public GT_TileEntity_MegaOilCracker(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_MegaOilCracker(String aName) { + super(aName); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Cracker") + .addInfo("Controller block for the Mega Oil Cracking") + .addInfo("Thermally cracks heavy hydrocarbons into lighter fractions") + .addInfo("More efficient than the Chemical Reactor") + .addInfo("Gives different benefits whether it hydro or steam-cracks:") + .addInfo("Hydro - Consumes 20% less Hydrogen and outputs 25% more cracked fluid") + .addInfo("Steam - Outputs 50% more cracked fluid") + .addInfo("(Values compared to cracking in the Chemical Reactor)") + .addInfo("Place the appropriate circuit in the controller or an input bus") + .addSeparator() + .beginStructureBlock(13, 7, 9, true) + .addController("Front bottom") + .addStructureInfo("The glass tier limits the Energy Input tier") + .addInfo("Gets 10% EU/t reduction per coil tier, up to a maximum of 50%") + .addEnergyHatch("Hint block", 1) + .addMaintenanceHatch("Hint block", 1) + .addInputHatch("Hint block", 2, 3) + .addOutputHatch("Hint block", 2, 3) + .addInputHatch("Steam/Hydrogen ONLY, Hint block", 4) + .addInputBus("Optional, for programmed circuit automation. Hint block", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_TileEntity_MegaOilCracker(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[0][CASING_INDEX] }; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.crackingRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Override + @Nonnull + public CheckRecipeResult process() { + this.setEuModifier( + 1.0F - Math.min(0.1F * (GT_TileEntity_MegaOilCracker.this.heatLevel.getTier() + 1), 0.5F)); + return super.process(); + } + }.setMaxParallel(ConfigHandler.megaMachinesMax); + } + + public HeatingCoilLevel getCoilLevel() { + return this.heatLevel; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + this.heatLevel = aCoilLevel; + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 6, 6, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 6, 6, 0, realBudget, source, actor, false, true); + } + // -------------- TEC TECH COMPAT ---------------- + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.glassTier = 0; + this.mInputOnSide = -1; + this.mOutputOnSide = -1; + this.mMiddleInputHatches.clear(); + + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 6, 6, 0) || this.mMaintenanceHatches.size() != 1) return false; + + if (this.glassTier < 8) { + for (int i = 0; i < this.mExoticEnergyHatches.size(); ++i) { + GT_MetaTileEntity_Hatch hatch = this.mExoticEnergyHatches.get(i); + if (hatch.getConnectionType() == GT_MetaTileEntity_Hatch.ConnectionType.LASER) { + return false; + } + if (this.glassTier < hatch.mTier) { + return false; + } + } + for (int i = 0; i < this.mEnergyHatches.size(); ++i) { + if (this.glassTier < this.mEnergyHatches.get(i).mTier) { + return false; + } + } + } + + return true; + } + + private boolean addLeftHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + if (this.mInputOnSide == 1) { + return false; + } + this.mInputOnSide = 0; + this.mOutputOnSide = 1; + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add(tHatch); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + if (this.mOutputOnSide == 1) { + return false; + } + this.mInputOnSide = 1; + this.mOutputOnSide = 0; + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return this.mOutputHatches.add(tHatch); + } + return false; + } + + private boolean addRightHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + if (this.mInputOnSide == 0) { + return false; + } + this.mInputOnSide = 1; + this.mOutputOnSide = 0; + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add(tHatch); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + if (this.mOutputOnSide == 0) { + return false; + } + this.mInputOnSide = 0; + this.mOutputOnSide = 1; + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return this.mOutputHatches.add(tHatch); + } + return false; + } + + private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input tHatch) { + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mMiddleInputHatches.add(tHatch); + } + return false; + } + + @Override + public ArrayList getStoredFluids() { + final ArrayList rList = new ArrayList<>(); + Map inputsFromME = new HashMap<>(); + for (final GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { + tHatch.mRecipeMap = getRecipeMap(); + if (tHatch instanceof GT_MetaTileEntity_Hatch_Input_ME meHatch) { + for (FluidStack tFluid : meHatch.getStoredFluids()) { + if (tFluid != null && !getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + inputsFromME.put(tFluid.getFluid(), tFluid); + } + } + } else if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { + for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { + if (tFluid != null && !getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + rList.add(tFluid); + } + } + } else { + if (tHatch.getFillableStack() != null) { + if (!getRecipeMap().getBackend() + .isValidCatalystFluid(tHatch.getFillableStack())) rList.add(tHatch.getFillableStack()); + } + } + } + for (final GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mMiddleInputHatches)) { + tHatch.mRecipeMap = getRecipeMap(); + if (tHatch instanceof GT_MetaTileEntity_Hatch_Input_ME meHatch) { + for (FluidStack tFluid : meHatch.getStoredFluids()) { + if (tFluid != null && getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + inputsFromME.put(tFluid.getFluid(), tFluid); + } + } + } else if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { + for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { + if (tFluid != null && getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + rList.add(tFluid); + } + } + } else { + if (tHatch.getFillableStack() != null) { + final FluidStack tStack = tHatch.getFillableStack(); + if (getRecipeMap().getBackend() + .isValidCatalystFluid(tStack)) { + rList.add(tStack); + } + } + } + } + if (!inputsFromME.isEmpty()) { + rList.addAll(inputsFromME.values()); + } + return rList; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + batchMode = !batchMode; + if (batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + protected void startRecipeProcessing() { + for (GT_MetaTileEntity_Hatch_Input hatch : filterValidMTEs(mMiddleInputHatches)) { + if (hatch instanceof IRecipeProcessingAwareHatch aware) { + aware.startRecipeProcessing(); + } + } + super.startRecipeProcessing(); + } + + @Override + protected void endRecipeProcessing() { + super.endRecipeProcessing(); + for (GT_MetaTileEntity_Hatch_Input hatch : filterValidMTEs(mMiddleInputHatches)) { + if (hatch instanceof IRecipeProcessingAwareHatch aware) { + setResultIfFailure(aware.endRecipeProcessing(this)); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java new file mode 100644 index 0000000000..0a2464de5e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTWORKS; +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_HatchElement.ExoticEnergy; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; + +public class GT_TileEntity_MegaVacuumFreezer extends GT_TileEntity_MegaMultiBlockBase + implements ISurvivalConstructable { + + public GT_TileEntity_MegaVacuumFreezer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_MegaVacuumFreezer(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_TileEntity_MegaVacuumFreezer(this.mName); + } + + private int mCasing = 0; + + private static final int CASING_INDEX = 17; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", + "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", + "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccc~ccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "c=============c", + "c=============c", "c=============c", "c=============c", "c=============c", "ccccccccccccccc" }, + { "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", + "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", + "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", "ccccccccccccccc", + "ccccccccccccccc" } })) + .addElement('=', StructureElementAirNoHint.getInstance()) + .addElement( + 'c', + buildHatchAdder(GT_TileEntity_MegaVacuumFreezer.class) + .atLeast(Energy.or(ExoticEnergy), InputHatch, InputBus, OutputHatch, OutputBus, Maintenance) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(onElementPass(x -> x.mCasing++, ofBlock(GregTech_API.sBlockCasings2, 1)))) + .build(); + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Vacuum Freezer") + .addInfo("Controller Block for the Mega Vacuum Freezer") + .addInfo("Cools hot ingots and cells") + .addSeparator() + .beginStructureBlock(15, 15, 15, true) + .addController("Front center") + .addCasingInfoMin("Frost Proof Machine Casing", 900, false) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addInputHatch("Any casing", 1) + .addOutputHatch("Any casing", 1) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 7, 7, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 7, 7, 0, realBudget, source, actor, false, true); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.vacuumFreezerRecipes; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + this.batchMode = !this.batchMode; + if (this.batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallel(ConfigHandler.megaMachinesMax); + } + + // -------------- TEC TECH COMPAT ---------------- + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.mCasing = 0; + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 7, 7, 0)) return false; + return this.mMaintenanceHatches.size() == 1 && this.mCasing >= 900; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + ITexture[] rTexture; + if (side == facing) { + if (aActive) { + rTexture = new ITexture[] { casingTexturePages[0][17], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + } else { + rTexture = new ITexture[] { casingTexturePages[0][17], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER_GLOW) + .extFacing() + .glow() + .build() }; + } + } else { + rTexture = new ITexture[] { casingTexturePages[0][17] }; + } + return rTexture; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java new file mode 100644 index 0000000000..c50e6cbd12 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; + +import gregtech.api.enums.GT_Values; +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_BasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; + +public class GT_MetaTileEntity_AcidGenerator extends GT_MetaTileEntity_BasicGenerator { + + public GT_MetaTileEntity_AcidGenerator(int aID, String aName, String aNameRegional, int aTier, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, new String[] {}, aTextures); + } + + public GT_MetaTileEntity_AcidGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getPollution() { + return 0; + } + + @Override + public RecipeMap getRecipeMap() { + return BartWorksRecipeMaps.acidGenFuels; + } + + @Override + public int getEfficiency() { + return 100 - 3 * this.mTier; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_AcidGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_GLOW")) + .glow() + .build() }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + TextureFactory + .of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE_GLOW")) + .glow() + .build() }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public String[] getDescription() { + return new String[] { StatCollector.translateToLocal("tooltip.tile.acidgen.0.name"), + StatCollector.translateToLocal("tooltip.tile.acidgen.1.name"), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + + ChatColorHelper.YELLOW + + GT_Values.V[this.mTier], + StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + + ChatColorHelper.YELLOW + + this.getEfficiency(), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + + ChatColorHelper.YELLOW + + this.maxAmperesOut(), + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java new file mode 100644 index 0000000000..d2ef329066 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java @@ -0,0 +1,412 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import static gregtech.api.enums.Mods.Gendustry; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.common.items.LabModule; +import com.github.bartimaeusnek.bartworks.common.items.LabParts; +import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import com.github.bartimaeusnek.bartworks.util.BioDNA; +import com.github.bartimaeusnek.bartworks.util.BioData; +import com.github.bartimaeusnek.bartworks.util.BioPlasmid; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +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_BasicMachine; +import gregtech.api.objects.XSTR; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; + +public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { + + private static final int DNA_EXTRACTION_MODULE = 0; + private static final int PCR_THERMOCYCLE_MODULE = 1; + private static final int PLASMID_SYNTHESIS_MODULE = 2; + private static final int TRANSFORMATION_MODULE = 3; + private static final int CLONAL_CELLULAR_SYNTHESIS_MODULE = 4; + private static final int INCUBATION_MODULE = 5; + + public GT_MetaTileEntity_BioLab(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + (String) null, + 6, + 2, + TextureFactory.of( + TextureFactory + .of(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE_ACTIVE")), + TextureFactory.builder() + .addIcon( + new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE_ACTIVE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory + .of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE")), + TextureFactory.builder() + .addIcon( + new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE_GLOW")) + .glow() + .build() /* this is topactive */), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_GLOW")) + .glow() + .build() /* this is top */), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM_ACTIVE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM_ACTIVE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM_GLOW")) + .glow() + .build())); + } + + public GT_MetaTileEntity_BioLab(String aName, int aTier, int aAmperage, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aAmperage, aDescription, aTextures, 6, 2); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_BioLab( + this.mName, + this.mTier, + this.mAmperage, + this.mDescriptionArray, + this.mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + return BartWorksRecipeMaps.bioLabRecipes; + } + + @Override + public int getCapacity() { + return this.mTier * 1000; + } + + @Override + public int checkRecipe(boolean skipOC) { + + int rTier = 3; + FluidStack dnaFluid = Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 1000) + : Materials.Biomass.getFluid(1000L); + + if (this.getSpecialSlot() != null && this.getSpecialSlot() + .getItem() instanceof LabModule) { + int damage = this.getSpecialSlot() + .getItemDamage(); + switch (damage) { + case DNA_EXTRACTION_MODULE: + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) + && this.mInventory[this.getInputSlot()].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot()].getItemDamage() == 0 + && this.mInventory[this.getInputSlot()].getTagCompound() != null + && // checks if it is a Culture + GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && this.mInventory[this.getInputSlot() + 1].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot() + 1].getItemDamage() == 1 + && this.mInventory[this.getInputSlot() + 1].getTagCompound() == null + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && this.mInventory[this.getInputSlot() + 2].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot() + 2].getItemDamage() == 3 + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot() + 3], Materials.Ethanol.getCells(1)) + && this.mFluid != null + && this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) + && this.mFluid.amount >= 1000) { + + NBTTagCompound DNABioDataTag = this.mInventory[this.getInputSlot()].getTagCompound() + .getCompoundTag("DNA"); + if (DNABioDataTag == null) return super.checkRecipe(skipOC); + BioData cultureDNABioData = BioData.getBioDataFromName( + this.mInventory[this.getInputSlot()].getTagCompound() + .getCompoundTag("DNA") + .getString("Name")); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + + if (this.mTier < rTier + cultureDNABioData.getTier()) + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + + for (int i = 0; i < 4; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + + this.mFluid.amount -= 1000; + + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList + .getDNASampleFlask(BioDNA.convertDataToDNA(cultureDNABioData)); + } + this.mOutputItems[1] = GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L); + this.calculateOverclockedNess( + BW_Util.getMachineVoltageFromTier(rTier + cultureDNABioData.getTier()), + 500); + + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + break; + case PCR_THERMOCYCLE_MODULE: { + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) + && this.mInventory[this.getInputSlot()].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot()].getItemDamage() == 1 + && this.mInventory[this.getInputSlot()].getTagCompound() != null + && // checks if it is a Culture + GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 3]) + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot() + 3], ItemList.Tool_DataOrb.get(1L)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot() + 1], FluidLoader.BioLabFluidCells[0]) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot() + 2], FluidLoader.BioLabFluidCells[3]) + && this.mFluid != null + && this.mFluid.isFluidEqual(dnaFluid) + && this.mFluid.amount >= 1000) { + NBTTagCompound DNABioDataTag = this.mInventory[this.getInputSlot()].getTagCompound(); + if (DNABioDataTag == null) return super.checkRecipe(skipOC); + BioData cultureDNABioData = BioData.getBioDataFromName(DNABioDataTag.getString("Name")); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + + if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + + for (int i = 0; i < 4; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + + this.mFluid.amount -= 1000; + + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + Behaviour_DataOrb.setDataName(Outp, cultureDNABioData.getName()); + + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = Outp; + } else this.mOutputItems[0] = ItemList.Tool_DataOrb.get(1L); + this.mOutputItems[1] = ItemList.Cell_Empty.get(2L); + + this.calculateOverclockedNess( + BW_Util.getMachineVoltageFromTier(1 + rTier + cultureDNABioData.getTier()), + 500); + + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case PLASMID_SYNTHESIS_MODULE: { + ItemStack inp2 = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(inp2, "DNA Sample"); + Behaviour_DataOrb.setDataName(inp2, BioCultureLoader.BIO_DATA_BETA_LACMATASE.getName()); + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) + && GT_Utility + .areStacksEqual(FluidLoader.BioLabFluidCells[1], this.mInventory[this.getInputSlot()]) + && // checks + // if + // it + // is + // a + // Culture + GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot() + 1], BioItemList.getPlasmidCell(null)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GT_Utility.areStacksEqual( + this.mInventory[this.getInputSlot() + 2], + ItemList.Tool_DataOrb.get(1L), + true) + && "DNA Sample".equals(Behaviour_DataOrb.getDataTitle(this.mInventory[this.getInputSlot() + 2])) + && !Behaviour_DataOrb.getDataName(this.mInventory[this.getInputSlot() + 2]) + .isEmpty() + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 3]) + && GT_Utility.areStacksEqual(this.mInventory[this.getInputSlot() + 3], inp2) + && this.mFluid != null + && this.mFluid.isFluidEqual(dnaFluid) + && this.mFluid.amount >= 1000) { + BioData cultureDNABioData = BioData.getBioDataFromName( + Behaviour_DataOrb.getDataName(this.mInventory[this.getInputSlot() + 2])); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < 2; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + this.mFluid.amount -= 1000; + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList + .getPlasmidCell(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + } + this.mOutputItems[1] = ItemList.Cell_Empty.get(1L); + this.calculateOverclockedNess( + BW_Util.getMachineVoltageFromTier(1 + rTier + cultureDNABioData.getTier()), + 500); + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case TRANSFORMATION_MODULE: { + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot()], BioItemList.getPetriDish(null), true) + && this.mInventory[this.getInputSlot()].getTagCompound() != null + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GT_Utility.areStacksEqual( + this.mInventory[this.getInputSlot() + 1], + BioItemList.getPlasmidCell(null), + true) + && this.mInventory[this.getInputSlot() + 1].getTagCompound() != null + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot() + 2], FluidLoader.BioLabFluidCells[2]) + && this.mFluid != null + && this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) + && this.mFluid.amount >= 1000) { + BioData cultureDNABioData = BioData + .getBioDataFromNBTTag(this.mInventory[this.getInputSlot() + 1].getTagCompound()); + BioCulture bioCulture = BioCulture + .getBioCultureFromNBTTag(this.mInventory[this.getInputSlot()].getTagCompound()); + if (cultureDNABioData == null || bioCulture == null) return super.checkRecipe(skipOC); + if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < 3; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + this.mFluid.amount -= 1000; + bioCulture = bioCulture.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList.getPetriDish(bioCulture); + } + this.mOutputItems[1] = ItemList.Cell_Empty.get(1L); + this.calculateOverclockedNess( + BW_Util.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), + 500); + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case CLONAL_CELLULAR_SYNTHESIS_MODULE: { + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) + && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot()], BioItemList.getPetriDish(null)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GT_Utility.areStacksEqual(this.mInventory[this.getInputSlot() + 1], BioItemList.getOther(4)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GT_Utility.areStacksEqual( + this.mInventory[this.getInputSlot() + 2], + ItemList.Circuit_Chip_Stemcell.get(2L)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 3]) + && GT_Utility.areStacksEqual( + this.mInventory[this.getInputSlot() + 3], + ItemList.Tool_DataOrb.get(1L), + true) + && "DNA Sample".equals(Behaviour_DataOrb.getDataTitle(this.mInventory[this.getInputSlot() + 3])) + && this.mFluid.isFluidEqual(dnaFluid) + && this.mFluid.amount >= 8000) { + + BioData cultureDNABioData = BioData.getBioDataFromName( + Behaviour_DataOrb.getDataName(this.mInventory[this.getInputSlot() + 3])); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < 3; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + this.mFluid.amount -= 8000; + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + BioCulture out = BioCulture.getBioCulture(BioDNA.convertDataToDNA(cultureDNABioData)); + if (out == null) return GT_MetaTileEntity_BasicMachine.DID_NOT_FIND_RECIPE; + out = out.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + this.mOutputItems[0] = BioItemList.getPetriDish(out); + } + this.calculateOverclockedNess( + BW_Util.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), + 500); + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case INCUBATION_MODULE: + default: + break; + } + } + return super.checkRecipe(skipOC); + } + + @Override + public String[] getDescription() { + return new String[] { StatCollector.translateToLocal("tooltip.tile.biolab.0.name"), + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_CompressedFluidHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_CompressedFluidHatch.java new file mode 100644 index 0000000000..e0903ce93c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_CompressedFluidHatch.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; + +import gregtech.api.enums.Materials; +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.util.GT_Utility; + +public class GT_MetaTileEntity_CompressedFluidHatch extends GT_MetaTileEntity_Hatch_Input { + + public GT_MetaTileEntity_CompressedFluidHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + this.mDescriptionArray[1] = "Capacity: 100,000,000L"; + } + + public GT_MetaTileEntity_CompressedFluidHatch(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getCapacity() { + return 100_000_000; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return GT_Utility.areFluidsEqual(aFluid, Materials.LiquidAir.getFluid(1)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_CompressedFluidHatch( + this.mName, + this.mTier, + this.mDescriptionArray, + this.mTextures); + } + + @Override + protected FluidSlotWidget createFluidSlot() { + return super.createFluidSlot().setFilter(f -> f == Materials.LiquidAir.mFluid); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java new file mode 100644 index 0000000000..76a9c1646e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; + +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicHull; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { + + private long maxAmps; + private long aAmps; + + public GT_MetaTileEntity_Diode(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, StatCollector.translateToLocal("tooltip.tile.diode.0.name")); + this.maxAmps = this.getAmpsfromMeta(aID); + this.aAmps = this.maxAmps; + } + + public GT_MetaTileEntity_Diode(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (this.maxAmps == 0 && !this.getBaseMetaTileEntity() + .getWorld().isRemote) { + this.maxAmps = this.getAmpsfromMeta( + this.getBaseMetaTileEntity() + .getMetaTileID()); + this.aAmps = this.maxAmps; + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + + if (this.getBaseMetaTileEntity() + .getWorld().isRemote) return; + if (!aPlayer.isSneaking()) { + --this.aAmps; + if (this.aAmps < 0) this.aAmps = this.maxAmps; + } else { + ++this.aAmps; + if (this.aAmps > this.maxAmps) this.aAmps = 0; + } + GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + this.aAmps); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("maxAmp", this.maxAmps); + aNBT.setLong("Amps", this.aAmps); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.maxAmps = aNBT.getLong("maxAmp"); + this.aAmps = aNBT.getLong("Amps"); + super.loadNBTData(aNBT); + } + + @Override + public long maxAmperesOut() { + return this.aAmps; + } + + @Override + public long maxAmperesIn() { + return this.aAmps; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Diode(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + private long getAmpsfromMeta(int meta) { + if (meta > ConfigHandler.IDOffset + GT_Values.VN.length + && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 2) return 2L; + if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 2 + && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 3) return 4L; + else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 3 + && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 4) return 8L; + else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 4 + && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 5) return 12L; + else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 5 + && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 6) return 16L; + else return 0L; + } + + @Override + @SuppressWarnings("deprecation") + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + + ChatColorHelper.YELLOW + + GT_Utility.formatNumbers(GT_Values.V[this.mTier]), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name") + " " + + ChatColorHelper.YELLOW + + GT_Utility.formatNumbers(this.maxAmperesIn()), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + + ChatColorHelper.YELLOW + + GT_Utility.formatNumbers(this.maxAmperesOut()), + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java new file mode 100644 index 0000000000..4431015ca8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import net.minecraft.util.StatCollector; + +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; + +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Transformer; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_EnergyDistributor extends GT_MetaTileEntity_Transformer { + + public GT_MetaTileEntity_EnergyDistributor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, null); + } + + public GT_MetaTileEntity_EnergyDistributor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_EnergyDistributor(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EnergyDistributor(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxAmperesOut() { + return 320; + } + + @Override + public long maxAmperesIn() { + return 320; + } + + @Override + public long maxEUStore() { + return 512L + GT_Values.V[this.mTier] * 320L; + } + + @Override + public String[] getDescription() { + return new String[] { StatCollector.translateToLocal("tooltip.tile.energydistributor.0.name"), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + + ChatColorHelper.YELLOW + + GT_Utility.formatNumbers(GT_Values.V[this.mTier]), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name") + " " + + ChatColorHelper.YELLOW + + GT_Utility.formatNumbers(this.maxAmperesIn()), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + + ChatColorHelper.YELLOW + + GT_Utility.formatNumbers(this.maxAmperesOut()), + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_GiantOutputHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_GiantOutputHatch.java new file mode 100644 index 0000000000..8d5a756cb5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_GiantOutputHatch.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; + +public class GT_MetaTileEntity_GiantOutputHatch extends GT_MetaTileEntity_Hatch_Output { + + public GT_MetaTileEntity_GiantOutputHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + this.mDescriptionArray[1] = "Capacity: 100000000L"; + } + + public GT_MetaTileEntity_GiantOutputHatch(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_GiantOutputHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public int getCapacity() { + return 100000000; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_HumongousInputHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_HumongousInputHatch.java new file mode 100644 index 0000000000..e9db8ac2d5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_HumongousInputHatch.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +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; + +public class GT_MetaTileEntity_HumongousInputHatch extends GT_MetaTileEntity_Hatch_Input { + + public GT_MetaTileEntity_HumongousInputHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 13); + this.mDescriptionArray[1] = "Capacity: 2,000,000,000L"; + } + + public GT_MetaTileEntity_HumongousInputHatch(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getCapacity() { + return 2_000_000_000; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_HumongousInputHatch( + this.mName, + this.mTier, + this.mDescriptionArray, + this.mTextures); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java new file mode 100644 index 0000000000..6a66b5209f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java @@ -0,0 +1,499 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import static gregtech.api.enums.GT_Values.ticksBetweenSounds; + +import java.util.Collections; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.MathUtils; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.shapes.Rectangle; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.ProgressBar.Direction; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.RecipeMapWorkable; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch + implements RecipeMapWorkable, IAddGregtechLogo { + + private final int cap; + public int sievert; + private long timer = 1; + private long decayTime = 1; + private short[] colorForGUI = { 0x02, 0x02, 0x02 }; + private byte mass; + private String material; + private byte coverage; + private ItemStack lastUsedItem = null; + private boolean lastFail = false; + private GT_Recipe lastRecipe = null; + + public GT_MetaTileEntity_RadioHatch(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + new String[] { StatCollector.translateToLocal("tooltip.tile.radhatch.0.name"), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.3.name") + " " + + (aTier - 2) + + " " + + (aTier - 2 >= 2 ? StatCollector.translateToLocal("tooltip.bw.kg.1.name") + : StatCollector.translateToLocal("tooltip.bw.kg.0.name")), + StatCollector.translateToLocal("tooltip.tile.radhatch.1.name"), + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }); + this.cap = aTier - 2; + } + + public GT_MetaTileEntity_RadioHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + this.cap = aTier - 2; + } + + public int getSievert() { + return this.sievert - MathUtils.ceilInt(this.sievert / 100f * this.coverage); + } + + public short[] getColorForGUI() { + if (this.colorForGUI != null) return this.colorForGUI; + return this.colorForGUI = new short[] { 0xFA, 0xFA, 0xFF }; + } + + public byte getMass() { + return this.mass; + } + + public byte getCoverage() { + return this.coverage; + } + + public void setCoverage(short coverage) { + byte nu; + if (coverage > 100) nu = 100; + else if (coverage < 0) nu = 0; + else nu = (byte) coverage; + this.coverage = nu; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.of(Textures.BlockIcons.OVERLAY_PIPE_IN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.of(Textures.BlockIcons.OVERLAY_PIPE_IN) }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_RadioHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + public void updateSlots() { + if (this.mInventory[0] != null && this.mInventory[0].stackSize <= 0) this.mInventory[0] = null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + BaseMetaTileEntity myMetaTileEntity = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); + if (myMetaTileEntity.isServerSide()) { + + if (this.mass > 0) { + ++this.timer; + } + + if (this.mass > 0 && (this.decayTime == 0 || this.decayTime > 0 && this.timer % this.decayTime == 0)) { + this.mass--; + if (this.mass == 0) { + this.material = StatCollector.translateToLocal("tooltip.bw.empty.name"); + this.sievert = 0; + } + this.timer = 1; + } + + if (myMetaTileEntity.mTickTimer > myMetaTileEntity.mLastSoundTick + ticksBetweenSounds + && this.sievert > 0) { + this.sendLoopStart((byte) 1); + myMetaTileEntity.mLastSoundTick = myMetaTileEntity.mTickTimer; + } + + if (this.mass == 0) { + ItemStack lStack = this.mInventory[0]; + + if (lStack == null) { + this.colorForGUI = new short[] { 0x37, 0x37, 0x37 }; + return; + } + ItemData itemData = GT_OreDictUnificator.getAssociation(lStack); + if (itemData != null) { + Materials mat = itemData.mMaterial.mMaterial; + this.colorForGUI = new short[] { mat.getRGBA()[0], mat.getRGBA()[1], mat.getRGBA()[2] }; + } else { + this.colorForGUI = new short[] { 0x37, 0x37, 0x37 }; + } + + if (this.lastFail && GT_Utility.areStacksEqual(this.lastUsedItem, lStack, true)) { + return; + } + + if (!this.lastFail && this.lastUsedItem != null && this.lastRecipe != null) { + if (GT_Utility.areStacksEqual(this.lastUsedItem, lStack, true)) { + this.mass = (byte) this.lastRecipe.mDuration; + this.decayTime = this.lastRecipe.mSpecialValue; + this.sievert = this.lastRecipe.mEUt; + this.material = this.lastUsedItem.getDisplayName(); + lStack.stackSize--; + this.updateSlots(); + } else { + this.lastRecipe = null; + } + } + + if (this.lastRecipe == null || this.lastFail) { + this.lastRecipe = BartWorksRecipeMaps.radioHatchRecipes.findRecipe( + this.getBaseMetaTileEntity(), + false, + Integer.MAX_VALUE - 7, + null, + this.mInventory[0]); + if (this.lastRecipe == null) { + this.lastFail = true; + this.lastUsedItem = this.mInventory[0] == null ? null : this.mInventory[0].copy(); + } else { + if (this.lastRecipe.mDuration > this.cap) { + this.lastFail = true; + this.lastUsedItem = this.mInventory[0].copy(); + return; + } + this.lastFail = false; + this.lastUsedItem = this.mInventory[0].copy(); + this.mass = (byte) this.lastRecipe.mDuration; + this.decayTime = this.lastRecipe.mSpecialValue; + this.sievert = this.lastRecipe.mEUt; + this.material = lStack.getDisplayName(); + lStack.stackSize--; + this.updateSlots(); + } + } + } + } + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + if (this.sievert != 0) return new String[] { + StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + + StatCollector.translateToLocal(this.material), + StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + this.sievert, + StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + this.mass, + StatCollector.translateToLocal("tooltip.tile.radhatch.5.name") + " " + + (this.decayTime - this.timer % (this.decayTime * 60)) + + StatCollector.translateToLocal("tooltip.tile.radhatch.6.name") + + "/" + + (this.decayTime - this.timer % this.decayTime) / 20 + + StatCollector.translateToLocal("tooltip.tile.radhatch.7.name") + + "/" + + (this.decayTime - this.timer % this.decayTime) / 20 / 60 + + StatCollector.translateToLocal("tooltip.tile.radhatch.8.name") + + "/" + + (this.decayTime - this.timer % this.decayTime) / 20 / 60 / 60 + + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name") }; + return new String[] { + StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + + StatCollector.translateToLocal("tooltip.bw.empty.name"), + StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + "0", + StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + "0" }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing() && BartWorksRecipeMaps.radioHatchRecipes.containsInput(aStack); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mMass", this.mass); + aNBT.setByte("mSv", (byte) (this.sievert - 100)); + aNBT.setByte("mCoverage", this.coverage); + aNBT.setInteger("mTextColor", BW_ColorUtil.getColorFromRGBArray(this.getColorForGUI())); + if (this.material != null && !this.material.isEmpty()) aNBT.setString("mMaterial", this.material); + aNBT.setLong("timer", this.timer); + aNBT.setLong("decay", this.decayTime); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.timer = aNBT.getLong("timer"); + this.mass = aNBT.getByte("mMass"); + this.sievert = aNBT.getByte("mSv") + 100; + this.coverage = aNBT.getByte("mCoverage"); + this.colorForGUI = BW_ColorUtil.splitColorToRBGArray(aNBT.getInteger("mTextColor")); + this.material = aNBT.getString("mMaterial"); + this.decayTime = aNBT.getLong("decay"); + super.loadNBTData(aNBT); + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + ResourceLocation rl = new ResourceLocation(MainMod.MOD_ID, "hatch.RadOn"); + if (aIndex == 1) { + GT_Utility.doSoundAtClient(rl, 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public RecipeMap getRecipeMap() { + // Only for visual + return BartWorksRecipeMaps.radioHatchRecipes; + } + + private static final int RADIATION_SHUTTER_WINDOW_ID = 999; + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + buildContext.addSyncedWindow(RADIATION_SHUTTER_WINDOW_ID, this::createShutterWindow); + + this.getBaseMetaTileEntity() + .add1by1Slot(builder); + builder.widget( + new DrawableWidget().setBackground(BW_UITextures.PICTURE_SIEVERT_CONTAINER) + .setPos(61, 9) + .setSize(56, 24)) + .widget( + new ProgressBar().setProgress(() -> this.getSievert() / 148f) + .setDirection(Direction.RIGHT) + .setTexture(BW_UITextures.PROGRESSBAR_SIEVERT, 24) + .setPos(65, 13) + .setSize(48, 16)) + .widget( + new DrawableWidget().setBackground(BW_UITextures.PICTURE_DECAY_TIME_INSIDE) + .setPos(124, 18) + .setSize(16, 48)) + .widget(new DrawableWidget() { + + @Override + public void draw(float partialTicks) { + if (GT_MetaTileEntity_RadioHatch.this.decayTime > 0) { + int height = MathUtils.ceilInt( + 48 * ((GT_MetaTileEntity_RadioHatch.this.decayTime + - GT_MetaTileEntity_RadioHatch.this.timer % GT_MetaTileEntity_RadioHatch.this.decayTime) + / (float) GT_MetaTileEntity_RadioHatch.this.decayTime)); + new Rectangle() + .setColor( + Color.argb( + GT_MetaTileEntity_RadioHatch.this.colorForGUI[0], + GT_MetaTileEntity_RadioHatch.this.colorForGUI[1], + GT_MetaTileEntity_RadioHatch.this.colorForGUI[2], + 255)) + .draw(new Pos2d(0, 48 - height), new Size(16, height), partialTicks); + } + } + }.dynamicTooltip( + () -> Collections.singletonList( + StatCollector.translateToLocalFormatted( + "tooltip.tile.radhatch.10.name", + this.timer <= 1 ? 0 : (this.decayTime - this.timer) / 20, + this.timer <= 1 ? 0 : this.decayTime / 20))) + .setPos(124, 18) + .setSize(16, 48) + .attachSyncer( + new FakeSyncWidget.LongSyncer(() -> this.decayTime, val -> this.decayTime = val), + builder, + (widget, val) -> widget.notifyTooltipChange()) + .attachSyncer( + new FakeSyncWidget.LongSyncer(() -> this.timer, val -> this.timer = val), + builder, + (widget, val) -> widget.notifyTooltipChange())) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[0], val -> this.colorForGUI[0] = val)) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[1], val -> this.colorForGUI[1] = val)) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[2], val -> this.colorForGUI[2] = val)) + .widget( + new DrawableWidget().setBackground(BW_UITextures.PICTURE_DECAY_TIME_CONTAINER) + .setPos(120, 14) + .setSize(24, 56)) + .widget( + new TextWidget() + .setStringSupplier( + () -> StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.1", this.mass)) + .setTextAlignment(Alignment.Center) + .setPos(65, 62)) + .widget(new FakeSyncWidget.ByteSyncer(() -> this.mass, val -> this.mass = val)) + .widget( + new TextWidget() + .setStringSupplier( + () -> StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.0", this.getSievert())) + .setTextAlignment(Alignment.Center) + .setPos(60, 72)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> this.sievert, val -> this.sievert = val)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(RADIATION_SHUTTER_WINDOW_ID); + } + }) + .addTooltip("Radiation Shutter") + .setBackground(GT_UITextures.BUTTON_STANDARD) + .setPos(153, 5) + .setSize(18, 18)) + .widget( + new ItemDrawable( + GT_MetaGenerated_Tool_01.INSTANCE + .getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, null, null, null)).asWidget() + .setPos(154, 6)); + } + + private ModularWindow createShutterWindow(EntityPlayer player) { + ModularWindow.Builder builder = ModularWindow.builder(176, 107); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.setGuiTint(this.getGUIColorization()); + + builder.widget( + new TextWidget("Radiation Shutter Control").setDefaultColor(this.COLOR_TITLE.get()) + .setPos(10, 9)) + .widget( + new DrawableWidget().setDrawable(BW_UITextures.PICTURE_RADIATION_SHUTTER_FRAME) + .setPos(14, 27) + .setSize(55, 54)) + .widget( + new DrawableWidget() + .setDrawable(() -> this.coverage < 100 ? BW_UITextures.PICTURE_RADIATION_SHUTTER_INSIDE : null) + .setPos(16, 29) + .setSize(51, 50) + .attachSyncer( + new FakeSyncWidget.ByteSyncer(this::getCoverage, this::setCoverage), + builder, + (widget, val) -> widget.setPos(16, 29 + this.coverage / 2) + .setSize(51, 50 - this.coverage / 2))) + .widget( + new NumericWidget().setSetter(val -> this.coverage = (byte) val) + .setGetter(() -> this.coverage) + .setBounds(0, 100) + .setScrollValues(1, 5, 50) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(86, 27) + .setSize(30, 12)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(176 - 15, 3)); + + return builder.build(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(BW_UITextures.PICTURE_BW_LOGO_47X21) + .setSize(47, 21) + .setPos(10, 53)); + } + + @Override + public GUITextureSet getGUITextureSet() { + return new GUITextureSet().setMainBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT) + .setGregTechLogo(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT); + } + + @Override + public boolean useModularUI() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java new file mode 100644 index 0000000000..46f20e441d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IBasicEnergyContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; + +public class GT_MetaTileEntity_Transistor extends GT_MetaTileEntity_TieredMachineBlock { + + boolean powered; + + public GT_MetaTileEntity_Transistor(int aID, String aName, String aNameRegional, int aTier, String aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 0, aDescription, aTextures); + } + + public GT_MetaTileEntity_Transistor(int aID, String aName, String aNameRegional, int aTier, String[] aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 0, aDescription, aTextures); + } + + public GT_MetaTileEntity_Transistor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + public GT_MetaTileEntity_Transistor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + rTextures[1][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + rTextures[2][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + rTextures[3][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[this.mTier] }; + rTextures[4][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[this.mTier] }; + rTextures[5][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[this.mTier] }; + rTextures[6][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier] }; + rTextures[7][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier] }; + rTextures[8][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier] }; + rTextures[9][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + rTextures[10][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + rTextures[11][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + } + + return rTextures; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Transistor(this.mName, this.mTier, this.getDescription(), null); + } + + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) {} + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + final ForgeDirection side = ForgeDirection.EAST; + if (aBaseMetaTileEntity.inputEnergyFrom(side)) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); + if (!(tTileEntity instanceof IBasicEnergyContainer tileAtSide)) { + this.powered = false; + return; + } + if (!tileAtSide.outputsEnergyTo(ForgeDirection.WEST) || !tileAtSide.isUniversalEnergyStored(4L) + || !tileAtSide.decreaseStoredEnergyUnits(4, false)) { + this.powered = false; + return; + } + if (aBaseMetaTileEntity.injectEnergyUnits(side, 4L, 1L) == 4L) { + this.powered = true; + } + } + + if (aBaseMetaTileEntity.isAllowedToWork()) this.powered = !this.powered; + } + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxAmperesIn() { + return 1L; + } + + @Override + public long maxAmperesOut() { + return this.powered ? 1L : 0; + } + + @Override + public long maxEUOutput() { + return this.powered ? GT_Values.V[this.mTier] : 0; + } + + @Override + public void loadNBTData(NBTTagCompound nbtTagCompound) {} + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity iGregTechTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean b3, boolean b4) { + return new ITexture[0]; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java new file mode 100644 index 0000000000..40233912e6 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.neiHandler; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.items.LabParts; + +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.recipe.RecipeCategory; +import gregtech.nei.GT_NEI_DefaultHandler; + +public class BW_NEI_BioLabHandler extends GT_NEI_DefaultHandler { + + public BW_NEI_BioLabHandler(RecipeCategory recipeCategory) { + super(recipeCategory); + if (!NEI_BW_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage( + GT_Values.GT, + "NEIPlugins", + "register-crafting-handler", + "gregtech@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + @Override + public TemplateRecipeHandler newInstance() { + return new BW_NEI_BioLabHandler(this.recipeCategory); + } + + @Override + public void loadCraftingRecipes(ItemStack aResult) { + if (aResult != null && aResult.getItem() instanceof LabParts + && aResult.getItemDamage() < 3 + && aResult.getTagCompound() != null) { + for (CachedDefaultRecipe recipe : this.getCache()) + if (NEI_BW_Config.checkRecipe(aResult, recipe.mOutputs)) this.arecipes.add(recipe); + } else { + super.loadCraftingRecipes(aResult); + } + } + + @Override + public void loadUsageRecipes(ItemStack aResult) { + if (aResult != null && aResult.getItem() instanceof LabParts + && aResult.getItemDamage() < 3 + && aResult.getTagCompound() != null) { + for (CachedDefaultRecipe recipe : this.getCache()) + if (NEI_BW_Config.checkRecipe(aResult, recipe.mInputs)) this.arecipes.add(recipe); + } else { + super.loadUsageRecipes(aResult); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java new file mode 100644 index 0000000000..cddb16c6c8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.neiHandler; + +import java.util.Collections; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.common.items.LabParts; + +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.recipe.RecipeCategory; +import gregtech.nei.GT_NEI_DefaultHandler; + +public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { + + public BW_NEI_BioVatHandler(RecipeCategory recipeCategory) { + super(recipeCategory); + if (!NEI_BW_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage( + GT_Values.GT, + "NEIPlugins", + "register-crafting-handler", + "gregtech@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + @Override + public TemplateRecipeHandler newInstance() { + return new BW_NEI_BioVatHandler(this.recipeCategory); + } + + private void loadLabPartRecipes(ItemStack aResult) { + for (CachedDefaultRecipe recipe : this.getCache()) { + // dirty way of finding the special slot item + // see constructor of CachedDefaultRecipe on why relx==120 and rely==52 means special slot + for (PositionedStack stack : recipe.mInputs) { + if (stack.relx == 120 && stack.rely == 52 + && NEI_BW_Config.checkRecipe(aResult, Collections.singletonList(stack))) this.arecipes.add(recipe); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack aResult) { + if (aResult != null && aResult.getItem() instanceof LabParts + && aResult.getItemDamage() < 3 + && aResult.getTagCompound() != null) { + this.loadLabPartRecipes(aResult); + } else { + super.loadUsageRecipes(aResult); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java new file mode 100644 index 0000000000..2b34250512 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.neiHandler; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_SmallOres; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_OreLayer; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_WorldGenRoss128b; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_WorldGenRoss128ba; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.OrePrefixes; + +public class BW_NEI_OreHandler extends TemplateRecipeHandler { + + public BW_NEI_OreHandler() { + if (!NEI_BW_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage( + MainMod.MOD_ID, + "NEIPlugins", + "register-crafting-handler", + MainMod.MOD_ID + "@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + } + } + + @Override + public void drawBackground(int recipe) { + GuiDraw.drawRect(0, 0, 166, 65, 0x888888); + } + + @Override + public void loadTransferRects() { + this.transferRects.add( + new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(0, 40, 40, 120), "quickanddirtyneihandler")); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if ("quickanddirtyneihandler".equalsIgnoreCase(outputId)) { + HashSet result = new HashSet<>(); + Werkstoff.werkstoffHashSet.stream() + .filter(w -> w.hasGenerationFeature(OrePrefixes.ore)) + .forEach(w -> result.add(w.get(OrePrefixes.ore))); + result.forEach(this::loadCraftingRecipes); + result.clear(); + Werkstoff.werkstoffHashSet.stream() + .filter(w -> w.hasGenerationFeature(OrePrefixes.ore)) + .forEach(w -> result.add(w.get(OrePrefixes.oreSmall))); + result.forEach(this::loadCraftingRecipes); + result.clear(); + HashSet hashSet = new HashSet<>(this.arecipes); + this.arecipes.clear(); + this.arecipes.addAll(hashSet); + } + if ("item".equals(outputId)) { + this.loadCraftingRecipes((ItemStack) results[0]); + HashSet hashSet = new HashSet<>(this.arecipes); + this.arecipes.clear(); + this.arecipes.addAll(hashSet); + } + } + + @Override + public void drawExtras(int recipe) { + if (recipe < this.arecipes.size() && this.arecipes.get(recipe) instanceof CachedOreRecipe) { + CachedOreRecipe cachedOreRecipe = (CachedOreRecipe) this.arecipes.get(recipe); + + if (cachedOreRecipe == null || cachedOreRecipe.getOtherStacks() == null + || cachedOreRecipe.getOtherStacks() + .size() == 0) + return; + + if (!cachedOreRecipe.small) { + if (cachedOreRecipe.getOtherStacks() + .get(0) == null + || cachedOreRecipe.getOtherStacks() + .get(0).item == null + || cachedOreRecipe.getOtherStacks() + .get(1) == null + || cachedOreRecipe.getOtherStacks() + .get(2) == null + || cachedOreRecipe.getOtherStacks() + .get(3) == null + || cachedOreRecipe.getOtherStacks() + .get(1).item == null + || cachedOreRecipe.getOtherStacks() + .get(2).item == null + || cachedOreRecipe.getOtherStacks() + .get(3).item == null) + return; + } else if (cachedOreRecipe.getOtherStacks() + .get(0) == null + || cachedOreRecipe.getOtherStacks() + .get(0).item == null) + return; + + if (cachedOreRecipe.worldGen != null) GuiDraw.drawString( + ChatColorHelper.BOLD + "DIM: " + ChatColorHelper.RESET + cachedOreRecipe.worldGen.getDimName(), + 0, + 40, + 0, + false); + + GuiDraw.drawString(ChatColorHelper.BOLD + "Primary:", 0, 50, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(0).item.getDisplayName(), + 0, + 60, + 0, + false); + + if (!cachedOreRecipe.small) { + GuiDraw.drawString(ChatColorHelper.BOLD + "Secondary:", 0, 70, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(1).item.getDisplayName(), + 0, + 80, + 0, + false); + GuiDraw.drawString(ChatColorHelper.BOLD + "InBetween:", 0, 90, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(2).item.getDisplayName(), + 0, + 100, + 0, + false); + GuiDraw.drawString(ChatColorHelper.BOLD + "Sporadic:", 0, 110, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(3).item.getDisplayName(), + 0, + 120, + 0, + false); + } else if (cachedOreRecipe.worldGen != null) { + GuiDraw.drawString(ChatColorHelper.BOLD + "Amount per Chunk:", 0, 70, 0, false); + GuiDraw.drawString(cachedOreRecipe.worldGen.mDensity + "", 0, 80, 0, false); + } + } + super.drawExtras(recipe); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + Block ore = Block.getBlockFromItem(result.getItem()); + if (ore instanceof BW_MetaGenerated_Ores) { + BW_OreLayer.NEIMAP.get((short) result.getItemDamage()) + .stream() + .filter( + l -> !(ore instanceof BW_MetaGenerated_SmallOres) || !l.getClass() + .equals(BW_WorldGenRoss128b.class) + && !l.getClass() + .equals(BW_WorldGenRoss128ba.class)) + .forEach( + l -> this.arecipes.add(new CachedOreRecipe(l, result, ore instanceof BW_MetaGenerated_SmallOres))); + } + } + + @Override + public String getGuiTexture() { + return "textures/gui/container/brewing_stand.png"; + } + + @Override + public String getRecipeName() { + return "BartWorks Ores"; + } + + class CachedOreRecipe extends TemplateRecipeHandler.CachedRecipe { + + public CachedOreRecipe(BW_OreLayer worldGen, ItemStack result, boolean smallOres) { + this.worldGen = worldGen; + this.stack = new PositionedStack(result, 0, 0); + this.small = smallOres; + } + + boolean small; + BW_OreLayer worldGen; + PositionedStack stack; + + @Override + public PositionedStack getResult() { + return this.stack; + } + + @Override + public List getOtherStacks() { + List ret = new ArrayList<>(); + int x = 0; + for (int i = 0; i < (this.small ? 1 : 4); i++) { + x += 20; + ret.add( + new PositionedStack( + this.worldGen.getStacks() + .get(i), + x, + 12)); + } + return ret; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CachedOreRecipe that)) return false; + return Objects.equals(this.worldGen, that.worldGen); + } + + @Override + public int hashCode() { + return this.worldGen.hashCode(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java new file mode 100644 index 0000000000..a6efebeb83 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.neiHandler; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import codechicken.nei.PositionedStack; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import gregtech.api.enums.OrePrefixes; + +public class NEI_BW_Config implements IConfigureNEI { + + static boolean sIsAdded = true; + + static boolean checkRecipe(ItemStack labPart, Iterable stacks) { + for (PositionedStack stack : stacks) { + for (ItemStack item : stack.items) { + if (labPart.getTagCompound() + .equals(item.getTagCompound())) { + return true; + } + } + } + return false; + } + + @Override + public void loadConfig() { + API.hideItem(new ItemStack(ItemRegistry.TAB)); + API.hideItem(new ItemStack(FluidLoader.bioFluidBlock)); + API.hideItem(new ItemStack(ItemRegistry.bw_fake_glasses)); + API.hideItem(new ItemStack(ItemRegistry.bw_fake_glasses2)); + ItemStack[] prefixesToHide = { + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustTiny, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustSmall, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushed, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedPurified, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedCentrifuged, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.nugget, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemChipped, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawed, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawless, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemExquisite, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustImpure, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustPure, WerkstoffLoader.Bismutite) + .copy(), }; + for (ItemStack stack : prefixesToHide) { + stack.setItemDamage(Short.MAX_VALUE); + API.hideItem(stack); + } + + NEI_BW_Config.sIsAdded = false; + new BW_NEI_OreHandler(); + new BW_NEI_BioVatHandler(BartWorksRecipeMaps.bacterialVatRecipes.getDefaultRecipeCategory()); + new BW_NEI_BioLabHandler(BartWorksRecipeMaps.bioLabRecipes.getDefaultRecipeCategory()); + NEI_BW_Config.sIsAdded = true; + } + + @Override + public String getName() { + return "BartWorks NEI Plugin"; + } + + @Override + public String getVersion() { + return MainMod.APIVERSION; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java new file mode 100644 index 0000000000..3ea2f28cb9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.server.EventHandler; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.net.OreDictCachePacket; +import com.github.bartimaeusnek.bartworks.common.net.ServerJoinedPackage; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +public class ServerEventHandler { + + // MinecraftForge.EVENT_BUS + @SubscribeEvent(priority = EventPriority.LOWEST) + public void EntityJoinWorldEvent(EntityJoinWorldEvent event) { + if (event == null || !(event.entity instanceof EntityPlayerMP) || !SideReference.Side.Server) return; + MainMod.BW_Network_instance + .sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity); + MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPackage(null), (EntityPlayerMP) event.entity); + } + + // FMLCommonHandler.instance().bus() + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerTickEventServer(TickEvent.PlayerTickEvent event) { + if (event == null || !(event.player instanceof EntityPlayerMP) + || event.player.worldObj.getTotalWorldTime() % 20 != 0) return; + + boolean replace = false; + ItemStack toReplace = null; + for (int i = 0; i < event.player.inventory.mainInventory.length; i++) { + ItemStack stack = event.player.inventory.mainInventory[i]; + if (stack == null) continue; + int[] oreIDs = OreDictionary.getOreIDs(stack); + + if (oreIDs.length > 0) { + loop: for (int oreID : oreIDs) { + String oreDictName = OreDictionary.getOreName(oreID); + for (Werkstoff e : Werkstoff.werkstoffHashSet) { + replace = e.getGenerationFeatures().enforceUnification; + if (replace) { + if (oreDictName.contains(e.getVarName())) { + String prefix = oreDictName.replace(e.getVarName(), ""); + OrePrefixes prefixes = OrePrefixes.getPrefix(prefix); + if (prefixes == null) { + continue; + } + toReplace = GT_OreDictUnificator.get(prefixes, e.getVarName(), stack.stackSize); + break loop; + } + for (String s : e.getADDITIONAL_OREDICT()) { + if (oreDictName.contains(s)) { + String prefix = oreDictName.replace(s, ""); + OrePrefixes prefixes = OrePrefixes.getPrefix(prefix); + if (prefixes == null) { + continue; + } + toReplace = GT_OreDictUnificator.get(prefixes, e.getVarName(), stack.stackSize); + break loop; + } + } + } + replace = false; + } + } + } + if (replace && toReplace != null) { + event.player.inventory.setInventorySlotContents(i, toReplace); + replace = false; + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_GT_MaterialReference.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_GT_MaterialReference.java new file mode 100644 index 0000000000..87ee19833d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_GT_MaterialReference.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +package com.github.bartimaeusnek.bartworks.system.material; + +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.Types.BIOLOGICAL; +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.Types.COMPOUND; +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.Types.ELEMENT; +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.Types.ISOTOPE; +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.Types.MIXTURE; + +import com.github.bartimaeusnek.bartworks.MainMod; + +import gregtech.api.enums.Materials; + +public class BW_GT_MaterialReference { + + private static final Werkstoff.GenerationFeatures ADD_CASINGS_ONLY = new Werkstoff.GenerationFeatures().disable() + .addCasings(); + + public static Werkstoff Aluminium = new Werkstoff(Materials.Aluminium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 19); + public static Werkstoff Americium = new Werkstoff(Materials.Americium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 103); + public static Werkstoff Antimony = new Werkstoff(Materials.Antimony, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 58); + public static Werkstoff Arsenic = new Werkstoff(Materials.Arsenic, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 39); + public static Werkstoff Barium = new Werkstoff(Materials.Barium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 63); + public static Werkstoff Beryllium = new Werkstoff(Materials.Beryllium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 8); + public static Werkstoff Bismuth = new Werkstoff(Materials.Bismuth, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 90); + public static Werkstoff Boron = new Werkstoff(Materials.Boron, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 9); + public static Werkstoff Caesium = new Werkstoff(Materials.Caesium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 62); + public static Werkstoff Carbon = new Werkstoff(Materials.Carbon, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 10); + public static Werkstoff Cadmium = new Werkstoff(Materials.Cadmium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 55); + public static Werkstoff Cerium = new Werkstoff(Materials.Cerium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 65); + public static Werkstoff Chrome = new Werkstoff(Materials.Chrome, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 30); + public static Werkstoff Cobalt = new Werkstoff(Materials.Cobalt, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 33); + public static Werkstoff Copper = new Werkstoff(Materials.Copper, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 35); + public static Werkstoff Dysprosium = new Werkstoff(Materials.Dysprosium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 73); + public static Werkstoff Erbium = new Werkstoff(Materials.Erbium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 75); + public static Werkstoff Europium = new Werkstoff(Materials.Europium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 70); + public static Werkstoff Gadolinium = new Werkstoff(Materials.Gadolinium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 71); + public static Werkstoff Gallium = new Werkstoff(Materials.Gallium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 37); + public static Werkstoff Gold = new Werkstoff(Materials.Gold, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 86); + public static Werkstoff Holmium = new Werkstoff(Materials.Holmium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 74); + public static Werkstoff Indium = new Werkstoff(Materials.Indium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 56); + public static Werkstoff Iridium = new Werkstoff(Materials.Iridium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 84); + public static Werkstoff Iron = new Werkstoff(Materials.Iron, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 32); + public static Werkstoff Lanthanum = new Werkstoff(Materials.Lanthanum, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 64); + public static Werkstoff Lead = new Werkstoff(Materials.Lead, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 89); + public static Werkstoff Lithium = new Werkstoff(Materials.Lithium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 6); + public static Werkstoff Lutetium = new Werkstoff(Materials.Lutetium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 78); + public static Werkstoff Magnesium = new Werkstoff(Materials.Magnesium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 18); + public static Werkstoff Manganese = new Werkstoff(Materials.Manganese, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 31); + public static Werkstoff Molybdenum = new Werkstoff(Materials.Molybdenum, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 48); + public static Werkstoff Neodymium = new Werkstoff(Materials.Neodymium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 67); + public static Werkstoff Neutronium = new Werkstoff(Materials.Neutronium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 129); + public static Werkstoff Nickel = new Werkstoff(Materials.Nickel, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 34); + public static Werkstoff Niobium = new Werkstoff(Materials.Niobium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 47); + public static Werkstoff Osmium = new Werkstoff(Materials.Osmium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 83); + public static Werkstoff Palladium = new Werkstoff(Materials.Palladium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 52); + public static Werkstoff Phosphorus = new Werkstoff(Materials.Phosphorus, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 21); + public static Werkstoff Platinum = new Werkstoff(Materials.Platinum, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 85); + public static Werkstoff Plutonium241 = new Werkstoff( + Materials.Plutonium241, + ADD_CASINGS_ONLY, + ISOTOPE, + 31_766 + 101); + public static Werkstoff Potassium = new Werkstoff(Materials.Potassium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 25); + public static Werkstoff Praseodymium = new Werkstoff( + Materials.Praseodymium, + ADD_CASINGS_ONLY, + ELEMENT, + 31_766 + 66); + public static Werkstoff Promethium = new Werkstoff(Materials.Promethium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 68); + public static Werkstoff Rubidium = new Werkstoff(Materials.Rubidium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 43); + public static Werkstoff Samarium = new Werkstoff(Materials.Samarium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 69); + public static Werkstoff Scandium = new Werkstoff(Materials.Scandium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 27); + public static Werkstoff Silicon = new Werkstoff(Materials.Silicon, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 20); + public static Werkstoff Silver = new Werkstoff(Materials.Silver, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 54); + public static Werkstoff Sodium = new Werkstoff(Materials.Sodium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 17); + public static Werkstoff Strontium = new Werkstoff(Materials.Strontium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 44); + public static Werkstoff Sulfur = new Werkstoff(Materials.Sulfur, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 22); + public static Werkstoff Tantalum = new Werkstoff(Materials.Tantalum, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 80); + public static Werkstoff Terbium = new Werkstoff(Materials.Terbium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 72); + public static Werkstoff Thorium = new Werkstoff(Materials.Thorium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 96); + public static Werkstoff Thulium = new Werkstoff(Materials.Thulium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 76); + public static Werkstoff Tin = new Werkstoff(Materials.Tin, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 57); + public static Werkstoff Titanium = new Werkstoff(Materials.Titanium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 28); + public static Werkstoff Tritanium = new Werkstoff(Materials.Tritanium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 329); + public static Werkstoff Tritium = new Werkstoff(Materials.Tritium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 3); + public static Werkstoff Tungsten = new Werkstoff(Materials.Tungsten, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 81); + public static Werkstoff Uranium = new Werkstoff(Materials.Uranium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 98); + public static Werkstoff Uranium235 = new Werkstoff(Materials.Uranium235, ADD_CASINGS_ONLY, ISOTOPE, 31_766 + 97); + public static Werkstoff Vanadium = new Werkstoff(Materials.Vanadium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 29); + public static Werkstoff Ytterbium = new Werkstoff(Materials.Ytterbium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 77); + public static Werkstoff Yttrium = new Werkstoff(Materials.Yttrium, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 45); + public static Werkstoff Zinc = new Werkstoff(Materials.Zinc, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 36); + public static Werkstoff Ardite = new Werkstoff(Materials.Ardite, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 382); + public static Werkstoff Naquadah = new Werkstoff(Materials.Naquadah, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 324); + public static Werkstoff NaquadahAlloy = new Werkstoff( + Materials.NaquadahAlloy, + ADD_CASINGS_ONLY, + COMPOUND, + 31_766 + 325); + public static Werkstoff NaquadahEnriched = new Werkstoff( + Materials.NaquadahEnriched, + ADD_CASINGS_ONLY, + ISOTOPE, + 31_766 + 326); + public static Werkstoff Naquadria = new Werkstoff(Materials.Naquadria, ADD_CASINGS_ONLY, ELEMENT, 31_766 + 327); + public static Werkstoff WroughtIron = new Werkstoff(Materials.WroughtIron, ADD_CASINGS_ONLY, ISOTOPE, 31_766 + 304); + public static Werkstoff AnnealedCopper = new Werkstoff( + Materials.AnnealedCopper, + ADD_CASINGS_ONLY, + ISOTOPE, + 31_766 + 345); + + public static Werkstoff Osmiridium = new Werkstoff(Materials.Osmiridium, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 317); + public static Werkstoff SterlingSilver = new Werkstoff( + Materials.SterlingSilver, + ADD_CASINGS_ONLY, + MIXTURE, + 31_766 + 350); + public static Werkstoff RoseGold = new Werkstoff(Materials.RoseGold, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 351); + public static Werkstoff BlackBronze = new Werkstoff(Materials.BlackBronze, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 352); + public static Werkstoff BismuthBronze = new Werkstoff( + Materials.BismuthBronze, + ADD_CASINGS_ONLY, + MIXTURE, + 31_766 + 353); + public static Werkstoff BlackSteel = new Werkstoff(Materials.BlackSteel, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 334); + public static Werkstoff RedSteel = new Werkstoff(Materials.RedSteel, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 348); + public static Werkstoff BlueSteel = new Werkstoff(Materials.BlueSteel, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 349); + public static Werkstoff DamascusSteel = new Werkstoff( + Materials.DamascusSteel, + ADD_CASINGS_ONLY, + MIXTURE, + 31_766 + 335); + public static Werkstoff TungstenSteel = new Werkstoff( + Materials.TungstenSteel, + ADD_CASINGS_ONLY, + MIXTURE, + 31_766 + 316); + public static Werkstoff Ultimet = new Werkstoff(Materials.Ultimet, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 344); + public static Werkstoff TungstenCarbide = new Werkstoff( + Materials.TungstenCarbide, + ADD_CASINGS_ONLY, + MIXTURE, + 31_766 + 370); + public static Werkstoff VanadiumSteel = new Werkstoff( + Materials.VanadiumSteel, + ADD_CASINGS_ONLY, + MIXTURE, + 31_766 + 371); + public static Werkstoff HSSG = new Werkstoff(Materials.HSSG, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 372); + public static Werkstoff HSSE = new Werkstoff(Materials.HSSE, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 373); + public static Werkstoff HSSS = new Werkstoff(Materials.HSSS, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 374); + public static Werkstoff StainlessSteel = new Werkstoff( + Materials.StainlessSteel, + ADD_CASINGS_ONLY, + MIXTURE, + 31_766 + 306); + public static Werkstoff Brass = new Werkstoff(Materials.Brass, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 301); + public static Werkstoff Bronze = new Werkstoff(Materials.Bronze, ADD_CASINGS_ONLY, MIXTURE, 31_766 + 300); + + public static Werkstoff Wood = new Werkstoff(Materials.Wood, ADD_CASINGS_ONLY, BIOLOGICAL, 31_766 + 809); + + public static Werkstoff Steel = new Werkstoff(Materials.Steel, ADD_CASINGS_ONLY, COMPOUND, 31_766 + 305); + public static Werkstoff Polytetrafluoroethylene = new Werkstoff( + Materials.Polytetrafluoroethylene, + ADD_CASINGS_ONLY, + COMPOUND, + 31_766 + 473); + public static Werkstoff Plastic = new Werkstoff(Materials.Plastic, ADD_CASINGS_ONLY, COMPOUND, 31_766 + 874); + public static Werkstoff Epoxid = new Werkstoff(Materials.Epoxid, ADD_CASINGS_ONLY, COMPOUND, 31_766 + 470); + public static Werkstoff Magnesia = new Werkstoff( + Materials.Magnesia, + new Werkstoff.GenerationFeatures().disable() + .addMetalItems() + .addMolten(), + COMPOUND, + 31_766 + 471); + + public static void init() { + MainMod.LOGGER.info("Load Elements from GT"); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java new file mode 100644 index 0000000000..41f28d033a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.werkstoffHashMap; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; + +public class BW_MetaGeneratedBlock_Item extends BW_ItemBlocks { + + public BW_MetaGeneratedBlock_Item(Block par1) { + super(par1); + } + + @Override + 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; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + Block block = Block.getBlockFromItem(aStack.getItem()); + if (block instanceof BW_MetaGenerated_Blocks metaBlock) { + int aMetaData = aStack.getItemDamage(); + Werkstoff werkstoff = werkstoffHashMap.get((short) aMetaData); + if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff; + return metaBlock.blockTypeLocalizedName.replace("%material", werkstoff.getLocalizedName()); + } + return GT_LanguageManager.getTranslation(this.getUnlocalizedName(aStack) + ".name"); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + if (!GT_Utility.isStackValid(aStack) || aPlayer == null || aStack.getItemDamage() <= 0) { + return; + } + if (aList == null) { + aList = new ArrayList<>(); + } + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get((short) aStack.getItemDamage()); + if (werkstoff != null) { + String tooltip = werkstoff.getLocalizedToolTip(); + if (!tooltip.isEmpty()) { + aList.add(tooltip); + } + + String owner = werkstoff.getOwner(); + if (owner != null) { + aList.add(BW_Tooltip_Reference.ADDED_VIA_BARTWORKS.apply(owner)); + } else { + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + } else { + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + } + + @Override + 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) this.getDamage(aStack); + if (tDamage > 0) { + if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { + return false; + } + BW_MetaGenerated_Block_TE tTileEntity = (BW_MetaGenerated_Block_TE) aWorld.getTileEntity(aX, aY, aZ); + tTileEntity.mMetaData = tDamage; + } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 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/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java new file mode 100644 index 0000000000..6fb1650c1f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import java.util.List; +import java.util.Optional; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.OrePrefixes; + +public class BW_MetaGeneratedBlocks_Casing extends BW_MetaGenerated_Blocks + implements com.gtnewhorizon.structurelib.structure.ICustomBlockSetting { + + public BW_MetaGeneratedBlocks_Casing(Material p_i45386_1_, Class tileEntity, String blockName, + OrePrefixes prefixes) { + super(p_i45386_1_, tileEntity, blockName, prefixes); + } + + @Override + public String getHarvestTool(int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return 2; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public float getExplosionResistance(Entity aTNT) { + return Blocks.iron_block.getExplosionResistance(aTNT); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetaData); + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + + @Override + protected void doRegistrationStuff(Werkstoff tMaterial) { + GregTech_API.registerMachineBlock(this, -1); + } + + @Override + public String getUnlocalizedName() { + if (this._prefixes == OrePrefixes.blockCasing) return "bw.werkstoffblockscasing.01"; + if (this._prefixes == OrePrefixes.blockCasingAdvanced) return "bw.werkstoffblockscasingadvanced.01"; + return ""; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + Werkstoff.werkstoffHashSet.stream() + .filter( + pMaterial -> Werkstoff.Types.BIOLOGICAL.equals(pMaterial.getType()) + && pMaterial.hasGenerationFeature(OrePrefixes.blockCasing) + || pMaterial.doesOreDictedItemExists(OrePrefixes.plate) + && pMaterial.doesOreDictedItemExists(OrePrefixes.screw) + && pMaterial.doesOreDictedItemExists(OrePrefixes.plateDouble) + && pMaterial.doesOreDictedItemExists(OrePrefixes.gearGt) + && pMaterial.doesOreDictedItemExists(OrePrefixes.gearGtSmall)) + .map(pMaterial -> new ItemStack(aItem, 1, pMaterial.getmID())) + .forEach(aList::add); + } + + /** + * ICustomBlockSetting setBlock override + */ + public void setBlock(World world, int x, int y, int z, int meta) { + world.setBlock(x, y, z, this, meta, 2); + try { + Thread.sleep(1); + // Fucking Minecraft TE settings. + } catch (InterruptedException ignored) {} + Optional.ofNullable(world.getTileEntity(x, y, z)) + .filter(te -> te instanceof BW_MetaGenerated_Block_TE) + .map(te -> (BW_MetaGenerated_Block_TE) te) + .ifPresent(te -> te.mMetaData = (short) meta); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java new file mode 100644 index 0000000000..02dd3c8f58 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; + +public class BW_MetaGeneratedBlocks_CasingAdvanced_TE extends BW_MetaGenerated_Block_TE { + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWBlockCasingsAdvanced; + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + if (SideReference.Side.Client) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + TextureSet set = aMaterial.getTexSet(); + ITexture aIconSet = TextureFactory.of( + PrefixTextureLinker.texMapBlocks.get(OrePrefixes.blockCasingAdvanced) + .getOrDefault(set, TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]), + aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.iron_block), aIconSet }; + } + } + return new ITexture[] { TextureFactory.of(Blocks.iron_block), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]) }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java new file mode 100644 index 0000000000..af61e1a68a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; + +public class BW_MetaGeneratedBlocks_Casing_TE extends BW_MetaGenerated_Block_TE { + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWBlockCasings; + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + if (SideReference.Side.Client) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + TextureSet set = aMaterial.getTexSet(); + ITexture aIconSet = TextureFactory.of( + PrefixTextureLinker.texMapBlocks.get(OrePrefixes.blockCasing) + .getOrDefault(set, TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]), + aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.iron_block), aIconSet }; + } + } + return new ITexture[] { TextureFactory.of(Blocks.iron_block), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]) }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java new file mode 100644 index 0000000000..ee5a0a1511 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static gregtech.api.enums.GT_Values.RA; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ModHandler.RecipeBits; +import gregtech.api.util.GT_OreDictUnificator; + +public class BW_MetaGeneratedFrames extends MetaPipeEntity { + + public final Werkstoff mMaterial; + + public BW_MetaGeneratedFrames(int aID, String aName, String aNameRegional, Werkstoff aMaterial) { + super(aID, aName, aNameRegional, 0); + this.mMaterial = aMaterial; + + GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, aMaterial, this.getStackForm(1)); + GT_ModHandler.addCraftingRecipe( + this.getStackForm(2), + RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SSS", "SwS", "SSS", 'S', this.mMaterial.get(OrePrefixes.stick) }); + + RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.stick, aMaterial.getVarName(), 4), + ItemList.Circuit_Integrated.getWithDamage(0, 4)) + .itemOutputs(getStackForm(1)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(8) + .addTo(assemblerRecipes); + } + + private BW_MetaGeneratedFrames(String aName, Werkstoff aMaterial) { + super(aName, 0); + this.mMaterial = aMaterial; + } + + @Override + public byte getTileEntityBaseType() { + return 4; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new BW_MetaGeneratedFrames(this.mName, this.mMaterial); + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, byte aConnections, + int aColorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { TextureFactory.of( + this.mMaterial.getTexSet().mTextures[OrePrefixes.frameGt.mTextureIndex], + Dyes.getModulation(aColorIndex, this.mMaterial.getRGBA())) }; + } + + @Override + public String[] getDescription() { + return new String[] { "Just something you can put a Cover or CFoam on." }; + } + + @Override + public final boolean isSimpleMachine() { + return true; + } + + @Override + public final boolean isFacingValid(ForgeDirection facing) { + return false; + } + + @Override + public final boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public final boolean renderInside(ForgeDirection side) { + return true; + } + + @Override + public final float getThickNess() { + return 1.0F; + } + + @Override + public final void saveNBTData(NBTTagCompound aNBT) { + /* Do nothing */ + } + + @Override + public final void loadNBTData(NBTTagCompound aNBT) { + /* Do nothing */ + } + + @Override + public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public int connect(ForgeDirection side) { + return 0; + } + + @Override + public void disconnect(ForgeDirection side) { + /* Do nothing */ + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java new file mode 100644 index 0000000000..9b393dff0f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.GT_Mod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_OreDictUnificator; + +public class BW_MetaGeneratedOreTE extends BW_MetaGenerated_Block_TE { + + protected static boolean shouldFortune = false; + protected static boolean shouldSilkTouch = false; + public boolean mNatural = false; + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.mNatural = aNBT.getBoolean("n"); + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setBoolean("n", this.mNatural); + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + ITexture aIconSet = TextureFactory + .of(aMaterial.getTexSet().mTextures[OrePrefixes.ore.mTextureIndex], aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.stone), aIconSet }; + } + return new ITexture[] { TextureFactory.of(Blocks.stone), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex]) }; + } + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWOres; + } + + @Override + public ArrayList getDrops(int aFortune) { + ArrayList rList = new ArrayList<>(); + if (this.mMetaData <= 0) { + rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); + return rList; + } + Materials aOreMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData) + .getBridgeMaterial(); + if (shouldSilkTouch) { + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } else { + switch (GT_Mod.gregtechproxy.oreDropSystem) { + case Item -> { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + case FortuneItem -> { + // if shouldFortune and isNatural then get fortune drops + // if not shouldFortune or not isNatural then get normal drops + // if not shouldFortune and isNatural then get normal drops + // if shouldFortune and not isNatural then get normal drops + if (shouldFortune && this.mNatural && aFortune > 0) { + int aMinAmount = 1; + // Max applicable fortune + if (aFortune > 3) aFortune = 3; + long amount = (long) new Random().nextInt(aFortune) + aMinAmount; + for (int i = 0; i < amount; i++) { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } else { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } + case UnifiedBlock -> { + // Unified ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + case PerDimBlock -> { + // Per Dimension ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + case Block -> { + // Regular ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + } + } + return rList; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java new file mode 100644 index 0000000000..110b17321f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.XSTR; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public class BW_MetaGeneratedSmallOreTE extends BW_MetaGeneratedOreTE { + + @Override + public ArrayList getDrops(int aFortune) { + ArrayList rList = new ArrayList<>(); + Materials aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData) + .getBridgeMaterial(); + + if (aMaterial != null) { + Random tRandom = new XSTR(this.xCoord ^ this.yCoord ^ this.zCoord); + ArrayList tSelector = new ArrayList<>(); + + ItemStack tStack = GT_OreDictUnificator + .get(OrePrefixes.gemExquisite, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 1; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator + .get(OrePrefixes.gemFlawless, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 2; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 12; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get( + OrePrefixes.gemFlawed, + aMaterial, + GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L), + 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get( + OrePrefixes.gemChipped, + aMaterial, + GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L), + 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + if (tSelector.size() > 0) { + int i = 0; + + for (int j = Math.max(1, aFortune > 0 ? tRandom.nextInt(1 + aFortune) : 0); i < j; ++i) { + rList.add(GT_Utility.copyAmount(1L, tSelector.get(tRandom.nextInt(tSelector.size())))); + } + } + if (tRandom.nextInt(3 + aFortune) > 1) { + rList.add( + GT_OreDictUnificator + .get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Stone, 1L)); + } + } + return rList; + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + ITexture aIconSet = TextureFactory + .of(aMaterial.getTexSet().mTextures[OrePrefixes.oreSmall.mTextureIndex], aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.stone), aIconSet }; + } + return new ITexture[] { TextureFactory.of(Blocks.stone), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.oreSmall.mTextureIndex]) }; + } + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWSmallOres; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java new file mode 100644 index 0000000000..77d3c23fbc --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static com.github.bartimaeusnek.bartworks.MainMod.BW_Network_instance; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; + +import com.github.bartimaeusnek.bartworks.common.net.MetaBlockPacket; + +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; + +public abstract class BW_MetaGenerated_Block_TE extends TileEntity implements ITexturedTileEntity { + + public short mMetaData; + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.mMetaData = aNBT.getShort("m"); + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setShort("m", this.mMetaData); + } + + @Override + public Packet getDescriptionPacket() { + if (!this.worldObj.isRemote) BW_Network_instance.sendPacketToAllPlayersInRange( + this.worldObj, + new MetaBlockPacket(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), + this.xCoord, + this.zCoord); + return null; + } + + protected abstract Block GetProperBlock(); + + public ArrayList getDrops(int aFortune) { + ArrayList rList = new ArrayList<>(); + if (this.mMetaData <= 0) { + rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); + return rList; + } + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + return rList; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java new file mode 100644 index 0000000000..84a498070a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Items.metaTab; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import com.github.bartimaeusnek.bartworks.util.BW_Util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_LanguageManager; + +public abstract class BW_MetaGenerated_Blocks extends BW_TileEntityContainer { + + public static ThreadLocal mTemporaryTileEntity = new ThreadLocal<>(); + protected OrePrefixes _prefixes; + protected String blockTypeLocalizedName; + + public BW_MetaGenerated_Blocks(Material p_i45386_1_, Class tileEntity, String blockName) { + this(p_i45386_1_, tileEntity, blockName, null); + } + + public BW_MetaGenerated_Blocks(Material p_i45386_1_, Class tileEntity, String blockName, + OrePrefixes types) { + super(p_i45386_1_, tileEntity, blockName); + this.setHardness(5.0F); + this.setResistance(5.0F); + this.setBlockTextureName("stone"); + this.setCreativeTab(metaTab); + this._prefixes = types; + if (this._prefixes != null) { + this.blockTypeLocalizedName = GT_LanguageManager.addStringLocalization( + "bw.blocktype." + this._prefixes, + this._prefixes.mLocalizedMaterialPre + "%material" + this._prefixes.mLocalizedMaterialPost); + } + Werkstoff.werkstoffHashSet.forEach(this::doRegistrationStuff); + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + // Waste some time to allow the TE to be set, do not use thread sleep here, it doesnt allow for nanoseconds. + // This will just waste a few cpu cycles to allow the TE to be set + BW_Util.shortSleep(0); + } + + @SideOnly(Side.CLIENT) + public final BW_MetaGenerated_Block_TE getProperTileEntityForRendering() { + return (BW_MetaGenerated_Block_TE) this.createNewTileEntity(null, 0); + } + + protected abstract void doRegistrationStuff(Werkstoff w); + + @Override + public String getHarvestTool(int metadata) { + return "pickaxe"; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public int getRenderType() { + if (BW_Renderer_Block_Ores.INSTANCE == null) return super.getRenderType(); + return BW_Renderer_Block_Ores.INSTANCE.renderID; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BW_MetaGenerated_Block_TE metaTE) { + return metaTE.mMetaData; + } + return 0; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return ((ITileEntityProvider) this).createNewTileEntity(world, metadata); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity tTileEntity = world.getTileEntity(x, y, z); + if (tTileEntity instanceof BW_MetaGenerated_Block_TE metaTE) { + mTemporaryTileEntity.set(metaTE); + } + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BW_MetaGenerated_Block_TE metaTE) { + return metaTE.getDrops(aFortune); + } + return mTemporaryTileEntity.get() == null ? new ArrayList<>() + : mTemporaryTileEntity.get() + .getDrops(aFortune); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java new file mode 100644 index 0000000000..4c355284ae --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.werkstoffHashMap; +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.werkstoffHashSet; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.API.IRadMaterial; +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Item; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import ic2.core.IC2Potion; + +public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRadMaterial { + + public static final CreativeTabs metaTab = new CreativeTabs("bartworksMetaMaterials") { + + @Override + public Item getTabIconItem() { + return new ItemStack(Blocks.iron_ore).getItem(); + } + }; + + protected final OrePrefixes orePrefixes; + protected final String itemTypeLocalizedName; + + public BW_MetaGenerated_Items(OrePrefixes orePrefixes, Object unused) { + super("bwMetaGeneratedGTEnhancement" + orePrefixes.name(), (short) 32766, (short) 0); + this.orePrefixes = orePrefixes; + this.itemTypeLocalizedName = GT_LanguageManager.addStringLocalization( + "bw.itemtype." + orePrefixes, + orePrefixes.mLocalizedMaterialPre + "%material" + orePrefixes.mLocalizedMaterialPost); + } + + public BW_MetaGenerated_Items(OrePrefixes orePrefixes) { + super("bwMetaGenerated" + orePrefixes.name(), (short) 32766, (short) 0); + this.orePrefixes = orePrefixes; + this.itemTypeLocalizedName = GT_LanguageManager.addStringLocalization( + "bw.itemtype." + orePrefixes, + orePrefixes.mLocalizedMaterialPre + "%material" + orePrefixes.mLocalizedMaterialPost); + this.setCreativeTab(BW_MetaGenerated_Items.metaTab); + for (Werkstoff w : werkstoffHashSet) { + ItemStack tStack = new ItemStack(this, 1, w.getmID()); + if (!w.hasItemType(this.orePrefixes)) continue; + GT_OreDictUnificator.registerOre(this.orePrefixes.name() + w.getVarName(), tStack); + } + } + + @Override + public boolean onEntityItemUpdate(EntityItem aItemEntity) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure + || this.orePrefixes == OrePrefixes.crushed) { + int aDamage = aItemEntity.getEntityItem() + .getItemDamage(); + if (aDamage >= 0 && !aItemEntity.worldObj.isRemote) { + Werkstoff aMaterial = werkstoffHashMap.get((short) aDamage); + if (aMaterial != null && aMaterial != Werkstoff.default_null_Werkstoff) { + int tX = MathHelper.floor_double(aItemEntity.posX); + int tY = MathHelper.floor_double(aItemEntity.posY); + int tZ = MathHelper.floor_double(aItemEntity.posZ); + Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); + byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); + if (tBlock == Blocks.cauldron && tMetaData > 0) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure) { + aItemEntity.setEntityItemStack( + WerkstoffLoader.getCorrespondingItemStack( + OrePrefixes.dust, + aMaterial, + aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } else { + aItemEntity.setEntityItemStack( + WerkstoffLoader.getCorrespondingItemStack( + OrePrefixes.crushedPurified, + aMaterial, + aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } + } + } + } + } + return false; + } + + @Override + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure) { + aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify")); + } + if (this.orePrefixes == OrePrefixes.crushed) + aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify.2")); + + if (aStack != null && aStack.getItem() instanceof BW_MetaGenerated_Items + && aStack.getItemDamage() == WerkstoffLoader.Tiberium.getmID()) + aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.nqgen")); + + Werkstoff werkstoff = werkstoffHashMap.get((short) this.getDamage(aStack)); + if (werkstoff != null) { + String tooltip = werkstoff.getLocalizedToolTip(); + if (!tooltip.isEmpty()) { + aList.add(tooltip); + } + + String owner = werkstoff.getOwner(); + if (owner != null) { + aList.add(BW_Tooltip_Reference.ADDED_VIA_BARTWORKS.apply(owner)); + } else { + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + } else { + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + int aMetaData = aStack.getItemDamage(); + Werkstoff werkstoff = werkstoffHashMap.get((short) aMetaData); + if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff; + return this.itemTypeLocalizedName.replace("%material", werkstoff.getLocalizedName()); + } + + @Override + public IIconContainer getIconContainer(int aMetaData) { + if (werkstoffHashMap.get((short) aMetaData) == null) return null; + if (this.orePrefixes.mTextureIndex == -1) return this.getIconContainerBartWorks(aMetaData); + return werkstoffHashMap.get((short) aMetaData) + .getTexSet().mTextures[this.orePrefixes.mTextureIndex]; + } + + protected IIconContainer getIconContainerBartWorks(int aMetaData) { + if (SideReference.Side.Client) return PrefixTextureLinker.texMap.get(this.orePrefixes) + .get( + werkstoffHashMap.get((short) aMetaData) + .getTexSet()); + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + for (Werkstoff werkstoff : werkstoffHashSet) { + if (werkstoff != null && werkstoff.hasItemType(this.orePrefixes)) { + ItemStack tStack = new ItemStack(this, 1, werkstoff.getmID()); + aList.add(tStack); + } + } + // super.getSubItems(var1, aCreativeTab, aList); + } + + @Override + public short[] getRGBa(ItemStack aStack) { + Werkstoff werkstoff = werkstoffHashMap.get((short) this.getDamage(aStack)); + return werkstoff == null ? Materials._NULL.mRGBa : werkstoff.getRGBA(); + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) { + super.onUpdate(aStack, aWorld, aPlayer, aTimer, aIsInHand); + if (aStack == null || aStack.getItem() == null || !(aPlayer instanceof EntityLivingBase)) return; + + EntityLivingBase bPlayer = (EntityPlayer) aPlayer; + Werkstoff w = werkstoffHashMap.get((short) aStack.getItemDamage()); + if (w == null || w.getStats() == null) return; + + if (w.getStats() + .isToxic() && !GT_Utility.isWearingFullBioHazmat(bPlayer)) { + bPlayer.addPotionEffect(new PotionEffect(Potion.poison.getId(), 80, 4)); + } + + if (w.getStats() + .isRadioactive() && !GT_Utility.isWearingFullRadioHazmat(bPlayer)) { + bPlayer.addPotionEffect(new PotionEffect(IC2Potion.radiation.id, 80, 4)); + } + } + + @Override + public IIcon getIconFromDamage(int aMetaData) { + if (aMetaData < 0) return null; + Werkstoff tMaterial = werkstoffHashMap.get((short) aMetaData); + if (tMaterial == null) return null; + IIconContainer tIcon = this.getIconContainer(aMetaData); + if (tIcon != null) return tIcon.getIcon(); + return null; + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + return this.orePrefixes.mDefaultStackSize; + } + + @Override + public int getRadiationLevel(ItemStack aStack) { + Werkstoff w = werkstoffHashMap.get((short) aStack.getItemDamage()); + return w.getStats() + .isRadioactive() + ? (int) w.getStats() + .getProtons() + : 0; + } + + @Override + public byte getAmountOfMaterial(ItemStack aStack) { + return (byte) (this.orePrefixes == OrePrefixes.stick ? 1 : this.orePrefixes == OrePrefixes.stickLong ? 2 : 0); + } + + @Override + public short[] getColorForGUI(ItemStack aStack) { + Werkstoff w = werkstoffHashMap.get((short) aStack.getItemDamage()); + return w.getRGBA(); + } + + @Override + public String getNameForGUI(ItemStack aStack) { + Werkstoff w = werkstoffHashMap.get((short) aStack.getItemDamage()); + return w.getDefaultName(); + } + + @Override + public int getCapacity(ItemStack aStack) { + return this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.cell + || this.orePrefixes == OrePrefixes.cellPlasma ? 1000 + : this.orePrefixes == OrePrefixes.cellMolten || this.orePrefixes == OrePrefixes.capsuleMolten ? 144 : 0; + } + + @Override + public ItemStack getContainerItem(ItemStack aStack) { + return this.orePrefixes == OrePrefixes.cell || this.orePrefixes == OrePrefixes.cellPlasma + || this.orePrefixes == OrePrefixes.cellMolten ? Materials.Empty.getCells(1) : null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java new file mode 100644 index 0000000000..2adb0d3d35 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; + +import com.github.bartimaeusnek.bartworks.util.MathUtils; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; + +public class BW_MetaGenerated_Ores extends BW_MetaGenerated_Blocks { + + public BW_MetaGenerated_Ores(Material p_i45386_1_, Class tileEntity, String blockName) { + super(p_i45386_1_, tileEntity, blockName); + this.blockTypeLocalizedName = GT_LanguageManager.addStringLocalization( + "bw.blocktype." + OrePrefixes.ore, + OrePrefixes.ore.mLocalizedMaterialPre + "%material" + OrePrefixes.ore.mLocalizedMaterialPost); + } + + @Override + protected void doRegistrationStuff(Werkstoff w) { + if (w != null) { + if (!w.hasItemType(OrePrefixes.ore) || (w.getGenerationFeatures().blacklist & 0b1000) != 0) return; + GT_ModHandler.addValuableOre(this, w.getmID(), 1); + } + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air, Block block, + int[] aBlockMeta) { + if (!air) { + aY = MathUtils.clamp(aY, 1, aWorld.getActualHeight()); + } + + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = WerkstoffLoader.BWOres; + if (aMetaData < 0 || tBlock == Blocks.air && !air + || Block.getIdFromBlock(tBlock) != Block.getIdFromBlock(block)) { + return false; + } + final int aaY = aY; + if (Arrays.stream(aBlockMeta) + .noneMatch(e -> e == aWorld.getBlockMetadata(aX, aaY, aZ))) { + return false; + } + + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BW_MetaGeneratedOreTE metaTE) { + metaTE.mMetaData = (short) aMetaData; + metaTE.mNatural = true; + } + + return true; + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public int getHarvestLevel(int metadata) { + return 3; + } + + @Override + public String getUnlocalizedName() { + return "bw.blockores.01"; + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + for (Werkstoff tMaterial : Werkstoff.werkstoffHashSet) { + if (tMaterial != null && tMaterial.hasItemType(OrePrefixes.ore) + && (tMaterial.getGenerationFeatures().blacklist & 0x8) == 0) { + aList.add(new ItemStack(aItem, 1, tMaterial.getmID())); + } + } + } + + @Override + public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) { + if (EnchantmentHelper.getSilkTouchModifier(player)) { + BW_MetaGeneratedOreTE.shouldSilkTouch = true; + super.harvestBlock(worldIn, player, x, y, z, meta); + + if (BW_MetaGeneratedOreTE.shouldSilkTouch) { + BW_MetaGeneratedOreTE.shouldSilkTouch = false; + } + return; + } + + if (!(player instanceof FakePlayer)) { + BW_MetaGeneratedOreTE.shouldFortune = true; + } + super.harvestBlock(worldIn, player, x, y, z, meta); + if (BW_MetaGeneratedOreTE.shouldFortune) { + BW_MetaGeneratedOreTE.shouldFortune = false; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java new file mode 100644 index 0000000000..0778645cb5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; + +public class BW_MetaGenerated_SmallOres extends BW_MetaGenerated_Ores { + + public BW_MetaGenerated_SmallOres(Material p_i45386_1_, Class tileEntity, String blockName) { + super(p_i45386_1_, tileEntity, blockName); + this.blockTypeLocalizedName = GT_LanguageManager.addStringLocalization( + "bw.blocktype." + OrePrefixes.oreSmall, + OrePrefixes.oreSmall.mLocalizedMaterialPre + "%material" + OrePrefixes.oreSmall.mLocalizedMaterialPost); + } + + @Override + protected void doRegistrationStuff(Werkstoff w) { + if (w != null) { + if (!w.hasItemType(OrePrefixes.ore) || (w.getGenerationFeatures().blacklist & 0b1000) != 0) return; + GT_ModHandler.addValuableOre(this, w.getmID(), 1); + } + } + + @Override + public String getUnlocalizedName() { + return "bw.blockores.02"; + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air, Block block, + int[] aBlockMeta) { + if (!air) { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + } + + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = WerkstoffLoader.BWSmallOres; + if (aMetaData < 0 || tBlock == Blocks.air && !air + || Block.getIdFromBlock(tBlock) != Block.getIdFromBlock(block)) { + return false; + } + final int aaY = aY; + if (Arrays.stream(aBlockMeta) + .noneMatch(e -> e == aWorld.getBlockMetadata(aX, aaY, aZ))) { + return false; + } + + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BW_MetaGeneratedOreTE metaTE) { + metaTE.mMetaData = (short) aMetaData; + } + + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java new file mode 100644 index 0000000000..4456a66535 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; + +public class BW_MetaGenerated_WerkstoffBlock_TE extends BW_MetaGenerated_Block_TE { + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + if (SideReference.Side.Client) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + TextureSet set = aMaterial.getTexSet(); + ITexture aIconSet = TextureFactory.of( + set.mTextures[PrefixTextureLinker.blockTexMap.getOrDefault(set, OrePrefixes.block.mTextureIndex)], + aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.iron_block), aIconSet }; + } + } + return new ITexture[] { TextureFactory.of(Blocks.iron_block), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]) }; + } + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWBlocks; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java new file mode 100644 index 0000000000..648f9a0027 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_LanguageManager; + +public class BW_MetaGenerated_WerkstoffBlocks extends BW_MetaGenerated_Blocks { + + public BW_MetaGenerated_WerkstoffBlocks(Material p_i45386_1_, Class tileEntity, + String blockName) { + super(p_i45386_1_, tileEntity, blockName); + this.blockTypeLocalizedName = GT_LanguageManager.addStringLocalization( + "bw.blocktype." + OrePrefixes.block, + OrePrefixes.block.mLocalizedMaterialPre + "%material" + OrePrefixes.block.mLocalizedMaterialPost); + } + + @Override + protected void doRegistrationStuff(Werkstoff tMaterial) {} + + @Override + public String getUnlocalizedName() { + return "bw.werkstoffblocks.01"; + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.iron_block.getIcon(0, 0); + } + + @Override + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { + return Blocks.iron_block.getIcon(0, 0); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs tab, List aList) { + Werkstoff.werkstoffHashSet.stream() + .filter(tMaterial -> tMaterial.hasItemType(OrePrefixes.gem) || tMaterial.hasItemType(OrePrefixes.ingot)) + .map(tMaterial -> new ItemStack(aItem, 1, tMaterial.getmID())) + .forEach(aList::add); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java new file mode 100644 index 0000000000..db53437858 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static gregtech.api.enums.GT_Values.W; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public enum BW_NonMeta_MaterialItems implements IItemContainer { + + Depleted_Tiberium_1, + Depleted_Tiberium_2, + Depleted_Tiberium_4, + TiberiumCell_1, + TiberiumCell_2, + TiberiumCell_4, + TheCoreCell, + Depleted_TheCoreCell; + + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + @Override + public IItemContainer set(Item aItem) { + this.mHasNotBeenSet = false; + if (aItem == null) return this; + ItemStack aStack = new ItemStack(aItem, 1, 0); + this.mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public IItemContainer set(ItemStack aStack) { + this.mHasNotBeenSet = false; + this.mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public Item getItem() { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return null; + return this.mStack.getItem(); + } + + @Override + public Block getBlock() { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + return GT_Utility.getBlockFromItem(this.getItem()); + } + + @Override + public final boolean hasBeenSet() { + return !this.mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(Object aStack) { + return this.isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { + if (GT_Utility.isStackInvalid(aStack)) return false; + return GT_Utility + .areUnificationsEqual((ItemStack) aStack, aWildcard ? this.getWildcard(1) : this.get(1), aIgnoreNBT); + } + + @Override + public ItemStack get(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWildcard(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getUndamaged(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility + .copyAmountAndMetaData(aAmount, this.mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) { + ItemStack rStack = this.get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) return null; + rStack.setStackDisplayName(aDisplayName); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) { + ItemStack rStack = this.get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) return null; + GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public IItemContainer registerOre(Object... aOreNames) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, this.get(1)); + return this; + } + + @Override + public IItemContainer registerWildcardAsOre(Object... aOreNames) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, this.getWildcard(1)); + return this; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java new file mode 100644 index 0000000000..6bd186a050 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +public class BW_CircuitsLoader { + + private static final BW_Meta_Items NEW_CIRCUITS = new BW_Meta_Items(); + + private BW_CircuitsLoader() {} + + public static BW_Meta_Items getNewCircuits() { + return BW_CircuitsLoader.NEW_CIRCUITS; + } + + public static void initNewCircuits() { + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(0, 4, "Primitive Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(1, 5, "Basic Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(2, 6, "Good Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(3, 7, "Advanced Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(4, 8, "Data Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(5, 9, "Elite Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(6, 10, "Master Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(7, 11, "Ultimate Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(8, 12, "Superconductor Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(9, 13, "Infinite Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(10, 14, "Bio Magneto Resonatic Circuit"); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java new file mode 100644 index 0000000000..99eb6e7d7e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import static gregtech.api.recipe.RecipeMaps.formingPressRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.BW_Util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.IItemBehaviour; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class BW_Meta_Items { + + public static BW_Meta_Items.BW_GT_MetaGenCircuits getNEWCIRCUITS() { + return BW_Meta_Items.NEWCIRCUITS; + } + + private static final BW_Meta_Items.BW_GT_MetaGenCircuits NEWCIRCUITS = new BW_Meta_Items.BW_GT_MetaGenCircuits(); + + static { + BW_Meta_Items.NEWCIRCUITS.addItem(0, "Circuit Imprint", "", SubTag.NO_UNIFICATION, SubTag.NO_RECYCLING); + BW_Meta_Items.NEWCIRCUITS.addItem(1, "Sliced Circuit", "", SubTag.NO_UNIFICATION, SubTag.NO_RECYCLING); + BW_Meta_Items.NEWCIRCUITS.addItem(2, "Raw Imprint supporting Board", "A Raw Board needed for Circuit Imprints"); + BW_Meta_Items.NEWCIRCUITS.addItem(3, "Imprint supporting Board", "A Board needed for Circuit Imprints"); + + GT_Values.RA.stdBuilder() + .itemInputs( + WerkstoffLoader.MagnetoResonaticDust.get(OrePrefixes.dust, 1), + WerkstoffLoader.ArInGaPhoBiBoTe.get(OrePrefixes.dust, 4)) + .itemOutputs(BW_Meta_Items.NEWCIRCUITS.getStack(2)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(formingPressRecipes); + + RecipeMaps.autoclaveRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { BW_Meta_Items.NEWCIRCUITS.getStack(2) }, + new ItemStack[] { BW_Meta_Items.NEWCIRCUITS.getStack(3) }, + null, + new int[] { 7500 }, + new FluidStack[] { Materials.SolderingAlloy.getMolten(576) }, + null, + 300, + (int) TierEU.RECIPE_EV, + BW_Util.CLEANROOM)); + } + + public void addNewCircuit(int aTier, int aID, String aName) { + + String additionalOreDictData = ""; + String tooltip = ""; + String aOreDictPrefix = OrePrefixes.circuit.toString(); + switch (aTier) { + case 0: + additionalOreDictData = Materials.Primitive.toString(); + tooltip = Materials.Primitive.getToolTip(); + break; + case 1: + additionalOreDictData = Materials.Basic.toString(); + tooltip = Materials.Basic.getToolTip(); + break; + case 2: + additionalOreDictData = Materials.Good.toString(); + tooltip = Materials.Good.getToolTip(); + break; + case 3: + additionalOreDictData = Materials.Advanced.toString(); + tooltip = Materials.Advanced.getToolTip(); + break; + case 4: + additionalOreDictData = Materials.Data.toString(); + tooltip = Materials.Data.getToolTip(); + break; + case 5: + additionalOreDictData = Materials.Elite.toString(); + tooltip = Materials.Elite.getToolTip(); + break; + case 6: + additionalOreDictData = Materials.Master.toString(); + tooltip = Materials.Master.getToolTip(); + break; + case 7: + additionalOreDictData = Materials.Ultimate.toString(); + tooltip = Materials.Ultimate.getToolTip(); + break; + case 8: + additionalOreDictData = Materials.SuperconductorUHV.toString(); + tooltip = Materials.SuperconductorUHV.getToolTip(); + break; + case 9: + additionalOreDictData = "Infinite"; + tooltip = "An Infinite Circuit"; + break; + case 10: + additionalOreDictData = "Bio"; + tooltip = "A Bio Circuit"; + break; + } + + ItemStack tStack = BW_Meta_Items.NEWCIRCUITS.addCircuit(aID, aName, tooltip, aTier); + + GT_OreDictUnificator.registerOre((aOreDictPrefix + additionalOreDictData).replace(" ", ""), tStack); + } + + public static class BW_GT_MetaGenCircuits extends BW_Meta_Items.BW_GT_MetaGen_Item_Hook { + + public BW_GT_MetaGenCircuits() { + super("bwMetaGeneratedItem0"); + } + + public final ItemStack addCircuit(int aID, String aEnglish, String aToolTip, int tier) { + CircuitImprintLoader.bwCircuitTagMap.put( + new CircuitData( + BW_Util.getMachineVoltageFromTier(Math.min(1, tier - 2)), + tier > 2 ? BW_Util.CLEANROOM : 0, + (byte) tier), + new ItemStack(BW_Meta_Items.NEWCIRCUITS, 1, aID)); + return this.addItem(aID, aEnglish, aToolTip, SubTag.NO_UNIFICATION); + } + + public final ItemStack getStack(int... meta_amount) { + ItemStack ret = new ItemStack(this); + if (meta_amount.length <= 0 || meta_amount.length > 2) return ret; + if (meta_amount.length == 1) { + ret.setItemDamage(meta_amount[0]); + return ret; + } + ret.setItemDamage(meta_amount[0]); + ret.stackSize = meta_amount[1]; + return ret; + } + + public final ItemStack getStackWithNBT(NBTTagCompound tag, int... meta_amount) { + ItemStack ret = this.getStack(meta_amount); + ret.setTagCompound(tag); + return ret; + } + + @Override + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + if (aCreativeTab == this.getCreativeTab()) + for (NBTTagCompound tag : CircuitImprintLoader.recipeTagMap.keySet()) { + ItemStack stack = new ItemStack(BW_Meta_Items.NEWCIRCUITS, 1, 0); + stack.setTagCompound(tag); + aList.add(stack); + } + super.getSubItems(var1, aCreativeTab, aList); + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(IIconRegister aIconRegister) { + + for (short i = 0; i < CircuitImprintLoader.reverseIDs; ++i) { + if (this.mEnabledItems.get(i)) { + BW_Util.set2DCoordTo1DArray( + i, + 0, + 2, + aIconRegister.registerIcon( + "gregtech:" + (GT_Config.troll ? "troll" : this.getUnlocalizedName() + "/" + i)), + this.mIconList); + } + } + + for (short i = CircuitImprintLoader.reverseIDs; i < Short.MAX_VALUE; i++) { + if (this.mEnabledItems.get(i)) { + BW_Util.set2DCoordTo1DArray( + i, + 0, + 2, + Objects.requireNonNull(CircuitImprintLoader.circuitIIconRefs.get(i)) + .get(1) + .getIconIndex(), + this.mIconList); + BW_Util.set2DCoordTo1DArray( + i, + 1, + 2, + aIconRegister.registerIcon(MainMod.MOD_ID + ":WrapOverlay"), + this.mIconList); + } + } + } + + @Override + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + if (aStack.getItemDamage() == 0) if (aStack.getTagCompound() != null + && CircuitImprintLoader.getStackFromTag(aStack.getTagCompound()) != null) + aList.add( + "An Imprint for: " + GT_LanguageManager.getTranslation( + GT_LanguageManager.getTranslateableItemStackName( + CircuitImprintLoader.getStackFromTag(aStack.getTagCompound())))); + else aList.add("An Imprint for a Circuit"); + else if (aStack.getItemDamage() == 1) if (aStack.getTagCompound() != null + && CircuitImprintLoader.getStackFromTag(aStack.getTagCompound()) != null) + aList.add( + "A Sliced " + GT_LanguageManager.getTranslation( + GT_LanguageManager.getTranslateableItemStackName( + CircuitImprintLoader.getStackFromTag(aStack.getTagCompound())))); + else aList.add("A Sliced Circuit"); + super.addAdditionalToolTips(aList, aStack, aPlayer); + } + } + + public static class BW_GT_MetaGen_Item_Hook extends GT_MetaBase_Item { + + public static final HashSet sInstances = new HashSet<>(); + public final IIcon[] mIconList; + public final BitSet mEnabledItems; + + { + this.mIconList = new IIcon[Short.MAX_VALUE * 2]; + this.mEnabledItems = new BitSet(Short.MAX_VALUE); + } + + private BW_GT_MetaGen_Item_Hook(String aUnlocalized) { + super(aUnlocalized); + + this.setCreativeTab(new CreativeTabs("bw.MetaItems.0") { + + @Override + public Item getTabIconItem() { + return ItemRegistry.TAB; + } + }); + this.setHasSubtypes(true); + this.setMaxDamage(0); + BW_Meta_Items.BW_GT_MetaGen_Item_Hook.sInstances.add(this); + } + + @Override + public Long[] getElectricStats(ItemStack itemStack) { + return null; + } + + @Override + public Long[] getFluidContainerStats(ItemStack itemStack) { + return null; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + ItemStack rStack = new ItemStack(this, 1, aID); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); + List tAspects = new ArrayList<>(); + this.mEnabledItems.set(aID); + Object[] var7 = aRandomData; + int var8 = aRandomData.length; + + int var9; + Object tRandomData; + for (var9 = 0; var9 < var8; ++var9) { + tRandomData = var7[var9]; + if (tRandomData instanceof SubTag && tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + } + } + + var7 = aRandomData; + var8 = aRandomData.length; + + for (var9 = 0; var9 < var8; ++var9) { + tRandomData = var7[var9]; + if (tRandomData != null) { + boolean tUseOreDict = true; + + if (tRandomData instanceof IItemBehaviour) { + this.addItemBehavior(aID, (IItemBehaviour) tRandomData); + tUseOreDict = false; + } + + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + + if (!(tRandomData instanceof SubTag)) { + if (tRandomData instanceof TC_Aspects.TC_AspectStack) { + ((TC_Aspects.TC_AspectStack) tRandomData).addToAspectList(tAspects); + } else if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + } else if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } + } + } + } + + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + + return rStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + int j = this.mEnabledItems.length(); + + for (int i = 0; i < j; ++i) { + if (this.mEnabledItems.get(i)) { + ItemStack tStack = new ItemStack(this, 1, i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + + @Override + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + super.addAdditionalToolTips(aList, aStack, aPlayer); + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.getUnlocalizedName() + "." + aStack.getItemDamage(); + } + + @Override + public IIcon getIconFromDamage(int i) { + if (this.mEnabledItems.get(i)) return (IIcon) BW_Util.get2DCoordFrom1DArray(i, 0, 2, this.mIconList); + return null; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, + int useRemaining) { + return this.getIconFromDamage(stack.getItemDamage()); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return this.getIconFromDamage(stack.getItemDamage()); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java new file mode 100644 index 0000000000..874ae202f1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import java.nio.ByteBuffer; + +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; + +public class CircuitData { + + private long aVoltage; + private int aSpecial; + private byte aTier; + + public CircuitData(long aVoltage, int aSpecial, byte aTier) { + this.aVoltage = aVoltage; + this.aSpecial = aSpecial; + this.aTier = aTier; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CircuitData that)) return false; + if (this.getaVoltage() != that.getaVoltage() || this.getaSpecial() != that.getaSpecial()) return false; + return this.getaTier() == that.getaTier(); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(13) + .put(this.aTier) + .putInt(this.aSpecial) + .putLong(this.aVoltage) + .array(), + 0, + 13, + 31); + } + + public long getaVoltage() { + return this.aVoltage; + } + + public void setaVoltage(long aVoltage) { + this.aVoltage = aVoltage; + } + + public int getaSpecial() { + return this.aSpecial; + } + + public void setaSpecial(int aSpecial) { + this.aSpecial = aSpecial; + } + + public byte getaTier() { + return this.aTier; + } + + public void setaTier(byte aTier) { + this.aTier = aTier; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java new file mode 100644 index 0000000000..5d3886b9e9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -0,0 +1,368 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; + +import com.github.bartimaeusnek.bartworks.API.recipe.BWNBTDependantCraftingRecipe; +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.ASM.BWCoreStaticReplacementMethodes; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class CircuitImprintLoader { + + public static short reverseIDs = Short.MAX_VALUE - 1; + + public static final ArrayListMultimap recipeTagMap = ArrayListMultimap.create(); + public static final HashBiMap circuitIIconRefs = HashBiMap.create(20); + public static final HashSet blacklistSet = new HashSet<>(); + static final HashBiMap bwCircuitTagMap = HashBiMap.create(20); + private static final HashSet recipeWorldCache = new HashSet<>(); + private static final HashSet gtrecipeWorldCache = new HashSet<>(); + private static final HashSet ORIGINAL_CAL_RECIPES = new HashSet<>(); + private static final HashSet MODIFIED_CAL_RECIPES = new HashSet<>(); + + public static void run() { + HashSet toRem = new HashSet<>(); + HashSet toAdd = new HashSet<>(); + + deleteCALRecipesAndTags(); + rebuildCircuitAssemblerMap(toRem, toAdd); + exchangeRecipesInList(toRem, toAdd); + makeCircuitImprintRecipes(); + + toRem = null; + toAdd = null; + } + + private static void reAddOriginalRecipes() { + RecipeMaps.circuitAssemblerRecipes.getBackend() + .removeRecipes(MODIFIED_CAL_RECIPES); + ORIGINAL_CAL_RECIPES.forEach(RecipeMaps.circuitAssemblerRecipes::add); + ORIGINAL_CAL_RECIPES.clear(); + MODIFIED_CAL_RECIPES.clear(); + } + + private static void rebuildCircuitAssemblerMap(HashSet toRem, HashSet toAdd) { + reAddOriginalRecipes(); + RecipeMaps.circuitAssemblerRecipes.getAllRecipes() + .forEach(e -> CircuitImprintLoader.handleCircuitRecipeRebuilding(e, toRem, toAdd)); + } + + private static void handleCircuitRecipeRebuilding(GT_Recipe circuitRecipe, HashSet toRem, + HashSet toAdd) { + ItemStack[] outputs = circuitRecipe.mOutputs; + boolean isOrePass = isCircuitOreDict(outputs[0]); + String unlocalizedName = outputs[0].getUnlocalizedName(); + if (isOrePass || unlocalizedName.contains("Circuit") || unlocalizedName.contains("circuit")) { + + CircuitImprintLoader.recipeTagMap + .put(CircuitImprintLoader.getTagFromStack(outputs[0]), circuitRecipe.copy()); + + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + + Fluid solderUEV = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + + if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0)) + || circuitRecipe.mFluidInputs[0].isFluidEqual(new FluidStack(solderIndalloy, 0)) + || circuitRecipe.mFluidInputs[0].isFluidEqual(new FluidStack(solderUEV, 0))) { + GT_Recipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe); + if (newRecipe != null) BartWorksRecipeMaps.circuitAssemblyLineRecipes.addRecipe(newRecipe); + addCutoffRecipeToSets(toRem, toAdd, circuitRecipe); + } else if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) toRem.add(circuitRecipe); + } + } + + private static boolean isCircuitOreDict(ItemStack item) { + return BW_Util.isTieredCircuit(item) || BW_Util.getOreNames(item) + .stream() + .anyMatch(s -> "circuitPrimitiveArray".equals(s)); + } + + private static void exchangeRecipesInList(HashSet toRem, HashSet toAdd) { + toAdd.forEach(RecipeMaps.circuitAssemblerRecipes::add); + RecipeMaps.circuitAssemblerRecipes.getBackend() + .removeRecipes(toRem); + ORIGINAL_CAL_RECIPES.addAll(toRem); + MODIFIED_CAL_RECIPES.addAll(toAdd); + } + + private static void addCutoffRecipeToSets(HashSet toRem, HashSet toAdd, + GT_Recipe circuitRecipe) { + if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) { + toRem.add(circuitRecipe); + toAdd.add(CircuitImprintLoader.makeMoreExpensive(circuitRecipe)); + } + } + + @SuppressWarnings("deprecation") + public static GT_Recipe makeMoreExpensive(GT_Recipe original) { + GT_Recipe newRecipe = original.copy(); + for (ItemStack is : newRecipe.mInputs) { + if (!BW_Util.isTieredCircuit(is)) { + is.stackSize = Math.min(is.stackSize * 6, 64); + if (is.stackSize > is.getItem() + .getItemStackLimit() || is.stackSize > is.getMaxStackSize()) is.stackSize = is.getMaxStackSize(); + } + } + newRecipe.mFluidInputs[0].amount *= 4; + newRecipe.mDuration *= 4; + return newRecipe; + } + + public static GT_Recipe reBuildRecipe(GT_Recipe original) { + ItemStack[] in = new ItemStack[6]; + BiMap inversed = CircuitImprintLoader.circuitIIconRefs.inverse(); + + for (int i = 0; i < 6; i++) { + try { + replaceCircuits(inversed, original, in, i); + replaceComponents(in, original, i); + } catch (ArrayIndexOutOfBoundsException e) { + break; + } catch (NullPointerException e) { + e.printStackTrace(); + } + } + + if (CircuitImprintLoader.checkForBlacklistedComponents(in)) { + return null; + } + + return new GT_Recipe( + false, + in, + new ItemStack[] { getOutputMultiplied(original) }, + BW_Meta_Items.getNEWCIRCUITS() + .getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]), 0, 0), + null, + original.mFluidInputs, + null, + original.mDuration * 12, + original.mEUt, + 0); + } + + private static ItemStack getOutputMultiplied(GT_Recipe original) { + ItemStack out = original.copy() + .getOutput(0); + out.stackSize *= 16; + return out; + } + + private static void replaceCircuits(BiMap inversed, GT_Recipe original, ItemStack[] in, + int index) { + for (ItemList il : inversed.keySet()) { + if (GT_Utility.areStacksEqual(il.get(1), replaceCircuitParts(original.mInputs[index]))) { + in[index] = BW_Meta_Items.getNEWCIRCUITS() + .getStack(inversed.get(il), original.mInputs[index].stackSize); + } + } + } + + private static final List> circuitPartsToReplace = Collections.unmodifiableList( + Arrays.asList( + new Pair<>(ItemList.Circuit_Parts_Resistor.get(1), ItemList.Circuit_Parts_ResistorSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Diode.get(1), ItemList.Circuit_Parts_DiodeSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Transistor.get(1), ItemList.Circuit_Parts_TransistorSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Capacitor.get(1), ItemList.Circuit_Parts_CapacitorSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Coil.get(1), ItemList.Circuit_Parts_InductorSMD.get(1)))); + + private static ItemStack replaceCircuitParts(ItemStack stack) { + for (Pair pair : circuitPartsToReplace) { + if (GT_Utility.areStacksEqual(pair.getKey(), stack)) { + ItemStack newStack = pair.getValue(); + newStack.stackSize = stack.stackSize; + return newStack; + } + } + return stack; + } + + @SuppressWarnings("deprecation") + private static void replaceComponents(ItemStack[] in, GT_Recipe original, int index) + throws ArrayIndexOutOfBoundsException { + if (original.mInputs[index] != null && in[index] == null) { + // big wires + if (BW_Util.checkStackAndPrefix(original.mInputs[index]) + && GT_OreDictUnificator.getAssociation(original.mInputs[index]).mPrefix == OrePrefixes.wireGt01) { + in[index] = GT_OreDictUnificator.get( + OrePrefixes.wireGt16, + GT_OreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, + original.mInputs[index].stackSize); + // fine wires + } else if (BW_Util.checkStackAndPrefix(original.mInputs[index]) + && GT_OreDictUnificator.getAssociation(original.mInputs[index]).mPrefix == OrePrefixes.wireFine) { + in[index] = GT_OreDictUnificator.get( + OrePrefixes.wireGt04, + GT_OreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, + original.mInputs[index].stackSize); + if (in[index] == null) { + in[index] = GT_OreDictUnificator.get( + OrePrefixes.wireFine, + GT_OreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, + original.mInputs[index].stackSize * 16); + } + // other components + } else { + in[index] = original.mInputs[index].copy(); + in[index].stackSize *= 16; + if (in[index].stackSize > in[index].getItem() + .getItemStackLimit() || in[index].stackSize > in[index].getMaxStackSize()) + in[index].stackSize = in[index].getMaxStackSize(); + } + } + } + + private static void makeCircuitImprintRecipes() { + removeOldRecipesFromRegistries(); + CircuitImprintLoader.recipeTagMap.keySet() + .forEach(e -> { + makeAndAddSlicingRecipe(e); + makeAndAddCraftingRecipes(e); + }); + } + + private static boolean checkForBlacklistedComponents(ItemStack[] itemStacks) { + for (ItemStack is : itemStacks) { + for (ItemStack is2 : CircuitImprintLoader.blacklistSet) { + if (GT_Utility.areStacksEqual(is, is2)) return true; + } + } + return false; + } + + private static void removeOldRecipesFromRegistries() { + recipeWorldCache.forEach( + CraftingManager.getInstance() + .getRecipeList()::remove); + BWCoreStaticReplacementMethodes.clearRecentlyUsedRecipes(); + RecipeMaps.slicerRecipes.getBackend() + .removeRecipes(gtrecipeWorldCache); + recipeWorldCache.forEach(r -> { + try { + BW_Util.getGTBufferedRecipeList() + .remove(r); + } catch (Exception e) { + e.printStackTrace(); + } + }); + recipeWorldCache.clear(); + gtrecipeWorldCache.clear(); + } + + private static void makeAndAddSlicingRecipe(NBTTagCompound tag) { + ItemStack stack = CircuitImprintLoader.getStackFromTag(tag); + int eut = Integer.MAX_VALUE; + + for (GT_Recipe recipe : CircuitImprintLoader.recipeTagMap.get(tag)) { + eut = Math.min(eut, recipe.mEUt); + } + + eut = Math.min( + eut, + BW_Util.getMachineVoltageFromTier( + BW_Util.getCircuitTierFromOreDictName( + OreDictionary.getOreName( + OreDictionary.getOreIDs(stack) != null && OreDictionary.getOreIDs(stack).length > 0 + ? OreDictionary.getOreIDs(stack)[0] + : -1)))); + GT_Recipe slicingRecipe = new GT_Recipe( + true, + new ItemStack[] { stack, ItemList.Shape_Slicer_Flat.get(0) }, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStackWithNBT(tag, 1, 1) }, + null, + null, + null, + null, + 300, + eut, + BW_Util.CLEANROOM); + gtrecipeWorldCache.add(slicingRecipe); + RecipeMaps.slicerRecipes.add(slicingRecipe); + } + + private static void makeAndAddCraftingRecipes(NBTTagCompound tag) { + ItemStack circuit = BW_Meta_Items.getNEWCIRCUITS() + .getStackWithNBT(tag, 0, 1); + Object[] imprintRecipe = { " X ", "GPG", " X ", 'P', BW_Meta_Items.getNEWCIRCUITS() + .getStackWithNBT(tag, 1, 1), 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite, 1), 'X', + BW_Meta_Items.getNEWCIRCUITS() + .getStack(3) }; + + IRecipe bwrecipe = new BWNBTDependantCraftingRecipe(circuit, imprintRecipe); + ShapedOreRecipe gtrecipe = BW_Util.createGTCraftingRecipe( + circuit, + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.KEEPNBT + | GT_ModHandler.RecipeBits.BUFFERED, + imprintRecipe); + + // Adds the actual recipe + recipeWorldCache.add(bwrecipe); + GameRegistry.addRecipe(bwrecipe); + // Adds the NEI visual recipe + recipeWorldCache.add(gtrecipe); + GameRegistry.addRecipe(gtrecipe); + } + + public static NBTTagCompound getTagFromStack(ItemStack stack) { + if (GT_Utility.isStackValid(stack)) return BW_Util.setStackSize(stack.copy(), 1) + .writeToNBT(new NBTTagCompound()); + return new NBTTagCompound(); + } + + public static ItemStack getStackFromTag(NBTTagCompound tagCompound) { + return ItemStack.loadItemStackFromNBT(tagCompound); + } + + private static void deleteCALRecipesAndTags() { + BartWorksRecipeMaps.circuitAssemblyLineRecipes.getBackend() + .clearRecipes(); + recipeTagMap.clear(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java new file mode 100644 index 0000000000..6db9c63134 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; + +import static gregtech.api.enums.ItemList.Circuit_Board_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Basic; +import static gregtech.api.enums.ItemList.Circuit_Board_Bio; +import static gregtech.api.enums.ItemList.Circuit_Board_Bio_Ultra; +import static gregtech.api.enums.ItemList.Circuit_Board_Coated; +import static gregtech.api.enums.ItemList.Circuit_Board_Coated_Basic; +import static gregtech.api.enums.ItemList.Circuit_Board_Elite; +import static gregtech.api.enums.ItemList.Circuit_Board_Epoxy; +import static gregtech.api.enums.ItemList.Circuit_Board_Epoxy_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Fiberglass; +import static gregtech.api.enums.ItemList.Circuit_Board_Fiberglass_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Multifiberglass; +import static gregtech.api.enums.ItemList.Circuit_Board_Multifiberglass_Elite; +import static gregtech.api.enums.ItemList.Circuit_Board_Optical; +import static gregtech.api.enums.ItemList.Circuit_Board_Phenolic; +import static gregtech.api.enums.ItemList.Circuit_Board_Phenolic_Good; +import static gregtech.api.enums.ItemList.Circuit_Board_Plastic; +import static gregtech.api.enums.ItemList.Circuit_Board_Plastic_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Wetware; +import static gregtech.api.enums.ItemList.Circuit_Board_Wetware_Extreme; +import static gregtech.api.enums.ItemList.Circuit_Chip_BioCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_Biocell; +import static gregtech.api.enums.ItemList.Circuit_Chip_CPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_CrystalCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_CrystalSoC; +import static gregtech.api.enums.ItemList.Circuit_Chip_CrystalSoC2; +import static gregtech.api.enums.ItemList.Circuit_Chip_HPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_ILC; +import static gregtech.api.enums.ItemList.Circuit_Chip_LPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_NAND; +import static gregtech.api.enums.ItemList.Circuit_Chip_NOR; +import static gregtech.api.enums.ItemList.Circuit_Chip_NPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_NanoCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_NeuroCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_Optical; +import static gregtech.api.enums.ItemList.Circuit_Chip_PIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_PPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_QPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_QuantumCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_Ram; +import static gregtech.api.enums.ItemList.Circuit_Chip_Simple_SoC; +import static gregtech.api.enums.ItemList.Circuit_Chip_SoC; +import static gregtech.api.enums.ItemList.Circuit_Chip_SoC2; +import static gregtech.api.enums.ItemList.Circuit_Chip_Stemcell; +import static gregtech.api.enums.ItemList.Circuit_Chip_UHPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_ULPIC; +import static gregtech.api.enums.ItemList.Circuit_Integrated; +import static gregtech.api.enums.ItemList.Circuit_Integrated_Good; +import static gregtech.api.enums.ItemList.Circuit_Parts_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Parts_CapacitorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_CapacitorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_CapacitorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_Chip_Bioware; +import static gregtech.api.enums.ItemList.Circuit_Parts_Crystal_Chip_Elite; +import static gregtech.api.enums.ItemList.Circuit_Parts_Crystal_Chip_Master; +import static gregtech.api.enums.ItemList.Circuit_Parts_Crystal_Chip_Wetware; +import static gregtech.api.enums.ItemList.Circuit_Parts_DiodeASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_DiodeSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_DiodeXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_GlassFiber; +import static gregtech.api.enums.ItemList.Circuit_Parts_InductorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_InductorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_InductorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_PetriDish; +import static gregtech.api.enums.ItemList.Circuit_Parts_ResistorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_ResistorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_ResistorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_TransistorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_TransistorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_TransistorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_Vacuum_Tube; +import static gregtech.api.enums.ItemList.Circuit_Parts_Wiring_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Parts_Wiring_Basic; +import static gregtech.api.enums.ItemList.Circuit_Parts_Wiring_Elite; +import static gregtech.api.enums.ItemList.Optical_Cpu_Containment_Housing; +import static gregtech.api.enums.ItemList.Optically_Compatible_Memory; +import static gregtech.api.enums.ItemList.Optically_Perfected_CPU; +import static gregtech.api.enums.ItemList.values; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.client.renderer.BW_GT_ItemRenderer; + +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; + +public class CircuitPartLoader implements Runnable { + + @Override + public void run() { + CircuitPartLoader.makeCircuitParts(); + if (FMLCommonHandler.instance() + .getEffectiveSide() + .isClient()) new BW_GT_ItemRenderer(); + } + + public static void makeCircuitParts() { + ItemList[] itemLists = values(); + for (ItemList single : itemLists) { + if (!single.hasBeenSet()) continue; + if (single.toString() + .contains("Wafer") + || single.toString() + .contains("Circuit_Silicon_Ingot") + || single.toString() + .contains("Raw") + || single.toString() + .contains("raw") + || single.toString() + .contains("Glass_Tube") + || single == Circuit_Parts_GlassFiber + || single == Circuit_Parts_Advanced + || single == Circuit_Parts_Wiring_Advanced + || single == Circuit_Parts_Wiring_Elite + || single == Circuit_Parts_Wiring_Basic + || single == Circuit_Integrated + || single == Circuit_Parts_PetriDish + || single == Circuit_Parts_Vacuum_Tube + || single == Circuit_Integrated_Good) { + + CircuitImprintLoader.blacklistSet.add(single.get(1)); + } + } + + for (ItemList single : CIRCUIT_PARTS) { + if (!single.hasBeenSet()) continue; + ItemStack itemStack = single.get(1); + if (!GT_Utility.isStackValid(itemStack)) continue; + ArrayList toolTip = new ArrayList<>(); + if (FMLCommonHandler.instance() + .getEffectiveSide() + .isClient()) + single.getItem() + .addInformation( + single.get(1) + .copy(), + null, + toolTip, + true); + String tt = toolTip.size() > 0 ? toolTip.get(0) : ""; + // tt += "Internal Name = "+single; + String localised = GT_LanguageManager + .getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack)); + BW_Meta_Items.getNEWCIRCUITS() + .addItem(CircuitImprintLoader.reverseIDs, "Wrap of " + localised + "s", tt); + + GT_Values.RA.stdBuilder() + .itemInputs( + single.get(16) + .copy(), + GT_Utility.getIntegratedCircuit(16)) + .itemOutputs( + BW_Meta_Items.getNEWCIRCUITS() + .getStack(CircuitImprintLoader.reverseIDs)) + .fluidInputs(Materials.Plastic.getMolten(72)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + + CircuitImprintLoader.circuitIIconRefs.put(CircuitImprintLoader.reverseIDs, single); + CircuitImprintLoader.reverseIDs--; + } + } + + /** + * Contains all the circuit parts we want to generate wrapped version of. New entries MUST be placed at the END of + * this list, to prevent id shift. + */ + private static final List CIRCUIT_PARTS = Collections.unmodifiableList( + Arrays.asList( + Circuit_Board_Basic, + Circuit_Board_Advanced, + Circuit_Board_Elite, + Circuit_Parts_Crystal_Chip_Elite, + Circuit_Parts_Crystal_Chip_Master, + Circuit_Board_Coated, + Circuit_Board_Coated_Basic, + Circuit_Board_Phenolic, + Circuit_Board_Phenolic_Good, + Circuit_Board_Epoxy, + Circuit_Board_Epoxy_Advanced, + Circuit_Board_Fiberglass, + Circuit_Board_Fiberglass_Advanced, + Circuit_Board_Multifiberglass_Elite, + Circuit_Board_Multifiberglass, + Circuit_Board_Wetware, + Circuit_Board_Wetware_Extreme, + Circuit_Board_Plastic, + Circuit_Board_Plastic_Advanced, + Circuit_Board_Bio, + Circuit_Board_Bio_Ultra, + Circuit_Parts_ResistorSMD, + Circuit_Parts_InductorSMD, + Circuit_Parts_DiodeSMD, + Circuit_Parts_TransistorSMD, + Circuit_Parts_CapacitorSMD, + Circuit_Parts_ResistorASMD, + Circuit_Parts_DiodeASMD, + Circuit_Parts_TransistorASMD, + Circuit_Parts_CapacitorASMD, + Circuit_Chip_ILC, + Circuit_Chip_Ram, + Circuit_Chip_NAND, + Circuit_Chip_NOR, + Circuit_Chip_CPU, + Circuit_Chip_SoC, + Circuit_Chip_SoC2, + Circuit_Chip_PIC, + Circuit_Chip_Simple_SoC, + Circuit_Chip_HPIC, + Circuit_Chip_UHPIC, + Circuit_Chip_ULPIC, + Circuit_Chip_LPIC, + Circuit_Chip_NPIC, + Circuit_Chip_PPIC, + Circuit_Chip_QPIC, + Circuit_Chip_NanoCPU, + Circuit_Chip_QuantumCPU, + Circuit_Chip_CrystalCPU, + Circuit_Chip_CrystalSoC, + Circuit_Chip_CrystalSoC2, + Circuit_Chip_NeuroCPU, + Circuit_Chip_BioCPU, + Circuit_Chip_Stemcell, + Circuit_Chip_Biocell, + Circuit_Parts_ResistorXSMD, + Circuit_Parts_DiodeXSMD, + Circuit_Parts_TransistorXSMD, + Circuit_Parts_CapacitorXSMD, + Circuit_Parts_InductorASMD, + Circuit_Parts_InductorXSMD, + Circuit_Chip_Optical, + Circuit_Board_Optical, + Optically_Perfected_CPU, + Optical_Cpu_Containment_Housing, + Optically_Compatible_Memory, + Circuit_Parts_Crystal_Chip_Wetware, + Circuit_Parts_Chip_Bioware)); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java new file mode 100644 index 0000000000..91dc709609 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.GT_Enhancement; + +import static com.github.bartimaeusnek.bartworks.system.material.GT_Enhancement.GTMetaItemEnhancer.NoMetaValue; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Items; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.render.items.GT_GeneratedMaterial_Renderer; + +public class BWGTMetaItems extends BW_MetaGenerated_Items { + + private boolean hasList; + private final Set hiddenThings = new HashSet<>(); + + public BWGTMetaItems(OrePrefixes orePrefixes, List noSubIDMaterials) { + super(orePrefixes, null); + // materialloop: + for (int i = 0; i < Materials.values().length; i++) { + ItemStack tStack = new ItemStack(this, 1, i); + Materials material = Materials.values()[i]; + if (material.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten + || material.getFluid(1) == null && material.getGas(1) == null + && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)) + continue; + + if (OreDictionary.doesOreNameExist(this.orePrefixes.name() + material.mDefaultLocalName.replace(" ", ""))) { + this.hiddenThings.add(i); + continue; + } + GT_OreDictUnificator + .registerOre(this.orePrefixes.name() + material.mDefaultLocalName.replace(" ", ""), tStack); + } + + if (noSubIDMaterials != null) { + this.hasList = true; + // materialloop: + for (int i = 0; i < noSubIDMaterials.size(); i++) { + ItemStack tStack = new ItemStack(this, 1, i + 1001); + Materials w = noSubIDMaterials.get(i); + if (w.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)) + continue; + + if (OreDictionary.doesOreNameExist(this.orePrefixes.name() + w.mDefaultLocalName.replace(" ", ""))) { + this.hiddenThings.add(i); + continue; + } + GT_OreDictUnificator + .registerOre(this.orePrefixes.name() + w.mDefaultLocalName.replace(" ", ""), tStack); + } + } + } + + private Materials getMaterial(ItemStack is) { + if (is == null || is.getItem() != this) return null; + final int meta = is.getItemDamage(); + return this.getMaterialFromMeta(meta); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + Materials material = this.getMaterial(aStack); + if (material == null) material = Materials._NULL; + return material.getLocalizedNameForItem(this.itemTypeLocalizedName); + } + + @Override + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + Materials material = this.getMaterial(aStack); + if (material != null) { + String tooltip = material.getToolTip(); + if (tooltip != null && !tooltip.isEmpty()) { + aList.add(tooltip); + } + } + aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); + } + + @Override + public IIconContainer getIconContainer(int aMetaData) { + if (this.orePrefixes.mTextureIndex == -1) return this.getIconContainerBartWorks(aMetaData); + Materials material = this.getMaterialFromMeta(aMetaData); + if (material != null) { + return material.mIconSet.mTextures[this.orePrefixes.mTextureIndex]; + } + return null; + } + + @Override + protected IIconContainer getIconContainerBartWorks(int aMetaData) { + if (SideReference.Side.Server || PrefixTextureLinker.texMap == null) return null; + + HashMap iconLink = PrefixTextureLinker.texMap.get(this.orePrefixes); + + if (iconLink == null) return null; + + Materials material = this.getMaterialFromMeta(aMetaData); + + if (material == null || material.mIconSet == null) return null; + + return iconLink.getOrDefault(material.mIconSet, iconLink.get(TextureSet.SET_DULL)); + } + + @Override + public IIcon getIconFromDamage(int aMetaData) { + return this.getIcon(aMetaData, 0); + } + + @Override + public GT_GeneratedMaterial_Renderer getMaterialRenderer(int aMetaData) { + return this.getMaterialFromMeta(aMetaData).renderer; + } + + public Materials getMaterialFromMeta(int aMetaData) { + if (aMetaData > 1000 && this.hasList) { + return NoMetaValue.get(aMetaData - 1001); + } + if (aMetaData < 0 || aMetaData >= Materials.values().length) { + return null; + } + return Materials.values()[aMetaData]; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + for (int i = 0; i < Materials.values().length; i++) { + Materials w = Materials.values()[i]; + if (w == null || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 + && Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes) != 0) continue; + if (w.getMolten(1) == null && this.orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.bottle)) + continue; + else if (this.hiddenThings.contains(i)) continue; + aList.add(new ItemStack(this, 1, i)); + } + if (this.hasList) for (int i = 0; i < NoMetaValue.size(); i++) { + Materials w = NoMetaValue.get(i); + if (w == null || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 + && Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes) != 0) continue; + if (w.getMolten(1) == null && this.orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.bottle)) + continue; + else if (this.hiddenThings.contains(i)) continue; + aList.add(new ItemStack(this, 1, i + 1001)); + } + } + + @Override + public short[] getColorForGUI(ItemStack aStack) { + return this.getMaterial(aStack).mRGBa; + } + + @Override + public String getNameForGUI(ItemStack aStack) { + return this.getMaterial(aStack).mDefaultLocalName; + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) {} + + @Override + public short[] getRGBa(ItemStack aStack) { + return this.getMaterial(aStack).mRGBa; + } + + @Override + public boolean onEntityItemUpdate(EntityItem aItemEntity) { + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java new file mode 100644 index 0000000000..5b475dc069 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.GT_Enhancement; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public class GTMetaItemEnhancer { + + static List NoMetaValue; + + private GTMetaItemEnhancer() {} + + public static void init() { + if (!Forestry.isModLoaded()) { + return; + } + NoMetaValue = Materials.getMaterialsMap() + .values() + .stream() + .filter(m -> m.mMetaItemSubID == -1) + .collect(Collectors.toList()); + Item moltenCapsuls = new BWGTMetaItems(OrePrefixes.capsuleMolten, null); + Item capsuls = new BWGTMetaItems(OrePrefixes.capsule, NoMetaValue); + // Item bottles = new BWGTMetaItems(OrePrefixes.bottle, NoMetaValue); + + Materials[] values = Materials.values(); + for (int i = 0, valuesLength = values.length; i < valuesLength; i++) { + Materials m = values[i]; + if (m.mStandardMoltenFluid != null && GT_OreDictUnificator.get(OrePrefixes.cellMolten, m, 1) != null) { + final FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + m.getMolten(144), + new ItemStack(moltenCapsuls, 1, i), + GT_ModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)); + FluidContainerRegistry.registerFluidContainer(emptyData); + GT_Utility.addFluidContainerData(emptyData); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_ModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)) + .itemOutputs(new ItemStack(moltenCapsuls, 1, i)) + .fluidInputs(m.getMolten(144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(moltenCapsuls, 1, i)) + .fluidOutputs(m.getMolten(144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + } + if (m.getFluid(1) == null && m.getGas(1) == null || OreDictionary.doesOreNameExist("capsule" + m.mName)) + continue; + addFluidData(m, GT_ModHandler.getModItem(Forestry.ID, "waxCapsule", 1), capsuls, 1000, i, true); + // addFluidData(m, new ItemStack(Items.glass_bottle), bottles, 250, i, false); + } + for (int i = 0, valuesLength = NoMetaValue.size(); i < valuesLength; i++) { + Materials m = NoMetaValue.get(i); + if (m.getFluid(1) == null && m.getGas(1) == null || OreDictionary.doesOreNameExist("capsule" + m.mName)) + continue; + addFluidData(m, GT_ModHandler.getModItem(Forestry.ID, "waxCapsule", 1), capsuls, 1000, i + 1001, true); + // addFluidData(m, new ItemStack(Items.glass_bottle), bottles, 250, i + 1001, false); + } + } + + private static void addFluidData(Materials m, ItemStack container, Item filled, int amount, int it, boolean empty) { + Fluid f = m.getFluid(1) != null ? m.getFluid(1) + .getFluid() + : m.getGas(1) + .getFluid(); + final FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + new FluidStack(f, amount), + new ItemStack(filled, 1, it), + container); + FluidContainerRegistry.registerFluidContainer(emptyData); + GT_Utility.addFluidContainerData(emptyData); + + GT_Values.RA.stdBuilder() + .itemInputs(container) + .itemOutputs(new ItemStack(filled, 1, it)) + .fluidInputs(new FluidStack(f, amount)) + .duration(amount / 62) + .eut(2) + .addTo(fluidCannerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(filled, 1, it)) + .fluidOutputs(new FluidStack(f, amount)) + .duration(amount / 62) + .eut(2) + .addTo(fluidCannerRecipes); + + } + + public static void addAdditionalOreDictToForestry() { + if (!Forestry.isModLoaded()) return; + OreDictionary.registerOre("capsuleWater", getForestryItem("waxCapsuleWater")); + OreDictionary.registerOre("capsuleIce", getForestryItem("waxCapsuleIce")); + OreDictionary.registerOre("capsuleHoney", getForestryItem("waxCapsuleHoney")); + OreDictionary.registerOre("capsuleJuice", getForestryItem("waxCapsuleJuice")); + OreDictionary.registerOre("capsuleSeedOil", getForestryItem("waxCapsuleSeedOil")); + OreDictionary.registerOre("capsuleEthanol", getForestryItem("waxCapsuleEthanol")); + OreDictionary.registerOre("capsuleBiomass", getForestryItem("waxCapsuleBiomass")); + OreDictionary.registerOre("capsuleShortMead", getForestryItem("waxCapsuleShortMead")); + OreDictionary.registerOre("capsuleMead", getForestryItem("waxCapsuleMead")); + OreDictionary.registerOre("capsuleFuel", getForestryItem("waxCapsuleFuel")); + OreDictionary.registerOre("capsuleOil", getForestryItem("waxCapsuleOil")); + OreDictionary.registerOre("capsuleLava", getForestryItem("refractoryLava")); + } + + private static ItemStack getForestryItem(String itemName) { + return GT_ModHandler.getModItem(Forestry.ID, itemName, 1); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java new file mode 100644 index 0000000000..ba08d083c2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java @@ -0,0 +1,1158 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.GT_Enhancement; + +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.AcidicIridiumSolution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.AcidicOsmiumSolution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.AmmoniumChloride; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.AquaRegia; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.CalciumChloride; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.CrudeRhMetall; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.FormicAcid; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.HotRutheniumTetroxideSollution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.IrLeachResidue; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.IrOsLeachResidue; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.IridiumChloride; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.IridiumDioxide; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.LeachResidue; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.OsmiumSolution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PDAmmonia; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PDMetallicPowder; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PDRawPowder; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PDSalt; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PGSDResidue; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PGSDResidue2; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PTConcentrate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PTMetallicPowder; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PTRawPowder; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PTResidue; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PTSaltCrude; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PTSaltRefined; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.PotassiumDisulfate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RHFilterCakeSolution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RHNitrate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RHSalt; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RHSaltSolution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RHSulfate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RHSulfateSolution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.ReRh; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RhFilterCake; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Rhodium; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Ruthenium; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RutheniumTetroxide; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RutheniumTetroxideSollution; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.SodiumNitrate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.SodiumRuthenate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Sodiumformate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Sodiumsulfate; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.ZincSulfate; +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GalaxySpace; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.crateGtDust; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedCentrifuged; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustImpure; +import static gregtech.api.enums.OrePrefixes.dustPure; +import static gregtech.api.enums.OrePrefixes.dustRefined; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.rawOre; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidHeaterRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.recipe.RecipeMaps.sifterRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.COIL_HEAT; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Items; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.CachedReflectionUtils; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.items.GT_Generic_Block; +import gregtech.api.items.GT_Generic_Item; +import gregtech.api.objects.ItemData; +import gregtech.api.objects.MaterialStack; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.blocks.GT_Block_Ores_Abstract; + +public class PlatinumSludgeOverHaul { + + private static final Materials[] BLACKLIST = { Materials.HSSS, Materials.EnderiumBase, Materials.Osmiridium, + Materials.TPV, Materials.get("Uraniumtriplatinid"), Materials.get("Tetranaquadahdiindiumhexaplatiumosminid"), + Materials.get("Longasssuperconductornameforuvwire"), }; + private static final OrePrefixes[] OPBLACKLIST = { crushedCentrifuged, crushed, crushedPurified, dustPure, + dustImpure, dustRefined, dust, dustTiny, dustSmall }; + + private PlatinumSludgeOverHaul() {} + + private static void runHelperrecipes() { + // DilutedSulfuricAcid + // 2H2SO4 + H2O = 3H2SO4(d) + GT_Values.RA.stdBuilder() + .itemInputs( + Materials.SulfuricAcid.getCells(2), + Materials.Water.getCells(1), + GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(Materials.DilutedSulfuricAcid.getCells(3)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Water.getCells(1), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.SulfuricAcid.getFluid(2000)) + .fluidOutputs(Materials.DilutedSulfuricAcid.getFluid(3000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.SulfuricAcid.getCells(2), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(2)) + .fluidInputs(Materials.Water.getFluid(1000)) + .fluidOutputs(Materials.DilutedSulfuricAcid.getFluid(3000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + // FormicAcid + // CO + NaOH = CHO2Na + GT_Values.RA.stdBuilder() + .itemInputs(Materials.CarbonMonoxide.getCells(1), Materials.SodiumHydroxide.getDust(3)) + .itemOutputs(Sodiumformate.get(cell)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + // H2SO4 + 2CHO2Na = 2CH2O2 + Na2SO4 + + GT_Values.RA.stdBuilder() + .itemInputs(Sodiumformate.get(cell, 2), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(FormicAcid.get(cell, 2), Sodiumsulfate.get(dust, 7)) + .fluidInputs(Materials.SulfuricAcid.getFluid(1000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.SulfuricAcid.getCells(1), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(1), Sodiumsulfate.get(dust, 7)) + .fluidInputs(Sodiumformate.getFluidOrGas(2000)) + .fluidOutputs(FormicAcid.getFluidOrGas(2000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // AquaRegia + GT_Values.RA.stdBuilder() + .itemInputs( + Materials.DilutedSulfuricAcid.getCells(1), + Materials.NitricAcid.getCells(1), + GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(AquaRegia.get(cell, 2)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + Materials.DilutedSulfuricAcid.getCells(1), + Materials.NitricAcid.getCells(1), + GT_Utility.getIntegratedCircuit(2)) + .itemOutputs(Materials.Empty.getCells(2)) + .fluidOutputs(AquaRegia.getFluidOrGas(2000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.NitricAcid.getCells(1), GT_Utility.getIntegratedCircuit(3)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.DilutedSulfuricAcid.getFluid(1000)) + .fluidOutputs(AquaRegia.getFluidOrGas(2000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.DilutedSulfuricAcid.getCells(1), GT_Utility.getIntegratedCircuit(4)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.NitricAcid.getFluid(1000)) + .fluidOutputs(AquaRegia.getFluidOrGas(2000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + // AmmoniumChloride + // NH3 + HCl = NH4Cl + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Ammonia.getCells(1), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(AmmoniumChloride.get(cell, 1)) + .fluidInputs(Materials.HydrochloricAcid.getFluid(1000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.HydrochloricAcid.getCells(1), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.Ammonia.getGas(1000)) + .fluidOutputs(AmmoniumChloride.getFluidOrGas(1000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.addMultiblockChemicalRecipe( + new ItemStack[] { GT_Utility.getIntegratedCircuit(9) }, + new FluidStack[] { Materials.Ammonia.getGas(64000), Materials.HydrochloricAcid.getFluid(64000) }, + new FluidStack[] { AmmoniumChloride.getFluidOrGas(64000) }, + null, + 60, + 480); + // base solution + for (Werkstoff w : Werkstoff.werkstoffHashSet) if (w.containsStuff(Materials.Sulfur) + && (w.containsStuff(Materials.Copper) || w.containsStuff(Materials.Nickel))) { + + GT_Values.RA.stdBuilder() + .itemInputs(w.get(crushedPurified), GT_Utility.getIntegratedCircuit(1)) + .fluidInputs(AquaRegia.getFluidOrGas(150)) + .fluidOutputs(PTConcentrate.getFluidOrGas(150)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(w.get(crushedPurified, 9), GT_Utility.getIntegratedCircuit(9)) + .fluidInputs(AquaRegia.getFluidOrGas(1350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(1350)) + .duration(11 * SECONDS + 5 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(w.get(crushedPurified, 9), PTMetallicPowder.get(dust, 9)) + .itemOutputs(PTResidue.get(dust)) + .fluidInputs(AquaRegia.getFluidOrGas(10350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(10350)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + } + for (Materials m : Materials.values()) if (PlatinumSludgeOverHaul.materialsContains(m, Materials.Sulfur) + && (PlatinumSludgeOverHaul.materialsContains(m, Materials.Copper) + || PlatinumSludgeOverHaul.materialsContains(m, Materials.Nickel))) { + + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(crushedPurified, m, 1), GT_Utility.getIntegratedCircuit(1)) + .fluidInputs(AquaRegia.getFluidOrGas(150)) + .fluidOutputs(PTConcentrate.getFluidOrGas(150)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(crushedPurified, m, 9), GT_Utility.getIntegratedCircuit(9)) + .fluidInputs(AquaRegia.getFluidOrGas(1350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(1350)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(crushedPurified, m, 9), PTMetallicPowder.get(dust, 9)) + .itemOutputs(PTResidue.get(dust)) + .fluidInputs(AquaRegia.getFluidOrGas(10350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(10350)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + } + // Pt + GT_Values.RA.stdBuilder() + .itemInputs(PTMetallicPowder.get(dust, 3), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Platinum.getNuggets(2)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, Materials.Platinum.mMeltingPoint) + .addTo(blastFurnaceRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(PTMetallicPowder.get(dust), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(PTResidue.get(dustTiny)) + .fluidInputs(AquaRegia.getFluidOrGas(1000)) + .fluidOutputs(PTConcentrate.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(PTMetallicPowder.get(dust, 9), GT_Utility.getIntegratedCircuit(9)) + .itemOutputs(PTResidue.get(dust)) + .fluidInputs(AquaRegia.getFluidOrGas(9000)) + .fluidOutputs(PTConcentrate.getFluidOrGas(9000)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(PTConcentrate.get(cell, 2)) + .itemOutputs( + PTSaltCrude.get(dustTiny, 16), + PTRawPowder.get(dustTiny, 4), + Materials.NitrogenDioxide.getCells(1), + Materials.DilutedSulfuricAcid.getCells(1)) + .fluidInputs(AmmoniumChloride.getFluidOrGas(400)) + .fluidOutputs(PDAmmonia.getFluidOrGas(400)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GT_Values.RA.addMultiblockChemicalRecipe( + new ItemStack[] { GT_Utility.getIntegratedCircuit(1) }, + new FluidStack[] { PTConcentrate.getFluidOrGas(2000), AmmoniumChloride.getFluidOrGas(400) }, + new FluidStack[] { PDAmmonia.getFluidOrGas(400), Materials.NitrogenDioxide.getGas(1000), + Materials.DilutedSulfuricAcid.getFluid(1000) }, + new ItemStack[] { PTSaltCrude.get(dustTiny, 16), PTRawPowder.get(dustTiny, 4) }, + 1200, + 30); + GT_Values.RA.addMultiblockChemicalRecipe( + new ItemStack[] { GT_Utility.getIntegratedCircuit(2) }, + new FluidStack[] { PTConcentrate.getFluidOrGas(18000), AmmoniumChloride.getFluidOrGas(3600) }, + new FluidStack[] { PDAmmonia.getFluidOrGas(3600), Materials.NitrogenDioxide.getGas(9000), + Materials.DilutedSulfuricAcid.getFluid(9000) }, + new ItemStack[] { PTSaltCrude.get(dust, 16), PTRawPowder.get(dust, 4) }, + 1400, + 240); + + GT_Values.RA.stdBuilder() + .itemInputs(PTSaltCrude.get(dust)) + .itemOutputs( + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust)) + .outputChances(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1500) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(sifterRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(PTSaltRefined.get(dust), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(PTMetallicPowder.get(dust)) + .fluidOutputs(Materials.Chlorine.getGas(87)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 900) + .addTo(blastFurnaceRecipes); + + // 2PtCl + Ca = 2Pt + CaCl2 + + GT_Values.RA.stdBuilder() + .itemInputs(PTRawPowder.get(dust, 4), Materials.Calcium.getDust(1)) + .itemOutputs(Materials.Platinum.getDust(2), CalciumChloride.get(dust, 3)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + // Pd + + GT_Values.RA.stdBuilder() + .itemInputs(PDMetallicPowder.get(dust), GT_Utility.getIntegratedCircuit(1)) + .fluidInputs(Materials.Ammonia.getGas(1000)) + .fluidOutputs(PDAmmonia.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(PDMetallicPowder.get(dust), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(PDSalt.get(dustTiny, 16), PDRawPowder.get(dustTiny, 2)) + .fluidInputs(PDAmmonia.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(PDMetallicPowder.get(dust, 9), GT_Utility.getIntegratedCircuit(9)) + .itemOutputs(PDSalt.get(dust, 16), PDRawPowder.get(dust, 2)) + .fluidInputs(PDAmmonia.getFluidOrGas(9000)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(2)) + .itemOutputs(PDSalt.get(dust)) + .fluidInputs(PDAmmonia.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(PDSalt.get(dust)) + .itemOutputs( + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust)) + .outputChances(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1500) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(sifterRecipes); + + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + PDRawPowder.get(dust, 4), + Materials.Empty.getCells(1), + FormicAcid.getFluidOrGas(4000), + Materials.Ammonia.getGas(4000), + Materials.Palladium.getDust(2), + Materials.Ethylene.getCells(1), + 250, + 30); + GT_Values.RA.addMultiblockChemicalRecipe( + new ItemStack[] { PDRawPowder.get(dust, 4) }, + new FluidStack[] { FormicAcid.getFluidOrGas(4000) }, + new FluidStack[] { Materials.Ammonia.getGas(4000), Materials.Ethylene.getGas(1000), + Materials.Water.getFluid(1000) }, + new ItemStack[] { Materials.Palladium.getDust(2) }, + 250, + 30); + // Na2SO4 + 2H = 2Na + H2SO4 + + GT_Values.RA.stdBuilder() + .itemInputs(Sodiumsulfate.get(dust, 7), Materials.Hydrogen.getCells(2)) + .itemOutputs(Materials.Sodium.getDust(2), Materials.Empty.getCells(2)) + .fluidOutputs(Materials.SulfuricAcid.getFluid(1000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // K2S2O7 + // GT_Values.RA.addChemicalRecipe(Sodiumsulfate.get(dust), Materials.Potassium.getDust(2), + // Materials.Oxygen.getGas(3000), null, PotassiumDisulfate.get(dust,6), null, 30); + // Rh/Os/Ir/Ru + GT_Values.RA.stdBuilder() + .itemInputs(PTResidue.get(dust), GT_Utility.getIntegratedCircuit(11)) + .itemOutputs(LeachResidue.get(dust)) + .fluidInputs(PotassiumDisulfate.getMolten(360)) + .fluidOutputs(RHSulfate.getFluidOrGas(360)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + // Ru + GT_Values.RA.stdBuilder() + .itemInputs(LeachResidue.get(dust, 10), Materials.Saltpeter.getDust(10)) + .itemOutputs(SodiumRuthenate.get(dust, 3), IrOsLeachResidue.get(dust, 6)) + .fluidInputs(Materials.SaltWater.getFluid(1000)) + .fluidOutputs(GT_ModHandler.getSteam(1000)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(SodiumRuthenate.get(dust, 6), Materials.Chlorine.getCells(3)) + .itemOutputs(Materials.Empty.getCells(3)) + .fluidOutputs(RutheniumTetroxideSollution.getFluidOrGas(9000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(1)) + .fluidInputs(RutheniumTetroxideSollution.getFluidOrGas(800)) + .fluidOutputs(HotRutheniumTetroxideSollution.getFluidOrGas(800)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(fluidHeaterRecipes); + + GT_Values.RA.addCrackingRecipe( + 17, + RutheniumTetroxideSollution.getFluidOrGas(1000), + GT_ModHandler.getSteam(1000), + HotRutheniumTetroxideSollution.getFluidOrGas(2000), + 150, + 480); + GT_Values.RA.addDistillationTowerRecipe( + HotRutheniumTetroxideSollution.getFluidOrGas(9000), + new FluidStack[] { Materials.Water.getFluid(1800), RutheniumTetroxide.getFluidOrGas(7200) }, + Materials.Salt.getDust(6), + 1500, + 480); + + GT_Values.RA.stdBuilder() + .itemInputs(RutheniumTetroxide.get(dust, 1), Materials.HydrochloricAcid.getCells(6)) + .itemOutputs(Ruthenium.get(dust), Materials.Chlorine.getCells(6)) + .fluidOutputs(Materials.Water.getFluid(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // Os + GT_Values.RA.stdBuilder() + .itemInputs(IrOsLeachResidue.get(dust, 4), GT_Utility.getIntegratedCircuit(11)) + .itemOutputs(IrLeachResidue.get(dust, 2)) + .fluidInputs(Materials.HydrochloricAcid.getFluid(1000)) + .fluidOutputs(AcidicOsmiumSolution.getFluidOrGas(2000)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + GT_Values.RA.addDistillationTowerRecipe( + AcidicOsmiumSolution.getFluidOrGas(1000), + new FluidStack[] { OsmiumSolution.getFluidOrGas(100), Materials.Water.getFluid(900) }, + null, + 150, + (int) TierEU.RECIPE_IV); + + GT_Values.RA.stdBuilder() + .itemInputs(OsmiumSolution.get(cell), Materials.HydrochloricAcid.getCells(6)) + .itemOutputs(Materials.Osmium.getDust(1), Materials.Chlorine.getCells(7)) + .fluidOutputs(Materials.Water.getFluid(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // Ir + GT_Values.RA.stdBuilder() + .itemInputs(IrLeachResidue.get(dust), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(PGSDResidue.get(dust), IridiumDioxide.get(dust)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(IridiumDioxide.get(dust), Materials.HydrochloricAcid.getCells(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidOutputs(AcidicIridiumSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(AcidicIridiumSolution.get(cell), AmmoniumChloride.get(cell, 3)) + .itemOutputs(Materials.Empty.getCells(4), IridiumChloride.get(dust)) + .fluidOutputs(Materials.Ammonia.getGas(3000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(IridiumChloride.get(dust), Materials.Calcium.getDust(1)) + .itemOutputs(PGSDResidue2.get(dust), Materials.Iridium.getDust(1)) + .fluidOutputs(CalciumChloride.getFluidOrGas(3000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(UniversalChemical); + // Rh + + GT_Values.RA.stdBuilder() + .itemInputs(RHSulfate.get(cell, 11), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(RHSulfateSolution.get(cell, 11), LeachResidue.get(dustTiny, 10)) + .fluidInputs(Materials.Water.getFluid(10000)) + .fluidOutputs(Materials.Potassium.getMolten(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.addMultiblockChemicalRecipe( + new ItemStack[] { GT_Utility.getIntegratedCircuit(3) }, + new FluidStack[] { Materials.Water.getFluid(36000), RHSulfate.getFluidOrGas(39600) }, + new FluidStack[] { Materials.Potassium.getMolten(7200), RHSulfateSolution.getFluidOrGas(39600) }, + new ItemStack[] { LeachResidue.get(dust, 4) }, + 1200, + 30); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Zinc.getDust(1)) + .itemOutputs(ZincSulfate.get(dust, 6), CrudeRhMetall.get(dust)) + .fluidInputs(RHSulfateSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(CrudeRhMetall.get(dust), Materials.Salt.getDust(1)) + .itemOutputs(RHSalt.get(dust, 3)) + .fluidInputs(Materials.Chlorine.getGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 600) + .addTo(blastFurnaceRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(RHSalt.get(dust, 10)) + .fluidInputs(Materials.Water.getFluid(2000)) + .fluidOutputs(RHSaltSolution.getFluidOrGas(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(SodiumNitrate.get(dust, 5), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(RHNitrate.get(dust), Materials.Salt.getDust(2)) + .fluidInputs(RHSaltSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + // Na + HNO3 = NaNO3 + H + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Sodium.getDust(1)) + .itemOutputs(SodiumNitrate.get(dust, 5)) + .fluidInputs(Materials.NitricAcid.getFluid(1000)) + .fluidOutputs(Materials.Hydrogen.getGas(1000)) + .duration(8 * TICKS) + .eut(60) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(RHNitrate.get(dust)) + .itemOutputs( + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust)) + .outputChances(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1500) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(sifterRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(RhFilterCake.get(dust)) + .fluidInputs(Materials.Water.getFluid(1000)) + .fluidOutputs(RHFilterCakeSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(2)) + .itemOutputs(ReRh.get(dust)) + .fluidInputs(RHFilterCakeSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(ReRh.get(dust), Materials.Empty.getCells(1)) + .itemOutputs(Rhodium.get(dust), Materials.Ammonia.getCells(1)) + .fluidInputs(Materials.HydrochloricAcid.getFluid(1000)) + .fluidOutputs(Materials.Chlorine.getGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + } + + private static boolean materialsContains(Materials one, ISubTagContainer other) { + if (one == null || one.mMaterialList == null || one.mMaterialList.isEmpty()) return false; + for (MaterialStack stack : one.mMaterialList) if (stack.mMaterial.equals(other)) return true; + return false; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static void replacePureElements() { + // furnace + for (Object entry : FurnaceRecipes.smelting() + .getSmeltingList() + .entrySet()) { + Map.Entry realEntry = (Map.Entry) entry; + if (GT_Utility.isStackValid(realEntry.getKey()) + && BW_Util.checkStackAndPrefix((ItemStack) realEntry.getKey())) { + ItemData association = GT_OreDictUnificator.getAssociation((ItemStack) realEntry.getKey()); + if (!dust.equals(association.mPrefix) && !dustTiny.equals(association.mPrefix) + || !association.mMaterial.mMaterial.equals(Materials.Platinum)) + if (GT_Utility.isStackValid(realEntry.getValue()) + && BW_Util.checkStackAndPrefix((ItemStack) realEntry.getValue())) { + ItemData ass = GT_OreDictUnificator.getAssociation((ItemStack) realEntry.getValue()); + if (ass.mMaterial.mMaterial.equals(Materials.Platinum)) + if (!PlatinumSludgeOverHaul.isInBlackList((ItemStack) realEntry.getKey())) + realEntry.setValue( + PTMetallicPowder.get( + ass.mPrefix == nugget ? dustTiny : dust, + ((ItemStack) realEntry.getValue()).stackSize * 2)); + else if (ass.mMaterial.mMaterial.equals(Materials.Palladium)) + if (!PlatinumSludgeOverHaul.isInBlackList((ItemStack) realEntry.getKey())) + realEntry.setValue( + PDMetallicPowder.get( + ass.mPrefix == nugget ? dustTiny : dust, + ((ItemStack) realEntry.getValue()).stackSize * 2)); + } + } + } + // vanilla crafting + CraftingManager.getInstance() + .getRecipeList() + .forEach(PlatinumSludgeOverHaul::setnewMaterialInRecipe); + // gt crafting + try { + ((List) FieldUtils.getDeclaredField(GT_ModHandler.class, "sBufferRecipeList", true) + .get(null)).forEach(PlatinumSludgeOverHaul::setnewMaterialInRecipe); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + // gt machines + maploop: for (RecipeMap map : RecipeMap.ALL_RECIPE_MAPS.values()) { + if (map == RecipeMaps.fusionRecipes || map == RecipeMaps.unpackagerRecipes + || map == RecipeMaps.packagerRecipes + || map == RecipeMaps.replicatorRecipes + || "gt.recipe.eyeofharmony".equals(map.unlocalizedName) + || "gtpp.recipe.quantumforcesmelter".equals(map.unlocalizedName)) continue; + HashSet toDel = new HashSet<>(); + recipeloop: for (GT_Recipe recipe : map.getAllRecipes()) { + if (recipe.mFakeRecipe) continue maploop; + + for (int i = 0; i < recipe.mFluidOutputs.length; i++) { + if (map.equals(RecipeMaps.fluidExtractionRecipes)) continue maploop; + if ("gtpp.recipe.alloyblastsmelter".equals(map.unlocalizedName)) continue maploop; + if (map.equals(RecipeMaps.multiblockChemicalReactorRecipes) + || map.equals(RecipeMaps.chemicalReactorRecipes)) { + if (GT_Utility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + else if (GT_Utility.areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = AcidicIridiumSolution.getFluidOrGas(1000); + recipe.reloadOwner(); + } else + if (GT_Utility.areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = PTConcentrate.getFluidOrGas(1000); + recipe.reloadOwner(); + } else + if (GT_Utility.areFluidsEqual(Materials.Osmium.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = AcidicOsmiumSolution.getFluidOrGas(1000); + recipe.reloadOwner(); + } + } else if (GT_Utility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + else if (GT_Utility.areFluidsEqual(Materials.Osmium.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + } + for (int i = 0; i < recipe.mOutputs.length; i++) { + if (!GT_Utility.isStackValid(recipe.mOutputs[i])) continue; + if ((BW_Util.areStacksEqualOrNull(Ruthenium.get(dust), recipe.mOutputs[i]) + || BW_Util.areStacksEqualOrNull(Ruthenium.get(dustImpure), recipe.mOutputs[i]) + || BW_Util.areStacksEqualOrNull(Ruthenium.get(dustPure), recipe.mOutputs[i])) + && !BW_Util.areStacksEqualOrNull(Ruthenium.get(ingot), recipe.mInputs[0])) { + for (ItemStack mInput : recipe.mInputs) + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + int amount = recipe.mOutputs[i].stackSize * 2; + recipe.mOutputs[i] = LeachResidue.get(dust, amount); + recipe.reloadOwner(); + } + if ((BW_Util.areStacksEqualOrNull(Rhodium.get(dust), recipe.mOutputs[i]) + || BW_Util.areStacksEqualOrNull(Rhodium.get(dustImpure), recipe.mOutputs[i]) + || BW_Util.areStacksEqualOrNull(Rhodium.get(dustPure), recipe.mOutputs[i])) + && !BW_Util.areStacksEqualOrNull(Rhodium.get(ingot), recipe.mInputs[0])) { + for (ItemStack mInput : recipe.mInputs) + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + int amount = recipe.mOutputs[i].stackSize * 2; + recipe.mOutputs[i] = CrudeRhMetall.get(dust, amount); + recipe.reloadOwner(); + } + if (!BW_Util.checkStackAndPrefix(recipe.mOutputs[i])) continue; + // Pt + if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Platinum)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util.setStackSize(PTMetallicPowder.get(dust), amount * 2); + recipe.reloadOwner(); + } else if (dustSmall.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util.setStackSize(PTMetallicPowder.get(dustSmall), amount * 2); + recipe.reloadOwner(); + } else if (dustTiny.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util.setStackSize(PTMetallicPowder.get(dustTiny), amount * 2); + recipe.reloadOwner(); + } + } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Palladium)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util.setStackSize(PDMetallicPowder.get(dust), amount * 4); + recipe.reloadOwner(); + } else + if (dustSmall.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util + .setStackSize(PDMetallicPowder.get(dustSmall), amount * 4); + recipe.reloadOwner(); + } else if (dustTiny + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util + .setStackSize(PDMetallicPowder.get(dustTiny), amount * 4); + recipe.reloadOwner(); + } + } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Osmium)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util.setStackSize(IrOsLeachResidue.get(dust), amount); + recipe.reloadOwner(); + } else if (dustSmall + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util + .setStackSize(IrOsLeachResidue.get(dustSmall), amount); + recipe.reloadOwner(); + } else if (dustTiny + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util + .setStackSize(IrOsLeachResidue.get(dustTiny), amount); + recipe.reloadOwner(); + } + } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Iridium)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util.setStackSize(IrLeachResidue.get(dust), amount); + recipe.reloadOwner(); + } else if (dustSmall + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util + .setStackSize(IrLeachResidue.get(dustSmall), amount); + recipe.reloadOwner(); + } else if (dustTiny + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BW_Util + .setStackSize(IrLeachResidue.get(dustTiny), amount); + recipe.reloadOwner(); + } + } + } + } + map.getBackend() + .removeRecipes(toDel); + } + // TODO: remove EnderIO recipes + + // fix HV tier + PlatinumSludgeOverHaul.replaceHVCircuitMaterials(); + // add new recipes + PlatinumSludgeOverHaul.runHelperrecipes(); + } + + @SuppressWarnings("deprecation") + private static void replaceHVCircuitMaterials() { + GT_Values.RA.addMixerRecipe( + Materials.Redstone.getDust(1), + Materials.Electrum.getDust(1), + GT_Utility.getIntegratedCircuit(1), + null, + null, + null, + Materials.Nikolite.getDust(8), + 1800, + 120); + for (GT_Recipe recipe : RecipeMaps.circuitAssemblerRecipes.getAllRecipes()) { + if (recipe.mEUt > 512) continue; + if (BW_Util.checkStackAndPrefix(recipe.mOutputs[0])) { + for (int i = 0; i < recipe.mInputs.length; i++) { + ItemStack stack = recipe.mInputs[i]; + ItemData ass = GT_OreDictUnificator.getAssociation(stack); + if (BW_Util.checkStackAndPrefix(stack) && ass.mMaterial.mMaterial.equals(Materials.Platinum)) { + recipe.mInputs[i] = GT_OreDictUnificator.get(ass.mPrefix, Materials.BlueAlloy, stack.stackSize); + recipe.reloadOwner(); + } + } + } + } + } + + private static void setnewMaterialInRecipe(Object obj) { + String inputName = "output"; + String inputItemName = "input"; + if (!(obj instanceof ShapedOreRecipe) && !(obj instanceof ShapelessOreRecipe)) { + if (obj instanceof ShapedRecipes || obj instanceof ShapelessRecipes) { + inputName = "recipeOutput"; + inputItemName = "recipeItems"; + } else if (GTPlusPlus.isModLoaded()) { + try { + if (Class.forName("gtPlusPlus.api.objects.minecraft.ShapedRecipe") + .isAssignableFrom(obj.getClass())) + obj = CachedReflectionUtils.getField(obj.getClass(), "mRecipe") + .get(obj); + } catch (ClassNotFoundException | IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + IRecipe recipe = (IRecipe) obj; + ItemStack otpt = recipe.getRecipeOutput(); + + Field out = CachedReflectionUtils.getDeclaredField(recipe.getClass(), inputName); + if (out == null) out = CachedReflectionUtils.getField(recipe.getClass(), inputName); + + Field in = CachedReflectionUtils.getDeclaredField(recipe.getClass(), inputItemName); + if (in == null) in = CachedReflectionUtils.getField(recipe.getClass(), inputItemName); + if (in == null) return; + + Object input; + try { + input = in.get(obj); + } catch (IllegalAccessException e) { + e.printStackTrace(); + return; + } + + if (out != null && GT_Utility.areStacksEqual(otpt, Materials.Platinum.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Platinum)) return; + try { + out.set(recipe, PTMetallicPowder.get(dust, otpt.stackSize * 2)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } else if (out != null && GT_Utility.areStacksEqual(otpt, Materials.Palladium.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Palladium)) return; + try { + out.set(recipe, PDMetallicPowder.get(dust, otpt.stackSize * 2)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } else if (out != null && GT_Utility.areStacksEqual(otpt, Materials.Iridium.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Iridium)) return; + try { + out.set(recipe, IrLeachResidue.get(dust, otpt.stackSize)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } else if (out != null && GT_Utility.areStacksEqual(otpt, Materials.Osmium.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Osmium)) return; + try { + out.set(recipe, IrOsLeachResidue.get(dust, otpt.stackSize)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static boolean checkRecipe(Object input, Materials mat) { + if (input instanceof List || input instanceof Object[]) { + Set lists = new HashSet(), stacks = new HashSet(); + List ip = input instanceof List ? (List) input : new ArrayList(); + Object[] ip2 = input instanceof Object[] ? (Object[]) input : new Object[0]; + + for (Object o : ip) { + if (o instanceof List) lists.add(o); + else if (o instanceof ItemStack) stacks.add(o); + } + for (Object o : ip2) { + if (o instanceof List) lists.add(o); + else if (o instanceof ItemStack) stacks.add(o); + } + + for (Object o : lists) { + if (!((List) o).isEmpty()) stacks.add(((List) o).get(0)); + } + + for (Object stack : stacks) { + if (stack instanceof ItemStack + && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(crateGtDust, mat, 1), (ItemStack) stack)) + return true; + } + + boolean allSame = false; + for (Object stack : stacks) { + if (!(stack instanceof ItemStack)) { + allSame = false; + break; + } + allSame = BW_Util.checkStackAndPrefix((ItemStack) stack) + && GT_OreDictUnificator.getAssociation((ItemStack) stack).mMaterial.mMaterial.equals(mat); + if (!allSame) break; + } + return allSame; + } + return false; + } + + private static boolean isInBlackList(ItemStack stack) { + if (stack == null || stack.getItem() instanceof BW_MetaGenerated_Items + || MainMod.MOD_ID.equals(GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId) + || BartWorksCrossmod.MOD_ID.equals(GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId)) + return true; + + if (GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId.equals(NewHorizonsCoreMod.ID) + && !stack.getUnlocalizedName() + .contains("dust") + && !stack.getUnlocalizedName() + .contains("Dust")) + return true; + + if (Block.getBlockFromItem(stack.getItem()) instanceof GT_Generic_Block + && !(Block.getBlockFromItem(stack.getItem()) instanceof GT_Block_Ores_Abstract)) return true; + + if (Arrays.stream(ItemList.values()) + .filter(ItemList::hasBeenSet) + .anyMatch(e -> !BW_Util.checkStackAndPrefix(stack) && GT_Utility.areStacksEqual(e.get(1), stack, true))) + return true; + + if (stack.getItem() instanceof GT_Generic_Item) { + if (!BW_Util.checkStackAndPrefix(stack)) return false; + if (GT_OreDictUnificator.getAssociation(stack).mPrefix != rawOre) { + return !Arrays.asList(PlatinumSludgeOverHaul.OPBLACKLIST) + .contains(GT_OreDictUnificator.getAssociation(stack).mPrefix) + || Arrays.asList(PlatinumSludgeOverHaul.BLACKLIST) + .contains(GT_OreDictUnificator.getAssociation(stack).mMaterial.mMaterial); + } + } + + if (GTPlusPlus.isModLoaded()) { + try { + if (Class.forName("gtPlusPlus.core.item.base.BaseItemComponent") + .isAssignableFrom( + stack.getItem() + .getClass()) + && !stack.getUnlocalizedName() + .contains("dust") + && !stack.getUnlocalizedName() + .contains("Dust")) + return true; + if (Class.forName("gtPlusPlus.core.block.base.BlockBaseModular") + .isAssignableFrom( + Block.getBlockFromItem(stack.getItem()) + .getClass())) + return true; + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + if (stack.getItem() == GT_ModHandler.getModItem(GTPlusPlus.ID, "itemDustHeLiCoPtEr", 1L) + .getItem()) { + return true; + } + if (stack.getItem() == GT_ModHandler.getModItem(GTPlusPlus.ID, "itemDustWhiteMetal", 1L) + .getItem()) { + return true; + } + } + if (GalaxySpace.isModLoaded()) { + if (stack.getItem() == GT_ModHandler.getModItem(GalaxySpace.ID, "metalsblock", 1L, 7) + .getItem()) { + return true; + } + } + if (NewHorizonsCoreMod.isModLoaded()) { + if (stack.getItem() == GT_ModHandler.getModItem(NewHorizonsCoreMod.ID, "item.IndustryFrame", 1L) + .getItem()) { + return true; + } + } + if (!BW_Util.checkStackAndPrefix(stack)) { + return false; + } + return Arrays.asList(PlatinumSludgeOverHaul.BLACKLIST) + .contains(GT_OreDictUnificator.getAssociation(stack).mMaterial.mMaterial); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java new file mode 100644 index 0000000000..af8651dc6b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -0,0 +1,1265 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static gregtech.api.enums.Mods.GalaxySpace; +import static net.minecraft.util.EnumChatFormatting.DARK_PURPLE; +import static net.minecraft.util.EnumChatFormatting.GREEN; + +import java.lang.reflect.InvocationTargetException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.loaders.StaticRecipeChangeLoaders; +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; +import com.github.bartimaeusnek.bartworks.util.NonNullWrappedHashMap; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.github.bartimaeusnek.crossmod.tgregworks.MaterialsInjector; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; + +import cpw.mods.fml.common.Loader; +import gregtech.api.GregTech_API; +import gregtech.api.enums.FluidState; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; + +public class Werkstoff implements IColorModulationContainer, ISubTagContainer { + + public static final LinkedHashSet werkstoffHashSet = new LinkedHashSet<>(); + public static final LinkedHashMap werkstoffHashMap = new LinkedHashMap<>(); + public static final LinkedHashMap werkstoffNameHashMap = new LinkedHashMap<>(); + + public static final Map modNameOverrides = new HashMap<>() { + + private static final long serialVersionUID = 6399917619058898648L; + + { + this.put(GalaxySpace.ID, DARK_PURPLE + "GalaxySpace"); + } + }; + + private static final List BWModNames = Arrays + .asList(MainMod.NAME, BartWorksCrossmod.NAME, MaterialsInjector.NAME); + + private static final HashSet idHashSet = new HashSet<>(); + + private static final Werkstoff.Stats DEFAULT_NULL_STATS = new Werkstoff.Stats(); + private static final Werkstoff.GenerationFeatures DEFAULT_NULL_GENERATION_FEATURES = new Werkstoff.GenerationFeatures() + .disable(); + public static Werkstoff default_null_Werkstoff; + + private final HashSet ADDITIONAL_OREDICT = new HashSet<>(); + private final List mOreByProducts = new ArrayList<>(); + private final LinkedHashSet> CONTENTS = new LinkedHashSet<>(); + private final HashSet SUBTAGS = new HashSet<>(); + private byte[] rgb = new byte[3]; + private final String defaultName; + private String toolTip; + + private Werkstoff.Stats stats; + private final Werkstoff.Types type; + private final Werkstoff.GenerationFeatures generationFeatures; + private final short mID; + private final TextureSet texSet; + private Materials bridgeMaterial; + private final String owner; + + public Materials getBridgeMaterial() { + return this.bridgeMaterial; + } + + public void setBridgeMaterial(Materials bridgeMaterial) { + this.bridgeMaterial = bridgeMaterial; + } + + public static void init() { + Werkstoff.default_null_Werkstoff = new Werkstoff( + new short[3], + "_NULL", + "Default null Werkstoff", + Werkstoff.DEFAULT_NULL_STATS, + Werkstoff.Types.UNDEFINED, + Werkstoff.DEFAULT_NULL_GENERATION_FEATURES, + -1, + TextureSet.SET_NONE); + } + + /** + * GT Materials Bridge Constructor + * + * @param materials a GT Materials + * @param generationFeatures the new Types you want to add + * @param type - self explainatory + * @param mID > 31_766 && <= 32_767 + */ + public Werkstoff(Materials materials, Werkstoff.GenerationFeatures generationFeatures, Types type, int mID) { + this( + materials.mRGBa, + materials.mDefaultLocalName, + materials.getToolTip(), + type == null ? materials.mElement != null ? Types.ELEMENT : Types.UNDEFINED : type, + generationFeatures, + mID, + materials.mIconSet, + (List) materials.mOreByProducts, + new Pair<>(materials, 1)); + if (mID <= 31_766 || mID > 32_767) throw new IllegalArgumentException(); + this.stats.mass = materials.getMass(); + this.stats.protons = materials.getProtons(); + this.stats.meltingPoint = materials.mMeltingPoint; + this.stats.neutrons = materials.getNeutrons(); + this.stats.speedOverride = materials.mToolSpeed; + this.stats.durOverride = materials.mDurability; + this.stats.qualityOverride = materials.mToolQuality; + this.stats.setGas(materials.mHasGas); + this.stats.setRadioactive(materials.isRadioactive()); + this.stats.setBlastFurnace(materials.mBlastFurnaceRequired); + this.stats.setMeltingVoltage(120); + if (type == Types.COMPOUND) { + this.stats.setElektrolysis(true); + this.generationFeatures.addChemicalRecipes(); + } else if (type == Types.MIXTURE) { + this.stats.setCentrifuge(true); + this.generationFeatures.addMixerRecipes(); + } + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int meltingpoint, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type) + .setMeltingPoint(meltingpoint), + type, + generationFeatures, + mID, + texSet, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type), + type, + generationFeatures, + mID, + texSet, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int meltingpoint, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List oreByProduct, Pair... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type) + .setMeltingPoint(meltingpoint), + type, + generationFeatures, + mID, + texSet, + oreByProduct, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List oreByProduct, Pair... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type), + type, + generationFeatures, + mID, + texSet, + oreByProduct, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String toolTip, String defaultName, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List oreByProduct, Pair... contents) { + this( + rgba, + toolTip, + defaultName, + Werkstoff.Types.getDefaultStatForType(type), + type, + generationFeatures, + mID, + texSet, + oreByProduct, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List oreByProduct, Pair... contents) { + this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); + this.mOreByProducts.clear(); + this.mOreByProducts.addAll(oreByProduct); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair... contents) { + this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List oreByProduct, Pair... contents) { + this(rgba, defaultName, toolTip, stats, type, generationFeatures, mID, texSet, contents); + this.mOreByProducts.clear(); + this.mOreByProducts.addAll(oreByProduct); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair... contents) { + + if (Werkstoff.idHashSet.contains((short) mID)) + throw new UnsupportedOperationException("ID (" + mID + ") is already in use!"); + Werkstoff.idHashSet.add((short) mID); + if (type == null) type = Werkstoff.Types.UNDEFINED; + + this.mID = (short) mID; + this.defaultName = defaultName; + // Ensure that localization key are written to the lang file + GregTech_API.sAfterGTPreload.add(() -> { this.getLocalizedName(); }); + this.stats = stats; + this.type = type; + this.generationFeatures = generationFeatures; + this.setRgb(BW_ColorUtil.correctCorlorArray(rgba)); + this.CONTENTS.addAll(Arrays.asList(contents)); + this.toolTip = ""; + if (toolTip.isEmpty()) { + for (Pair p : contents) { + if (contents.length > 1) { + if (p.getKey() instanceof Materials) { + if (((Materials) p.getKey()).mMaterialList.size() > 1 && p.getValue() > 1) + this.toolTip += "(" + getFormula((Materials) p.getKey()) + + ")" + + BW_Util.subscriptNumber(p.getValue()); + else this.toolTip += getFormula((Materials) p.getKey()) + + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } + if (p.getKey() instanceof Werkstoff) { + if (((Werkstoff) p.getKey()).CONTENTS.size() > 1 && p.getValue() > 1) + this.toolTip += "(" + getFormula((Werkstoff) p.getKey()) + + ")" + + BW_Util.subscriptNumber(p.getValue()); + else this.toolTip += getFormula((Werkstoff) p.getKey()) + + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } + } else if (p.getKey() instanceof Materials) { + this.toolTip += getFormula((Materials) p.getKey()) + + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } else if (p.getKey() instanceof Werkstoff) this.toolTip += getFormula((Werkstoff) p.getKey()) + + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } + } else this.toolTip = toolTip; + + // if (this.toolTip.length() > 25) + // this.toolTip = "The formula is to long..."; + + // Ensure that localization key are written to the lang file + GregTech_API.sAfterGTPreload.add(() -> { this.getLocalizedToolTip(); }); + + if (this.stats.protons == 0) { + long tmpprotons = 0; + for (Pair p : contents) { + if (p.getKey() instanceof Materials) { + tmpprotons += ((Materials) p.getKey()).getProtons() * p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpprotons += ((Werkstoff) p.getKey()).getStats().protons * p.getValue(); + } + } + this.stats = stats.setProtons(tmpprotons); + } + if (this.stats.mass == 0) { + long tmpmass = 0; + int count = 0; + for (Pair p : contents) { + if (p.getKey() instanceof Materials) { + tmpmass += ((Materials) p.getKey()).getMass() * p.getValue(); + count += p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpmass += ((Werkstoff) p.getKey()).getStats().mass * p.getValue(); + count += p.getValue(); + } + } + if (count > 0) this.stats = stats.setMass(tmpmass / count); + } + + if (this.stats.meltingPoint == 0) this.stats.meltingPoint = 1123; + + if (this.stats.meltingVoltage == 0) this.stats.meltingVoltage = 120; + + this.texSet = texSet; + + switch (this.mOreByProducts.size()) { + case 0: + this.mOreByProducts.add(this); + this.mOreByProducts.add(this); + this.mOreByProducts.add(this); + break; + case 1: + this.mOreByProducts.add(this); + this.mOreByProducts.add(this); + break; + case 2: + this.mOreByProducts.add(this); + break; + } + + Optional> firstContent; + if (this.CONTENTS.size() == 1 && (firstContent = this.CONTENTS.stream() + .findFirst()).isPresent()) { + ISubTagContainer firstContentSubTagContainer = firstContent.get() + .getKey(); + if (firstContent.get() + .getValue() == 1 && firstContentSubTagContainer instanceof Materials) this.getGenerationFeatures() + .setExtension(); + } + + Werkstoff.werkstoffHashSet.add(this); + Werkstoff.werkstoffHashMap.put(this.mID, this); + Werkstoff.werkstoffNameHashMap.put(this.defaultName, this); + + this.owner = this.getMaterialOwner(); + } + + private static String getFormula(Materials material) { + return material.mChemicalFormula.isEmpty() ? "?" : material.mChemicalFormula; + } + + private static String getFormula(Werkstoff material) { + return material.toolTip.isEmpty() ? "?" : material.toolTip; + } + + public Werkstoff addAdditionalOreDict(String s) { + this.ADDITIONAL_OREDICT.add(s); + return this; + } + + public HashSet getADDITIONAL_OREDICT() { + return this.ADDITIONAL_OREDICT; + } + + public void setTCAspects(Pair... pAspectsArr) { + this.stats.mTC_Aspects = pAspectsArr; + } + + @SuppressWarnings("unchecked") + public Pair[] getTCAspects(int ratio) { + if (this.stats.mTC_Aspects == null) { + HashSet tc_aspectStacks = new HashSet<>(); + HashSet> set = new HashSet<>(); + for (Pair p : this.getContents() + .getValue()) { + if (p.getKey() instanceof Materials) tc_aspectStacks.addAll(((Materials) p.getKey()).mAspects); + if (p.getKey() instanceof Werkstoff) set.addAll(Arrays.asList(((Werkstoff) p.getKey()).getTCAspects())); + } + tc_aspectStacks.forEach( + tc_aspectStack -> set.add(new Pair<>(tc_aspectStack.mAspect.mAspect, (int) tc_aspectStack.mAmount))); + this.stats.mTC_Aspects = set.toArray(new Pair[0]); + } + Pair[] ret = this.stats.mTC_Aspects.clone(); + for (int i = 0; i < ret.length; i++) { + ret[i] = ret[i].copyWithNewValue(ret[i].getValue() * ratio); + } + return ret; + } + + public List getGTWrappedTCAspects() { + final List ret = new ArrayList<>(); + Arrays.stream(this.getTCAspects()) + .forEach(objectIntegerPair -> { + try { + new TC_Aspects.TC_AspectStack( + TC_Aspects.valueOf( + ((String) ThaumcraftHandler.AspectAdder.getName.invoke(objectIntegerPair.getKey())) + .toUpperCase(Locale.US)), + objectIntegerPair.getValue()).addToAspectList(ret); + } catch (IllegalAccessException | InvocationTargetException ignored) {} + }); + return ret; + } + + public Pair[] getTCAspects() { + return this.getTCAspects(1); + } + + public Werkstoff.Types getType() { + return this.type; + } + + public boolean containsStuff(ISubTagContainer stuff) { + for (Pair pair : this.CONTENTS) { + if (pair.getKey() + .equals(stuff)) return true; + } + return false; + } + + public Pair>> getContents() { + int ret = 0; + switch (this.type) { + case COMPOUND: + case MIXTURE: + case BIOLOGICAL: { + for (int i = 0; i < this.CONTENTS.toArray().length; i++) { + ret += (int) this.CONTENTS.toArray(new Pair[0])[i].getValue(); + } + break; + } + default: + ret = 1; + break; + } + return new Pair<>(ret, this.CONTENTS); + } + + public int getNoOfByProducts() { + return this.mOreByProducts.size(); + } + + public ISubTagContainer getOreByProductRaw(int aNumber) { + if (this.mOreByProducts.size() == 0) return null; + if (aNumber < 0) aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) aNumber--; + ISubTagContainer o = this.mOreByProducts.get(aNumber); + if (o == null || o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) return this; + return o; + } + + public ItemStack getOreByProduct(int aNumber, OrePrefixes prefixes) { + if (this.mOreByProducts.size() == 0) return null; + if (aNumber < 0) aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) aNumber--; + Object o = this.mOreByProducts.get(aNumber); + if (o == null || o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) + return this.get(prefixes); + if (o instanceof Werkstoff) return WerkstoffLoader.getCorrespondingItemStack(prefixes, (Werkstoff) o); + if (o instanceof Materials) return GT_OreDictUnificator.get(prefixes, o, 1L); + return null; + } + + public String getDefaultName() { + return this.defaultName; + } + + public String getLocalizedName() { + return GT_LanguageManager.addStringLocalization( + String.format("bw.werkstoff.%05d.name", this.mID), + this.defaultName, + !GregTech_API.sPostloadFinished); + } + + public String getVarName() { + return this.defaultName.replace(" ", ""); + } + + public String getToolTip() { + return this.toolTip; + } + + public String getLocalizedToolTip() { + return GT_LanguageManager.addStringLocalization( + String.format("bw.werkstoff.%05d.tooltip", this.mID), + this.toolTip, + !GregTech_API.sPostloadFinished); + } + + public Werkstoff.Stats getStats() { + return this.stats; + } + + public short getmID() { + return this.mID; + } + + public short getMixCircuit() { + return this.getGenerationFeatures().mixCircuit; + } + + public Werkstoff.GenerationFeatures getGenerationFeatures() { + return this.generationFeatures; + } + + public TextureSet getTexSet() { + return this.texSet; + } + + public void setRgb(short[] rgb) { + this.rgb = new byte[] { (byte) (rgb[0] - 128), (byte) (rgb[1] - 128), (byte) (rgb[2] - 128) }; + } + + @Override + public short[] getRGBA() { + return new short[] { (short) (this.rgb[0] + 128), (short) (this.rgb[1] + 128), (short) (this.rgb[2] + 128), 0 }; + } + + @Override + public boolean contains(SubTag subTag) { + if (!subTag.equals(WerkstoffLoader.NOBLE_GAS) && !subTag.equals(WerkstoffLoader.ANAEROBE_GAS) + && !subTag.equals(WerkstoffLoader.NO_BLAST)) + for (Pair p : this.CONTENTS) if (p.getKey() + .contains(subTag)) return true; + return this.SUBTAGS.contains(subTag); + } + + @Override + public ISubTagContainer add(SubTag... subTags) { + this.SUBTAGS.addAll(Arrays.asList(subTags)); + return this; + } + + @Override + public boolean remove(SubTag subTag) { + return this.SUBTAGS.remove(subTag); + } + + public void getAndAddToCollection(OrePrefixes prefixes, int amount, Collection stacks) { + stacks.add(this.get(prefixes, amount)); + } + + public ItemStack get(OrePrefixes prefixes) { + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this); + } + + public FluidStack getFluidOrGas(int fluidAmount) { + return new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(this)), fluidAmount); + } + + public FluidStack getMolten(int fluidAmount) { + return new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(this)), fluidAmount); + } + + public ItemStack get(OrePrefixes prefixes, int amount) { + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this, amount); + } + + public byte getToolQuality() { + return this.stats.getQualityOverride() > 0 ? this.stats.getQualityOverride() + : (byte) (15f * (this.getStats() + .getProtons() / 188f + + this.getStats() + .getMeltingPoint() / 10801f) + / (float) this.getContents() + .getKey()); + } + + public float getToolSpeed() { + return this.stats.getSpeedOverride() > 0f ? this.stats.getSpeedOverride() + : Math.max( + 1f, + 2f * (-this.getStats() + .getMass() + 0.1f + * this.getStats() + .getMeltingPoint() + + this.getStats() + .getProtons()) + * 0.1f + / (float) this.getContents() + .getKey() + * 0.1f + * this.getToolQuality()); + } + + public int getDurability() { + return this.stats.getDurOverride() > 0 ? this.stats.getDurOverride() + : (int) (this.stats.durMod * (0.01f * this.getStats() + .getMeltingPoint() + * this.getStats() + .getMass() + / (float) this.getContents() + .getKey())); + } + + /** + * Checks if the generation feature is enabled and if its not in the blacklist + */ + public boolean hasItemType(OrePrefixes prefixes) { + int unpacked = Werkstoff.GenerationFeatures.getPrefixDataRaw(prefixes); + return (this.getGenerationFeatures().toGenerate & unpacked) != 0 + && (this.getGenerationFeatures().blacklist & unpacked) == 0; + } + + /** + * DOES NOT CHECK BLACKLIST! + */ + public boolean hasGenerationFeature(OrePrefixes prefixes) { + int unpacked = Werkstoff.GenerationFeatures.getPrefixDataRaw(prefixes); + return (this.getGenerationFeatures().toGenerate & unpacked) != 0; + } + + /** + * Checks if the Actual Stack exists in the OreDict + */ + public boolean doesOreDictedItemExists(OrePrefixes prefixes) { + return OreDictHandler.getItemStack(this.getDefaultName(), prefixes, 1) != null; + } + + public String getOwner() { + return this.owner; + } + + private String getMaterialOwner() { + String modName = Loader.instance() + .activeModContainer() + .getName(); + if (modNameOverrides.get(modName) != null) { + return modNameOverrides.get(modName); + } + if (BWModNames.contains(modName)) { + return null; + } + return GREEN + modName; + } + + public enum Types { + + MATERIAL, + COMPOUND, + MIXTURE, + BIOLOGICAL, + ELEMENT, + ISOTOPE, + UNDEFINED; + + public static Werkstoff.Stats getDefaultStatForType(Werkstoff.Types T) { + return switch (T) { + case COMPOUND, BIOLOGICAL -> new Werkstoff.Stats().setElektrolysis(true); + case MIXTURE -> new Werkstoff.Stats().setCentrifuge(true); + default -> new Werkstoff.Stats(); + }; + } + } + + public static class GenerationFeatures { + + public static final GenerationFeatures DISABLED = new GenerationFeatures().disable(); + long toGenerate = 0b0001001; + // logic gate shit + /* + * dust 1 metal 10 (ingot, nugget) gem 100 ore 1000 cell 10000 plasma 100000 molten 1000000 crafting metal + * 10000000 (sticks, plates) meta crafting metal 100000000 (gears, screws, bolts, springs) multiple ingotWorth + * stuff 1000000000 (double, triple, quadruple, ingot/plates) + */ + private boolean isExtension; + private static final NonNullWrappedHashMap prefixLogic = new NonNullWrappedHashMap<>(0); + + public GenerationFeatures() {} + + public static void initPrefixLogic() { + Arrays.stream(OrePrefixes.values()) + .forEach(e -> prefixLogic.put(e, 0)); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dust, 0b1); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustTiny, 0b1); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustSmall, 0b1); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingot, 0b10); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotHot, 0b10); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.nugget, 0b10); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gem, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemFlawed, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemExquisite, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemChipped, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemFlawless, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.lens, 0b100); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.block, 0b110); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ore, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustImpure, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustPure, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushed, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushedPurified, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushedCentrifuged, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.rawOre, 0b1000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.cell, 0b10000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.capsule, 0b10000); + // Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.bottle,0b10000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.capsuleMolten, 0b1000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.cellMolten, 0b1000000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plate, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.foil, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.stick, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.stickLong, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.toolHeadHammer, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.toolHeadWrench, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.toolHeadSaw, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.turbineBlade, 0b10000000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.screw, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gearGt, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gearGtSmall, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.bolt, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ring, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.spring, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.springSmall, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.rotor, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.wireFine, 0b100000000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateDouble, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateTriple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateQuadruple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateQuintuple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateDense, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotDouble, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotTriple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotQuadruple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotQuintuple, 0x200); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.blockCasing, 0x380); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.blockCasingAdvanced, 0x380); + } + + public void setExtension() { + this.isExtension = !this.isExtension; + } + + public static int getPrefixDataRaw(OrePrefixes prefixes) { + if (prefixes == null) throw new IllegalArgumentException("OrePrefixes is NULL!"); + return GenerationFeatures.prefixLogic.get(prefixes); + } + + public boolean isExtension() { + return this.isExtension; + } + + // public byte toGenerateSecondary = 0b0000000; + public byte blacklist; + + public boolean enforceUnification; + + /* + * Auto add Chemical Recipes 1 Auto add mixer Recipes 10 Auto add Sifter Recipe 100 Auto add + * MetalWorking(sticks, plates) Recipe 1000 Auto add MetalWorking(crafting components) Recipe 10000 + */ + public byte extraRecipes; + + /* + * Here so that new recipes don't fuck with existing functionality Auto add Crafting Metal Solidifier recipes 1 + * Auto add Meta Crafting Metal Solidifier recipes 10 Auto add Multiple Ingot Metal Solidifier recipes 100 + * (Unused) + */ + public byte extraRecipes2; + + public short mixCircuit = -1; + + public Werkstoff.GenerationFeatures setBlacklist(OrePrefixes p) { + this.blacklist |= getPrefixDataRaw(p); + return this; + } + + @Deprecated + public boolean hasDusts() { + return (this.toGenerate & 0b1) != 0; + } + + @Deprecated + public boolean hasGems() { + return (this.toGenerate & 0b100) != 0; + } + + @Deprecated + public boolean hasOres() { + return (this.toGenerate & 0b1000) != 0; + } + + public Werkstoff.GenerationFeatures enforceUnification() { + this.enforceUnification = true; + return this; + } + + @Deprecated + public Werkstoff.GenerationFeatures removeGems() { + if (this.hasGems()) this.toGenerate = this.toGenerate ^ 0b100; + return this; + } + + @Deprecated + public Werkstoff.GenerationFeatures removeDusts() { + if (this.hasDusts()) this.toGenerate = this.toGenerate ^ 0b1; + return this; + } + + @Deprecated + public Werkstoff.GenerationFeatures removeOres() { + if (this.hasOres()) this.toGenerate = this.toGenerate ^ 0b1000; + return this; + } + + public Werkstoff.GenerationFeatures addChemicalRecipes() { + this.extraRecipes = (byte) (this.extraRecipes | 1); + return this; + } + + public boolean hasChemicalRecipes() { + return (this.extraRecipes & 1) != 0; + } + + public Werkstoff.GenerationFeatures addMetalCraftingSolidifierRecipes() { + this.extraRecipes2 = (byte) (this.extraRecipes2 | 1); + return this; + } + + public boolean hasMetalCraftingSolidifierRecipes() { + return (this.extraRecipes2 & 1) != 0; + } + + public Werkstoff.GenerationFeatures addMetaSolidifierRecipes() { + this.extraRecipes2 = (byte) (this.extraRecipes2 | 10); + return this; + } + + public boolean hasMetaSolidifierRecipes() { + return (this.extraRecipes2 & 10) != 0; + } + + public Werkstoff.GenerationFeatures addMultipleMetalSolidifierRecipes() { + this.extraRecipes2 = (byte) (this.extraRecipes2 | 100); + return this; + } + + public boolean hasMultipleMetalSolidifierRecipes() { + return (this.extraRecipes2 & 100) != 0; + } + + public Werkstoff.GenerationFeatures addMixerRecipes() { + this.extraRecipes = (byte) (this.extraRecipes | 10); + return this; + } + + public Werkstoff.GenerationFeatures addMixerRecipes(short aCircuit) { + this.extraRecipes = (byte) (this.extraRecipes | 10); + if (aCircuit >= 1 && aCircuit <= 24) this.mixCircuit = aCircuit; + return this; + } + + public boolean hasMixerRecipes() { + return (this.extraRecipes & 10) != 0; + } + + public Werkstoff.GenerationFeatures addSifterRecipes() { + this.extraRecipes = (byte) (this.extraRecipes | 100); + return this; + } + + public boolean hasSifterRecipes() { + return (this.extraRecipes & 100) != 0; + } + + public Werkstoff.GenerationFeatures onlyDust() { + this.toGenerate = 0b1; + return this; + } + + /** + * Automatically adds Simple Metal Working Items + */ + public Werkstoff.GenerationFeatures addMetalItems() { + this.toGenerate = this.addSimpleMetalWorkingItems().toGenerate | 0b10; + return this; + } + + public Werkstoff.GenerationFeatures disable() { + this.toGenerate = 0; + return this; + } + + public Werkstoff.GenerationFeatures addCells() { + this.toGenerate = this.toGenerate | 0b10000; + return this; + } + + @Deprecated + public boolean hasCells() { + return (this.toGenerate & 0b10000) != 0; + } + + @Deprecated + public boolean hasMolten() { + return (this.toGenerate & 0b1000000) != 0; + } + + public Werkstoff.GenerationFeatures addMolten() { + this.toGenerate = this.toGenerate | 0b1000000; + return this; + } + + /** + * Automatically adds Simple Metal Working Items + */ + public Werkstoff.GenerationFeatures addGems() { + this.toGenerate = this.addSimpleMetalWorkingItems().toGenerate | 0x4; + return this; + } + + public Werkstoff.GenerationFeatures addSimpleMetalWorkingItems() { + this.toGenerate = this.toGenerate | 0b10000000; + return this; + } + + public Werkstoff.GenerationFeatures addCasings() { + this.toGenerate = this.toGenerate | 0x382; + return this; + } + + @Deprecated + public boolean hasSimpleMetalWorkingItems() { + return (this.toGenerate & 0b10000000) != 0; + } + + public Werkstoff.GenerationFeatures addCraftingMetalWorkingItems() { + this.toGenerate = this.toGenerate | 0x100; + return this; + } + + public Werkstoff.GenerationFeatures addMultipleIngotMetalWorkingItems() { + this.toGenerate = this.toGenerate | 0x200; + return this; + } + + public Werkstoff.GenerationFeatures addPrefix(OrePrefixes prefixes) { + this.toGenerate = this.toGenerate | getPrefixDataRaw(prefixes); + return this; + } + + public Werkstoff.GenerationFeatures removePrefix(OrePrefixes prefixes) { + this.toGenerate = this.toGenerate ^ getPrefixDataRaw(prefixes); + return this; + } + } + + public static class Stats { + + public static final int NULL_KELVIN = 0; + + int boilingPoint; + + public int getBoilingPoint() { + return this.boilingPoint; + } + + public Werkstoff.Stats setBoilingPoint(int boilingPoint) { + this.boilingPoint = boilingPoint; + return this; + } + + public long getMass() { + return this.mass; + } + + public long getProtons() { + return this.protons; + } + + public int getMeltingPoint() { + return this.meltingPoint; + } + + public Werkstoff.Stats setMeltingPoint(int meltingPoint) { + this.meltingPoint = meltingPoint; + return this; + } + + public double getEbfGasRecipeTimeMultiplier() { + return this.ebfGasRecipeTimeMultiplier; + } + + /** + * The generated EBF recipes using this gas will have their duration multiplied by this number. If set to a + * negative value, the default proton count-based logic is used. For GT Materials gases, add the overrides to + * {@link StaticRecipeChangeLoaders#addEBFGasRecipes()} + */ + public Werkstoff.Stats setEbfGasRecipeTimeMultiplier(double timeMultiplier) { + this.ebfGasRecipeTimeMultiplier = timeMultiplier; + return this; + } + + public double getEbfGasRecipeConsumedAmountMultiplier() { + return this.ebfGasRecipeConsumedAmountMultiplier; + } + + /** + * The generated EBF recipes using this gas will have the amount of gas consumed multiplied by this number. For + * GT Materials gases, add the overrides to {@link StaticRecipeChangeLoaders#addEBFGasRecipes()} + */ + public Werkstoff.Stats setEbfGasRecipeConsumedAmountMultiplier(double amountMultiplier) { + this.ebfGasRecipeConsumedAmountMultiplier = amountMultiplier; + return this; + } + + public int getDurOverride() { + return this.durOverride; + } + + public Werkstoff.Stats setDurOverride(int durOverride) { + this.durOverride = durOverride; + return this; + } + + public float getSpeedOverride() { + return this.speedOverride; + } + + public Werkstoff.Stats setSpeedOverride(float speedOverride) { + this.speedOverride = speedOverride; + return this; + } + + public byte getQualityOverride() { + return this.qualityOverride; + } + + public Werkstoff.Stats setQualityOverride(byte qualityOverride) { + this.qualityOverride = qualityOverride; + return this; + } + + private byte qualityOverride; + private int durOverride; + private float speedOverride; + private int meltingPoint; + private int meltingVoltage; + private long protons; + private long neutrons; + private long electrons; + private long mass; + private double ebfGasRecipeTimeMultiplier = -1.0; + private double ebfGasRecipeConsumedAmountMultiplier = 1.0; + + float durMod = 1f; + + public float getDurMod() { + return this.durMod; + } + + public void setDurMod(float durMod) { + this.durMod = durMod; + } + + private Pair[] mTC_Aspects; + // logic gate shit + byte quality = ~0b1111111; + + public Werkstoff.Stats setmTC_AspectsArray(Pair[] mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + @SafeVarargs + public final Werkstoff.Stats setmTC_AspectsVarArg(Pair... mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + Pair[] getmTC_Aspects() { + return this.mTC_Aspects; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Werkstoff.Stats that)) return false; + + if (this.boilingPoint != that.boilingPoint || this.meltingPoint != that.meltingPoint + || this.mass != that.mass + || this.protons != that.protons) return false; + if (this.neutrons != that.neutrons) return false; + if (this.electrons != that.electrons) return false; + if (Math.abs(this.ebfGasRecipeTimeMultiplier - that.ebfGasRecipeTimeMultiplier) > 1.0e-6D) return false; + if (Math.abs(this.ebfGasRecipeConsumedAmountMultiplier - that.ebfGasRecipeConsumedAmountMultiplier) + > 1.0e-6D) return false; + return this.quality == that.quality; + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(49) + .put(this.quality) + .putInt(this.boilingPoint) + .putInt(this.meltingPoint) + .putLong(this.protons) + .putLong(this.neutrons) + .putLong(this.electrons) + .putLong(this.mass) + .putDouble(this.ebfGasRecipeTimeMultiplier) + .putDouble(this.ebfGasRecipeConsumedAmountMultiplier) + .array(), + 0, + 49, + 31); + } + + public Werkstoff.Stats setMass(long mass) { + this.mass = mass; + return this; + } + + public Werkstoff.Stats setProtons(long protons) { + this.protons = protons; + return this; + } + + public boolean isSublimation() { + return (this.quality & 0b1) != 0; + } + + public Werkstoff.Stats setSublimation(boolean sublimation) { + if (sublimation) this.quality = (byte) (this.quality | 0b000001); + else this.quality = (byte) (this.quality & 0b1111110); + return this; + } + + public boolean isToxic() { + return (this.quality & 0b10) != 0; + } + + public Werkstoff.Stats setToxic(boolean toxic) { + if (toxic) this.quality = (byte) (this.quality | 0b000010); + else this.quality = (byte) (this.quality & 0b1111101); + return this; + } + + byte enchantmentlvl = 3; + + public byte getEnchantmentlvl() { + return this.enchantmentlvl; + } + + public Werkstoff.Stats setEnchantmentlvl(byte enchantmentlvl) { + this.enchantmentlvl = enchantmentlvl; + return this; + } + + public boolean isRadioactive() { + return (this.quality & 0b100) != 0; + } + + public Werkstoff.Stats setRadioactive(boolean radioactive) { + if (radioactive) this.quality = (byte) (this.quality | 0b000100); + else this.quality = (byte) (this.quality & 0b1111011); + return this; + } + + public boolean isBlastFurnace() { + return (this.quality & 0b1000) != 0; + } + + public Werkstoff.Stats setBlastFurnace(boolean blastFurnace) { + if (blastFurnace) this.quality = (byte) (this.quality | 0b001000); + else this.quality = (byte) (this.quality & 0b1110111); + return this; + } + + public Werkstoff.Stats setMeltingVoltage(int meltingVoltage) { + this.meltingVoltage = meltingVoltage; + return this; + } + + public int getMeltingVoltage() { + return this.meltingVoltage; + } + + public boolean isElektrolysis() { + return (this.quality & 0x10) != 0; + } + + public Werkstoff.Stats setElektrolysis(boolean elektrolysis) { + if (elektrolysis) this.quality = (byte) (this.quality | 0x10); + else this.quality = (byte) (this.quality & 0b1101111); + return this; + } + + public boolean isCentrifuge() { + return (this.quality & 0x20) != 0; + } + + public Werkstoff.Stats setCentrifuge(boolean centrifuge) { + if (centrifuge) this.quality = (byte) (this.quality | 0x20); + else this.quality = (byte) (this.quality & 0b1011111); + return this; + } + + public boolean isGas() { + return (this.quality & 0x40) != 0; + } + + public FluidState getFluidState() { + if ((this.quality & 0x40) != 0) { + return FluidState.GAS; + } + return FluidState.LIQUID; + } + + public Werkstoff.Stats setGas(boolean gas) { + if (gas) this.quality = (byte) (this.quality | 0x40); + else this.quality = (byte) (this.quality & 0b0111111); + return this; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java new file mode 100644 index 0000000000..197ada7f22 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -0,0 +1,2092 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import static com.github.bartimaeusnek.bartworks.util.BW_Util.subscriptNumbers; +import static com.github.bartimaeusnek.bartworks.util.BW_Util.superscriptNumbers; +import static gregtech.api.enums.Mods.BetterLoadingScreen; +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.bottle; +import static gregtech.api.enums.OrePrefixes.capsule; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.cellPlasma; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedCentrifuged; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustImpure; +import static gregtech.api.enums.OrePrefixes.dustPure; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.foil; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.gemChipped; +import static gregtech.api.enums.OrePrefixes.gemExquisite; +import static gregtech.api.enums.OrePrefixes.gemFlawed; +import static gregtech.api.enums.OrePrefixes.gemFlawless; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.ingotDouble; +import static gregtech.api.enums.OrePrefixes.ingotHot; +import static gregtech.api.enums.OrePrefixes.ingotQuadruple; +import static gregtech.api.enums.OrePrefixes.ingotQuintuple; +import static gregtech.api.enums.OrePrefixes.ingotTriple; +import static gregtech.api.enums.OrePrefixes.lens; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.enums.OrePrefixes.oreSmall; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDense; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.plateQuadruple; +import static gregtech.api.enums.OrePrefixes.plateQuintuple; +import static gregtech.api.enums.OrePrefixes.plateTriple; +import static gregtech.api.enums.OrePrefixes.rawOre; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.rotor; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.spring; +import static gregtech.api.enums.OrePrefixes.springSmall; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.enums.OrePrefixes.toolHeadHammer; +import static gregtech.api.enums.OrePrefixes.toolHeadSaw; +import static gregtech.api.enums.OrePrefixes.toolHeadWrench; +import static gregtech.api.enums.OrePrefixes.turbineBlade; +import static gregtech.api.enums.OrePrefixes.values; +import static gregtech.api.enums.OrePrefixes.wireFine; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.logging.log4j.Level; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.API.WerkstoffAdderRegistry; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_CircuitsLoader; +import com.github.bartimaeusnek.bartworks.system.material.GT_Enhancement.GTMetaItemEnhancer; +import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.AdditionalRecipes; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.AspectLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.BlockLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.CasingLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.CellLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.CraftingMaterialLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.CrushedLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.DustLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.GemLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.MetalLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.MoltenCellLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.MultipleMetalLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.OreLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.RawOreLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.SimpleMetalLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.ToolLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.registration.AssociationLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.registration.BridgeMaterialsLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.registration.CasingRegistrator; +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.EnumUtils; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.bartworks.util.log.DebugLog; +import com.github.bartimaeusnek.crossmod.cls.CLSCompat; +import com.google.common.collect.HashBiMap; + +import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Element; +import gregtech.api.enums.FluidState; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TextureSet; +import gregtech.api.fluid.GT_FluidFactory; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GT_OreDictUnificator; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; + +@SuppressWarnings("deprecation") +public class WerkstoffLoader { + + private WerkstoffLoader() {} + + public static final SubTag NOBLE_GAS = SubTag.getNewSubTag("NobleGas"); + public static final SubTag ANAEROBE_GAS = SubTag.getNewSubTag("AnaerobeGas"); + public static final SubTag ANAEROBE_SMELTING = SubTag.getNewSubTag("AnaerobeSmelting"); + public static final SubTag NOBLE_GAS_SMELTING = SubTag.getNewSubTag("NobleGasSmelting"); + public static final SubTag NO_BLAST = SubTag.getNewSubTag("NoBlast"); + public static ItemList rotorMold; + public static ItemList rotorShape; + public static ItemList smallGearShape; + public static ItemList ringMold; + public static ItemList boltMold; + + public static void setUp() { + + OrePrefixes.cellMolten.mMaterialGenerationBits = 0b1000000; + OrePrefixes.capsuleMolten.mMaterialGenerationBits = 0b1000000; + + try { + WerkstoffLoader.rotorMold = Enum.valueOf(ItemList.class, "Shape_Mold_Rotor"); + WerkstoffLoader.rotorShape = Enum.valueOf(ItemList.class, "Shape_Extruder_Rotor"); + WerkstoffLoader.smallGearShape = Enum.valueOf(ItemList.class, "Shape_Extruder_Small_Gear"); + WerkstoffLoader.ringMold = Enum.valueOf(ItemList.class, "Shape_Mold_Ring"); + WerkstoffLoader.boltMold = Enum.valueOf(ItemList.class, "Shape_Mold_Bolt"); + } catch (NullPointerException | IllegalArgumentException ignored) {} + + // add tiberium + EnumUtils.createNewElement("Tr", 123L, 203L, 0L, -1L, null, "Tiberium", false); + + bottle.mDefaultStackSize = 1; + Werkstoff.GenerationFeatures.initPrefixLogic(); + BW_GT_MaterialReference.init(); + } + + // TODO: + // FREE ID RANGE: 12_000-28_998 + // bartimaeusnek reserved 0-10_000 + // GlodBlock reserved range 10_001-10_999 + // Elisis reserved range 11_000-11_499 + // glowredman reserved range 11_500-11_999 + // bot reserved range 29_899-29_999 + // Tec & basdxz reserved range 30_000-31_000 + // GT Material range reserved on 31_767-32_767 + public static final Werkstoff Bismutite = new Werkstoff( + new short[] { 255, 233, 0, 0 }, + "Bismutite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 1, + TextureSet.SET_FLINT, + Collections.singletonList(Materials.Bismuth), + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Oxygen, 2), + new Pair<>(Materials.CarbonDioxide, 2)); + public static final Werkstoff Bismuthinit = new Werkstoff( + new short[] { 192, 192, 192, 0 }, + "Bismuthinite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 2, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Bismuth, Materials.Sulfur), + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Sulfur, 3)); + public static final Werkstoff Zirconium = new Werkstoff( + new short[] { 175, 175, 175, 0 }, + "Zirconium", + "Zr", + new Werkstoff.Stats().setProtons(40) + .setBlastFurnace(true) + .setMeltingPoint(2130) + .setMeltingVoltage(480), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .enforceUnification(), + 3, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff CubicZirconia = new Werkstoff( + new short[] { 255, 255, 255, 0 }, + "Cubic Zirconia", + Werkstoff.Types.COMPOUND, + 3273, + new Werkstoff.GenerationFeatures().onlyDust() + .addGems() + .enforceUnification(), + 4, + TextureSet.SET_DIAMOND, + Collections.singletonList(WerkstoffLoader.Zirconium), + new Pair<>(WerkstoffLoader.Zirconium, 1), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff FluorBuergerit = new Werkstoff( + new short[] { 0x20, 0x20, 0x20, 0 }, + "Fluor-Buergerite", + subscriptNumbers("NaFe3Al6(Si6O18)(BO3)3O3F"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 5, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Iron, 3), + new Pair<>(Materials.Aluminium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 30), + new Pair<>(Materials.Fluorine, 1)); + public static final Werkstoff YttriumOxide = new Werkstoff( + new short[] { 255, 255, 255, 0 }, + "Yttrium Oxide", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust() + .enforceUnification(), // No autoadd here to gate this material + // by hand + 6, + TextureSet.SET_DULL, + new Pair<>(Materials.Yttrium, 2), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff ChromoAluminoPovondrait = new Werkstoff( + new short[] { 0, 0x79, 0x6A, 0 }, + "Chromo-Alumino-Povondraite", + subscriptNumbers("NaCr3(Al4Mg2)(Si6O18)(BO3)3(OH)3O"), + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND) + .setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 7, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Chrome, 3), + new Pair<>(Materials.Magnalium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 3)); + public static final Werkstoff VanadioOxyDravit = new Werkstoff( + new short[] { 0x60, 0xA0, 0xA0, 0 }, + "Vanadio-Oxy-Dravite", + subscriptNumbers("NaV3(Al4Mg2)(Si6O18)(BO3)3(OH)3O"), + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND) + .setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 8, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Vanadium, 3), + new Pair<>(Materials.Magnalium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 3)); + public static final Werkstoff Olenit = new Werkstoff( + new short[] { 210, 210, 210, 0 }, + "Olenite", + subscriptNumbers("NaAl3Al6(Si6O18)(BO3)3O3OH"), + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND) + .setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 9, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Aluminium, 9), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff Arsenopyrite = new Werkstoff( + new short[] { 0xB0, 0xB0, 0xB0, 0 }, + "Arsenopyrite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 10, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Sulfur, Materials.Arsenic, Materials.Iron), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Arsenic, 1), + new Pair<>(Materials.Sulfur, 1)); + public static final Werkstoff Ferberite = new Werkstoff( + new short[] { 0xB0, 0xB0, 0xB0, 0 }, + "Ferberite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 11, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Tungsten), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Tungsten, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff Loellingit = new Werkstoff( + new short[] { 0xD0, 0xD0, 0xD0, 0 }, + "Loellingite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 12, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Arsenic), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Arsenic, 2)); + public static final Werkstoff Roquesit = new Werkstoff( + new short[] { 0xA0, 0xA0, 0xA0, 0 }, + "Roquesite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 13, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Sulfur), + new Pair<>(Materials.Copper, 1), + new Pair<>(Materials.Indium, 1), + new Pair<>(Materials.Sulfur, 2)); + public static final Werkstoff Bornite = new Werkstoff( + new short[] { 0x97, 0x66, 0x2B, 0 }, + "Bornite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 14, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Iron, Materials.Sulfur), + new Pair<>(Materials.Copper, 5), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Sulfur, 4)); + public static final Werkstoff Wittichenit = new Werkstoff( + Materials.Copper.mRGBa, + "Wittichenite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 15, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Bismuth, Materials.Sulfur), + new Pair<>(Materials.Copper, 5), + new Pair<>(Materials.Bismuth, 1), + new Pair<>(Materials.Sulfur, 4)); + public static final Werkstoff Djurleit = new Werkstoff( + new short[] { 0x60, 0x60, 0x60, 0 }, + "Djurleite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 16, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Copper, Materials.Sulfur), + new Pair<>(Materials.Copper, 31), + new Pair<>(Materials.Sulfur, 16)); + public static final Werkstoff Huebnerit = new Werkstoff( + new short[] { 0x80, 0x60, 0x60, 0 }, + "Huebnerite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 17, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Manganese, Materials.Tungsten), + new Pair<>(Materials.Manganese, 1), + new Pair<>(Materials.Tungsten, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff Thorianit = new Werkstoff( + new short[] { 0x30, 0x30, 0x30, 0 }, + "Thorianite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 18, + TextureSet.SET_METALLIC, + Collections.singletonList(Materials.Thorium), + new Pair<>(Materials.Thorium, 1), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff RedZircon = new Werkstoff( + new short[] { 195, 19, 19, 0 }, + "Red Zircon", + new Werkstoff.Stats().setElektrolysis(false) + .setMeltingPoint(2130), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 19, + TextureSet.SET_GEM_VERTICAL, + Arrays.asList(WerkstoffLoader.Zirconium, Materials.SiliconDioxide), + new Pair<>(WerkstoffLoader.Zirconium, 1), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4)); + + // GT Enhancements + public static final Werkstoff Salt = new Werkstoff( + Materials.Salt.mRGBa, + "Salt", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addGems() + .addSifterRecipes(), + 20, + TextureSet.SET_FLINT, + Arrays.asList(Materials.RockSalt, Materials.Borax), + new Pair<>(Materials.Salt, 1)); + public static final Werkstoff Spodumen = new Werkstoff( + Materials.Spodumene.mRGBa, + "Spodumene", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addGems() + .addSifterRecipes(), + 21, + TextureSet.SET_FLINT, + Collections.singletonList(Materials.Spodumene), + new Pair<>(Materials.Spodumene, 1)); + public static final Werkstoff RockSalt = new Werkstoff( + Materials.RockSalt.mRGBa, + "Rock Salt", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addGems() + .addSifterRecipes(), + 22, + TextureSet.SET_FLINT, + Arrays.asList(Materials.RockSalt, Materials.Borax), + new Pair<>(Materials.RockSalt, 1)); + + // More NonGT Stuff + public static final Werkstoff Fayalit = new Werkstoff( + new short[] { 50, 50, 50, 0 }, + "Fayalite", + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 23, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Iron, Materials.SiliconDioxide), + new Pair<>(Materials.Iron, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff Forsterit = new Werkstoff( + new short[] { 255, 255, 255, 0 }, + "Forsterite", + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 24, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Magnesium, Materials.SiliconDioxide), + new Pair<>(Materials.Magnesium, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff Hedenbergit = new Werkstoff( + new short[] { 100, 150, 100, 0 }, + "Hedenbergite", + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 25, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Iron, Materials.Calcium, Materials.SiliconDioxide), + new Pair<>(Materials.Calcium, 1), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Silicon, 2), + new Pair<>(Materials.Oxygen, 6)); + public static final Werkstoff DescloiziteZNVO4 = new Werkstoff( + new short[] { 0xBF, 0x18, 0x0F, 0 }, + "Red Descloizite", // Pb(Zn,Cu)[OH|VO4 + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 26, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Lead, Materials.Copper, Materials.Vanadium), + new Pair<>(Materials.Lead, 1), + new Pair<>(Materials.Zinc, 1), + new Pair<>(Materials.Vanadium, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff DescloiziteCUVO4 = new Werkstoff( + new short[] { 0xf9, 0x6d, 0x18, 0 }, + "Orange Descloizite", // Pb(Zn,Cu)[OH|VO4 + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 27, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Lead, Materials.Zinc, Materials.Vanadium), + new Pair<>(Materials.Lead, 1), + new Pair<>(Materials.Copper, 1), + new Pair<>(Materials.Vanadium, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff FuchsitAL = new Werkstoff( + new short[] { 0x4D, 0x7F, 0x64, 0 }, + "Green Fuchsite", + subscriptNumbers("KAl3Si3O10(OH)2"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 28, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Potassium, Materials.Aluminiumoxide, Materials.SiliconDioxide), + new Pair<>(Materials.Potassium, 1), + new Pair<>(Materials.Aluminium, 3), + new Pair<>(Materials.Silicon, 3), + new Pair<>(Materials.Oxygen, 12), + new Pair<>(Materials.Hydrogen, 2)); + + public static final Werkstoff FuchsitCR = new Werkstoff( + new short[] { 128, 0, 0, 0 }, + "Red Fuchsite", + subscriptNumbers("KCr3Si3O10(OH)2"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 29, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Potassium, Materials.Chrome, Materials.SiliconDioxide), + new Pair<>(Materials.Potassium, 1), + new Pair<>(Materials.Chrome, 3), + new Pair<>(Materials.Silicon, 3), + new Pair<>(Materials.Oxygen, 12), + new Pair<>(Materials.Hydrogen, 2)); + + public static final Werkstoff Thorium232 = new Werkstoff( + new short[] { 0, 64, 0, 0 }, + "Thorium 232", + superscriptNumbers("Th232"), + new Werkstoff.Stats().setRadioactive(true) + .setBlastFurnace(true) + .setMass(232) + .setProtons(Element.Th.mProtons), + Werkstoff.Types.ISOTOPE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .enforceUnification(), + 30, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff BismuthTellurite = new Werkstoff( + new short[] { 32, 72, 32, 0 }, + // Telluride is correct, tellurite is not. + // Only the display name gets renamed to avoid problems in other mods + "Bismuth Telluride", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addChemicalRecipes(), + 31, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Tellurium, 3)); + public static final Werkstoff Tellurium = new Werkstoff( + new short[] { 0xff, 0xff, 0xff, 0 }, + "Tellurium", + new Werkstoff.Stats(), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().addMetalItems() + .removePrefix(ore), + 32, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Tellurium, 1)); + public static final Werkstoff BismuthHydroBorat = new Werkstoff( + new short[] { 72, 144, 72, 0 }, + "Dibismuthhydroborat", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addChemicalRecipes(), + 33, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Boron, 1), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff ArInGaPhoBiBoTe = new Werkstoff( + new short[] { 36, 36, 36, 0 }, + "Circuit Compound MK3", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMixerRecipes(), + 34, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.IndiumGalliumPhosphide, 1), + new Pair<>(WerkstoffLoader.BismuthHydroBorat, 3), + new Pair<>(WerkstoffLoader.BismuthTellurite, 2)); + + public static final Werkstoff Prasiolite = new Werkstoff( + new short[] { 0xD0, 0xDD, 0x95, 0 }, + "Prasiolite", + new Werkstoff.Stats().setElektrolysis(false) + .setMeltingPoint(1923), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 35, + TextureSet.SET_QUARTZ, + // No Byproducts + new Pair<>(Materials.Silicon, 5), + new Pair<>(Materials.Oxygen, 10), + new Pair<>(Materials.Iron, 1)); + + public static final Werkstoff MagnetoResonaticDust = new Werkstoff( + new short[] { 0xDD, 0x77, 0xDD, 0 }, + "Magneto Resonatic", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust() + .addMixerRecipes() + .addGems(), + 36, + TextureSet.SET_MAGNETIC, + // No Byproducts + new Pair<>(WerkstoffLoader.Prasiolite, 3), + new Pair<>(WerkstoffLoader.BismuthTellurite, 4), + new Pair<>(WerkstoffLoader.CubicZirconia, 1), + new Pair<>(Materials.SteelMagnetic, 1)); + public static final Werkstoff Xenon = new Werkstoff( + new short[] { 0x14, 0x39, 0x7F, 0 }, + "Xenon", + "Xe", + new Werkstoff.Stats().setProtons(54) + .setMass(131) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.4d) + .setEbfGasRecipeConsumedAmountMultiplier(0.25d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells() + .enforceUnification(), + 37, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Oganesson = new Werkstoff( + new short[] { 0x14, 0x39, 0x7F, 0 }, + "Oganesson", + "Og", + new Werkstoff.Stats().setProtons(118) + .setMass(294) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.3d) + .setEbfGasRecipeConsumedAmountMultiplier(0.1d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 38, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Californium = new Werkstoff( + new short[] { 0xAA, 0xAA, 0xAA, 0 }, + "Californium", + "Cf", + new Werkstoff.Stats().setProtons(98) + .setMass(251) + .setBlastFurnace(true) + .setMeltingPoint(900), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .addMolten() + .enforceUnification(), + 39, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Calcium = new Werkstoff( + Materials.Calcium.mRGBa, + "Calcium", + "Ca", + new Werkstoff.Stats().setProtons(Element.Ca.mProtons) + .setMass(Element.Ca.getMass()) + .setBlastFurnace(true) + .setMeltingPoint(1115) + .setBoilingPoint(1757), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .addMolten(), + 40, + Materials.Calcium.mIconSet, + // No Byproducts + new Pair<>(Materials.Calcium, 1)); + public static final Werkstoff Neon = new Werkstoff( + new short[] { 0xff, 0x07, 0x3a }, + "Neon", + "Ne", + new Werkstoff.Stats().setProtons(Element.Ne.mProtons) + .setMass(Element.Ne.getMass()) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.6d) + .setEbfGasRecipeConsumedAmountMultiplier(0.55d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells() + .enforceUnification(), + 41, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Krypton = new Werkstoff( + new short[] { 0xb1, 0xff, 0x32 }, + "Krypton", + "Kr", + new Werkstoff.Stats().setProtons(Element.Kr.mProtons) + .setMass(Element.Kr.getMass()) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.5d) + .setEbfGasRecipeConsumedAmountMultiplier(0.4d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells() + .enforceUnification(), + 42, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff BArTiMaEuSNeK = new Werkstoff( + new short[] { 0x00, 0xff, 0x00 }, + "BArTiMaEuSNeK", + "Are you serious?", + new Werkstoff.Stats().setMeltingPoint(9001) + .setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingVoltage(1920), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems() + .addMetalItems() + .addMolten(), + 43, + TextureSet.SET_DIAMOND, + Arrays.asList(Materials.Boron, Materials.Titanium, Materials.Europium), + new Pair<>(Materials.Boron, 1), + new Pair<>(Materials.Argon, 1), + new Pair<>(Materials.Titanium, 1), + new Pair<>(Materials.Magic, 1), + new Pair<>(Materials.Europium, 1), + new Pair<>(Materials.Sulfur, 1), + new Pair<>(WerkstoffLoader.Neon, 1), + new Pair<>(Materials.Potassium, 1)); + public static final Werkstoff PTConcentrate = new Werkstoff( + Materials.Platinum.getRGBA(), + "Platinum Concentrate", + "", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 44, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PTSaltCrude = new Werkstoff( + Materials.Platinum.getRGBA(), + "Platinum Salt", + "", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 45, + TextureSet.SET_DULL + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PTSaltRefined = new Werkstoff( + Materials.Platinum.getRGBA(), + "Refined Platinum Salt", + "", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 46, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PTMetallicPowder = new Werkstoff( + Materials.Platinum.getRGBA(), + "Platinum Metallic Powder", + "??PtPdIrOsRhRu??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 47, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Platinum, 1), + new Pair<>(Materials.Stone, 2)); + public static final Werkstoff AquaRegia = new Werkstoff( + new short[] { 0xff, 0xb1, 0x32 }, + "Aqua Regia", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 48, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.DilutedSulfuricAcid, 1), + new Pair<>(Materials.NitricAcid, 1)); + public static final Werkstoff PTResidue = new Werkstoff( + new short[] { 0x64, 0x63, 0x2E }, + "Platinum Residue", + "??IrOsRhRu??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 49, + TextureSet.SET_ROUGH + // No Byproducts + ); + public static final Werkstoff AmmoniumChloride = new Werkstoff( + new short[] { 0xff, 0xff, 0xff }, + "Ammonium Chloride", + subscriptNumbers("NH4Cl"), + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 50, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Ammonium, 1), + new Pair<>(Materials.HydrochloricAcid, 1)); + public static final Werkstoff PTRawPowder = new Werkstoff( + Materials.Platinum.getRGBA(), + "Reprecipitated Platinum", + "PtCl", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 51, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff PDAmmonia = new Werkstoff( + Materials.Palladium.getRGBA(), + "Palladium Enriched Ammonia", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 52, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Ammonium, 1), + new Pair<>(Materials.Palladium, 1)); + public static final Werkstoff PDMetallicPowder = new Werkstoff( + Materials.Palladium.getRGBA(), + "Palladium Metallic Powder", + "??Pd??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 53, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Palladium, 1), + new Pair<>(Materials.Stone, 2)); + public static final Werkstoff PDRawPowder = new Werkstoff( + Materials.Palladium.getRGBA(), + "Reprecipitated Palladium", + subscriptNumbers("Pd2NH4"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 54, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PDSalt = new Werkstoff( + Materials.Palladium.getRGBA(), + "Palladium Salt", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 55, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Sodiumformate = new Werkstoff( + new short[] { 0xff, 0xaa, 0xaa }, + "Sodium Formate", + "HCOONa", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 56, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.SodiumHydroxide, 1), + new Pair<>(Materials.CarbonMonoxide, 1)); + public static final Werkstoff Sodiumsulfate = new Werkstoff( + new short[] { 0xff, 0xff, 0xff }, + "Sodium Sulfate", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 57, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Sodium, 2), + new Pair<>(Materials.Sulfur, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff FormicAcid = new Werkstoff( + new short[] { 0xff, 0xaa, 0x77 }, + "Formic Acid", + subscriptNumbers("CH2O2"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 58, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Carbon, 1), + new Pair<>(Materials.Hydrogen, 2), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff PotassiumDisulfate = new Werkstoff( + new short[] { 0xfb, 0xbb, 0x66 }, + "Potassium Disulfate", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addChemicalRecipes(), + 59, + TextureSet.SET_DULL, + // No Byproducts + new Pair<>(Materials.Potassium, 2), + new Pair<>(Materials.Sulfur, 2), + new Pair<>(Materials.Oxygen, 7)); + public static final Werkstoff LeachResidue = new Werkstoff( + new short[] { 0x64, 0x46, 0x29 }, + "Leach Residue", + "??IrOsRu??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 60, + TextureSet.SET_ROUGH + // No Byproducts + ); + public static final Werkstoff RHSulfate = new Werkstoff( + new short[] { 0xee, 0xaa, 0x55 }, + "Rhodium Sulfate", + new Werkstoff.Stats().setGas(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 61, + TextureSet.SET_FLUID + // No Byproducts + ); + public static final Werkstoff RHSulfateSolution = new Werkstoff( + new short[] { 0xff, 0xbb, 0x66 }, + "Rhodium Sulfate Solution", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 62, + TextureSet.SET_FLUID + // No Byproducts + ); + public static final Werkstoff CalciumChloride = new Werkstoff( + new short[] { 0xff, 0xff, 0xff }, + "Calcium Chloride", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addCells(), + 63, + TextureSet.SET_DULL, + new Pair<>(Materials.Calcium, 1), + new Pair<>(Materials.Chlorine, 2) + // No Byproducts + ); + public static final Werkstoff Ruthenium = new Werkstoff( + new short[] { 0x64, 0x64, 0x64 }, + "Ruthenium", + "Ru", + new Werkstoff.Stats().setBlastFurnace(true) + .setMeltingPoint(2607) + .setMass(Element.Ru.getMass()) + .setProtons(Element.Ru.mProtons), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().onlyDust() + .addMolten() + .addMetalItems() + .enforceUnification(), + 64, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff SodiumRuthenate = new Werkstoff( + new short[] { 0x3a, 0x40, 0xcb }, + "Sodium Ruthenate", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 65, + TextureSet.SET_SHINY, + new Pair<>(Materials.Sodium, 2), + new Pair<>(Ruthenium, 1), + new Pair<>(Materials.Oxygen, 3) + // No Byproducts + ); + public static final Werkstoff RutheniumTetroxide = new Werkstoff( + new short[] { 0xc7, 0xc7, 0xc7 }, + "Ruthenium Tetroxide", + new Werkstoff.Stats().setMeltingPoint(313), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addCells(), + 66, + TextureSet.SET_DULL, + new Pair<>(WerkstoffLoader.Ruthenium, 1), + new Pair<>(Materials.Oxygen, 4) + // No Byproducts + ); + public static final Werkstoff HotRutheniumTetroxideSollution = new Werkstoff( + new short[] { 0xc7, 0xc7, 0xc7 }, + "Hot Ruthenium Tetroxide Solution", + "???", + new Werkstoff.Stats().setGas(true) + .setMeltingPoint(700), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 67, + TextureSet.SET_FLUID, + new Pair<>(WerkstoffLoader.Ruthenium, 1), + new Pair<>(Materials.Oxygen, 4), + new Pair<>(Materials.Chlorine, 2), + new Pair<>(Materials.Sodium, 2), + new Pair<>(Materials.Water, 2) + // No Byproducts + ); + public static final Werkstoff RutheniumTetroxideSollution = new Werkstoff( + new short[] { 0xc7, 0xc7, 0xc7 }, + "Ruthenium Tetroxide Solution", + "???", + new Werkstoff.Stats().setMeltingPoint(313), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 68, + TextureSet.SET_FLUID, + new Pair<>(Ruthenium, 1), + new Pair<>(Materials.Oxygen, 4), + new Pair<>(Materials.Chlorine, 2), + new Pair<>(Materials.Sodium, 2), + new Pair<>(Materials.Water, 2) + // No Byproducts + ); + public static final Werkstoff IrOsLeachResidue = new Werkstoff( + new short[] { 0x64, 0x46, 0x29 }, + "Rarest Metal Residue", + "??OsIr??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 69, + TextureSet.SET_ROUGH, + // No Byproducts + new Pair<>(Materials.Osmiridium, 1), + new Pair<>(Materials.Stone, 2)); + public static final Werkstoff IrLeachResidue = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Iridium Metal Residue", + "??Ir??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 70, + TextureSet.SET_ROUGH, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Stone, 2) + // No Byproducts + ); + public static final Werkstoff PGSDResidue = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Sludge Dust Residue", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 71, + TextureSet.SET_DULL, + new Pair<>(Materials.SiliconDioxide, 3), + new Pair<>(Materials.Gold, 2)); + public static final Werkstoff AcidicOsmiumSolution = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Acidic Osmium Solution", + "???", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 72, + TextureSet.SET_FLUID, + new Pair<>(Materials.Osmium, 1), + new Pair<>(Materials.HydrochloricAcid, 1)); + public static final Werkstoff IridiumDioxide = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Iridium Dioxide", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 73, + TextureSet.SET_FLUID, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff OsmiumSolution = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Osmium Solution", + "???", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 74, + TextureSet.SET_FLUID, + new Pair<>(Materials.Osmium, 1), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff AcidicIridiumSolution = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Acidic Iridium Solution", + "???", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 75, + TextureSet.SET_FLUID, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff IridiumChloride = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Iridium Chloride", + subscriptNumbers("IrCl3"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 76, + TextureSet.SET_LAPIS, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Chlorine, 3)); + public static final Werkstoff PGSDResidue2 = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Metallic Sludge Dust Residue", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 77, + TextureSet.SET_DULL, + new Pair<>(Materials.Nickel, 1), + new Pair<>(Materials.Copper, 1)); + public static final Werkstoff Rhodium = new Werkstoff( + new short[] { 0xF4, 0xF4, 0xF4 }, + "Rhodium", + "Rh", + new Werkstoff.Stats().setProtons(Element.Rh.mProtons) + .setMass(Element.Rh.getMass()) + .setBlastFurnace(true) + .setMeltingPoint(2237), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .addMolten() + .enforceUnification(), + 78, + TextureSet.SET_METALLIC); + public static final Werkstoff CrudeRhMetall = new Werkstoff( + new short[] { 0x66, 0x66, 0x66 }, + "Crude Rhodium Metal", + "??Rh??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 79, + TextureSet.SET_DULL, + new Pair<>(Rhodium, 1), + new Pair<>(Materials.Stone, 1)); + public static final Werkstoff RHSalt = new Werkstoff( + new short[] { 0x84, 0x84, 0x84 }, + "Rhodium Salt", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 80, + TextureSet.SET_GEM_VERTICAL); + public static final Werkstoff RHSaltSolution = new Werkstoff( + new short[] { 0x66, 0x77, 0x88 }, + "Rhodium Salt Solution", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 81, + TextureSet.SET_FLUID); + public static final Werkstoff SodiumNitrate = new Werkstoff( + new short[] { 0x84, 0x66, 0x84 }, + "Sodium Nitrate", + subscriptNumbers("NaNO3"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 82, + TextureSet.SET_ROUGH, + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Nitrogen, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff RHNitrate = new Werkstoff( + new short[] { 0x77, 0x66, 0x49 }, + "Rhodium Nitrate", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 83, + TextureSet.SET_QUARTZ); + public static final Werkstoff ZincSulfate = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Zinc Sulfate", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 84, + TextureSet.SET_QUARTZ, + new Pair<>(Materials.Zinc, 1), + new Pair<>(Materials.Sulfur, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff RhFilterCake = new Werkstoff( + new short[] { 0x77, 0x66, 0x49 }, + "Rhodium Filter Cake", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 85, + TextureSet.SET_QUARTZ); + public static final Werkstoff RHFilterCakeSolution = new Werkstoff( + new short[] { 0x66, 0x77, 0x88 }, + "Rhodium Filter Cake Solution", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 86, + TextureSet.SET_FLUID); + public static final Werkstoff ReRh = new Werkstoff( + new short[] { 0x77, 0x66, 0x49 }, + "Reprecipitated Rhodium", + subscriptNumbers("Rh2NH4"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 87, + TextureSet.SET_QUARTZ); + public static final Werkstoff LuVTierMaterial = new Werkstoff( + Materials.Chrome.getRGBA(), + "Rhodium-Plated Palladium", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingPoint(4500) + .setMeltingVoltage(480), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addMetalItems() + .addMixerRecipes((short) 1) + .addSimpleMetalWorkingItems() + .addCraftingMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 88, + TextureSet.SET_METALLIC, + new Pair<>(Materials.Palladium, 3), + new Pair<>(WerkstoffLoader.Rhodium, 1)); + public static final Werkstoff Tiberium = new Werkstoff( + new short[] { 0x22, 0xEE, 0x22 }, + "Tiberium", + "Tr", + new Werkstoff.Stats().setProtons(123) + .setMass(326) + .setBlastFurnace(true) + .setMeltingPoint(1800) + .setRadioactive(true) + .setToxic(true), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().addGems() + .addCraftingMetalWorkingItems() + .addSimpleMetalWorkingItems(), + 89, + TextureSet.SET_DIAMOND); + public static final Werkstoff Ruridit = new Werkstoff( + new short[] { 0xA4, 0xA4, 0xA4 }, + "Ruridit", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingPoint(4500) + .setMeltingVoltage(480), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addMetalItems() + .addMixerRecipes((short) 1) + .addSimpleMetalWorkingItems() + .addCraftingMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 90, + TextureSet.SET_METALLIC, + new Pair<>(WerkstoffLoader.Ruthenium, 2), + new Pair<>(Materials.Iridium, 1)); + public static final Werkstoff Fluorspar = new Werkstoff( + new short[] { 185, 69, 251 }, + "Fluorspar", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 91, + TextureSet.SET_GEM_VERTICAL, + new Pair<>(Materials.Calcium, 1), + new Pair<>(Materials.Fluorine, 2)); + public static final Werkstoff HDCS = new Werkstoff( + new short[] { 0x33, 0x44, 0x33 }, + "High Durability Compound Steel", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingPoint(9000) + .setMeltingVoltage(7680), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addMetalItems() + .addMixerRecipes() + .addSimpleMetalWorkingItems() + .addCraftingMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 92, + TextureSet.SET_SHINY, + new Pair<>(Materials.TungstenSteel, 12), + new Pair<>(Materials.HSSE, 9), + new Pair<>(Materials.HSSG, 6), + new Pair<>(WerkstoffLoader.Ruridit, 3), + new Pair<>(WerkstoffLoader.MagnetoResonaticDust, 2), + new Pair<>(Materials.Plutonium, 1)); + public static final Werkstoff Atheneite = new Werkstoff( + new short[] { 175, 175, 175 }, + "Atheneite", + subscriptNumbers("(Pd,Hg)3As"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 93, + TextureSet.SET_SHINY, + new Pair<>(WerkstoffLoader.PDMetallicPowder, 3), + new Pair<>(Materials.Mercury, 3), + new Pair<>(Materials.Arsenic, 1)); + public static final Werkstoff Temagamite = new Werkstoff( + new short[] { 245, 245, 245 }, + "Temagamite", + subscriptNumbers("Pd3HgTe"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 94, + TextureSet.SET_ROUGH, + new Pair<>(WerkstoffLoader.PDMetallicPowder, 3), + new Pair<>(Materials.Mercury, 1), + new Pair<>(Materials.Tellurium, 1)); + public static final Werkstoff Terlinguaite = new Werkstoff( + new short[] { 245, 245, 245 }, + "Terlinguaite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 95, + TextureSet.SET_GEM_HORIZONTAL, + new Pair<>(Materials.Mercury, 2), + new Pair<>(Materials.Chlorine, 1), + new Pair<>(Materials.Oxygen, 1)); + public static final Werkstoff AdemicSteel = new Werkstoff( + new short[] { 0xcc, 0xcc, 0xcc }, + "Ademic Steel", + "The break in the line", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setDurOverride(6144) + .setMeltingPoint(1800) + .setSpeedOverride(12) + .setQualityOverride((byte) 4) + .setMeltingVoltage(1920), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().onlyDust() + .addMetalItems() + .addCraftingMetalWorkingItems() + .addMolten() + .addSimpleMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 96, + TextureSet.SET_METALLIC, + new Pair<>(Materials.Steel, 2), + new Pair<>(Materials.VanadiumSteel, 1), + new Pair<>(Materials.DamascusSteel, 1), + new Pair<>(Materials.Carbon, 4)); + public static final Werkstoff RawAdemicSteel = new Werkstoff( + new short[] { 0xed, 0xed, 0xed }, + "Raw Ademic Steel", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().onlyDust() + .addMixerRecipes(), + 97, + TextureSet.SET_ROUGH, + new Pair<>(Materials.Steel, 2), + new Pair<>(Materials.VanadiumSteel, 1), + new Pair<>(Materials.DamascusSteel, 1)); + public static final Werkstoff HexafluorosilicicAcid = new Werkstoff( + new short[] { 0x2c, 0x70, 0xb5 }, + "Hexafluorosilicic Acid", + subscriptNumbers("H2SiF6"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 98, + TextureSet.SET_FLUID, + new Pair<>(Materials.Hydrogen, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Fluorine, 6)); + public static final Werkstoff Potassiumfluorosilicate = new Werkstoff( + new short[] { 0x2e, 0x97, 0xb2 }, + "Potassiumfluorosilicate", + subscriptNumbers("K2SiF6"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 99, + TextureSet.SET_SHINY, + new Pair<>(Materials.Potassium, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Fluorine, 6)); + public static final Werkstoff Alumina = new Werkstoff( + new short[] { 0xa0, 0xad, 0xb1 }, + "Alumina", + subscriptNumbers("Al2O3"), + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 100, + TextureSet.SET_DULL); + public static final Werkstoff PotassiumCarbonate = new Werkstoff( + new short[] { 0x7b, 0x96, 0x4f }, + "Potassium Carbonate", + subscriptNumbers("K2CO3"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 101, + TextureSet.SET_DULL, + new Pair<>(Materials.Potassium, 2), + new Pair<>(Materials.Carbon, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff RawFluorophlogopite = new Werkstoff( + new short[] { 0x36, 0x51, 0x0b }, + "Raw Fluorophlogopite", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 102, + TextureSet.SET_DULL); + public static final Werkstoff HotFluorophlogopite = new Werkstoff( + new short[] { 0xbf, 0xd3, 0x55 }, + "Unformed Fluorophlogopite", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 103, + TextureSet.SET_FLUID); + public static final Werkstoff Fluorophlogopite = new Werkstoff( + new short[] { 0xbf, 0xd3, 0x55 }, + "Fluorophlogopite", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems(), + 104, + TextureSet.SET_SHINY); + + public static HashMap items = new HashMap<>(); + public static HashBiMap fluids = HashBiMap.create(); + public static HashBiMap molten = HashBiMap.create(); + public static Block BWOres; + public static Block BWSmallOres; + public static Block BWBlocks; + public static Block BWBlockCasings; + public static Block BWBlockCasingsAdvanced; + public static boolean registered; + public static final HashSet ENABLED_ORE_PREFIXES = new HashSet<>(); + + public static Werkstoff getWerkstoff(String Name) { + try { + Field f = WerkstoffLoader.class.getField(Name); + return (Werkstoff) f.get(null); + } catch (IllegalAccessException | NoSuchFieldException | ClassCastException e) { + MainMod.LOGGER.catching(e); + } + return Werkstoff.default_null_Werkstoff; + } + + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { + return WerkstoffLoader.getCorrespondingItemStack(orePrefixes, werkstoff, 1); + } + + public static ItemStack getCorrespondingItemStackUnsafe(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + if (!werkstoff.getGenerationFeatures().enforceUnification) { + ItemStack ret = GT_OreDictUnificator.get(orePrefixes, werkstoff.getBridgeMaterial(), amount); + if (ret != null) return ret; + ret = OreDictHandler.getItemStack(werkstoff.getVarName(), orePrefixes, amount); + if (ret != null) return ret; + } + if (orePrefixes == ore) return new ItemStack(WerkstoffLoader.BWOres, amount, werkstoff.getmID()); + if (orePrefixes == oreSmall) return new ItemStack(WerkstoffLoader.BWSmallOres, amount, werkstoff.getmID()); + else if (orePrefixes == block) return new ItemStack(WerkstoffLoader.BWBlocks, amount, werkstoff.getmID()); + else if (orePrefixes == OrePrefixes.blockCasing) + return new ItemStack(WerkstoffLoader.BWBlockCasings, amount, werkstoff.getmID()); + else if (orePrefixes == OrePrefixes.blockCasingAdvanced) + return new ItemStack(WerkstoffLoader.BWBlockCasingsAdvanced, amount, werkstoff.getmID()); + else if (WerkstoffLoader.items.get(orePrefixes) == null) return null; + return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy(); + } + + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + ItemStack stack = getCorrespondingItemStackUnsafe(orePrefixes, werkstoff, amount); + if (stack != null) return stack; + MainMod.LOGGER.catching( + Level.ERROR, + new Exception( + "NO SUCH ITEM! " + orePrefixes + + werkstoff.getVarName() + + " If you encounter this as a user, make sure to contact the authors of the pack/the mods you're playing! " + + "If you are a Developer, you forgot to enable " + + orePrefixes + + " OrePrefix for Werkstoff " + + werkstoff.getDefaultName())); + return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy(); + } + + public static void runInit() { + MainMod.LOGGER.info("Making Meta Items for BW Materials"); + long timepre = System.nanoTime(); + WerkstoffAdderRegistry.run(); + addSubTags(); + addItemsForGeneration(); + addBridgeSubTags(); + runAdditionalOreDict(); + long timepost = System.nanoTime(); + MainMod.LOGGER.info( + "Making Meta Items for BW Materials took " + (timepost - timepre) + + "ns/" + + (timepost - timepre) / 1000000 + + "ms/" + + (timepost - timepre) / 1000000000 + + "s!"); + } + + public static void run() { + if (!registered) { + MainMod.LOGGER.info("Loading Processing Recipes for BW Materials"); + long timepre = System.nanoTime(); + ProgressManager.ProgressBar progressBar = ProgressManager + .push("Register BW Materials", Werkstoff.werkstoffHashSet.size() + 1); + DebugLog.log("Loading Recipes" + (System.nanoTime() - timepre)); + Integer[] clsArr = {}; + int size = 0; + if (BetterLoadingScreen.isModLoaded()) clsArr = CLSCompat.initCls(); + + IWerkstoffRunnable[] werkstoffRunnables = { new ToolLoader(), new DustLoader(), new GemLoader(), + new SimpleMetalLoader(), new CasingLoader(), new AspectLoader(), new OreLoader(), new RawOreLoader(), + new CrushedLoader(), new CraftingMaterialLoader(), new CellLoader(), new MoltenCellLoader(), + new MultipleMetalLoader(), new MetalLoader(), new BlockLoader() }; + + long timepreone = 0; + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + timepreone = System.nanoTime(); + DebugLog.log( + "Werkstoff is null or id < 0 ? " + (werkstoff == null || werkstoff.getmID() < 0) + + " " + + (System.nanoTime() - timepreone)); + if (werkstoff == null || werkstoff.getmID() < 0) { + progressBar.step(""); + continue; + } + if (BetterLoadingScreen.isModLoaded()) size = CLSCompat.invokeStepSize(werkstoff, clsArr, size); + DebugLog.log("Werkstoff: " + werkstoff.getDefaultName() + " " + (System.nanoTime() - timepreone)); + for (IWerkstoffRunnable runnable : werkstoffRunnables) { + String loaderName = runnable.getClass() + .getSimpleName(); + DebugLog.log(loaderName + " started " + (System.nanoTime() - timepreone)); + runnable.run(werkstoff); + DebugLog.log(loaderName + " done " + (System.nanoTime() - timepreone)); + } + DebugLog.log("Done" + " " + (System.nanoTime() - timepreone)); + progressBar.step(werkstoff.getDefaultName()); + } + DebugLog.log("Loading New Circuits" + " " + (System.nanoTime() - timepreone)); + BW_CircuitsLoader.initNewCircuits(); + + if (BetterLoadingScreen.isModLoaded()) { + CLSCompat.disableCls(); + } + + progressBar.step("Load Additional Recipes"); + AdditionalRecipes.run(); + ProgressManager.pop(progressBar); + long timepost = System.nanoTime(); + MainMod.LOGGER.info( + "Loading Processing Recipes for BW Materials took " + (timepost - timepre) + + "ns/" + + (timepost - timepre) / 1000000 + + "ms/" + + (timepost - timepre) / 1000000000 + + "s!"); + registered = true; + } + } + + @SuppressWarnings("unchecked") + private static void addSubTags() { + WerkstoffLoader.CubicZirconia.getStats() + .setDurOverride(Materials.Diamond.mDurability); + WerkstoffLoader.HDCS.getStats() + .setSpeedOverride(Materials.HSSS.mToolSpeed); + WerkstoffLoader.HDCS.getStats() + .setDurMod(10f); + Materials.Helium.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Neon.add(WerkstoffLoader.NOBLE_GAS); + Materials.Argon.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Krypton.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Xenon.add(WerkstoffLoader.NOBLE_GAS, WerkstoffLoader.ANAEROBE_GAS); + Materials.Radon.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Oganesson.add(WerkstoffLoader.NOBLE_GAS, WerkstoffLoader.ANAEROBE_GAS); + + Materials.Nitrogen.add(WerkstoffLoader.ANAEROBE_GAS); + + WerkstoffLoader.Calcium.add(WerkstoffLoader.ANAEROBE_SMELTING); + + WerkstoffLoader.LuVTierMaterial.add(WerkstoffLoader.NOBLE_GAS_SMELTING); + WerkstoffLoader.Ruridit.add(WerkstoffLoader.NOBLE_GAS_SMELTING); + WerkstoffLoader.AdemicSteel.add(WerkstoffLoader.NOBLE_GAS_SMELTING); + + WerkstoffLoader.MagnetoResonaticDust.add(WerkstoffLoader.NO_BLAST); + + // Calcium Smelting block + Materials.Calcium.mBlastFurnaceRequired = true; + + Materials.Salt.mDurability = WerkstoffLoader.Salt.getDurability(); + Materials.Spodumene.mDurability = WerkstoffLoader.Spodumen.getDurability(); + Materials.RockSalt.mDurability = WerkstoffLoader.RockSalt.getDurability(); + Materials.Calcium.mDurability = WerkstoffLoader.Calcium.getDurability(); + + Materials.Salt.mToolSpeed = WerkstoffLoader.Salt.getToolSpeed(); + Materials.Spodumene.mToolSpeed = WerkstoffLoader.Spodumen.getToolSpeed(); + Materials.RockSalt.mToolSpeed = WerkstoffLoader.RockSalt.getToolSpeed(); + Materials.Calcium.mToolSpeed = WerkstoffLoader.Calcium.getToolSpeed(); + + Materials.Salt.mToolQuality = WerkstoffLoader.Salt.getToolQuality(); + Materials.Spodumene.mToolQuality = WerkstoffLoader.Spodumen.getToolQuality(); + Materials.RockSalt.mToolQuality = WerkstoffLoader.RockSalt.getToolQuality(); + Materials.Calcium.mToolQuality = WerkstoffLoader.Calcium.getToolQuality(); + + for (Werkstoff W : Werkstoff.werkstoffHashSet) { + for (Pair pair : W.getContents() + .getValue() + .toArray(new Pair[0])) { + + if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Neodymium) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM); + break; + } + if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Iron) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_IRON); + break; + } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Gold) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD); + break; + } + } + if (W.hasItemType(gem)) { + W.add(SubTag.CRYSTAL); + W.add(SubTag.CRYSTALLISABLE); + } + } + } + + private static void addBridgeSubTags() { + // add specific GT materials subtags to various werkstoff bridgematerials + + SubTag.METAL.addTo(LuVTierMaterial.getBridgeMaterial()); + } + + public static long toGenerateGlobal; + + private static void addItemsForGeneration() { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if (werkstoff.hasItemType(cell)) { + if (!FluidRegistry.isFluidRegistered(werkstoff.getDefaultName())) { + DebugLog.log("Adding new Fluid: " + werkstoff.getDefaultName()); + Fluid fluid = GT_FluidFactory.builder(werkstoff.getDefaultName()) + .withLocalizedName(werkstoff.getDefaultName()) + .withStateAndTemperature( + werkstoff.getStats() + .getFluidState(), + 300) + .withColorRGBA(werkstoff.getRGBA()) + .withTextureName("autogenerated") + .buildAndRegister() + .asFluid(); + WerkstoffLoader.fluids.put(werkstoff, fluid); + } else { + WerkstoffLoader.fluids.put(werkstoff, FluidRegistry.getFluid(werkstoff.getDefaultName())); + } + } + if (werkstoff.hasItemType(OrePrefixes.cellMolten)) { + if (!FluidRegistry.isFluidRegistered("molten." + werkstoff.getDefaultName())) { + DebugLog.log("Adding new Molten: " + werkstoff.getDefaultName()); + Fluid fluid = GT_FluidFactory.builder("molten." + werkstoff.getDefaultName()) + .withLocalizedName("Molten " + werkstoff.getDefaultName()) + .withStateAndTemperature( + FluidState.MOLTEN, + werkstoff.getStats() + .getMeltingPoint() > 0 ? werkstoff.getStats() + .getMeltingPoint() : 300) + .withColorRGBA(werkstoff.getRGBA()) + .withTextureName("molten.autogenerated") + .buildAndRegister() + .asFluid(); + WerkstoffLoader.molten.put(werkstoff, fluid); + } else { + WerkstoffLoader.molten.put(werkstoff, FluidRegistry.getFluid(werkstoff.getDefaultName())); + } + } + for (OrePrefixes p : values()) if (Materials.get(werkstoff.getDefaultName()) != null + && Materials.get(werkstoff.getDefaultName()).mMetaItemSubID != -1 + && (werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 + && OreDictHandler.getItemStack(werkstoff.getDefaultName(), p, 1) != null) { + DebugLog.log( + "Found: " + p + + werkstoff.getVarName() + + " in GT material system, disable and reroute my Items to that, also add a Tooltip."); + werkstoff.getGenerationFeatures() + .setBlacklist(p); + } + WerkstoffLoader.toGenerateGlobal = WerkstoffLoader.toGenerateGlobal + | werkstoff.getGenerationFeatures().toGenerate; + } + DebugLog.log("GlobalGeneration: " + WerkstoffLoader.toGenerateGlobal); + if ((WerkstoffLoader.toGenerateGlobal & 0b1) != 0) { + WerkstoffLoader.items.put(dust, new BW_MetaGenerated_Items(dust)); + WerkstoffLoader.items.put(dustTiny, new BW_MetaGenerated_Items(dustTiny)); + WerkstoffLoader.items.put(dustSmall, new BW_MetaGenerated_Items(dustSmall)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b10) != 0) { + WerkstoffLoader.items.put(ingot, new BW_MetaGenerated_Items(ingot)); + WerkstoffLoader.items.put(ingotHot, new BW_MetaGenerated_Items(ingotHot)); // 1750 + WerkstoffLoader.items.put(nugget, new BW_MetaGenerated_Items(nugget)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100) != 0) { + WerkstoffLoader.items.put(gem, new BW_MetaGenerated_Items(gem)); + WerkstoffLoader.items.put(gemChipped, new BW_MetaGenerated_Items(gemChipped)); + WerkstoffLoader.items.put(gemExquisite, new BW_MetaGenerated_Items(gemExquisite)); + WerkstoffLoader.items.put(gemFlawed, new BW_MetaGenerated_Items(gemFlawed)); + WerkstoffLoader.items.put(gemFlawless, new BW_MetaGenerated_Items(gemFlawless)); + WerkstoffLoader.items.put(lens, new BW_MetaGenerated_Items(lens)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b1000) != 0) { + gameRegistryHandler(); + WerkstoffLoader.items.put(crushed, new BW_MetaGenerated_Items(crushed)); + WerkstoffLoader.items.put(crushedPurified, new BW_MetaGenerated_Items(crushedPurified)); + WerkstoffLoader.items.put(crushedCentrifuged, new BW_MetaGenerated_Items(crushedCentrifuged)); + WerkstoffLoader.items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); + WerkstoffLoader.items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); + WerkstoffLoader.items.put(rawOre, new BW_MetaGenerated_Items(rawOre)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b10000) != 0) { + WerkstoffLoader.items.put(cell, new BW_MetaGenerated_Items(cell)); + if (Forestry.isModLoaded()) WerkstoffLoader.items.put(capsule, new BW_MetaGenerated_Items(capsule)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100000) != 0) { + WerkstoffLoader.items.put(cellPlasma, new BW_MetaGenerated_Items(cellPlasma)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b1000000) != 0) { + WerkstoffLoader.items.put(OrePrefixes.cellMolten, new BW_MetaGenerated_Items(OrePrefixes.cellMolten)); + if (Forestry.isModLoaded()) WerkstoffLoader.items + .put(OrePrefixes.capsuleMolten, new BW_MetaGenerated_Items(OrePrefixes.capsuleMolten)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b10000000) != 0) { + WerkstoffLoader.items.put(plate, new BW_MetaGenerated_Items(plate)); + WerkstoffLoader.items.put(foil, new BW_MetaGenerated_Items(foil)); + WerkstoffLoader.items.put(stick, new BW_MetaGenerated_Items(stick)); + WerkstoffLoader.items.put(stickLong, new BW_MetaGenerated_Items(stickLong)); + WerkstoffLoader.items.put(toolHeadWrench, new BW_MetaGenerated_Items(toolHeadWrench)); + WerkstoffLoader.items.put(toolHeadHammer, new BW_MetaGenerated_Items(toolHeadHammer)); + WerkstoffLoader.items.put(toolHeadSaw, new BW_MetaGenerated_Items(toolHeadSaw)); + WerkstoffLoader.items.put(turbineBlade, new BW_MetaGenerated_Items(turbineBlade)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100000000) != 0) { + WerkstoffLoader.items.put(gearGt, new BW_MetaGenerated_Items(gearGt)); + WerkstoffLoader.items.put(gearGtSmall, new BW_MetaGenerated_Items(gearGtSmall)); + WerkstoffLoader.items.put(bolt, new BW_MetaGenerated_Items(bolt)); + WerkstoffLoader.items.put(screw, new BW_MetaGenerated_Items(screw)); + WerkstoffLoader.items.put(ring, new BW_MetaGenerated_Items(ring)); + WerkstoffLoader.items.put(spring, new BW_MetaGenerated_Items(spring)); + WerkstoffLoader.items.put(springSmall, new BW_MetaGenerated_Items(springSmall)); + WerkstoffLoader.items.put(rotor, new BW_MetaGenerated_Items(rotor)); + WerkstoffLoader.items.put(wireFine, new BW_MetaGenerated_Items(wireFine)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b1000000000) != 0) { + WerkstoffLoader.items.put(plateDouble, new BW_MetaGenerated_Items(plateDouble)); + WerkstoffLoader.items.put(plateTriple, new BW_MetaGenerated_Items(plateTriple)); + WerkstoffLoader.items.put(plateQuadruple, new BW_MetaGenerated_Items(plateQuadruple)); + WerkstoffLoader.items.put(plateQuintuple, new BW_MetaGenerated_Items(plateQuintuple)); + WerkstoffLoader.items.put(plateDense, new BW_MetaGenerated_Items(plateDense)); + WerkstoffLoader.items.put(ingotDouble, new BW_MetaGenerated_Items(ingotDouble)); + WerkstoffLoader.items.put(ingotTriple, new BW_MetaGenerated_Items(ingotTriple)); + WerkstoffLoader.items.put(ingotQuadruple, new BW_MetaGenerated_Items(ingotQuadruple)); + WerkstoffLoader.items.put(ingotQuintuple, new BW_MetaGenerated_Items(ingotQuintuple)); + } + ENABLED_ORE_PREFIXES.addAll(WerkstoffLoader.items.keySet()); + ENABLED_ORE_PREFIXES.add(ore); + ENABLED_ORE_PREFIXES.add(oreSmall); + WerkstoffLoader.runGTItemDataRegistrator(); + } + + static void gameRegistryHandler() { + if (SideReference.Side.Client) BW_Renderer_Block_Ores.register(); + + GameRegistry.registerTileEntity(BW_MetaGeneratedOreTE.class, "bw.blockoresTE"); + GameRegistry.registerTileEntity(BW_MetaGeneratedSmallOreTE.class, "bw.blockoresSmallTE"); + GameRegistry.registerTileEntity(BW_MetaGenerated_WerkstoffBlock_TE.class, "bw.werkstoffblockTE"); + GameRegistry.registerTileEntity(BW_MetaGeneratedBlocks_Casing_TE.class, "bw.werkstoffblockcasingTE"); + GameRegistry + .registerTileEntity(BW_MetaGeneratedBlocks_CasingAdvanced_TE.class, "bw.werkstoffblockscasingadvancedTE"); + + WerkstoffLoader.BWOres = new BW_MetaGenerated_Ores(Material.rock, BW_MetaGeneratedOreTE.class, "bw.blockores"); + WerkstoffLoader.BWSmallOres = new BW_MetaGenerated_SmallOres( + Material.rock, + BW_MetaGeneratedSmallOreTE.class, + "bw.blockoresSmall"); + WerkstoffLoader.BWBlocks = new BW_MetaGenerated_WerkstoffBlocks( + Material.iron, + BW_MetaGenerated_WerkstoffBlock_TE.class, + "bw.werkstoffblocks"); + WerkstoffLoader.BWBlockCasings = new BW_MetaGeneratedBlocks_Casing( + Material.iron, + BW_MetaGeneratedBlocks_Casing_TE.class, + "bw.werkstoffblockscasing", + OrePrefixes.blockCasing); + WerkstoffLoader.BWBlockCasingsAdvanced = new BW_MetaGeneratedBlocks_Casing( + Material.iron, + BW_MetaGeneratedBlocks_CasingAdvanced_TE.class, + "bw.werkstoffblockscasingadvanced", + OrePrefixes.blockCasingAdvanced); + + GameRegistry.registerBlock(WerkstoffLoader.BWOres, BW_MetaGeneratedBlock_Item.class, "bw.blockores.01"); + GameRegistry.registerBlock(WerkstoffLoader.BWSmallOres, BW_MetaGeneratedBlock_Item.class, "bw.blockores.02"); + GameRegistry.registerBlock(WerkstoffLoader.BWBlocks, BW_MetaGeneratedBlock_Item.class, "bw.werkstoffblocks.01"); + if (!ConfigHandler.disableBoltedBlocksCasing) GameRegistry.registerBlock( + WerkstoffLoader.BWBlockCasings, + BW_MetaGeneratedBlock_Item.class, + "bw.werkstoffblockscasing.01"); + if (!ConfigHandler.disableReboltedBlocksCasing) GameRegistry.registerBlock( + WerkstoffLoader.BWBlockCasingsAdvanced, + BW_MetaGeneratedBlock_Item.class, + "bw.werkstoffblockscasingadvanced.01"); + + GTMetaItemEnhancer.addAdditionalOreDictToForestry(); + GTMetaItemEnhancer.init(); + } + + private static void runGTItemDataRegistrator() { + IWerkstoffRunnable[] registrations = { new BridgeMaterialsLoader(), new AssociationLoader(), + new CasingRegistrator() }; + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + for (IWerkstoffRunnable registration : registrations) { + registration.run(werkstoff); + } + } + addFakeItemDataToInWorldBlocksAndCleanUpFakeData(); + addVanillaCasingsToGTOreDictUnificator(); + } + + public static void addVanillaCasingsToGTOreDictUnificator() { + GT_OreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Aluminium, ItemList.Casing_FrostProof.get(1L), false); + GT_OreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Nickel, ItemList.Casing_HeatProof.get(1L), false); + GT_OreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Lead, ItemList.Casing_RadiationProof.get(1L), false); + GT_OreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Steel, ItemList.Casing_SolidSteel.get(1L), false); + GT_OreDictUnificator.addAssociation( + OrePrefixes.blockCasing, + Materials.TungstenSteel, + ItemList.Casing_RobustTungstenSteel.get(1L), + false); + GT_OreDictUnificator.addAssociation( + OrePrefixes.blockCasing, + Materials.Polytetrafluoroethylene, + ItemList.Casing_Chemically_Inert.get(1L), + false); + } + + /** + * very hacky way to make my ores/blocks/smallores detectable by gt assosication in world, well at least the prefix. + * used for the miners mostly removing this hacky material from the materials map instantly. we only need the item + * data. + */ + @SuppressWarnings("unchecked") + private static void addFakeItemDataToInWorldBlocksAndCleanUpFakeData() { + + Map MATERIALS_MAP = null; + + try { + Field f = Materials.class.getDeclaredField("MATERIALS_MAP"); + f.setAccessible(true); + MATERIALS_MAP = (Map) f.get(null); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + + if (MATERIALS_MAP == null) throw new NullPointerException("MATERIALS_MAP null!"); + + Materials oreMat = new Materials(-1, null, 0, 0, 0, false, "bwores", "bwores", null, true, null); + Materials smallOreMat = new Materials(-1, null, 0, 0, 0, false, "bwsmallores", "bwsmallores", null, true, null); + Materials blockMat = new Materials(-1, null, 0, 0, 0, false, "bwblocks", "bwblocks", null, true, null); + + for (int i = 0; i < 16; i++) { + GT_OreDictUnificator.addAssociation(ore, oreMat, new ItemStack(BWOres, 1, i), true); + GT_OreDictUnificator.addAssociation(oreSmall, smallOreMat, new ItemStack(BWSmallOres, 1, i), true); + GT_OreDictUnificator.addAssociation(block, blockMat, new ItemStack(BWBlocks, 1, i), true); + } + + MATERIALS_MAP.remove("bwores"); + MATERIALS_MAP.remove("bwsmallores"); + MATERIALS_MAP.remove("bwblocks"); + } + + public static void removeIC2Recipes() { + try { + Set> remset = new HashSet<>(); + for (Map.Entry curr : Recipes.macerator.getRecipes() + .entrySet()) { + if (curr.getKey() instanceof RecipeInputOreDict) { + if ("oreNULL".equalsIgnoreCase(((RecipeInputOreDict) curr.getKey()).input)) { + remset.add(curr); + } + for (ItemStack stack : curr.getValue().items) { + if (stack.getItem() instanceof BW_MetaGenerated_Items) remset.add(curr); + } + } + } + Recipes.macerator.getRecipes() + .entrySet() + .removeAll(remset); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void runAdditionalOreDict() { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if (werkstoff.hasItemType(ore)) { + GT_OreDictUnificator.registerOre(ore + werkstoff.getVarName(), werkstoff.get(ore)); + GT_OreDictUnificator.registerOre(oreSmall + werkstoff.getVarName(), werkstoff.get(oreSmall)); + werkstoff.getADDITIONAL_OREDICT() + .forEach(e -> OreDictionary.registerOre(ore + e, werkstoff.get(ore))); + werkstoff.getADDITIONAL_OREDICT() + .forEach(e -> OreDictionary.registerOre(oreSmall + e, werkstoff.get(oreSmall))); + } + + if (werkstoff.hasItemType(gem)) OreDictionary.registerOre( + "craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), + werkstoff.get(lens)); + + if (werkstoff.hasItemType(gem) || werkstoff.hasItemType(ingot)) { + GT_OreDictUnificator.registerOre(block + werkstoff.getVarName(), werkstoff.get(block)); + werkstoff.getADDITIONAL_OREDICT() + .forEach(e -> OreDictionary.registerOre(block + e, werkstoff.get(block))); + } + + werkstoff.getADDITIONAL_OREDICT() + .forEach( + s -> ENABLED_ORE_PREFIXES.stream() + .filter(o -> Objects.nonNull(werkstoff.get(o))) + .forEach(od -> OreDictionary.registerOre(od + s, werkstoff.get(od)))); + } + + GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.CubicZirconia.get(gemExquisite)); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AddSomeRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AddSomeRecipes.java new file mode 100644 index 0000000000..c31013eb78 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AddSomeRecipes.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.processingLoaders; + +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import com.github.bartimaeusnek.bartworks.system.material.BW_NonMeta_MaterialItems; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; + +public class AddSomeRecipes implements Runnable { + + public void run() { + + GT_Values.RA.stdBuilder() + .itemInputs(BW_NonMeta_MaterialItems.Depleted_Tiberium_1.get(1)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(dust), + WerkstoffLoader.Zirconium.get(dust), + WerkstoffLoader.Tiberium.get(dustSmall, 2), + WerkstoffLoader.Zirconium.get(dust, 2), + GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 8L), + GT_OreDictUnificator.get(dust, Materials.Platinum, 1L)) + .outputChances(100_00, 50_00, 50_00, 25_00, 100_00, 100_00) + .fluidOutputs(WerkstoffLoader.Xenon.getFluidOrGas(1)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(BW_NonMeta_MaterialItems.Depleted_Tiberium_2.get(1)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(dust, 2), + WerkstoffLoader.Zirconium.get(dust, 2), + WerkstoffLoader.Tiberium.get(dust), + WerkstoffLoader.Zirconium.get(dust, 4), + GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 18L), + GT_OreDictUnificator.get(dust, Materials.Platinum, 2L)) + .outputChances(100_00, 50_00, 50_00, 25_00, 100_00, 100_00) + .fluidOutputs(WerkstoffLoader.Xenon.getFluidOrGas(2)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(BW_NonMeta_MaterialItems.Depleted_Tiberium_4.get(1)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(dust, 4), + WerkstoffLoader.Zirconium.get(dust, 4), + WerkstoffLoader.Tiberium.get(dust, 2), + WerkstoffLoader.Zirconium.get(dust, 8), + GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 38L), + GT_OreDictUnificator.get(dust, Materials.Platinum, 4L)) + .outputChances(100_00, 50_00, 50_00, 25_00, 100_00, 100_00) + .fluidOutputs(WerkstoffLoader.Xenon.getFluidOrGas(4)) + .duration(50 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(BW_NonMeta_MaterialItems.Depleted_TheCoreCell.get(1)) + .itemOutputs( + ItemList.Depleted_Naquadah_4.get(8), + WerkstoffLoader.Zirconium.get(dust, 64), + WerkstoffLoader.Zirconium.get(dust, 64), + GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 64L), + GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 64L), + GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 48L)) + .outputChances(100_00, 50_00, 50_00, 100_00, 100_00, 100_00) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(centrifugeRecipes); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java new file mode 100644 index 0000000000..3638536ca6 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java @@ -0,0 +1,671 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.processingLoaders; + +import static com.github.bartimaeusnek.bartworks.util.BW_Util.CLEANROOM; +import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.gemChipped; +import static gregtech.api.enums.OrePrefixes.gemExquisite; +import static gregtech.api.enums.OrePrefixes.gemFlawed; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.recipe.RecipeMaps.autoclaveRecipes; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.recipe.RecipeMaps.primitiveBlastRecipes; +import static gregtech.api.recipe.RecipeMaps.sifterRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.ADDITIVE_AMOUNT; + +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + +import com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.BW_NonMeta_MaterialItems; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_Meta_Items; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import com.github.bartimaeusnek.bartworks.util.BioDNA; +import com.github.bartimaeusnek.bartworks.util.BioData; +import com.github.bartimaeusnek.bartworks.util.BioPlasmid; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_RecipeConstants; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; + +public class AdditionalRecipes { + + private static void runBWRecipes() { + + if (ConfigHandler.BioLab) { + FluidStack[] dnaFluid = { Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 1000) + : Materials.Biomass.getFluid(1000L) }; + + for (ItemStack stack : BioItemList.getAllPetriDishes()) { + BioData DNA = BioData.getBioDataFromNBTTag( + stack.getTagCompound() + .getCompoundTag("DNA")); + if (DNA != null) { + ItemStack Detergent = BioItemList.getOther(1); + ItemStack DNAFlask = BioItemList.getDNASampleFlask(null); + ItemStack EthanolCell = Materials.Ethanol.getCells(1); + BartWorksRecipeMaps.bioLabRecipes.addFakeRecipe( + false, + new ItemStack[] { stack, DNAFlask, Detergent, EthanolCell }, + new ItemStack[] { BioItemList.getDNASampleFlask(BioDNA.convertDataToDNA(DNA)), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L) }, + BioItemList.mBioLabParts[0], + new int[] { DNA.getChance(), 10000 }, + new FluidStack[] { FluidRegistry.getFluidStack("ic2distilledwater", 1000) }, + null, + 500, + BW_Util.getMachineVoltageFromTier(3 + DNA.getTier()), + BW_Util.STANDART); + } + } + + for (ItemStack stack : BioItemList.getAllDNASampleFlasks()) { + BioData DNA = BioData.getBioDataFromNBTTag(stack.getTagCompound()); + + if (DNA != null) { + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + Behaviour_DataOrb.setDataName(Outp, DNA.getName()); + + BartWorksRecipeMaps.bioLabRecipes.addFakeRecipe( + false, + new ItemStack[] { stack, FluidLoader.BioLabFluidCells[0], FluidLoader.BioLabFluidCells[3], + ItemList.Tool_DataOrb.get(1L) }, + new ItemStack[] { Outp, ItemList.Cell_Empty.get(2L) }, + BioItemList.mBioLabParts[1], + new int[] { DNA.getChance(), 10000 }, + dnaFluid, + null, + 500, + BW_Util.getMachineVoltageFromTier(4 + DNA.getTier()), + BW_Util.STANDART); + } + } + + for (ItemStack stack : BioItemList.getAllPlasmidCells()) { + BioData DNA = BioData.getBioDataFromNBTTag(stack.getTagCompound()); + + if (DNA != null) { + ItemStack inp = ItemList.Tool_DataOrb.get(0L); + Behaviour_DataOrb.setDataTitle(inp, "DNA Sample"); + Behaviour_DataOrb.setDataName(inp, DNA.getName()); + ItemStack inp2 = ItemList.Tool_DataOrb.get(0L); + Behaviour_DataOrb.setDataTitle(inp2, "DNA Sample"); + Behaviour_DataOrb.setDataName(inp2, BioCultureLoader.BIO_DATA_BETA_LACMATASE.getName()); + + BartWorksRecipeMaps.bioLabRecipes.addFakeRecipe( + false, + new ItemStack[] { FluidLoader.BioLabFluidCells[1], BioItemList.getPlasmidCell(null), inp, + inp2 }, + new ItemStack[] { stack, ItemList.Cell_Empty.get(1L) }, + BioItemList.mBioLabParts[2], + new int[] { DNA.getChance(), 10000 }, + dnaFluid, + null, + 500, + BW_Util.getMachineVoltageFromTier(4 + DNA.getTier()), + BW_Util.STANDART); + } + } + + for (ItemStack stack : BioItemList.getAllPetriDishes()) { + BioData DNA = BioData.getBioDataFromNBTTag( + stack.getTagCompound() + .getCompoundTag("DNA")); + BioData Plasmid = BioData.getBioDataFromNBTTag( + stack.getTagCompound() + .getCompoundTag("Plasmid")); + if (!Objects.equals(DNA.getName(), Plasmid.getName())) { + BartWorksRecipeMaps.bioLabRecipes.addFakeRecipe( + true, + new ItemStack[] { BioItemList.getPetriDish(BioCulture.getBioCulture(DNA.getName())), + BioItemList.getPlasmidCell(BioPlasmid.convertDataToPlasmid(Plasmid)), + FluidLoader.BioLabFluidCells[2], }, + new ItemStack[] { stack, ItemList.Cell_Empty.get(1L) }, + BioItemList.mBioLabParts[3], + new int[] { Plasmid.getChance(), 10000 }, + new FluidStack[] { FluidRegistry.getFluidStack("ic2distilledwater", 1000) }, + null, + 500, + (int) TierEU.RECIPE_LuV, + BW_Util.STANDART); + } + } + + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + Behaviour_DataOrb.setDataName(Outp, "Any DNA"); + // Clonal Cellular Synthesis- [Liquid DNA] + Medium Petri Dish + Plasma Membrane + Stem Cells + Genome Data + BartWorksRecipeMaps.bioLabRecipes.addFakeRecipe( + false, + new ItemStack[] { BioItemList.getPetriDish(null), BioItemList.getOther(4), + ItemList.Circuit_Chip_Stemcell.get(2L), Outp }, + new ItemStack[] { BioItemList.getPetriDish(null) + .setStackDisplayName("The Culture made from DNA"), }, + BioItemList.mBioLabParts[4], + new int[] { 7500, 10000 }, + new FluidStack[] { new FluidStack(dnaFluid[0].getFluid(), 8000) }, + null, + 500, + (int) TierEU.RECIPE_LuV, + BW_Util.STANDART); + + FluidStack[] easyFluids = { Materials.Water.getFluid(1000L), + FluidRegistry.getFluidStack("ic2distilledwater", 1000) }; + for (FluidStack fluidStack : easyFluids) { + for (BioCulture bioCulture : BioCulture.BIO_CULTURE_ARRAY_LIST) { + if (bioCulture.isBreedable() && bioCulture.getTier() == 0) { + BartWorksRecipeMaps.bacterialVatRecipes.addRecipe( + // boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + // int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, + // int aEUt, int aSpecialValue + new GT_Recipe( + true, + new ItemStack[] { GT_Utility.getIntegratedCircuit(1), new ItemStack(Items.sugar, 64) }, + null, + BioItemList.getPetriDish(bioCulture), + null, + new FluidStack[] { fluidStack }, + new FluidStack[] { new FluidStack(bioCulture.getFluid(), 10) }, + 1000, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART)); + // aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, + // aDuration, aEUt, aSpecialValue + BartWorksRecipeMaps.bioLabRecipes.addRecipe( + new GT_Recipe( + false, + new ItemStack[] { BioItemList.getPetriDish(null), + fluidStack.equals(Materials.Water.getFluid(1000L)) ? Materials.Water.getCells(1) + : GT_Utility.getContainersFromFluid(GT_ModHandler.getDistilledWater(1000)) + .get(0) }, + new ItemStack[] { BioItemList.getPetriDish(bioCulture), Materials.Empty.getCells(1) }, + null, + new int[] { bioCulture.getChance(), 10000 }, + new FluidStack[] { new FluidStack(bioCulture.getFluid(), 1000) }, + null, + 500, + (int) TierEU.RECIPE_HV, + BW_Util.STANDART)); + } + } + } + } + + List> liquidFuels = Arrays.asList( + ImmutablePair.of(Materials.PhosphoricAcid, 36), + ImmutablePair.of(Materials.DilutedHydrochloricAcid, 14), + ImmutablePair.of(Materials.HypochlorousAcid, 30), + ImmutablePair.of(Materials.HydrofluoricAcid, 40), + ImmutablePair.of(Materials.HydrochloricAcid, 28), + ImmutablePair.of(Materials.NitricAcid, 24), + ImmutablePair.of(Materials.Mercury, 32), + ImmutablePair.of(Materials.DilutedSulfuricAcid, 9), + ImmutablePair.of(Materials.SulfuricAcid, 18), + ImmutablePair.of(Materials.AceticAcid, 11), + ImmutablePair.of(WerkstoffLoader.FormicAcid.getBridgeMaterial(), 40)); + for (Pair fuel : liquidFuels) { + GT_Values.RA.stdBuilder() + .itemInputs( + fuel.getLeft() + .getCells(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .metadata(GT_RecipeConstants.FUEL_VALUE, fuel.getRight()) + .addTo(BartWorksRecipeMaps.acidGenFuels); + } + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Redstone, 1)) + .itemOutputs(Materials.Empty.getCells(1)) + .metadata(GT_RecipeConstants.FUEL_VALUE, 10) + .addTo(BartWorksRecipeMaps.acidGenFuels); + } + + @SuppressWarnings("deprecation") + public static void run() { + runBWRecipes(); + GT_Values.RA.addImplosionRecipe( + WerkstoffLoader.RawAdemicSteel.get(dust), + 4, + WerkstoffLoader.AdemicSteel.get(dust), + null); + // Thorium/Yttrium Glas + GT_Values.RA.addBlastRecipe( + WerkstoffLoader.YttriumOxide.get(dustSmall, 2), + WerkstoffLoader.Thorianit.get(dustSmall, 2), + Materials.Glass.getMolten(144), + null, + new ItemStack(ItemRegistry.bw_glasses[0], 1, 12), + null, + 800, + (int) TierEU.RECIPE_IV, + 3663); + // Thorianite recipes + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Thorianit.get(crushedPurified)) + .itemOutputs( + WerkstoffLoader.Thorianit.get(dust), + WerkstoffLoader.Thorianit.get(dust), + WerkstoffLoader.Thorianit.get(dust), + Materials.Thorium.getDust(1), + Materials.Thorium.getDust(1), + WerkstoffLoader.Thorium232.get(dust)) + .outputChances(7000, 1300, 700, 600, 300, 100) + .duration(20 * SECONDS) + .eut((int) TierEU.RECIPE_IV) + .addTo(sifterRecipes); + + // 3ThO2 + 4Al = 3Th + 2Al2O3 + GT_Values.RA.addChemicalRecipe( + WerkstoffLoader.Thorianit.get(dust, 9), + Materials.Aluminium.getDust(4), + null, + null, + Materials.Thorium.getDust(3), + Materials.Aluminiumoxide.getDust(10), + 1000); + // ThO2 + 2Mg = Th + 2MgO + GT_Values.RA.addChemicalRecipe( + WerkstoffLoader.Thorianit.get(dust, 3), + Materials.Magnesium.getDust(2), + null, + null, + Materials.Thorium.getDust(1), + Materials.Magnesia.getDust(4), + 1000); + GT_Values.RA.addChemicalRecipe( + WerkstoffLoader.Thorianit.get(crushed), + ItemList.Crop_Drop_Thorium.get(9), + Materials.Water.getFluid(1000), + Materials.Thorium.getMolten(144), + WerkstoffLoader.Thorianit.get(crushedPurified, 4), + 96, + 24); + + // Prasiolite + GT_Values.RA.addBlastRecipe( + GT_OreDictUnificator.get(dust, Materials.Quartzite, 40L), + Materials.Amethyst.getDust(10), + GT_Values.NF, + GT_Values.NF, + WerkstoffLoader.Prasiolite.get(OrePrefixes.gemFlawed, 20), + GT_Values.NI, + 800, + (int) TierEU.RECIPE_MV, + 500); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_OreDictUnificator.get(dust, Materials.Quartzite, 40L)) + .itemOutputs(Materials.Amethyst.getDust(10)) + .duration(40 * SECONDS) + .eut(0) + .metadata(ADDITIVE_AMOUNT, 6) + .addTo(primitiveBlastRecipes); + + // Cubic Circonia + // 2Y + 3O = Y2O3 + GT_Values.RA.addChemicalRecipe( + Materials.Yttrium.getDust(2), + GT_Utility.getIntegratedCircuit(5), + Materials.Oxygen.getGas(3000), + GT_Values.NF, + WerkstoffLoader.YttriumOxide.get(dust, 5), + 4096, + (int) TierEU.RECIPE_LV); + // Zr + 2O =Y22O3= ZrO2 + RecipeMaps.blastFurnaceRecipes.addRecipe( + false, + new ItemStack[] { WerkstoffLoader.Zirconium.get(dust, 10), WerkstoffLoader.YttriumOxide.get(dust, 0) }, + new ItemStack[] { WerkstoffLoader.CubicZirconia.get(gemFlawed, 40) }, + null, + null, + new FluidStack[] { Materials.Oxygen.getGas(20000) }, + null, + 57600, + (int) TierEU.RECIPE_HV, + 2953); + // Tellurium + GT_Values.RA.addBlastRecipe( + GT_OreDictUnificator.get(crushed, Materials.Lead, 10L), + GT_Utility.getIntegratedCircuit(17), + GT_Values.NF, + GT_Values.NF, + Materials.Lead.getIngots(10), + Materials.Tellurium.getNuggets(20), + 800, + (int) TierEU.RECIPE_MV, + 722); + GT_Values.RA.addFusionReactorRecipe( + Materials.Plutonium.getMolten(48), + Materials.Beryllium.getMolten(48), + WerkstoffLoader.Californium.getMolten(48), + 240, + 49152, + 480000000); + GT_Values.RA.addFusionReactorRecipe( + WerkstoffLoader.Californium.getMolten(32), + WerkstoffLoader.Calcium.getMolten(720), + WerkstoffLoader.Oganesson.getFluidOrGas(720), + 420, + 49152, + 600000000); + GT_Values.RA.addDistillationTowerRecipe( + Materials.LiquidAir.getFluid(100000000), + new FluidStack[] { Materials.Nitrogen.getGas(78084000), Materials.Oxygen.getGas(20946000), + Materials.Argon.getGas(934000), Materials.CarbonDioxide.getGas(40700), + WerkstoffLoader.Neon.getFluidOrGas(1818), Materials.Helium.getGas(524), Materials.Methane.getGas(180), + WerkstoffLoader.Krypton.getFluidOrGas(114), Materials.Hydrogen.getGas(55), + WerkstoffLoader.Xenon.getFluidOrGas(9) }, + null, + 7500, + (int) TierEU.RECIPE_EV); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.MagnetoResonaticDust.get(dust)) + .itemOutputs(WerkstoffLoader.MagnetoResonaticDust.get(gemChipped, 9)) + .outputChances(90_00) + .fluidInputs(WerkstoffLoader.Neon.getFluidOrGas(1000)) + .duration(3 * MINUTES + 45 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(autoclaveRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(WerkstoffLoader.MagnetoResonaticDust.get(dust)) + .itemOutputs(WerkstoffLoader.MagnetoResonaticDust.get(gem)) + .fluidInputs(WerkstoffLoader.Krypton.getFluidOrGas(1000)) + .duration(3 * MINUTES + 45 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(autoclaveRecipes); + + // Milk + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(1)) + .itemOutputs( + Materials.Sugar.getDustSmall(21), + Materials.Calcium.getDustTiny(1), + Materials.Magnesium.getDustTiny(1), + Materials.Potassium.getDustTiny(1), + Materials.Sodium.getDustTiny(4), + Materials.Phosphor.getDustTiny(1)) + .outputChances(100_00, 100_00, 10_00, 100_00, 10_00, 10_00) + .fluidInputs(Materials.Milk.getFluid(10000)) + .fluidOutputs(Materials.Water.getFluid(8832)) + .duration(2 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(centrifugeRecipes); + + // Magneto Resonatic Circuits + + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + + Fluid solderUEV = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + // ULV + RecipeMaps.circuitAssemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(3), WerkstoffLoader.MagnetoResonaticDust.get(gem), ItemList.NandChip.get(1), + ItemList.Circuit_Parts_DiodeSMD.get(4), ItemList.Circuit_Parts_CapacitorSMD.get(4), + ItemList.Circuit_Parts_TransistorSMD.get(4) }, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(4) }, + null, + null, + new FluidStack[] { Materials.SolderingAlloy.getMolten(36) }, + null, + 750, + (int) TierEU.RECIPE_LV, + CLEANROOM)); + // LV-EV + for (int i = 1; i <= 4; i++) { + RecipeMaps.circuitAssemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(3), WerkstoffLoader.MagnetoResonaticDust.get(gem), + BW_Meta_Items.getNEWCIRCUITS() + .getStack(i + 3), + ItemList.Circuit_Parts_DiodeSMD.get((i + 1) * 4), + ItemList.Circuit_Parts_CapacitorSMD.get((i + 1) * 4), + ItemList.Circuit_Parts_TransistorSMD.get((i + 1) * 4) }, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(i + 4) }, + null, + null, + new FluidStack[] { Materials.SolderingAlloy.getMolten((i + 1) * 36) }, + null, + (i + 1) * 750, + BW_Util.getMachineVoltageFromTier(i + 1), + CLEANROOM)); + } + // IV-LuV + for (int i = 5; i <= 6; i++) { + RecipeMaps.circuitAssemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(3), WerkstoffLoader.MagnetoResonaticDust.get(gem), + BW_Meta_Items.getNEWCIRCUITS() + .getStack(i + 3), + ItemList.Circuit_Parts_DiodeASMD.get((i + 1) * 4), + ItemList.Circuit_Parts_CapacitorASMD.get((i + 1) * 4), + ItemList.Circuit_Parts_TransistorASMD.get((i + 1) * 4) }, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(i + 4) }, + null, + null, + new FluidStack[] { new FluidStack(solderIndalloy, (i + 1) * 36) }, + null, + (i + 1) * 750, + BW_Util.getMachineVoltageFromTier(i + 1), + CLEANROOM)); + } + // ZPM + RecipeMaps.circuitAssemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(3), WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, 1), + BW_Meta_Items.getNEWCIRCUITS() + .getStack(7 + 3), + ItemList.Circuit_Parts_DiodeASMD.get((7 + 6) * 4), + ItemList.Circuit_Parts_CapacitorASMD.get((7 + 6) * 4), + ItemList.Circuit_Parts_TransistorASMD.get((7 + 6) * 4) }, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(7 + 4) }, + null, + null, + new FluidStack[] { new FluidStack(solderIndalloy, (7 + 1) * 36) }, + null, + (7 + 1) * 1500, + BW_Util.getMachineVoltageFromTier(7 + 1), + CLEANROOM)); + // UV + RecipeMaps.circuitAssemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(3), WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, 1), + BW_Meta_Items.getNEWCIRCUITS() + .getStack(8 + 3), + ItemList.Circuit_Parts_DiodeASMD.get((8 + 6) * 4), + ItemList.Circuit_Parts_CapacitorASMD.get((8 + 6) * 4), + ItemList.Circuit_Parts_TransistorASMD.get((8 + 6) * 4) }, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(8 + 4) }, + null, + null, + new FluidStack[] { new FluidStack(solderUEV, (8 + 1) * 36) }, + null, + (8 + 1) * 1500, + BW_Util.getMachineVoltageFromTier(8 + 1), + CLEANROOM)); + // UHV-UEV + for (int i = 9; i <= 10; i++) { + RecipeMaps.circuitAssemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(3), WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, 1), + BW_Meta_Items.getNEWCIRCUITS() + .getStack(i + 3), + ItemList.Circuit_Parts_DiodeXSMD.get((i + 6) * 4), + ItemList.Circuit_Parts_CapacitorXSMD.get((i + 6) * 4), + ItemList.Circuit_Parts_TransistorXSMD.get((i + 6) * 4) }, + new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS() + .getStack(i + 4) }, + null, + null, + new FluidStack[] { new FluidStack(solderUEV, (i + 1) * 36) }, + null, + (i + 1) * 1500, + BW_Util.getMachineVoltageFromTier(i + 1), + CLEANROOM)); + } + RecipeMaps.smallNaquadahReactorFuels.addRecipe( + true, + new ItemStack[] { WerkstoffLoader.Tiberium.get(bolt) }, + new ItemStack[] {}, + null, + null, + null, + 0, + 0, + 12500); + RecipeMaps.largeNaquadahReactorFuels.addRecipe( + true, + new ItemStack[] { WerkstoffLoader.Tiberium.get(stick) }, + new ItemStack[] {}, + null, + null, + null, + 0, + 0, + 62500); + + RecipeMaps.hugeNaquadahReactorFuels.addRecipe( + true, + new ItemStack[] { WerkstoffLoader.Tiberium.get(stickLong) }, + new ItemStack[] {}, + null, + null, + null, + 0, + 0, + 125000); + RecipeMaps.extremeNaquadahReactorFuels.addRecipe( + true, + new ItemStack[] { WerkstoffLoader.Tiberium.get(stick) }, + new ItemStack[] {}, + null, + null, + null, + 0, + 0, + 31250); + RecipeMaps.ultraHugeNaquadahReactorFuels.addRecipe( + true, + new ItemStack[] { WerkstoffLoader.Tiberium.get(stickLong) }, + new ItemStack[] {}, + null, + null, + null, + 0, + 0, + 125000); + + LoadItemContainers.run(); + + GT_Values.RA.addCannerRecipe( + ItemList.Large_Fluid_Cell_TungstenSteel.get(1L), + WerkstoffLoader.Tiberium.get(dust, 3), + BW_NonMeta_MaterialItems.TiberiumCell_1.get(1L), + null, + 30, + 16); + GT_Values.RA.addAssemblerRecipe( + BW_NonMeta_MaterialItems.TiberiumCell_1.get(2L), + GT_OreDictUnificator.get(stick, Materials.TungstenSteel, 4L), + BW_NonMeta_MaterialItems.TiberiumCell_2.get(1L), + 100, + 400); + GT_Values.RA.addAssemblerRecipe( + BW_NonMeta_MaterialItems.TiberiumCell_1.get(4L), + GT_OreDictUnificator.get(stickLong, Materials.TungstenSteel, 6L), + BW_NonMeta_MaterialItems.TiberiumCell_4.get(1L), + 150, + 400); + GT_Values.RA.addAssemblerRecipe( + BW_NonMeta_MaterialItems.TiberiumCell_2.get(2L), + GT_OreDictUnificator.get(stick, Materials.TungstenSteel, 4L), + BW_NonMeta_MaterialItems.TiberiumCell_4.get(1L), + 100, + 400); + + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.NaquadahCell_1.get(32L), + GT_OreDictUnificator.get(stickLong, Materials.TungstenSteel, 64L), + GT_OreDictUnificator.get(stickLong, Materials.TungstenSteel, 64L), + GT_OreDictUnificator.get(stickLong, Materials.TungstenSteel, 64L), + WerkstoffLoader.Tiberium.get(dust, 64), WerkstoffLoader.Tiberium.get(dust, 64) }, + null, + BW_NonMeta_MaterialItems.TheCoreCell.get(1L), + 100, + (int) TierEU.RECIPE_LuV); + + GregTech_API.sAfterGTPostload.add(new AddSomeRecipes()); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java new file mode 100644 index 0000000000..f07faa79a8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.processingLoaders; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.StreamUtils; + +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_Recipe; + +public class DownTierLoader { + + public static void run() { + RecipeMap.ALL_RECIPE_MAPS.values() + .stream() + .filter(map -> StreamUtils.filterVisualMaps(map) && map != RecipeMaps.fusionRecipes) + .forEach(map -> { + Set newRecipes = new HashSet<>(); + Set toRem = new HashSet<>(); + map.getAllRecipes() + .stream() + .filter(recipe -> Objects.nonNull(recipe) && recipe.mEUt > 128) + .forEach(recipe -> { + toRem.add(recipe); + newRecipes.add(BW_Util.copyAndSetTierToNewRecipe(recipe, (byte) 2)); + }); + map.getBackend() + .removeRecipes(toRem); + newRecipes.forEach(map::add); + }); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/LoadItemContainers.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/LoadItemContainers.java new file mode 100644 index 0000000000..67de5d5f5b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/LoadItemContainers.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.processingLoaders; + +import com.github.bartimaeusnek.bartworks.system.material.BW_NonMeta_MaterialItems; + +import gregtech.api.items.GT_RadioactiveCellIC_Item; +import gregtech.common.items.GT_DepletetCell_Item; + +public class LoadItemContainers { + + public static void run() { + BW_NonMeta_MaterialItems.Depleted_Tiberium_1 + .set(new GT_DepletetCell_Item("TiberiumcellDep", "Fuel Rod (Depleted Tiberium)", 1)); + BW_NonMeta_MaterialItems.Depleted_Tiberium_2 + .set(new GT_DepletetCell_Item("Double_TiberiumcellDep", "Dual Fuel Rod (Depleted Tiberium)", 1)); + BW_NonMeta_MaterialItems.Depleted_Tiberium_4 + .set(new GT_DepletetCell_Item("Quad_TiberiumcellDep", "Quad Fuel Rod (Depleted Tiberium)", 1)); + BW_NonMeta_MaterialItems.TiberiumCell_1.set( + new GT_RadioactiveCellIC_Item( + "Tiberiumcell", + "Fuel Rod (Tiberium)", + 1, + 50000, + 2F, + 1, + 0.5F, + BW_NonMeta_MaterialItems.Depleted_Tiberium_1.get(1), + false)); + BW_NonMeta_MaterialItems.TiberiumCell_2.set( + new GT_RadioactiveCellIC_Item( + "Double_Tiberiumcell", + "Dual Fuel Rod (Tiberium)", + 2, + 50000, + 2F, + 1, + 0.5F, + BW_NonMeta_MaterialItems.Depleted_Tiberium_2.get(1), + false)); + BW_NonMeta_MaterialItems.TiberiumCell_4.set( + new GT_RadioactiveCellIC_Item( + "Quad_Tiberiumcell", + "Quad Fuel Rod (Tiberium)", + 4, + 50000, + 2F, + 1, + 0.5F, + BW_NonMeta_MaterialItems.Depleted_Tiberium_4.get(1), + false)); + BW_NonMeta_MaterialItems.Depleted_TheCoreCell + .set(new GT_DepletetCell_Item("Core_Reactor_CellDep", "Depleted \"The Core\" Cell", 32)); + BW_NonMeta_MaterialItems.TheCoreCell.set( + new GT_RadioactiveCellIC_Item( + "Core_Reactor_Cell", + "\"The Core\" Cell", + 32, + 100000, + 8F, + 32, + 1F, + BW_NonMeta_MaterialItems.Depleted_TheCoreCell.get(1), + false)); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/IWerkstoffRunnable.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/IWerkstoffRunnable.java new file mode 100644 index 0000000000..d409084406 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/IWerkstoffRunnable.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; + +public interface IWerkstoffRunnable { + + void run(Werkstoff werkstoff); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java new file mode 100644 index 0000000000..a61bc55d59 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.Mods.Thaumcraft; + +import java.util.Objects; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.bartworks.util.log.DebugLog; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TC_Aspects; + +public class AspectLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!Thaumcraft.isModLoaded()) { + return; + } + + for (OrePrefixes enabledOrePrefixes : WerkstoffLoader.ENABLED_ORE_PREFIXES) { + if (werkstoff.hasItemType(enabledOrePrefixes)) { + if (enabledOrePrefixes.mMaterialAmount >= 3628800L || enabledOrePrefixes == OrePrefixes.ore) { + DebugLog.log( + "OrePrefix: " + enabledOrePrefixes.name() + + " mMaterialAmount: " + + enabledOrePrefixes.mMaterialAmount / 3628800L); + if (Objects.nonNull(WerkstoffLoader.items.get(enabledOrePrefixes))) + ThaumcraftHandler.AspectAdder.addAspectViaBW( + werkstoff.get(enabledOrePrefixes), + werkstoff.getTCAspects( + enabledOrePrefixes == OrePrefixes.ore ? 1 + : (int) (enabledOrePrefixes.mMaterialAmount / 3628800L))); + } else if (enabledOrePrefixes.mMaterialAmount >= 0L + && Objects.nonNull(WerkstoffLoader.items.get(enabledOrePrefixes))) + ThaumcraftHandler.AspectAdder + .addAspectViaBW(werkstoff.get(enabledOrePrefixes), new Pair<>(TC_Aspects.PERDITIO.mAspect, 1)); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/BlockLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/BlockLoader.java new file mode 100644 index 0000000000..1262ab2499 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/BlockLoader.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.recipe.RecipeMaps.cutterRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.UniversalArcFurnace; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TierEU; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.util.GT_RecipeConstants; + +public class BlockLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(block)) return; + if (werkstoff.hasItemType(ingot)) { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(ingot, 9)) + .duration(16 * TICKS) + .eut(90) + .metadata(GT_RecipeConstants.RECYCLE, true) + .addTo(UniversalArcFurnace); + } + if (werkstoff.hasItemType(cellMolten)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .fluidOutputs(werkstoff.getMolten(1296)) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .duration(14 * SECONDS + 8 * TICKS) + .eut(8) + .addTo(fluidExtractionRecipes); + + } + if (werkstoff.hasItemType(plate)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(plate, 9)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 10L, + 1L)) + .eut(TierEU.RECIPE_LV) + .addTo(cutterRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java new file mode 100644 index 0000000000..9ec4030943 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.blockCasing; +import static gregtech.api.enums.OrePrefixes.blockCasingAdvanced; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.plank; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import com.github.bartimaeusnek.bartworks.system.material.BW_GT_MaterialReference; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; + +public class CasingLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff == BW_GT_MaterialReference.Wood /* || werkstoff == BW_GT_MaterialReference.WoodSealed */) { + addCasingRecipes(werkstoff, plank); + } else { + if (!werkstoff.hasGenerationFeature(blockCasing) || !werkstoff.doesOreDictedItemExists(plate) + || !werkstoff.doesOreDictedItemExists(screw) + || !werkstoff.doesOreDictedItemExists(gearGtSmall) + || !werkstoff.doesOreDictedItemExists(gearGt) + || !werkstoff.doesOreDictedItemExists(plateDouble)) return; + + addCasingRecipes(werkstoff, plateDouble); + } + } + + private static void addCasingRecipes(Werkstoff werkstoff, OrePrefixes reboltedCasingsOuterStuff) { + GT_ModHandler.addCraftingRecipe( + werkstoff.get(blockCasing), + new Object[] { "PSP", "PGP", "PSP", 'P', werkstoff.get(plate), 'S', werkstoff.get(screw), 'G', + werkstoff.get(gearGtSmall) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 6), werkstoff.get(screw, 2), werkstoff.get(gearGtSmall)) + .itemOutputs(werkstoff.get(blockCasing)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(blockCasingAdvanced), + new Object[] { "PSP", "PGP", "PSP", 'P', werkstoff.get(reboltedCasingsOuterStuff), 'S', + werkstoff.get(screw), 'G', werkstoff.get(gearGt) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(reboltedCasingsOuterStuff, 6), werkstoff.get(screw, 2), werkstoff.get(gearGt)) + .itemOutputs(werkstoff.get(blockCasingAdvanced)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java new file mode 100644 index 0000000000..2b86f46149 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java @@ -0,0 +1,332 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.OrePrefixes.capsule; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import com.github.bartimaeusnek.bartworks.util.Pair; + +import gregtech.api.enums.Element; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; + +public class CellLoader implements IWerkstoffRunnable { + + @Override + @SuppressWarnings("unchecked") + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(cell)) return; + + if ((werkstoff.getStats() + .isElektrolysis() + || werkstoff.getStats() + .isCentrifuge()) + && !werkstoff.hasItemType(dust)) { + List flOutputs = new ArrayList<>(); + List stOutputs = new ArrayList<>(); + HashMap> tracker = new HashMap<>(); + int cells = 0; + for (Pair container : werkstoff.getContents() + .getValue() + .toArray(new Pair[0])) { + if (container.getKey() instanceof Materials) { + if ((((Materials) container.getKey()).hasCorrespondingGas() + || ((Materials) container.getKey()).hasCorrespondingFluid() + || ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID) + && ((Materials) container.getKey()).getDust(0) == null) { + FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000L * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Materials) container.getKey()).getFluid(1000L * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Materials) container.getKey()).getCells(container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Materials) container.getKey()).getCells( + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + cells += container.getValue(); + } + } else { + if (((Materials) container.getKey()).getDust(container.getValue()) == null) continue; + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Materials) container.getKey()).getDust( + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + } + } else if (container.getKey() instanceof Werkstoff) { + if (((Werkstoff) container.getKey()).getStats() + .isGas() || ((Werkstoff) container.getKey()).hasItemType(cell)) { + FluidStack tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Werkstoff) container.getKey()).get( + cell, + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + cells += container.getValue(); + } + } else { + if (!((Werkstoff) container.getKey()).hasItemType(dust)) continue; + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Werkstoff) container.getKey()).get( + dust, + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + } + } + } + ItemStack input = werkstoff.get(cell); + input.stackSize = 1; + + int cellEmpty = cells - 1; + + stOutputs.add(Materials.Empty.getCells(-cellEmpty)); + if (werkstoff.getStats() + .isElektrolysis()) + RecipeMaps.electrolyzerRecipes.add( + new GT_Recipe( + true, + new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + * werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0)); + if (werkstoff.getStats() + .isCentrifuge()) + RecipeMaps.centrifugeRecipes.add( + new GT_Recipe( + true, + new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getMass() + * werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + } + + // Tank "Recipe" + GT_Utility.addFluidContainerData( + new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000), + werkstoff.get(cell), + Materials.Empty.getCells(1))); + FluidContainerRegistry.registerFluidContainer( + werkstoff.getFluidOrGas(1) + .getFluid(), + werkstoff.get(cell), + Materials.Empty.getCells(1)); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Empty.getCells(1)) + .itemOutputs(werkstoff.get(cell)) + .fluidInputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000)) + .duration(16 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(cell)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000)) + .duration(16 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + if (Forestry.isModLoaded()) { + FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000), + werkstoff.get(capsule), + GT_ModHandler.getModItem(Forestry.ID, "waxCapsule", 1), + true); + GT_Utility.addFluidContainerData(emptyData); + FluidContainerRegistry.registerFluidContainer(emptyData); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(capsule)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000)) + .duration(16 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + } + + if (werkstoff.hasItemType(dust)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dust)) + .fluidOutputs(werkstoff.getFluidOrGas(1000)) + .duration( + werkstoff.getStats() + .getMass()) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(werkstoff.get(dust)) + .fluidInputs(werkstoff.getFluidOrGas(1000)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + } + + if (Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + Materials werkstoffBridgeMaterial = null; + boolean ElementSet = false; + for (Element e : Element.values()) { + if (e.toString() + .equals(werkstoff.getToolTip())) { + werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null ? werkstoff.getBridgeMaterial() + : new Materials( + -1, + werkstoff.getTexSet(), + 0, + 0, + 0, + false, + werkstoff.getDefaultName(), + werkstoff.getDefaultName()); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + ElementSet = true; + werkstoff.setBridgeMaterial(werkstoffBridgeMaterial); + break; + } + } + if (!ElementSet) return; + + GT_OreDictUnificator.addAssociation(cell, werkstoffBridgeMaterial, werkstoff.get(cell), false); + + ItemStack scannerOutput = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(scannerOutput, "Elemental-Scan"); + Behaviour_DataOrb.setDataName(scannerOutput, werkstoff.getToolTip()); + RecipeMaps.scannerFakeRecipes.addFakeRecipe( + false, + new GT_Recipe( + false, + new ItemStack[] { werkstoff.get(cell) }, + new ItemStack[] { scannerOutput }, + ItemList.Tool_DataOrb.get(1L), + null, + null, + null, + (int) (werkstoffBridgeMaterial.getMass() * 8192L), + 30, + 0)); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CraftingMaterialLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CraftingMaterialLoader.java new file mode 100644 index 0000000000..91fe34e89f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CraftingMaterialLoader.java @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.rotor; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.wireFine; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.cutterRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.recipe.RecipeMaps.latheRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.wiremillRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; + +public class CraftingMaterialLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(screw)) { + int tVoltageMultiplier = werkstoff.getStats() + .getMeltingPoint() >= 2800 ? 60 : 15; + + // bolt + + GT_Values.RA.stdBuilder() + .itemInputs( + werkstoff.hasItemType(gem) ? werkstoff.get(gem) : werkstoff.get(ingot), + ItemList.Shape_Extruder_Bolt.get(0L)) + .itemOutputs(werkstoff.get(bolt, 8)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1)) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stick)) + .itemOutputs(werkstoff.get(bolt, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(4) + .addTo(cutterRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(bolt)) + .itemOutputs(werkstoff.get(dustTiny, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + // screw + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(bolt)) + .itemOutputs(werkstoff.get(screw)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 8L, + 1L)) + .eut(4) + .addTo(latheRecipes); + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(screw), + GT_Proxy.tBits, + new Object[] { "fX", "X ", 'X', werkstoff.get(bolt) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(screw)) + .itemOutputs(werkstoff.get(dustTiny, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + if (werkstoff.hasItemType(gem)) return; + + // ring + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Ring.get(0L)) + .itemOutputs(werkstoff.get(ring, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1)) + .eut(6 * tVoltageMultiplier) + .addTo(extruderRecipes); + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(ring), + GT_Proxy.tBits, + new Object[] { "h ", "fX", 'X', werkstoff.get(stick) }); + + // Gear + GT_ModHandler.addCraftingRecipe( + werkstoff.get(gearGt), + GT_Proxy.tBits, + new Object[] { "SPS", "PwP", "SPS", 'P', werkstoff.get(plate), 'S', werkstoff.get(stick) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 4), ItemList.Shape_Extruder_Gear.get(0L)) + .itemOutputs(werkstoff.get(gearGt)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 5L, + 1)) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + // wireFine + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Wire.get(0L)) + .itemOutputs(werkstoff.get(wireFine, 8)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 1.5F, + 1F)) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), GT_Utility.getIntegratedCircuit(3)) + .itemOutputs(werkstoff.get(wireFine, 8)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1)) + .eut(8 * tVoltageMultiplier) + .addTo(wiremillRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stick), GT_Utility.getIntegratedCircuit(3)) + .itemOutputs(werkstoff.get(wireFine, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 0.5F, + 1F)) + .eut(8 * tVoltageMultiplier) + .addTo(wiremillRecipes); + + // smallGear + if (WerkstoffLoader.smallGearShape != null) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), WerkstoffLoader.smallGearShape.get(0L)) + .itemOutputs(werkstoff.get(gearGtSmall)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + + } + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(gearGtSmall), + GT_Proxy.tBits, + new Object[] { " S ", "hPx", " S ", 'S', werkstoff.get(stick), 'P', werkstoff.get(plate) }); + + // Rotor + GT_ModHandler.addCraftingRecipe( + werkstoff.get(rotor), + GT_Proxy.tBits, + new Object[] { "PhP", "SRf", "PdP", 'P', werkstoff.get(plate), 'R', werkstoff.get(ring), 'S', + werkstoff.get(screw) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 4), werkstoff.get(ring)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(Materials.Tin.getMolten(32)) + .duration(12 * SECONDS) + .eut(24) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 4), werkstoff.get(ring)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(Materials.Lead.getMolten(48)) + .duration(12 * SECONDS) + .eut(24) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 4), werkstoff.get(ring)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(Materials.SolderingAlloy.getMolten(16)) + .duration(12 * SECONDS) + .eut(24) + .addTo(assemblerRecipes); + + if (WerkstoffLoader.rotorShape != null) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 5), WerkstoffLoader.rotorShape.get(0L)) + .itemOutputs(werkstoff.get(rotor)) + .duration(10 * SECONDS) + .eut(60) + .addTo(extruderRecipes); + + } + + // molten -> metal + if (werkstoff.hasItemType(cellMolten)) { + + /* + * !! No more hardcoded gear, etc. recipe gen, now must go through GenerationFeatures() !! + * GT_Values.RA.addFluidSolidifierRecipe( ItemList.Shape_Mold_Gear.get(0L), werkstoff.getMolten(576), + * werkstoff.get(gearGt), 128, 8); GT_Values.RA.addFluidSolidifierRecipe( + * ItemList.Shape_Mold_Gear_Small.get(0L), werkstoff.getMolten(144), werkstoff.get(gearGtSmall), 16, 8); + * if (WerkstoffLoader.ringMold != null) GT_Values.RA.addFluidSolidifierRecipe( + * WerkstoffLoader.ringMold.get(0L), werkstoff.getMolten(36), werkstoff.get(ring), 100, 4 * + * tVoltageMultiplier); if (WerkstoffLoader.boltMold != null) GT_Values.RA.addFluidSolidifierRecipe( + * WerkstoffLoader.boltMold.get(0L), werkstoff.getMolten(18), werkstoff.get(bolt), 50, 2 * + * tVoltageMultiplier); if (WerkstoffLoader.rotorMold != null) GT_Values.RA.addFluidSolidifierRecipe( + * WerkstoffLoader.rotorMold.get(0L), werkstoff.getMolten(612), werkstoff.get(rotor), 100, 60); + */ + } + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gearGt)) + .itemOutputs(werkstoff.get(dust, 4)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gearGtSmall)) + .itemOutputs(werkstoff.get(dust, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(rotor)) + .itemOutputs(werkstoff.get(dust, 4), werkstoff.get(dustSmall)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ring)) + .itemOutputs(werkstoff.get(dustSmall, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java new file mode 100644 index 0000000000..b33d0ddd20 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedCentrifuged; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustImpure; +import static gregtech.api.enums.OrePrefixes.dustPure; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.recipe.RecipeMaps.autoclaveRecipes; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.recipe.RecipeMaps.chemicalBathRecipes; +import static gregtech.api.recipe.RecipeMaps.electroMagneticSeparatorRecipes; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; + +public class CrushedLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(ore) || !werkstoff.hasItemType(dust)) return; + + if (werkstoff.hasItemType(ingot) && !werkstoff.getStats() + .isBlastFurnace()) { + if (Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushed), werkstoff.get(nugget, 10)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushedPurified), werkstoff.get(nugget, 10)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushedCentrifuged), werkstoff.get(nugget, 10)); + } else { + GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushed), werkstoff.get(ingot)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushedPurified), werkstoff.get(ingot)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushedCentrifuged), werkstoff.get(ingot)); + } + GT_ModHandler.addSmeltingRecipe(werkstoff.get(dustImpure), werkstoff.get(ingot)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(dustPure), werkstoff.get(ingot)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(dust), werkstoff.get(ingot)); + } + + GT_ModHandler + .addCraftingRecipe(werkstoff.get(dustImpure), new Object[] { "h ", "W ", 'W', werkstoff.get(crushed) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(dustPure), + new Object[] { "h ", "W ", 'W', werkstoff.get(crushedPurified) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(dust), + new Object[] { "h ", "W ", 'W', werkstoff.get(crushedCentrifuged) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs(werkstoff.get(dustImpure)) + .duration(10 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(crushed), + werkstoff.get(dustImpure), + werkstoff.getOreByProduct(0, dust), + 10, + false); + GT_ModHandler.addOreWasherRecipe( + werkstoff.get(crushed), + new int[] { 10000, 1111, 10000 }, + 1000, + werkstoff.get(crushedPurified), + werkstoff.getOreByProduct(0, dust), + GT_OreDictUnificator.get(dust, Materials.Stone, 1L)); + GT_ModHandler.addThermalCentrifugeRecipe( + werkstoff.get(crushed), + new int[] { 10000, 1111, 10000 }, + (int) Math.min( + 5000L, + Math.abs( + werkstoff.getStats() + .getProtons() * 20L)), + werkstoff.get(crushedCentrifuged), + werkstoff.getOreByProduct(1, dust), + GT_OreDictUnificator.get(dust, Materials.Stone, 1L)); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(crushedPurified)) + .itemOutputs(werkstoff.get(dustPure)) + .duration(10 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(crushedPurified), + werkstoff.get(dustPure), + werkstoff.getOreByProduct(1, dust), + 10, + false); + GT_ModHandler.addThermalCentrifugeRecipe( + werkstoff.get(crushedPurified), + new int[] { 10000, 1111 }, + (int) Math.min( + 5000L, + Math.abs( + werkstoff.getStats() + .getProtons() * 20L)), + werkstoff.get(crushedCentrifuged), + werkstoff.getOreByProduct(1, dust)); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(crushedCentrifuged)) + .itemOutputs(werkstoff.get(dust)) + .duration(10 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(crushedCentrifuged), + werkstoff.get(dust), + werkstoff.getOreByProduct(2, dust), + 10, + false); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustImpure)) + .itemOutputs(werkstoff.get(dust), werkstoff.getOreByProduct(0, dust)) + .outputChances(100_00, 11_11) + .duration( + Math.max( + 1L, + werkstoff.getStats() + .getMass() * 8L)) + .eut(5) + .addTo(centrifugeRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs(werkstoff.get(dust), werkstoff.getOreByProduct(1, dust)) + .outputChances(100_00, 11_11) + .duration( + Math.max( + 1L, + werkstoff.getStats() + .getMass() * 8L)) + .eut(5) + .addTo(centrifugeRecipes); + + if (werkstoff.contains(SubTag.CRYSTALLISABLE)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9000) + .fluidInputs(Materials.Water.getFluid(200L)) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustImpure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9000) + .fluidInputs(Materials.Water.getFluid(200L)) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9500) + .fluidInputs(gregtech.api.util.GT_ModHandler.getDistilledWater(200L)) + .duration(1 * MINUTES + 15 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustImpure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9500) + .fluidInputs(gregtech.api.util.GT_ModHandler.getDistilledWater(200L)) + .duration(1 * MINUTES + 15 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + } + if (werkstoff.contains(SubTag.WASHING_MERCURY)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs( + werkstoff.get(crushedPurified), + werkstoff.getOreByProduct(1, dust), + GT_OreDictUnificator.get(dust, Materials.Stone, 1L)) + .outputChances(10000, 7000, 4000) + .fluidInputs(Materials.Mercury.getFluid(1000L)) + .duration(40 * SECONDS) + .eut(8) + .addTo(chemicalBathRecipes); + + } + if (werkstoff.contains(SubTag.WASHING_SODIUMPERSULFATE)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs( + werkstoff.get(crushedPurified), + werkstoff.getOreByProduct(1, dust), + GT_OreDictUnificator.get(dust, Materials.Stone, 1L)) + .outputChances(10000, 7000, 4000) + .fluidInputs( + Materials.SodiumPersulfate.getFluid(GT_Mod.gregtechproxy.mDisableOldChemicalRecipes ? 1000L : 100L)) + .duration(40 * SECONDS) + .eut(8) + .addTo(chemicalBathRecipes); + + } + if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs( + werkstoff.get(dust), + GT_OreDictUnificator.get(dustSmall, Materials.Gold, 1L), + GT_OreDictUnificator.get(nugget, Materials.Gold, 1L)) + .outputChances(10000, 4000, 2000) + .duration(20 * SECONDS) + .eut(24) + .addTo(electroMagneticSeparatorRecipes); + + } else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_IRON)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs( + werkstoff.get(dust), + GT_OreDictUnificator.get(dustSmall, Materials.Iron, 1L), + GT_OreDictUnificator.get(nugget, Materials.Iron, 1L)) + .outputChances(10000, 4000, 2000) + .duration(20 * SECONDS) + .eut(24) + .addTo(electroMagneticSeparatorRecipes); + + } else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs( + werkstoff.get(dust), + GT_OreDictUnificator.get(dustSmall, Materials.Neodymium, 1L), + GT_OreDictUnificator.get(nugget, Materials.Neodymium, 1L)) + .outputChances(10000, 4000, 2000) + .duration(20 * SECONDS) + .eut(24) + .addTo(electroMagneticSeparatorRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java new file mode 100644 index 0000000000..088c4bb55b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java @@ -0,0 +1,529 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.ingotHot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.packagerRecipes; +import static gregtech.api.recipe.RecipeMaps.primitiveBlastRecipes; +import static gregtech.api.recipe.RecipeMaps.vacuumFreezerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeConstants.ADDITIVE_AMOUNT; +import static gregtech.api.util.GT_RecipeConstants.COIL_HEAT; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import com.github.bartimaeusnek.bartworks.util.Pair; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_RecipeConstants; +import gregtech.api.util.GT_Utility; + +public class DustLoader implements IWerkstoffRunnable { + + @Override + @SuppressWarnings("unchecked") + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(dust)) { + List flOutputs = new ArrayList<>(); + List stOutputs = new ArrayList<>(); + HashMap> tracker = new HashMap<>(); + int cells = 0; + + if (werkstoff.getGenerationFeatures() + .hasMixerRecipes() + || werkstoff.getStats() + .isElektrolysis() + || werkstoff.getStats() + .isCentrifuge() + || werkstoff.getGenerationFeatures() + .hasChemicalRecipes()) { + for (Pair container : werkstoff.getContents() + .getValue() + .toArray(new Pair[0])) { + final ISubTagContainer key = container.getKey(); + final int value = container.getValue(); + if (key instanceof Materials materialKey) { + if ((materialKey.getGas(0) != null || materialKey.getFluid(0) != null + || materialKey.mIconSet == TextureSet.SET_FLUID) && materialKey.getDust(0) == null) { + FluidStack tmpFl = materialKey.getGas(1000L * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = materialKey.getFluid(1000L * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getCells( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } else { + if (materialKey.getDust(value) == null) { + if (materialKey.getCells(value) == null + || materialKey.getMolten(0) == null && materialKey.getSolid(0) == null) continue; + FluidStack tmpFl = materialKey.getMolten(1000L * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = materialKey.getSolid(1000L * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getCells( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getDust(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getDust( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + } + } else if (key instanceof Werkstoff werkstoffKey) { + if (werkstoffKey.getStats() + .isGas() || werkstoffKey.hasItemType(cell)) { + FluidStack tmpFl = werkstoffKey.getFluidOrGas(1000 * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = werkstoffKey.getFluidOrGas(1000 * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(werkstoffKey.get(cell, value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + werkstoffKey.get( + cell, + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } else { + if (!werkstoffKey.hasItemType(dust)) continue; + if (!tracker.containsKey(key)) { + stOutputs.add(werkstoffKey.get(dust, value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + werkstoffKey.get( + dust, + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + } + } + } + ItemStack input = werkstoff.get(dust); + input.stackSize = werkstoff.getContents() + .getKey(); + if (werkstoff.getStats() + .isElektrolysis()) { + GT_Recipe tRecipe = new GT_Recipe( + true, + new ItemStack[] { input, cells > 0 ? Materials.Empty.getCells(cells) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0); + RecipeMaps.electrolyzerRecipes.add(tRecipe); + RecipeMaps.electrolyzerNonCellRecipes.add(tRecipe); + } + if (werkstoff.getStats() + .isCentrifuge()) { + RecipeMaps.centrifugeRecipes.add( + new GT_Recipe( + true, + new ItemStack[] { input, cells > 0 ? Materials.Empty.getCells(cells) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getMass() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + GT_Recipe tRecipe = new GT_Recipe( + false, + stOutputs.toArray(new ItemStack[0]), + new ItemStack[] { input }, + null, + null, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + null, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0); + RecipeMaps.centrifugeNonCellRecipes.add(tRecipe); + } + if (werkstoff.getGenerationFeatures() + .hasChemicalRecipes()) { + if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); + GT_Values.RA.stdBuilder() + .itemInputs(stOutputs.toArray(new ItemStack[0])) + .itemOutputs(input) + .fluidInputs(flOutputs.toArray(new FluidStack[0])) + .duration( + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size()))) + .eut( + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30) + .addTo(GT_RecipeConstants.UniversalChemical); + } + if (werkstoff.getGenerationFeatures() + .hasMixerRecipes()) { + if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); + short circuitID = werkstoff.getMixCircuit(); + ItemStack circuit = circuitID == -1 ? null : GT_Utility.getIntegratedCircuit(circuitID); + if (circuit != null) stOutputs.add(circuit); + RecipeMaps.mixerRecipes.add( + new GT_Recipe( + true, + stOutputs.toArray(new ItemStack[0]), + new ItemStack[] { input }, + null, + null, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + null, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getMass() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + GT_Recipe tRecipe = new GT_Recipe( + false, + stOutputs.toArray(new ItemStack[0]), + new ItemStack[] { input }, + null, + null, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + null, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0); + RecipeMaps.mixerNonCellRecipes.add(tRecipe); + } + } + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(dust), + new Object[] { "TTT", "TTT", "TTT", 'T', werkstoff.get(dustTiny) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(dust), + new Object[] { "TT ", "TT ", 'T', WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff) }); + GT_ModHandler.addCraftingRecipe( + WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff, 4), + new Object[] { " T ", 'T', werkstoff.get(dust) }); + GT_ModHandler.addCraftingRecipe( + WerkstoffLoader.getCorrespondingItemStack(dustTiny, werkstoff, 9), + new Object[] { "T ", 'T', werkstoff.get(dust) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustTiny, 9), ItemList.Schematic_Dust.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustSmall, 4), ItemList.Schematic_Dust.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustTiny, 9), ItemList.Schematic_3by3.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustSmall, 4), ItemList.Schematic_2by2.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + if (werkstoff.hasItemType(ingot) && !werkstoff.getStats() + .isBlastFurnace()) { + GT_ModHandler.addSmeltingRecipe(werkstoff.get(dust), werkstoff.get(ingot)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(dustTiny), werkstoff.get(nugget)); + } else if (werkstoff.hasItemType(ingot) && werkstoff.getStats() + .isBlastFurnace() + && werkstoff.getStats() + .getMeltingPoint() != 0) { + if (werkstoff.contains(WerkstoffLoader.ANAEROBE_SMELTING)) { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dust), GT_Utility.getIntegratedCircuit(11)) + .itemOutputs( + werkstoff.getStats() + .getMeltingPoint() < 1750 ? werkstoff.get(ingot) : werkstoff.get(ingotHot)) + .fluidInputs(Materials.Nitrogen.getGas(1000)) + .duration( + Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) + * werkstoff.getStats() + .getMeltingPoint()) + .eut( + werkstoff.getStats() + .getMeltingVoltage()) + .metadata( + COIL_HEAT, + werkstoff.getStats() + .getMeltingPoint()) + .addTo(blastFurnaceRecipes); + + } else if (werkstoff.contains(WerkstoffLoader.NOBLE_GAS_SMELTING)) { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dust), GT_Utility.getIntegratedCircuit(11)) + .itemOutputs( + werkstoff.getStats() + .getMeltingPoint() < 1750 ? werkstoff.get(ingot) : werkstoff.get(ingotHot)) + .fluidInputs(Materials.Argon.getGas(1000)) + .duration( + Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) + * werkstoff.getStats() + .getMeltingPoint()) + .eut( + werkstoff.getStats() + .getMeltingVoltage()) + .metadata( + COIL_HEAT, + werkstoff.getStats() + .getMeltingPoint()) + .addTo(blastFurnaceRecipes); + + } else { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dust), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs( + werkstoff.getStats() + .getMeltingPoint() < 1750 ? werkstoff.get(ingot) : werkstoff.get(ingotHot)) + .duration( + Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) + * werkstoff.getStats() + .getMeltingPoint()) + .eut( + werkstoff.getStats() + .getMeltingVoltage()) + .metadata( + COIL_HEAT, + werkstoff.getStats() + .getMeltingPoint()) + .addTo(blastFurnaceRecipes); + + if (werkstoff.getStats() + .getMeltingPoint() <= 1000) { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dust)) + .itemOutputs(werkstoff.get(ingot)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) * werkstoff.getStats() + .getMeltingPoint()) + .eut(0) + .metadata(ADDITIVE_AMOUNT, 9) + .addTo(primitiveBlastRecipes); + } + } + } + + if (werkstoff.getStats() + .isBlastFurnace() + && werkstoff.getStats() + .getMeltingPoint() > 1750) { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingotHot)) + .itemOutputs(werkstoff.get(ingot)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 3L, + 1L)) + .eut(TierEU.RECIPE_MV) + .addTo(vacuumFreezerRecipes); + } + + if (werkstoff.hasItemType(ingot)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .itemOutputs(werkstoff.get(dust)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(nugget)) + .itemOutputs(werkstoff.get(dustTiny)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + } + if (werkstoff.hasItemType(ingot) || werkstoff.hasItemType(gem)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(dust, 9)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java new file mode 100644 index 0000000000..187456a3b4 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.gemChipped; +import static gregtech.api.enums.OrePrefixes.gemExquisite; +import static gregtech.api.enums.OrePrefixes.gemFlawed; +import static gregtech.api.enums.OrePrefixes.gemFlawless; +import static gregtech.api.enums.OrePrefixes.lens; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.recipe.RecipeMaps.compressorRecipes; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.implosionRecipes; +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.recipe.RecipeMaps.latheRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.sifterRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.ADDITIVE_AMOUNT; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; + +public class GemLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(gem)) { + if (werkstoff.getGenerationFeatures() + .hasSifterRecipes() || werkstoff.hasItemType(ore) && werkstoff.hasItemType(dust)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gem, 9)) + .itemOutputs(werkstoff.get(block)) + .duration(15 * SECONDS) + .eut(2) + .addTo(compressorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(gem, 9)) + .duration(5 * SECONDS) + .eut(24) + .addTo(hammerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(crushedPurified)) + .itemOutputs( + werkstoff.get(gemExquisite), + werkstoff.get(gemFlawless), + werkstoff.get(gem), + werkstoff.get(gemFlawed), + werkstoff.get(gemChipped), + werkstoff.get(dust)) + .outputChances(200, 1000, 2500, 2000, 4000, 5000) + .duration(40 * SECONDS) + .eut(16) + .addTo(sifterRecipes); + + } + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemExquisite)) + .itemOutputs(werkstoff.get(dust, 4)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless)) + .itemOutputs(werkstoff.get(dust, 2)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gem)) + .itemOutputs(werkstoff.get(dust)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed)) + .itemOutputs(werkstoff.get(dustSmall, 2)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped)) + .itemOutputs(werkstoff.get(dustSmall)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(gemFlawless, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gemExquisite) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(gem, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gemFlawless) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(gemFlawed, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gem) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(gemChipped, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gemFlawed) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemExquisite)) + .itemOutputs(werkstoff.get(gemFlawless, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless)) + .itemOutputs(werkstoff.get(gem, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gem)) + .itemOutputs(werkstoff.get(gemFlawed, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed)) + .itemOutputs(werkstoff.get(gemChipped, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped)) + .itemOutputs(werkstoff.get(dustTiny)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + if (!werkstoff.contains(WerkstoffLoader.NO_BLAST)) { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless, 3)) + .itemOutputs(werkstoff.get(gemExquisite), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gem, 3)) + .itemOutputs(werkstoff.get(gemFlawless), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed, 3)) + .itemOutputs(werkstoff.get(gem), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped, 3)) + .itemOutputs(werkstoff.get(gemFlawed), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dust, 4)) + .itemOutputs(werkstoff.get(gem, 3), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 8)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 24) + .addTo(implosionRecipes); + } + + if (werkstoff.hasItemType(plate)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .itemOutputs(werkstoff.get(lens), werkstoff.get(dustSmall)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(latheRecipes); + + } + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemExquisite)) + .itemOutputs(werkstoff.get(lens), werkstoff.get(dust, 2)) + .duration(2 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(latheRecipes); + + final ITexture texture = TextureFactory.of( + Textures.BlockIcons.MACHINE_CASINGS[2][0], + TextureFactory.of(Textures.BlockIcons.OVERLAY_LENS, werkstoff.getRGBA(), false)); + GregTech_API.registerCover( + werkstoff.get(lens), + texture, + new gregtech.common.covers.GT_Cover_Lens( + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mIndex, + texture)); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(lens)) + .itemOutputs(werkstoff.get(dustSmall, 3)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + for (ItemStack is : OreDictionary + .getOres("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""))) { + is.stackSize = 0; + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped, 3), is) + .itemOutputs(werkstoff.get(gemFlawed, 1)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(laserEngraverRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed, 3), is) + .itemOutputs(werkstoff.get(gem, 1)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(laserEngraverRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gem, 3), is) + .itemOutputs(werkstoff.get(gemFlawless, 1)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(laserEngraverRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless, 3), is) + .itemOutputs(werkstoff.get(gemExquisite, 1)) + .duration(2 * MINUTES) + .eut(2000) + .addTo(laserEngraverRecipes); + + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MetalLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MetalLoader.java new file mode 100644 index 0000000000..d969ff056f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MetalLoader.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.recipe.RecipeMaps.compressorRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.recipe.RecipeMaps; + +public class MetalLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(ingot)) { + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 9)) + .itemOutputs(werkstoff.get(block)) + .duration(15 * SECONDS) + .eut(2) + .addTo(compressorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 9), ItemList.Shape_Extruder_Block.get(0)) + .itemOutputs(werkstoff.get(block)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut( + 8 * werkstoff.getStats() + .getMeltingPoint() >= 2800 ? 60 : 15) + .addTo(extruderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 9), ItemList.Shape_Mold_Block.get(0L)) + .itemOutputs(werkstoff.get(block)) + .duration( + (int) (werkstoff.getStats() + .getMass() / 2)) + .eut( + 4 * werkstoff.getStats() + .getMeltingPoint() >= 2800 ? 60 : 15) + .recipeCategory(RecipeCategories.alloySmelterMolding) + .addTo(RecipeMaps.alloySmelterRecipes); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java new file mode 100644 index 0000000000..86cc6aa732 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java @@ -0,0 +1,377 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.capsuleMolten; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.rotor; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import java.util.Objects; + +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +public class MoltenCellLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(cellMolten)) { + return; + } + + if (!werkstoff.hasItemType(ingot)) { + if (!werkstoff.hasItemType(dust)) { + return; + } + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dust)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustSmall)) + .fluidOutputs(werkstoff.getMolten(36)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(dustTiny)) + .fluidOutputs(werkstoff.getMolten(16)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + } else { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(nugget)) + .fluidOutputs(werkstoff.getMolten(16)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Ingot.get(0)) + .itemOutputs(werkstoff.get(ingot)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Nugget.get(0)) + .itemOutputs(werkstoff.get(nugget)) + .fluidInputs(werkstoff.getMolten(16)) + .duration( + (int) ((double) werkstoff.getStats() + .getMass() / 9D)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Block.get(0)) + .itemOutputs(werkstoff.get(block)) + .fluidInputs(werkstoff.getMolten(1296)) + .duration( + (int) werkstoff.getStats() + .getMass() * 9) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + if (!werkstoff.hasItemType(plate)) { + return; + } + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stickLong)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stick)) + .fluidOutputs(werkstoff.getMolten(72)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + } + + if (werkstoff.getGenerationFeatures() + .hasMetalCraftingSolidifierRecipes()) { + + if (!werkstoff.hasItemType(plate)) { + return; + } + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Rod_Long.get(0)) + .itemOutputs(werkstoff.get(stickLong)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Rod.get(0)) + .itemOutputs(werkstoff.get(stick)) + .fluidInputs(werkstoff.getMolten(72)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 2, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Plate.get(0)) + .itemOutputs(werkstoff.get(plate)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + } + + if (werkstoff.getGenerationFeatures() + .hasMetaSolidifierRecipes()) { + if (!werkstoff.hasItemType(screw)) { + return; + } + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Screw.get(0)) + .itemOutputs(werkstoff.get(screw)) + .fluidInputs(werkstoff.getMolten(18)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 8, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Gear.get(0)) + .itemOutputs(werkstoff.get(gearGt)) + .fluidInputs(werkstoff.getMolten(576)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 4, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Gear_Small.get(0)) + .itemOutputs(werkstoff.get(gearGtSmall)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Bolt.get(0)) + .itemOutputs(werkstoff.get(bolt)) + .fluidInputs(werkstoff.getMolten(18)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 8, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Ring.get(0)) + .itemOutputs(werkstoff.get(ring)) + .fluidInputs(werkstoff.getMolten(36)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 4, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + // No Spring Molds + + if (WerkstoffLoader.rotorMold == null) { + return; + } + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Rotor.get(0)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(werkstoff.getMolten(612)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 4.25, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + } + + if (werkstoff.getGenerationFeatures() + .hasMultipleMetalSolidifierRecipes() && !werkstoff.hasItemType(plateDouble)) { + // No multiple plate molds + return; + } + + // Tank "Recipe" + final FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144), + werkstoff.get(cellMolten), + Materials.Empty.getCells(1)); + FluidContainerRegistry + .registerFluidContainer(werkstoff.getMolten(144), werkstoff.get(cellMolten), Materials.Empty.getCells(1)); + GT_Utility.addFluidContainerData(data); + + GT_Values.RA.stdBuilder() + .itemInputs(Materials.Empty.getCells(1)) + .itemOutputs(werkstoff.get(cellMolten)) + .fluidInputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(cellMolten)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + if (!Forestry.isModLoaded()) return; + + final FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144), + werkstoff.get(capsuleMolten), + GT_ModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)); + FluidContainerRegistry.registerFluidContainer( + werkstoff.getMolten(144), + werkstoff.get(capsuleMolten), + GT_ModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)); + GT_Utility.addFluidContainerData(emptyData); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(capsuleMolten)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MultipleMetalLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MultipleMetalLoader.java new file mode 100644 index 0000000000..5975b7b898 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MultipleMetalLoader.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plateDense; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class MultipleMetalLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(plateDense)) { + RecipeMaps.benderRecipes.add( + new GT_Recipe( + true, + new ItemStack[] { werkstoff.get(ingot, 2), GT_Utility.getIntegratedCircuit(2) }, + new ItemStack[] { werkstoff.get(plateDouble) }, + null, + null, + null, + null, + (int) Math.max( + werkstoff.getStats() + .getMass() * 2, + 1L), + 60, + 0)); + GregTech_API.registerCover( + werkstoff.get(plateDouble), + TextureFactory.of(werkstoff.getTexSet().mTextures[72], werkstoff.getRGBA(), false), + null); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plateDouble)) + .itemOutputs(werkstoff.get(dust, 2)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/OreLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/OreLoader.java new file mode 100644 index 0000000000..8c9d3837c9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/OreLoader.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; + +public class OreLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(ore) && werkstoff.hasItemType(ingot) + && !werkstoff.getStats() + .isBlastFurnace()) + GT_ModHandler + .addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(ore, werkstoff), werkstoff.get(ingot)); + + if (werkstoff.hasItemType(ore)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ore)) + .itemOutputs(werkstoff.hasItemType(gem) ? werkstoff.get(gem) : werkstoff.get(crushed)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(ore), + werkstoff.get(crushed, 2), + werkstoff.contains(SubTag.CRYSTAL) ? werkstoff.get(gem) : werkstoff.getOreByProduct(0, dust), + werkstoff.getNoOfByProducts() > 0 ? 10 : 0, + Materials.Stone.getDust(1), + 50, + true); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java new file mode 100644 index 0000000000..2fbb086022 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.rawOre; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; + +public class RawOreLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(rawOre) && werkstoff.hasItemType(ingot) + && !werkstoff.getStats() + .isBlastFurnace()) + GT_ModHandler + .addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(rawOre, werkstoff), werkstoff.get(ingot)); + + if (werkstoff.hasItemType(rawOre)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(rawOre)) + .itemOutputs(werkstoff.hasItemType(gem) ? werkstoff.get(gem) : werkstoff.get(crushed)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(rawOre), + werkstoff.get(crushed, 2), + werkstoff.contains(SubTag.CRYSTAL) ? werkstoff.get(gem) : werkstoff.getOreByProduct(0, dust), + werkstoff.getNoOfByProducts() > 0 ? 5 : 0, + Materials.Stone.getDust(1), + 50, + true); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/SimpleMetalLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/SimpleMetalLoader.java new file mode 100644 index 0000000000..88bfac24ee --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/SimpleMetalLoader.java @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.foil; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.recipe.RecipeMaps.benderRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.latheRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; + +public class SimpleMetalLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(plate)) { + if (werkstoff.hasItemType(gem)) { + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(gem)) + .itemOutputs(werkstoff.get(stick), werkstoff.get(dustSmall, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 5L, + 1L)) + .eut(16) + .addTo(latheRecipes); + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(stick, 2), + GT_Proxy.tBits, + new Object[] { "s", "X", 'X', werkstoff.get(stickLong) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(stick), + GT_Proxy.tBits, + new Object[] { "f ", " X", 'X', werkstoff.get(gem) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stick, 2)) + .itemOutputs(werkstoff.get(stickLong)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut(16) + .addTo(hammerRecipes); + + TextureSet texSet = werkstoff.getTexSet(); + ITexture texture = SideReference.Side.Client ? TextureFactory.of( + texSet.mTextures[PrefixTextureLinker.blockTexMap.getOrDefault(texSet, block.mTextureIndex)], + werkstoff.getRGBA(), + false) : TextureFactory.of(texSet.mTextures[block.mTextureIndex], werkstoff.getRGBA(), false); + GregTech_API.registerCover(werkstoff.get(plate), texture, null); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + return; + } + + GT_ModHandler.addCraftingRecipe( + werkstoff.get(stick, 2), + GT_Proxy.tBits, + new Object[] { "s", "X", 'X', werkstoff.get(stickLong) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(stick), + GT_Proxy.tBits, + new Object[] { "f ", " X", 'X', werkstoff.get(ingot) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(plate), + GT_Proxy.tBits, + new Object[] { "h", "X", "X", 'X', werkstoff.get(ingot) }); + GT_ModHandler.addCraftingRecipe( + werkstoff.get(foil, 2), + GT_Proxy.tBits, + new Object[] { "hX", 'X', werkstoff.get(plate) }); + + benderRecipes.add( + new GT_Recipe( + true, + new ItemStack[] { werkstoff.get(ingot), GT_Utility.getIntegratedCircuit(1) }, + new ItemStack[] { werkstoff.get(plate) }, + null, + null, + null, + null, + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L), + 24, + 0)); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 3)) + .itemOutputs(werkstoff.get(plate, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut(16) + .addTo(hammerRecipes); + + GregTech_API.registerCover( + werkstoff.get(plate), + TextureFactory.of(werkstoff.getTexSet().mTextures[71], werkstoff.getRGBA(), false), + null); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .itemOutputs(werkstoff.get(stick), werkstoff.get(dustSmall, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 5L, + 1L)) + .eut(16) + .addTo(latheRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(werkstoff.get(foil, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 1L, + 1L)) + .eut(24) + .addTo(benderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), GT_Utility.getIntegratedCircuit(10)) + .itemOutputs(werkstoff.get(foil, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(24) + .addTo(benderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stick, 2)) + .itemOutputs(werkstoff.get(stickLong)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut(16) + .addTo(hammerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Plate.get(0)) + .itemOutputs(werkstoff.get(plate)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(45) + .addTo(extruderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Rod.get(0)) + .itemOutputs(werkstoff.get(stick, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(45) + .addTo(extruderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stickLong)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(stick)) + .itemOutputs(werkstoff.get(dustSmall, 2)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/ToolLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/ToolLoader.java new file mode 100644 index 0000000000..499477a846 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/ToolLoader.java @@ -0,0 +1,602 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.enums.OrePrefixes.toolHeadHammer; +import static gregtech.api.enums.OrePrefixes.toolHeadSaw; +import static gregtech.api.enums.OrePrefixes.toolHeadWrench; +import static gregtech.api.enums.OrePrefixes.turbineBlade; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.recipe.RecipeMaps.formingPressRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.GT_Proxy; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +public class ToolLoader implements IWerkstoffRunnable { + + // GTNH-Specific + public static final short SCREWDRIVER_MV = 152; + public static final short SCREWDRIVER_HV = 154; + public static final short SOLDERING_IRON_MV = 162; + public static final short SOLDERING_IRON_HV = 164; + + public void run(Werkstoff werkstoff) { + if (werkstoff.getBridgeMaterial().mDurability == 0) return; + + if (werkstoff.hasItemType(gem)) { + if (!werkstoff.getGenerationFeatures() + .isExtension()) + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.HARDHAMMER, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "XX ", "XXS", "XX ", 'X', gem.get(werkstoff.getBridgeMaterial()), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GT_ModHandler.addCraftingRecipe( + GT_OreDictUnificator.get(toolHeadSaw, werkstoff.getBridgeMaterial(), 1L), + GT_Proxy.tBits, + new Object[] { "GGf", 'G', gem.get(werkstoff.getBridgeMaterial()) }); + } + + if (!werkstoff.hasItemType(plate)) return; + + // Disable recipe gen with handle Material for GT Materials + if (!werkstoff.getGenerationFeatures() + .isExtension()) { + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SCREWDRIVER, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { " fS", " Sh", "W ", 'S', stick.get(werkstoff.getBridgeMaterial()), 'W', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GT_ModHandler.addCraftingRecipe( + GT_OreDictUnificator.get(toolHeadWrench, werkstoff.getBridgeMaterial(), 1L), + GT_Proxy.tBits, + new Object[] { "hXW", "XRX", "WXd", 'X', plate.get(werkstoff.getBridgeMaterial()), 'S', + plate.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'R', + ring.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'W', + screw.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GT_ModHandler.addShapelessCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.HARDHAMMER, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { toolHeadHammer.get(werkstoff.getBridgeMaterial()), + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.FILE, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GT_ModHandler.RecipeBits.MIRRORED | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "P", "P", "S", 'P', plate.get(werkstoff.getBridgeMaterial()), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GT_ModHandler.addShapelessCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SAW, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + new Object[] { toolHeadSaw.get(werkstoff.getBridgeMaterial()), + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Rubber, + new long[] { 100000L, 32L, 1L, -1L }), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "LBf", "Sd ", "P ", 'B', bolt.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(Materials.AnyRubber), 'S', stick.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'L', + ItemList.Battery_RE_LV_Lithium.get(1L) }); + + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SOLDERING_IRON_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Rubber, + new long[] { 400000L, 128L, 2L, -1L }), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "LBf", "Sd ", "P ", 'B', bolt.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(Materials.AnyRubber), 'S', stick.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'L', + ItemList.Battery_RE_MV_Lithium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SOLDERING_IRON_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StyreneButadieneRubber, + new long[] { 1600000L, 512L, 3L, -1L }), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "LBf", "Sd ", "P ", 'B', bolt.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(Materials.StyreneButadieneRubber), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'L', + ItemList.Battery_RE_HV_Lithium.get(1L) }); + + if (!werkstoff.hasItemType(gem)) { + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.HARDHAMMER, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "XX ", "XXS", "XX ", 'X', ingot.get(werkstoff.getBridgeMaterial()), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + } + } + + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.PLUNGER, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "xRR", " SR", "S f", 'S', stick.get(werkstoff.getBridgeMaterial()), 'R', + plate.get(Materials.AnyRubber) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "IhI", "III", " I ", 'I', ingot.get(werkstoff.getBridgeMaterial()) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.CROWBAR, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "hDS", "DSD", "SDf", 'S', stick.get(werkstoff.getBridgeMaterial()), 'D', Dyes.dyeBlue }); + + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WIRECUTTER, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PfP", "hPd", "STS", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()), 'T', screw.get(werkstoff.getBridgeMaterial()) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SCOOP, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SWS", "SSS", "xSh", 'S', stick.get(werkstoff.getBridgeMaterial()), 'W', + new ItemStack(Blocks.wool, 1, 32767) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.BRANCHCUTTER, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PfP", "PdP", "STS", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()), 'T', screw.get(werkstoff.getBridgeMaterial()) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.KNIFE, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "fPh", " S ", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.BUTCHERYKNIFE, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PPf", "PP ", "Sh ", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()) }); + + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_LV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 100000L, 32L, 1L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Lithium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_LV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 75000L, 32L, 1L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Cadmium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_LV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 50000L, 32L, 1L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Sodium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 400000L, 128L, 2L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Aluminium), 'B', + ItemList.Battery_RE_MV_Lithium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 300000L, 128L, 2L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Aluminium), 'B', + ItemList.Battery_RE_MV_Cadmium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 200000L, 128L, 2L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Aluminium), 'B', + ItemList.Battery_RE_MV_Sodium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1600000L, 512L, 3L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Lithium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1200000L, 512L, 3L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Cadmium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 800000L, 512L, 3L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Sodium.get(1L) }); + + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SCREWDRIVER_LV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 100000L, 32L, 1L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Lithium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SCREWDRIVER_LV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 75000L, 32L, 1L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Cadmium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SCREWDRIVER_LV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 50000L, 32L, 1L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Sodium.get(1L) }); + + GT_ModHandler.addCraftingRecipe( + GT_OreDictUnificator.get(toolHeadHammer, werkstoff.getBridgeMaterial(), 1L), + GT_Proxy.tBits, + new Object[] { "II ", "IIh", "II ", 'P', plate.get(werkstoff.getBridgeMaterial()), 'I', + ingot.get(werkstoff.getBridgeMaterial()) }); + if (werkstoff.hasItemType(plateDouble) && werkstoff.hasItemType(cellMolten)) { + GT_ModHandler.addCraftingRecipe( + GT_OreDictUnificator.get(turbineBlade, werkstoff.getBridgeMaterial(), 1L), + GT_Proxy.tBits, + new Object[] { "fPd", "SPS", " P ", 'P', plateDouble.get(werkstoff.getBridgeMaterial()), 'S', + screw.get(werkstoff.getBridgeMaterial()) }); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 6), ItemList.Shape_Extruder_Turbine_Blade.get(0)) + .itemOutputs(werkstoff.get(turbineBlade, 1)) + .duration( + (int) werkstoff.getStats() + .getMass() / 2 * 20) + .eut(TierEU.RECIPE_MV) + .addTo(extruderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Turbine_Blade.get(0)) + .itemOutputs(werkstoff.get(turbineBlade, 1)) + .fluidInputs(werkstoff.getMolten(864)) + .duration( + (int) werkstoff.getStats() + .getMass() * 20) + .eut(TierEU.RECIPE_MV) + .addTo(fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(plateDouble, 3), werkstoff.get(screw, 2)) + .itemOutputs(werkstoff.get(turbineBlade, 1)) + .duration( + (werkstoff.getStats() + .getMass() / 4) * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(turbineBlade, 4), GT_OreDictUnificator.get(stickLong, Materials.Magnalium, 1)) + .itemOutputs( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.TURBINE_SMALL, + 1, + werkstoff.getBridgeMaterial(), + Materials.Magnalium, + null)) + .duration(8 * SECONDS) + .eut(100) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(werkstoff.get(turbineBlade, 8), GT_OreDictUnificator.get(stickLong, Materials.Titanium, 1)) + .itemOutputs( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.TURBINE, + 1, + werkstoff.getBridgeMaterial(), + Materials.Titanium, + null)) + .duration(16 * SECONDS) + .eut(400) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + werkstoff.get(turbineBlade, 12), + GT_OreDictUnificator.get(stickLong, Materials.TungstenSteel, 1)) + .itemOutputs( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.TURBINE_LARGE, + 1, + werkstoff.getBridgeMaterial(), + Materials.TungstenSteel, + null)) + .duration(32 * SECONDS) + .eut(1600) + .addTo(assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + werkstoff.get(turbineBlade, 16), + GT_OreDictUnificator.get(stickLong, Materials.Americium, 1)) + .itemOutputs( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.TURBINE_HUGE, + 1, + werkstoff.getBridgeMaterial(), + Materials.Americium, + null)) + .duration(1 * MINUTES + 4 * SECONDS) + .eut(6400) + .addTo(assemblerRecipes); + } + + if (!werkstoff.hasItemType(gem)) { + GT_ModHandler.addCraftingRecipe( + GT_OreDictUnificator.get(toolHeadSaw, werkstoff.getBridgeMaterial(), 1L), + GT_Proxy.tBits, + new Object[] { "PP ", "fh ", 'P', plate.get(werkstoff.getBridgeMaterial()), 'I', + ingot.get(werkstoff.getBridgeMaterial()) }); + } + + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SCREWDRIVER_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 400000L, 128L, 2L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Titanium), 'B', + ItemList.Battery_RE_MV_Lithium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SCREWDRIVER_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 300000L, 128L, 2L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Titanium), 'B', + ItemList.Battery_RE_MV_Cadmium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SCREWDRIVER_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 200000L, 128L, 2L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Titanium), 'B', + ItemList.Battery_RE_MV_Sodium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SCREWDRIVER_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1600000L, 512L, 3L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Lithium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SCREWDRIVER_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1200000L, 512L, 3L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Cadmium.get(1L) }); + GT_ModHandler.addCraftingRecipe( + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + SCREWDRIVER_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 800000L, 512L, 3L, -1L }), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Sodium.get(1L) }); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/AssociationLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/AssociationLoader.java new file mode 100644 index 0000000000..c6eacb8ad2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/AssociationLoader.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.registration; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +public class AssociationLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + for (OrePrefixes prefixes : OrePrefixes.values()) { + if (!werkstoff.hasItemType(prefixes)) continue; + + Materials werkstoffBridgeMaterial = werkstoff.getBridgeMaterial(); + ItemStack stack = WerkstoffLoader.getCorrespondingItemStackUnsafe(prefixes, werkstoff, 1); + + if (stack != null && stack.getItem() != null) { + GT_OreDictUnificator.addAssociation(prefixes, werkstoffBridgeMaterial, stack, false); + GT_OreDictUnificator.set(prefixes, werkstoffBridgeMaterial, stack, true, true); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java new file mode 100644 index 0000000000..5dafebb48e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.registration; + +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.values; + +import java.util.ArrayList; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enchants.Enchantment_Radioactivity; +import gregtech.api.enums.Element; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; + +public class BridgeMaterialsLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + // int aMetaItemSubID, TextureSet aIconSet, float aToolSpeed, int aDurability, int aToolQuality, int aTypes, int + // aR, int aG, int aB, int aA, String aName, String aDefaultLocalName, int aFuelType, int aFuelPower, int + // aMeltingPoint, int aBlastFurnaceTemp, boolean aBlastFurnaceRequired, boolean aTransparent, int aOreValue, int + // aDensityMultiplier, int aDensityDivider, Dyes aColor, String aConfigSection, boolean aCustomOre, String + // aCustomID + Materials werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null ? werkstoff.getBridgeMaterial() + : Materials.get(werkstoff.getVarName()) != Materials._NULL ? Materials.get(werkstoff.getVarName()) + : new Materials( + -1, + werkstoff.getTexSet(), + werkstoff.getToolSpeed(), + werkstoff.getDurability(), + werkstoff.getToolQuality(), + 0, + werkstoff.getRGBA()[0], + werkstoff.getRGBA()[1], + werkstoff.getRGBA()[2], + werkstoff.getRGBA()[3], + werkstoff.getVarName(), + werkstoff.getDefaultName(), + 0, + 0, + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .isBlastFurnace(), + false, + 0, + 1, + 1, + null); + for (OrePrefixes prefixes : values()) { + if (prefixes != cell || !Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + if (prefixes == dust && Werkstoff.Types.ELEMENT.equals(werkstoff.getType()) + && Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + boolean ElementSet = false; + for (Element e : Element.values()) { + if (e.toString() + .equals(werkstoff.getToolTip())) { + if (!e.mLinkedMaterials.isEmpty()) break; + werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null + ? werkstoff.getBridgeMaterial() + : Materials.get(werkstoff.getVarName()) != Materials._NULL + ? Materials.get(werkstoff.getVarName()) + : new Materials( + -1, + werkstoff.getTexSet(), + werkstoff.getToolSpeed(), + werkstoff.getDurability(), + werkstoff.getToolQuality(), + 0, + werkstoff.getRGBA()[0], + werkstoff.getRGBA()[1], + werkstoff.getRGBA()[2], + werkstoff.getRGBA()[3], + werkstoff.getVarName(), + werkstoff.getDefaultName(), + 0, + 0, + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .isBlastFurnace(), + false, + 0, + 1, + 1, + null); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials = new ArrayList<>(); + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + if (werkstoff.hasItemType(dust)) { + GT_OreDictUnificator + .addAssociation(dust, werkstoffBridgeMaterial, werkstoff.get(dust), false); + GT_OreDictUnificator + .set(dust, werkstoffBridgeMaterial, werkstoff.get(dust), true, true); + } + ElementSet = true; + break; + } + } + if (!ElementSet) { + continue; + } + } + + if (werkstoff.hasItemType(cell)) { + werkstoffBridgeMaterial.setHasCorrespondingFluid(true); + werkstoffBridgeMaterial.setHasCorrespondingGas(true); + werkstoffBridgeMaterial.mFluid = werkstoff.getFluidOrGas(1) + .getFluid(); + werkstoffBridgeMaterial.mGas = werkstoff.getFluidOrGas(1) + .getFluid(); + } + + if (werkstoff.hasItemType(cellMolten)) { + werkstoffBridgeMaterial.mStandardMoltenFluid = werkstoff.getMolten(1) + .getFluid(); + } + werkstoffBridgeMaterial.mName = werkstoff.getVarName(); + werkstoffBridgeMaterial.mDefaultLocalName = werkstoff.getDefaultName(); + werkstoffBridgeMaterial.mChemicalFormula = werkstoff.getToolTip(); + if ("null".equals(werkstoffBridgeMaterial.mLocalizedName)) + // only reload from lang file if not localized already + werkstoffBridgeMaterial.mLocalizedName = GT_LanguageManager.addStringLocalization( + "Material." + werkstoffBridgeMaterial.mName.toLowerCase(), + werkstoffBridgeMaterial.mDefaultLocalName); + if (Thaumcraft.isModLoaded()) { + werkstoffBridgeMaterial.mAspects = werkstoff.getGTWrappedTCAspects(); + } + werkstoffBridgeMaterial.mMaterialInto = werkstoffBridgeMaterial; + werkstoffBridgeMaterial.mHandleMaterial = werkstoff.contains(SubTag.BURNING) ? Materials.Blaze + : werkstoff.contains(SubTag.MAGICAL) ? Materials.Thaumium + : werkstoffBridgeMaterial.mDurability > 5120 ? Materials.TungstenSteel + : werkstoffBridgeMaterial.mDurability > 1280 ? Materials.Steel : Materials.Wood; + if (werkstoff.getStats() + .isRadioactive()) { + werkstoffBridgeMaterial.setEnchantmentForArmors( + Enchantment_Radioactivity.INSTANCE, + werkstoff.getStats() + .getEnchantmentlvl()); + werkstoffBridgeMaterial.setEnchantmentForTools( + Enchantment_Radioactivity.INSTANCE, + werkstoff.getStats() + .getEnchantmentlvl()); + } + werkstoff.setBridgeMaterial(werkstoffBridgeMaterial); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/CasingRegistrator.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/CasingRegistrator.java new file mode 100644 index 0000000000..b2287b48b5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/CasingRegistrator.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.registration; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +public class CasingRegistrator implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + GT_OreDictUnificator.addAssociation( + OrePrefixes.blockCasing, + werkstoff.getBridgeMaterial(), + new ItemStack(WerkstoffLoader.BWBlockCasings, 1, werkstoff.getmID()), + false); + GT_OreDictUnificator.addAssociation( + OrePrefixes.blockCasingAdvanced, + werkstoff.getBridgeMaterial(), + new ItemStack(WerkstoffLoader.BWBlockCasingsAdvanced, 1, werkstoff.getmID()), + false); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java new file mode 100644 index 0000000000..85f56cb7a9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oredict; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.bartworks.util.Pair; + +import gregtech.api.util.GT_OreDictUnificator; + +public class OreDictAdder { + + private static final ConcurrentHashMap toAddMap = new ConcurrentHashMap<>(); + + public static synchronized void addToMap(Pair element) { + OreDictAdder.toAddMap.put(element.getKey(), element.getValue()); + } + + @SafeVarargs + public static synchronized void addToMap(Pair... elements) { + for (Pair p : elements) OreDictAdder.toAddMap.put(p.getKey(), p.getValue()); + } + + public static void addToOreDict() { + for (Map.Entry entry : OreDictAdder.toAddMap.entrySet()) { + GT_OreDictUnificator.registerOre(entry.getKey(), entry.getValue()); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java new file mode 100644 index 0000000000..683b55b333 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oredict; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +public class OreDictHandler { + + private static final HashMap> cache = new HashMap<>(); + private static final HashSet> cacheNonBW = new HashSet<>(); + + public static HashMap> getCache() { + return OreDictHandler.cache; + } + + public static HashSet> getNonBWCache() { + return OreDictHandler.cacheNonBW; + } + + public static void adaptCacheForWorld() { + Set used = new HashSet<>(OreDictHandler.cache.keySet()); + OreDictHandler.cache.clear(); + OreDictHandler.cacheNonBW.clear(); + for (String s : used) { + if (!OreDictionary.getOres(s) + .isEmpty()) { + ItemStack tmpstack = OreDictionary.getOres(s) + .get(0) + .copy(); + Pair p = new Pair<>( + Item.getIdFromItem(tmpstack.getItem()), + (short) tmpstack.getItemDamage()); + OreDictHandler.cache.put(s, p); + for (ItemStack tmp : OreDictionary.getOres(s)) { + Pair p2 = new Pair<>( + Item.getIdFromItem(tmp.getItem()), + (short) tmp.getItemDamage()); + GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); + if (UI == null) UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); + if (!MainMod.MOD_ID.equals(UI.modId) && !BartWorksCrossmod.MOD_ID.equals(UI.modId) + && !"BWCore".equals(UI.modId)) { + OreDictHandler.cacheNonBW.add(p2); + } + } + } + } + } + + public static ItemStack getItemStack(String elementName, OrePrefixes prefixes, int amount) { + if (OreDictHandler.cache.get(prefixes + elementName.replace(" ", "")) != null) { + Pair p = OreDictHandler.cache.get(prefixes + elementName.replace(" ", "")); + return new ItemStack(Item.getItemById(p.getKey()), amount, p.getValue()); + } + if (!OreDictionary.getOres(prefixes + elementName.replace(" ", "")) + .isEmpty()) { + ItemStack tmp = GT_OreDictUnificator.get( + OreDictionary.getOres(prefixes + elementName.replace(" ", "")) + .get(0) + .copy()) + .copy(); + OreDictHandler.cache.put( + prefixes + elementName.replace(" ", ""), + new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage())); + tmp.stackSize = amount; + return tmp; + } + return null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java new file mode 100644 index 0000000000..3305741f27 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oregen; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_SmallOres; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.google.common.collect.ArrayListMultimap; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.world.GT_Worldgen; +import gregtech.common.blocks.GT_TileEntity_Ores; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public abstract class BW_OreLayer extends GT_Worldgen { + + public static final List sList = new ArrayList<>(); + public static final ArrayListMultimap NEIMAP = ArrayListMultimap.create(); + private static final boolean logOregenRoss128 = false; + public static int sWeight; + public byte bwOres; + public int mMinY, mWeight, mDensity, mSize, mMaxY, mPrimaryMeta, mSecondaryMeta, mBetweenMeta, mSporadicMeta; + + public abstract Block getDefaultBlockToReplace(); + + public abstract int[] getDefaultDamageToReplace(); + + public abstract String getDimName(); + + public BW_OreLayer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, + ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, ISubTagContainer sprinkled) { + super(aName, BW_OreLayer.sList, aDefault); + this.mMinY = (short) aMinY; + this.mMaxY = (short) aMaxY; + this.mWeight = (short) aWeight; + this.mDensity = (short) aDensity; + this.mSize = (short) Math.max(1, aSize); + + if (this.mEnabled) BW_OreLayer.sWeight += this.mWeight; + + if (top instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b1000); + if (bottom instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b0100); + if (between instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b0010); + if (sprinkled instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b0001); + + short aPrimary = top instanceof Materials ? (short) ((Materials) top).mMetaItemSubID + : top instanceof Werkstoff ? ((Werkstoff) top).getmID() : 0; + short aSecondary = bottom instanceof Materials ? (short) ((Materials) bottom).mMetaItemSubID + : bottom instanceof Werkstoff ? ((Werkstoff) bottom).getmID() : 0; + short aBetween = between instanceof Materials ? (short) ((Materials) between).mMetaItemSubID + : between instanceof Werkstoff ? ((Werkstoff) between).getmID() : 0; + short aSporadic = sprinkled instanceof Materials ? (short) ((Materials) sprinkled).mMetaItemSubID + : sprinkled instanceof Werkstoff ? ((Werkstoff) sprinkled).getmID() : 0; + this.mPrimaryMeta = aPrimary; + this.mSecondaryMeta = aSecondary; + this.mBetweenMeta = aBetween; + this.mSporadicMeta = aSporadic; + NEIMAP.put((short) this.mPrimaryMeta, this); + NEIMAP.put((short) this.mSecondaryMeta, this); + NEIMAP.put((short) this.mBetweenMeta, this); + NEIMAP.put((short) this.mSporadicMeta, this); + } + + public List getStacks() { + ArrayList ret = new ArrayList<>(); + ret.add( + (this.bwOres & 0b1000) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mPrimaryMeta) + : new ItemStack(GregTech_API.sBlockOres1, 1, this.mPrimaryMeta)); + ret.add( + (this.bwOres & 0b0100) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mSecondaryMeta) + : new ItemStack(GregTech_API.sBlockOres1, 1, this.mSecondaryMeta)); + ret.add( + (this.bwOres & 0b0010) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mBetweenMeta) + : new ItemStack(GregTech_API.sBlockOres1, 1, this.mBetweenMeta)); + ret.add( + (this.bwOres & 0b0001) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mSporadicMeta) + : new ItemStack(GregTech_API.sBlockOres1, 1, this.mSporadicMeta)); + return ret; + } + + public List> getStacksRawData() { + ArrayList> ret = new ArrayList<>(); + ret.add(new Pair<>(this.mPrimaryMeta, (this.bwOres & 0b1000) != 0)); + ret.add(new Pair<>(this.mSecondaryMeta, (this.bwOres & 0b0100) != 0)); + ret.add(new Pair<>(this.mBetweenMeta, (this.bwOres & 0b0010) != 0)); + ret.add(new Pair<>(this.mSporadicMeta, (this.bwOres & 0b0001) != 0)); + return ret; + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, + int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + { + int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); + int cX = aChunkX - aRandom.nextInt(this.mSize); + int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); + + boolean wasPlaced = false; + + for (int tX = cX; tX <= eX; ++tX) { + int cZ = aChunkZ - aRandom.nextInt(this.mSize); + int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); + + for (int tZ = cZ; tZ <= eZ; ++tZ) { + int i; + if (this.mSecondaryMeta > 0) { + for (i = tMinY - 1; i < tMinY + 2; ++i) { + if (this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + } + } + } + + if (this.mBetweenMeta > 0 && this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this + .setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + } + + if (this.mPrimaryMeta > 0) { + for (i = tMinY + 3; i < tMinY + 6; ++i) { + if (this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + } + } + } + + if (this.mSporadicMeta > 0 && this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this + .setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + + if (BW_OreLayer.logOregenRoss128) { + MainMod.LOGGER.info("Generated Orevein: " + this.mWorldGenName + " " + aChunkX + " " + aChunkZ); + } + + return wasPlaced; + } + } + + private boolean shouldPlace(Random aRandom, int cX, int eX, int tX, int cZ, int eZ, int tZ) { + if (aRandom.nextInt( + Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 + || aRandom.nextInt( + Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) + return true; + return false; + } + + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { + // security stuff to prevent crashes with 2 TileEntites on the same Spot + TileEntity te = aWorld.getTileEntity(aX, aY, aZ); + if (te instanceof BW_MetaGeneratedOreTE || te instanceof GT_TileEntity_Ores) return true; + + if (aMetaData == this.mSporadicMeta && (this.bwOres & 0b0001) != 0 + || aMetaData == this.mBetweenMeta && (this.bwOres & 0b0010) != 0 + || aMetaData == this.mPrimaryMeta && (this.bwOres & 0b1000) != 0 + || aMetaData == this.mSecondaryMeta && (this.bwOres & 0b0100) != 0) { + return isSmallOre + ? BW_MetaGenerated_SmallOres.setOreBlock( + aWorld, + aX, + aY, + aZ, + aMetaData, + false, + this.getDefaultBlockToReplace(), + this.getDefaultDamageToReplace()) + : BW_MetaGenerated_Ores.setOreBlock( + aWorld, + aX, + aY, + aZ, + aMetaData, + false, + this.getDefaultBlockToReplace(), + this.getDefaultDamageToReplace()); + } + + return this.setGTOreBlockSpace(aWorld, aX, aY, aZ, aMetaData, this.getDefaultBlockToReplace()); + } + + public boolean setGTOreBlockSpace(World aWorld, int aX, int aY, int aZ, int aMetaData, Block block) { + if (GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false, false)) return true; + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = GregTech_API.sBlockOres1; + if (aMetaData < 0 || tBlock == Blocks.air) { + return false; + } else { + if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, block)) { + return false; + } + aMetaData += 5000; + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof GT_TileEntity_Ores ore) { + ore.mMetaData = (short) aMetaData; + } + return true; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BW_OreLayer that)) return false; + + if (this.bwOres != that.bwOres || this.mMinY != that.mMinY + || this.mWeight != that.mWeight + || this.mDensity != that.mDensity) return false; + if (this.mSize != that.mSize) return false; + if (this.mMaxY != that.mMaxY) return false; + if (this.mPrimaryMeta != that.mPrimaryMeta) return false; + if (this.mSecondaryMeta != that.mSecondaryMeta) return false; + if (this.mBetweenMeta != that.mBetweenMeta) return false; + return this.mSporadicMeta == that.mSporadicMeta; + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(37) + .put(this.bwOres) + .putInt(this.mMinY) + .putInt(this.mWeight) + .putInt(this.mDensity) + .putInt(this.mSize) + .putInt(this.mMaxY) + .putInt(this.mPrimaryMeta) + .putInt(this.mSecondaryMeta) + .putInt(this.mBetweenMeta) + .putInt(this.mSporadicMeta) + .array(), + 0, + 37, + 31); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java new file mode 100644 index 0000000000..40c2302fb0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oregen; + +import java.util.HashSet; +import java.util.Random; + +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; + +import cpw.mods.fml.common.IWorldGenerator; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_Log; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public class BW_WordGenerator implements IWorldGenerator { + + public BW_WordGenerator() { + // GT_NH Override... wont be actually registered to force its generation directly in the ChunkProvider + // GameRegistry.registerWorldGenerator(this, 1073741823); + } + + public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + new BW_WordGenerator.WorldGenContainer( + aX * 16, + aZ * 16, + aWorld.provider.dimensionId, + aWorld, + aChunkGenerator, + aChunkProvider).run(); + } + + public static class WorldGenContainer implements Runnable { + + public static HashSet mGenerated = new HashSet<>(2000); + public final int mDimensionType; + public final World mWorld; + public final IChunkProvider mChunkGenerator; + public final IChunkProvider mChunkProvider; + public int mX; + public int mZ; + + public WorldGenContainer(int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + this.mX = aX; + this.mZ = aZ; + this.mDimensionType = aDimensionType; + this.mWorld = aWorld; + this.mChunkGenerator = aChunkGenerator; + this.mChunkProvider = aChunkProvider; + } + + // returns a coordinate of a center chunk of 3x3 square; the argument belongs to this square + public int getVeinCenterCoordinate(int c) { + c += c < 0 ? 1 : 3; + return c - c % 3 - 2; + } + + public boolean surroundingChunksLoaded(int xCenter, int zCenter) { + return this.mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); + } + + public XSTR getRandom(int xChunk, int zChunk) { + long worldSeed = this.mWorld.getSeed(); + XSTR fmlRandom = new XSTR(worldSeed); + long xSeed = fmlRandom.nextLong() >> 2 + 1L; + long zSeed = fmlRandom.nextLong() >> 2 + 1L; + long chunkSeed = xSeed * xChunk + zSeed * zChunk ^ worldSeed; + fmlRandom.setSeed(chunkSeed); + return new XSTR(fmlRandom.nextInt()); + } + + public void run() { + int xCenter = this.getVeinCenterCoordinate(this.mX >> 4); + int zCenter = this.getVeinCenterCoordinate(this.mZ >> 4); + Random random = this.getRandom(xCenter, zCenter); + xCenter <<= 4; + zCenter <<= 4; + ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter); + if (!BW_WordGenerator.WorldGenContainer.mGenerated.contains(centerChunk) + && this.surroundingChunksLoaded(xCenter, zCenter)) { + BW_WordGenerator.WorldGenContainer.mGenerated.add(centerChunk); + if (BW_OreLayer.sWeight > 0 && BW_OreLayer.sList.size() > 0) { + boolean temp = true; + int tRandomWeight; + for (int i = 0; i < 256 && temp; i++) { + tRandomWeight = random.nextInt(BW_OreLayer.sWeight); + for (BW_OreLayer tWorldGen : BW_OreLayer.sList) { + if (!tWorldGen.isGenerationAllowed(this.mWorld, this.mDimensionType, this.mDimensionType)) + continue; + tRandomWeight -= tWorldGen.mWeight; + if (tRandomWeight <= 0) { + try { + boolean placed; + int attempts = 0; + do { + placed = tWorldGen.executeWorldgen( + this.mWorld, + random, + "", + this.mDimensionType, + xCenter, + zCenter, + this.mChunkGenerator, + this.mChunkProvider); + ++attempts; + } while (!placed && attempts < 25); + temp = false; + break; + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + } + } + } + } + } + Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); + if (tChunk != null) { + tChunk.isModified = true; + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java new file mode 100644 index 0000000000..6e0f0543e4 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oregen; + +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Arsenopyrite; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Bismuthinit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Bismutite; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Bornite; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.ChromoAluminoPovondrait; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.DescloiziteCUVO4; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.DescloiziteZNVO4; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Djurleit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Fayalit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Ferberite; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.FluorBuergerit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Forsterit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.FuchsitAL; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.FuchsitCR; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Hedenbergit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Huebnerit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Loellingit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Olenit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RedZircon; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Roquesit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Thorianit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.VanadioOxyDravit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Wittichenit; +import static com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy.uo_dimensionList; +import static gregtech.api.enums.Materials.Bismuth; +import static gregtech.api.enums.Materials.Coal; +import static gregtech.api.enums.Materials.Diamond; +import static gregtech.api.enums.Materials.Graphite; +import static gregtech.api.enums.Materials.Lepidolite; +import static gregtech.api.enums.Materials.Scheelite; +import static gregtech.api.enums.Materials.Spodumene; +import static gregtech.api.enums.Materials.Stibnite; +import static gregtech.api.enums.Materials.Tetrahedrite; +import static gregtech.api.enums.Materials.Uraninite; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidRegistry; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + +import gregtech.api.interfaces.ISubTagContainer; + +public class BW_WorldGenRoss128b extends BW_OreLayer { + + @Override + public Block getDefaultBlockToReplace() { + return Blocks.stone; + } + + @Override + public int[] getDefaultDamageToReplace() { + return new int[] { 0 }; + } + + @Override + public String getDimName() { + return StatCollector.translateToLocal("planet.Ross128b"); + } + + public BW_WorldGenRoss128b(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, + int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, + ISubTagContainer sprinkled) { + super(aName, aDefault, aMinY, aMaxY, aWeight, aDensity, aSize, top, bottom, between, sprinkled); + } + + public static void initOres() { + new BW_WorldGenRoss128b( + "ore.mix.ross128.Thorianit", + true, + 30, + 60, + 17, + 1, + 16, + Thorianit, + Uraninite, + Lepidolite, + Spodumene); + new BW_WorldGenRoss128b("ore.mix.ross128.carbon", true, 5, 25, 5, 4, 12, Graphite, Diamond, Coal, Graphite); + new BW_WorldGenRoss128b( + "ore.mix.ross128.bismuth", + true, + 5, + 80, + 30, + 1, + 16, + Bismuthinit, + Stibnite, + Bismuth, + Bismutite); + new BW_WorldGenRoss128b( + "ore.mix.ross128.TurmalinAlkali", + true, + 5, + 80, + 15, + 4, + 48, + Olenit, + FluorBuergerit, + ChromoAluminoPovondrait, + VanadioOxyDravit); + new BW_WorldGenRoss128b( + "ore.mix.ross128.Roquesit", + true, + 30, + 50, + 3, + 1, + 12, + Arsenopyrite, + Ferberite, + Loellingit, + Roquesit); + new BW_WorldGenRoss128b( + "ore.mix.ross128.Tungstate", + true, + 5, + 40, + 10, + 4, + 14, + Ferberite, + Huebnerit, + Loellingit, + Scheelite); + new BW_WorldGenRoss128b( + "ore.mix.ross128.CopperSulfits", + true, + 40, + 70, + 80, + 3, + 24, + Djurleit, + Bornite, + Wittichenit, + Tetrahedrite); + new BW_WorldGenRoss128b( + "ore.mix.ross128.Forsterit", + true, + 20, + 90, + 50, + 2, + 32, + Forsterit, + Fayalit, + DescloiziteCUVO4, + DescloiziteZNVO4); + new BW_WorldGenRoss128b( + "ore.mix.ross128.Hedenbergit", + true, + 20, + 90, + 50, + 2, + 32, + Hedenbergit, + Fayalit, + DescloiziteCUVO4, + DescloiziteZNVO4); + new BW_WorldGenRoss128b( + "ore.mix.ross128.RedZircon", + true, + 10, + 80, + 40, + 3, + 24, + Fayalit, + FuchsitAL, + RedZircon, + FuchsitCR); + } + + public static void initundergroundFluids() { + String ross128b = StatCollector.translateToLocal("planet.Ross128b"); + uo_dimensionList.SetConfigValues(ross128b, ross128b, "veryheavyoil", "liquid_extra_heavy_oil", 0, 625, 40, 5); + uo_dimensionList + .SetConfigValues(ross128b, ross128b, "lava", FluidRegistry.getFluidName(FluidRegistry.LAVA), 0, 820, 5, 5); + uo_dimensionList.SetConfigValues(ross128b, ross128b, "gas_natural_gas", "gas_natural_gas", 0, 625, 65, 5); + } + + @Override + public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { + return aDimensionType == ConfigHandler.ross128BID; + } + + @Override + public boolean isGenerationAllowed(String aDimName, int aDimensionType, int aAllowedDimensionType) { + return aDimensionType == ConfigHandler.ross128BID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128ba.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128ba.java new file mode 100644 index 0000000000..7454b0dd93 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128ba.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oregen; + +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.BArTiMaEuSNeK; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Bornite; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.ChromoAluminoPovondrait; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Djurleit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Fayalit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Ferberite; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.FluorBuergerit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Fluorspar; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.FuchsitAL; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.FuchsitCR; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Hedenbergit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Huebnerit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Loellingit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Olenit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Prasiolite; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.RedZircon; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Tiberium; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.VanadioOxyDravit; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.Wittichenit; +import static com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy.uo_dimensionList; +import static gregtech.api.enums.Materials.Amethyst; +import static gregtech.api.enums.Materials.Barite; +import static gregtech.api.enums.Materials.Galena; +import static gregtech.api.enums.Materials.Helium_3; +import static gregtech.api.enums.Materials.NaquadahEnriched; +import static gregtech.api.enums.Materials.Olivine; +import static gregtech.api.enums.Materials.SaltWater; +import static gregtech.api.enums.Materials.Scheelite; +import static gregtech.api.enums.Materials.Sphalerite; +import static gregtech.api.enums.Materials.Tetrahedrite; + +import net.minecraft.block.Block; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + +import gregtech.api.interfaces.ISubTagContainer; + +public class BW_WorldGenRoss128ba extends BW_OreLayer { + + public BW_WorldGenRoss128ba(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, + int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, + ISubTagContainer sprinkled) { + super(aName, aDefault, aMinY, aMaxY, aWeight, aDensity, aSize, top, bottom, between, sprinkled); + } + + @Override + public Block getDefaultBlockToReplace() { + return Block.getBlockFromName("GalacticraftCore:tile.moonBlock"); + } + + @Override + public int[] getDefaultDamageToReplace() { + int[] ret = new int[12]; + for (int i = 0; i < 12; i++) { + if (i != 5 && i != 3) ret[i] = i; + } + return ret; + } + + @Override + public String getDimName() { + return StatCollector.translateToLocal("moon.Ross128ba"); + } + + public static void init_Ores() { + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.tib", + true, + 30, + 60, + 6, + 1, + 16, + Tiberium, + Tiberium, + NaquadahEnriched, + NaquadahEnriched); + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.Tungstate", + true, + 5, + 40, + 60, + 4, + 14, + Ferberite, + Huebnerit, + Loellingit, + Scheelite); + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.bart", + true, + 30, + 60, + 1, + 1, + 1, + BArTiMaEuSNeK, + BArTiMaEuSNeK, + BArTiMaEuSNeK, + BArTiMaEuSNeK); + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.TurmalinAlkali", + true, + 5, + 80, + 60, + 4, + 48, + Olenit, + FluorBuergerit, + ChromoAluminoPovondrait, + VanadioOxyDravit); + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.Amethyst", + true, + 5, + 80, + 35, + 2, + 8, + Amethyst, + Olivine, + Prasiolite, + Hedenbergit); + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.CopperSulfits", + true, + 40, + 70, + 80, + 3, + 24, + Djurleit, + Bornite, + Wittichenit, + Tetrahedrite); + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.RedZircon", + true, + 10, + 80, + 40, + 3, + 24, + Fayalit, + FuchsitAL, + RedZircon, + FuchsitCR); + new BW_WorldGenRoss128ba( + "ore.mix.ross128ba.Fluorspar", + true, + 10, + 80, + 35, + 4, + 8, + Galena, + Sphalerite, + Fluorspar, + Barite); + } + + public static void init_undergroundFluids() { + String ross128b = StatCollector.translateToLocal("moon.Ross128ba"); + uo_dimensionList.SetConfigValues( + ross128b, + ross128b, + SaltWater.getFluid(1) + .getFluid() + .getName(), + SaltWater.getFluid(1) + .getFluid() + .getName(), + 0, + 1250, + 40, + 5); + uo_dimensionList.SetConfigValues( + ross128b, + ross128b, + Helium_3.getGas(1) + .getFluid() + .getName(), + Helium_3.getGas(1) + .getFluid() + .getName(), + 0, + 1250, + 60, + 5); + } + + @Override + public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { + return aDimensionType == ConfigHandler.ross128BAID; + } + + @Override + public boolean isGenerationAllowed(String aDimName, int aDimensionType, int aAllowedDimensionType) { + return aDimensionType == ConfigHandler.ross128BAID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java new file mode 100644 index 0000000000..7d599b441a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.worldgen; + +import java.util.Random; + +import net.minecraft.block.Block; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + +import gregtech.api.GregTech_API; + +public class GT_WorldgenUtil { + + private GT_WorldgenUtil() {} + + public static final Block GT_TILES = GregTech_API.sBlockMachines; + + public static short getGenerator(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[0][tier][rand.nextInt(ConfigHandler.metasForTiers[0][tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? (short) meta : GT_WorldgenUtil.getGenerator(rand, tier); + } + + public static short getBuffer(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[1][tier][rand.nextInt(ConfigHandler.metasForTiers[1][tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? (short) meta : GT_WorldgenUtil.getBuffer(rand, tier); + } + + public static short getCable(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[2][tier][rand.nextInt(ConfigHandler.metasForTiers[2][tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? (short) meta : GT_WorldgenUtil.getCable(rand, tier); + } + + public static short getMachine(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[3][tier][rand.nextInt(ConfigHandler.metasForTiers[3][tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? (short) meta : GT_WorldgenUtil.getMachine(rand, tier); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java new file mode 100644 index 0000000000..ef6b88cc5a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java @@ -0,0 +1,502 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.worldgen; + +import static com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler.maxTierRoss; +import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST; + +import java.security.SecureRandom; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.util.Pair; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.XSTR; +import gregtech.api.threads.GT_Runnable_MachineBlockUpdate; + +public abstract class MapGenRuins extends WorldGenerator { + + @SuppressWarnings("unchecked") + protected Pair[][] ToBuildWith = new Pair[4][0]; + + @Override + public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) { + return false; + } + + @SuppressWarnings("unchecked") + protected void setFloorBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[0] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[0][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + @SuppressWarnings("unchecked") + protected void setWallBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[1] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[1][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + @SuppressWarnings("unchecked") + protected void setRoofBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[2] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[2][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + @SuppressWarnings("unchecked") + protected void setMiscBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[3] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[3][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + int[] statBlocks = new int[4]; + + protected void setRandomBlockWAirChance(World worldObj, int x, int y, int z, Random rand, int airchance, + Pair... blocks) { + if (rand.nextInt(100) > airchance) this.setRandomBlock(worldObj, x, y, z, rand, blocks); + else this.setBlock(worldObj, x, y, z, Blocks.air, 0); + } + + protected void setRandomBlock(World worldObj, int x, int y, int z, Random rand, Pair... blocks) { + Block toSet = blocks[rand.nextInt(blocks.length)].getKey(); + int meta = blocks[rand.nextInt(blocks.length)].getValue(); + this.setBlock(worldObj, x, y, z, toSet, meta); + } + + protected void setBlock(World worldObj, int x, int y, int z, Block block, int meta) { + this.setBlockAndNotifyAdequately(worldObj, x, y, z, block, meta); + } + + protected void setBlock(World worldObj, int x, int y, int z, Pair pair) { + this.setBlockAndNotifyAdequately(worldObj, x, y, z, pair.getKey(), pair.getValue()); + } + + private TileEntity setGTMachineBlock(World worldObj, int x, int y, int z, int meta) { + boolean isEnabled = true; + try { + isEnabled = GT_Runnable_MachineBlockUpdate.isEnabled(); + } catch (Throwable ignored) { + isEnabled = false; + } + if (isEnabled) + throw new IllegalStateException("Machine Block Runnable needs to be disabled while creating world!"); + this.setBlockAndNotifyAdequately( + worldObj, + x, + y, + z, + GT_WorldgenUtil.GT_TILES, + GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); + TileEntity tile = worldObj.getTileEntity(x, y, z); + ((IGregTechTileEntity) tile).setInitialValuesAsNBT(null, (short) meta); + return tile; + } + + protected TileEntity reSetGTTileEntity(IGregTechTileEntity bte, World worldObj, int x, int y, int z, int meta) { + worldObj.removeTileEntity(x, y, z); + this.setBlock(worldObj, x, y, z, Blocks.air, 0); + return this.setGTMachineBlock(worldObj, x, y, z, meta); + } + + protected void setGTMachineBlockWChance(World worldObj, int x, int y, int z, Random rand, int airchance, int meta) { + if (rand.nextInt(100) > airchance) { + this.setGTMachineBlock(worldObj, x, y, z, meta); + } else this.setBlock(worldObj, x, y, z, Blocks.air, 0); + } + + protected void setGTCablekWChance(World worldObj, int x, int y, int z, Random rand, int airchance, int meta) { + if (rand.nextInt(100) > airchance) { + this.setGTCable(worldObj, x, y, z, meta); + } else this.setBlock(worldObj, x, y, z, Blocks.air, 0); + } + + protected void setGTMachine(World worldObj, int x, int y, int z, int meta, String ownerName, + ForgeDirection facing) { + try { + GT_Runnable_MachineBlockUpdate.setDisabled(); + } catch (Throwable ignored) {} + this.setGTMachineBlock(worldObj, x, y, z, meta); + BaseMetaTileEntity BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); + BTE.setOwnerName(ownerName); + BTE.setFrontFacing(facing); + BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); + this.checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, 0); + try { + GT_Runnable_MachineBlockUpdate.setEnabled(); + } catch (Throwable ignored) {} + } + + private void checkTile(BaseMetaTileEntity BTE, World worldObj, int x, int y, int z, int meta, String ownerName, + ForgeDirection facing, int depth) { + if (depth < 25) { + if (BTE.getMetaTileID() != meta || worldObj.getTileEntity(x, y, z) != BTE || BTE.isInvalid()) { + this.redoTile(BTE, worldObj, x, y, z, meta, ownerName, facing); + this.checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, depth); + depth++; + } + } else { + worldObj.removeTileEntity(x, y, z); + worldObj.setBlockToAir(x, y, z); + } + } + + private void redoTile(BaseMetaTileEntity BTE, World worldObj, int x, int y, int z, int meta, String ownerName, + ForgeDirection facing) { + this.reSetGTTileEntity(BTE, worldObj, x, y, z, meta); + BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); + BTE.setOwnerName(ownerName); + BTE.setFrontFacing(facing); + } + + protected void setGTCable(World worldObj, int x, int y, int z, int meta) { + try { + GT_Runnable_MachineBlockUpdate.setDisabled(); + } catch (Throwable ignored) {} + BaseMetaPipeEntity BTE = (BaseMetaPipeEntity) this.setGTMachineBlock(worldObj, x, y, z, meta); + MetaPipeEntity MPE = (MetaPipeEntity) BTE.getMetaTileEntity(); + BTE.mConnections |= (byte) (1 << (byte) 4); + BTE.mConnections |= (byte) (1 << ForgeDirection.getOrientation(4) + .getOpposite() + .ordinal()); + BaseMetaTileEntity BPE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z - 1); + if (BPE != null) { + BTE.mConnections |= (byte) (1 << (byte) 2); + } + MPE.mConnections = BTE.mConnections; + try { + GT_Runnable_MachineBlockUpdate.setEnabled(); + } catch (Throwable ignored) {} + } + + public static class RuinsBase extends MapGenRuins { + + private static final String owner = "Ancient Cultures"; + + @Override + public boolean generate(World worldObj, Random rand1, int x, int y, int z) { + + for (int i = 0; i < rand1.nextInt(144); i++) { + rand1.nextLong(); + } + + Random rand = new XSTR(rand1.nextLong()); + SecureRandom secureRandom = new SecureRandom(); + + if (worldObj.getBlock(x, y, z) == Blocks.air) { + while (worldObj.getBlock(x, y, z) == Blocks.air) { + y--; + } + } + + this.setFloorBlocks(new int[] { 0, 0, 0 }, Blocks.brick_block, Blocks.double_stone_slab, Blocks.stonebrick); + this.setWallBlocks(new int[] { 0, 1, 2, 1, 1 }, Blocks.stonebrick); + this.setRoofBlocks(new int[] { 9 }, Blocks.log); + this.setMiscBlocks(new int[] { 1 }, Blocks.log); + this.statBlocks = new int[] { rand.nextInt(this.ToBuildWith[0].length) }; + int colored = rand.nextInt(15); + int tier = secureRandom.nextInt(maxTierRoss); + boolean useColor = rand.nextBoolean(); + byte set = 0; + byte toSet = (byte) (rand.nextInt(maxTierRoss - tier) + 1); + short cablemeta = GT_WorldgenUtil.getCable(secureRandom, tier); + byte treeinaRow = 0; + boolean lastset = rand.nextBoolean(); + for (int dx = -6; dx <= 6; dx++) { + for (int dy = 0; dy <= 8; dy++) { + for (int dz = -6; dz <= 6; dz++) { + this.setBlock(worldObj, x + dx, y + dy, z + dz, Blocks.air, 0); + if (dy == 0) { + Pair floor = this.ToBuildWith[0][this.statBlocks[0]]; + this.setBlock(worldObj, x + dx, y + 0, z + dz, floor.getKey(), floor.getValue()); + } else if (dy > 0 && dy < 4) { + if (Math.abs(dx) == 5 && Math.abs(dz) == 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 5, + this.ToBuildWith[3][0]); + } else if (dx == 0 && dz == -5 && (dy == 1 || dy == 2)) { + if (dy == 1) { + this.setBlock(worldObj, x + dx, y + 1, z + -5, Blocks.iron_door, 1); + } + if (dy == 2) { + this.setBlock(worldObj, x + dx, y + 2, z + dz, Blocks.iron_door, 8); + } + } else if (Math.abs(dx) == 5 && Math.abs(dz) < 5 || Math.abs(dz) == 5 && Math.abs(dx) < 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + if (dy == 2 && rand.nextInt(100) < 12) { + if (useColor) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 2, + z + dz, + rand, + 25, + new Pair<>(Blocks.stained_glass_pane, colored)); + } + } else { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + new Pair<>(Blocks.glass_pane, 0)); + } + } + + if (dy == 3 && Math.abs(dx) == 6) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 3, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + } + + if (dy == 1) { + if (dx == 3 && dz == -3) { + this.setBlock(worldObj, x + 3, y + 1, z + dz, Blocks.crafting_table, 0); + } + if (dx == -3 && (dz == -3 || dz == -2)) { + this.setBlock(worldObj, x + -3, y + dy, z + dz, Blocks.chest, 5); + IInventory chest = (IInventory) worldObj.getTileEntity(x + dx, y + dy, z + dz); + if (chest != null) { + WeightedRandomChestContent.generateChestContents( + secureRandom, + ChestGenHooks.getItems(PYRAMID_JUNGLE_CHEST, rand), + chest, + ChestGenHooks.getCount(PYRAMID_JUNGLE_CHEST, rand)); + } + } + + if (dx == 4 && dz == 4) { + short meta = GT_WorldgenUtil.getGenerator(secureRandom, tier); + this.setGTMachine( + worldObj, + x + dx, + y + dy, + z + dz, + meta, + owner, + tier > 0 ? ForgeDirection.WEST : ForgeDirection.UP); + } else if (dx == 3 && dz == 4) { + if (tier > 0) { + short meta = GT_WorldgenUtil.getBuffer(secureRandom, tier); + this.setGTMachine( + worldObj, + x + dx, + y + dy, + z + dz, + meta, + owner, + ForgeDirection.WEST); + } else { + this.setGTCablekWChance(worldObj, x + dx, y + dy, z + dz, rand, 33, cablemeta); + } + } else if (dx < 3 && dx > -5 && dz == 4) { + this.setGTCablekWChance(worldObj, x + dx, y + dy, z + dz, rand, 33, cablemeta); + } else if (dx < 3 && dx > -5 && dz == 3 && set < toSet) { + if (!lastset || treeinaRow > 2) { + short meta = GT_WorldgenUtil.getMachine(secureRandom, tier); + this.setGTMachine( + worldObj, + x + dx, + y + dy, + z + dz, + meta, + owner, + ForgeDirection.UP); + + set++; + treeinaRow = 0; + lastset = true; + } else { + lastset = rand.nextBoolean(); + if (lastset) treeinaRow++; + } + } + } + } else switch (dy) { + case 4: + if (Math.abs(dx) == 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 4, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 5: + if (Math.abs(dx) == 4) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 5, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 4) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 6: + if (Math.abs(dx) == 3) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 6, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 3) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 7: + if (Math.abs(dx) == 2) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 7, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 2) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 8: + if (Math.abs(dx) == 1 || Math.abs(dx) == 0) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 8, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + } + break; + default: + break; + } + } + } + } + tosetloop: while (set < toSet) { + int dy = 1; + int dz = 3; + for (int dx = 2; dx > -5; dx--) { + if (set >= toSet) { + break tosetloop; + } + if (!lastset || treeinaRow > 2 && worldObj.getTileEntity(x + dx, y + dy, z + dz) == null) { + short meta = GT_WorldgenUtil.getMachine(secureRandom, tier); + this.setGTMachine(worldObj, x + dx, y + dy, z + dz, meta, owner, ForgeDirection.UP); + + set++; + treeinaRow = 0; + lastset = true; + } else { + lastset = rand.nextBoolean(); + if (lastset) { + treeinaRow++; + } + } + } + } + return true; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java new file mode 100644 index 0000000000..aec0972a67 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import static com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps.bacterialVatRecipes; +import static com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps.bioLabRecipes; +import static com.github.bartimaeusnek.bartworks.API.recipe.BartWorksRecipeMaps.radioHatchRecipes; +import static com.github.bartimaeusnek.bartworks.util.BW_Util.calculateSv; +import static com.github.bartimaeusnek.bartworks.util.BW_Util.specialToByte; + +import javax.annotation.Nonnegative; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Recipe; + +@SuppressWarnings("UnusedReturnValue") +public class BWRecipes { + + public static final BWRecipes instance = new BWRecipes(); + + public static long calcDecayTicks(int x) { + long ret; + if (x == 43) ret = 5000; + else if (x == 61) ret = 4500; + else if (x <= 100) ret = MathUtils.ceilLong((8000D * Math.tanh(-x / 20D) + 8000D) * 1000D); + else ret = MathUtils.ceilLong(8000D * Math.tanh(-x / 65D) + 8000D); + return ret; + } + + public boolean addRadHatch(ItemStack item, int radioLevel, int amount, short[] rgba) { + return radioHatchRecipes.addRecipe( + new GT_Recipe( + false, + new ItemStack[] { item }, + null, + null, + new int[] { rgba[0], rgba[1], rgba[2] }, + null, + null, + amount, + radioLevel, + (int) calcDecayTicks(radioLevel))) + != null; + } + + public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack aSpecialItems, int[] aChances, + FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + return bioLabRecipes.addRecipe( + new GT_Recipe( + true, + aInputs, + new ItemStack[] { aOutput }, + aSpecialItems, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue)) + != null; + } + + public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, + FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { + return bioLabRecipes.addRecipe( + new GT_Recipe( + true, + new ItemStack[] { BioItemList.getPetriDish(null), aInput }, + new ItemStack[] { BioItemList.getPetriDish(aOutput) }, + null, + aChances, + aFluidInputs, + new FluidStack[] { GT_Values.NF }, + aDuration, + aEUt, + aSpecialValue)) + != null; + } + + public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, + FluidStack aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { + return bioLabRecipes.addRecipe( + new GT_Recipe( + true, + new ItemStack[] { BioItemList.getPetriDish(null), aInput }, + new ItemStack[] { BioItemList.getPetriDish(aOutput) }, + null, + aChances, + new FluidStack[] { aFluidInputs }, + new FluidStack[] { GT_Values.NF }, + aDuration, + aEUt, + aSpecialValue)) + != null; + } + + public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, @Nonnegative int aDuration, @Nonnegative int aEUt, @Nonnegative int aSv, + @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + int aSievert = 0; + if (aSv >= 83 || aSv == 61 || aSv == 43) aSievert += aSv; + aSievert = aSievert << 1; + aSievert = aSievert | (exactSv ? 1 : 0); + aSievert = aSievert << 2; + aSievert = aSievert | specialToByte(aSpecialValue); + aSievert = aSievert << 4; + aSievert = aSievert | glasTier; + return bacterialVatRecipes.addRecipe( + new GT_Recipe( + false, + aInputs, + null, + BioItemList.getPetriDish(aCulture), + new int[] {}, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSievert)) + != null; + } + + @Deprecated + public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, int aDuration, int aEUt, Materials material, @Nonnegative int glasTier, + int aSpecialValue, boolean exactSv) { + byte gTier = (byte) glasTier; + int aSievert = 0; + if (material.getProtons() >= 83 || material.getProtons() == 61 || material.getProtons() == 43) + aSievert += calculateSv(material); + aSievert = aSievert << 1; + aSievert = aSievert | (exactSv ? 1 : 0); + aSievert = aSievert << 2; + aSievert = aSievert | specialToByte(aSpecialValue); + aSievert = aSievert << 4; + aSievert = aSievert | gTier; + return bacterialVatRecipes.addRecipe( + new GT_Recipe( + false, + aInputs, + null, + BioItemList.getPetriDish(aCulture), + new int[] {}, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSievert)) + != null; + } + + /** + * Adds a Vat recipe without Rad requirements but with Glas requirements + */ + public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture culture, FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, int aDuration, int aEUt, byte glasTier) { + int aSievert = 0; + aSievert = aSievert | glasTier; + return bacterialVatRecipes.addRecipe( + new GT_Recipe( + false, + aInputs, + null, + BioItemList.getPetriDish(culture), + new int[] {}, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSievert)) + != null; + } + + /** + * Adds a Vat recipe without Rad or Glas requirements + */ + public boolean addBacterialVatRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, BioCulture culture, + FluidStack[] aFluidOutputs, int aDuration, int aEUt) { + return bacterialVatRecipes.addRecipe( + new GT_Recipe( + false, + aInputs, + null, + BioItemList.getPetriDish(culture), + new int[] {}, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + 0)) + != null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java new file mode 100644 index 0000000000..2e384c8e0c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.util.Arrays; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; + +@SuppressWarnings("unused") +public class BW_ColorUtil { + + private BW_ColorUtil() {} + + public static byte getDarknessFromColor(short[] rgba, int index) { + int g = rgba[index]; + if (g >= 0 && g < 64) return 0; + if (g >= 64 && g < 160) return 1; + else if (g >= 160 && g < 223) return 2; + else if (g >= 233 && g <= 255) return 3; + return 4; + } + + public static Dyes getDyeFromColor(short[] rgba) { + rgba = correctCorlorArray(rgba); + if (isGrayScale(rgba, 2)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + return Dyes.dyeBlack; + case 1: + return Dyes.dyeGray; + case 2: + return Dyes.dyeLightGray; + case 3: + return Dyes.dyeWhite; + } + } else { + short[] tmp = roundColor(rgba, 2); + if (isRedScale(tmp)) { + if (isPurpleScale(tmp)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + if (rgba[3] - 50 > rgba[0]) return Dyes.dyePurple; + else return Dyes.dyeRed; + case 2: + case 3: + if (rgba[3] - 50 > rgba[0]) return Dyes.dyeMagenta; + else if (rgba[0] > 200 && rgba[2] > 140) return Dyes.dyePink; + else if (rgba[0] > rgba[1] + rgba[1] / 10 && rgba[0] > rgba[2] + rgba[2] / 10 + && rgba[1] >> 4 == rgba[2] >> 4 + && rgba[1] + 50 > rgba[0]) { + return Dyes.dyeBrown; + } else return Dyes.dyeRed; + case 4: + return Dyes._NULL; + } + } + if (isYellowScale(tmp)) switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBrown; + case 2: + case 3: { + if (rgba[0] >> 5 > rgba[1] >> 5) return Dyes.dyeOrange; + else return Dyes.dyeYellow; + } + case 4: + return Dyes._NULL; + } + return Dyes.dyePink; + } + if (isGrenScale(tmp)) { + if (isCyanScale(tmp)) { + if (rgba[2] + 40 < rgba[1]) switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeGreen; + case 2: + case 3: + return Dyes.dyeLime; + } + return Dyes.dyeCyan; + } + if (isYellowScale(tmp)) switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBrown; + case 2: + case 3: { + if (rgba[0] >> 5 > rgba[1] >> 5) return Dyes.dyeOrange; + else return Dyes.dyeYellow; + } + } + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeGreen; + case 2: + case 3: + return Dyes.dyeLime; + } + } else if (isBlueScale(tmp)) { + if (isPurpleScale(tmp)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyePurple; + case 2: + case 3: + return Dyes.dyeMagenta; + } + } else if (isCyanScale(tmp)) { + return Dyes.dyeCyan; + } + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBlue; + case 2: + case 3: + return Dyes.dyeLightBlue; + } + } + } + return Dyes._NULL; + } + + public static boolean isCyanScale(short[] rgba) { + return !isRedScale(rgba); + } + + public static boolean isPurpleScale(short[] rgba) { + return !isGrenScale(rgba); + } + + public static boolean isYellowScale(short[] rgba) { + return !isBlueScale(rgba); + } + + public static boolean isBlueScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[2] * 2 >= rgba[1] + rgba[0]; + } + + public static boolean isGrenScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[1] * 2 >= rgba[0] + rgba[2]; + } + + public static boolean isRedScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[0] * 2 >= rgba[1] + rgba[2]; + } + + public static boolean isGrayScale(short[] rgba, int magin) { + rgba = correctCorlorArray(rgba); + return rgba[0] >> magin == rgba[1] >> magin && rgba[1] >> magin == rgba[2] >> magin; + } + + public static short[] roundColor(short[] rgba, int magin) { + short[] tmp = Arrays.copyOf(rgba, 4); + tmp[0] = (short) (rgba[0] >> magin); + tmp[1] = (short) (rgba[1] >> magin); + tmp[2] = (short) (rgba[2] >> magin); + return tmp; + } + + public static boolean isGrayScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[0] == rgba[1] && rgba[1] == rgba[2]; + } + + public static short[] correctCorlorArray(short[] rgba) { + if (rgba.length > 4) { + rgba = Arrays.copyOfRange(rgba, 0, 4); + } + if (rgba.length < 4) { + short[] tmp = Arrays.copyOf(rgba, 4); + Arrays.fill(tmp, rgba.length, 4, (short) 0); + rgba = tmp; + } + if (rgba[0] > 255) rgba[0] = 255; + if (rgba[1] > 255) rgba[1] = 255; + if (rgba[2] > 255) rgba[2] = 255; + if (rgba[3] > 255) rgba[3] = 255; + if (rgba[0] < 0) rgba[0] = 0; + if (rgba[1] < 0) rgba[1] = 0; + if (rgba[2] < 0) rgba[2] = 0; + if (rgba[3] < 0) rgba[3] = 0; + return rgba; + } + + public static short[] splitColorToRBGArray(int rgb) { + return new short[] { (short) (rgb >> 16 & 0xFF), (short) (rgb >> 8 & 0xFF), (short) (rgb & 0xFF) }; + } + + public static int getColorFromRGBArray(short[] color) { + return (color[0] & 0x0ff) << 16 | (color[1] & 0x0ff) << 8 | color[2] & 0x0ff; + } + + public static int getColorFromRGBArray(int[] color) { + return (color[0] & 0x0ff) << 16 | (color[1] & 0x0ff) << 8 | color[2] & 0x0ff; + } + + public static String getColorForTier(int tier) { + return GT_Values.TIER_COLORS[tier]; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Tooltip_Reference.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Tooltip_Reference.java new file mode 100644 index 0000000000..b68f3fb437 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Tooltip_Reference.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import static net.minecraft.util.EnumChatFormatting.BLUE; +import static net.minecraft.util.EnumChatFormatting.DARK_BLUE; +import static net.minecraft.util.EnumChatFormatting.GRAY; +import static net.minecraft.util.EnumChatFormatting.GREEN; + +import java.util.function.Function; +import java.util.function.Supplier; + +import net.minecraft.util.StatCollector; + +public class BW_Tooltip_Reference { + + public static final String BW_NO_RESET = ChatColorHelper.DARKGREEN + "BartWorks"; + public static final String TT_NO_RESET = BLUE + "Tec" + DARK_BLUE + "Tech"; + public static final String BW = BW_NO_RESET + GRAY; + public static final String TT = TT_NO_RESET + GRAY; + + public static final Supplier ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS = () -> StatCollector.translateToLocal( + "tooltip.bw.1.name") + " " + BW; + public static final Supplier ADDED_BY_BARTWORKS = () -> StatCollector.translateToLocal("tooltip.bw.0.name") + + " " + + BW; + public static final Function ADDED_VIA_BARTWORKS = owner -> String + .format(StatCollector.translateToLocal("tooltip.bw.via.name"), owner); + public static final String MULTIBLOCK_ADDED_BY_BARTWORKS = BW; + public static final Function MULTIBLOCK_ADDED_VIA_BARTWORKS = owner -> String + .format(StatCollector.translateToLocal("tooltip.bw.mb_via.name"), owner); + public static final String MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS = MULTIBLOCK_ADDED_VIA_BARTWORKS + .apply(GREEN + "bartimaeusnek"); + + public static final String ADV_STR_CHECK = "Uses an advanced " + TT + " structure check, due to " + BW; + public static final String TT_BLUEPRINT = "To see the structure, use a " + TT + " Blueprint on the Controller!"; + + public static String[] getTranslatedBrandedTooltip(String key) { + String[] dsc = StatCollector.translateToLocal(key) + .split(";"); + String[] fdsc = new String[dsc.length + 1]; + System.arraycopy(dsc, 0, fdsc, 0, dsc.length); + fdsc[dsc.length] = ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get(); + return fdsc; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java new file mode 100644 index 0000000000..38982f35b3 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -0,0 +1,803 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import static gregtech.api.enums.GT_Values.D1; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.GT_Values.W; + +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureElement; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.ToolDictNames; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Shaped_Recipe; +import gregtech.api.util.GT_Utility; + +public class BW_Util { + + public static final int STANDART = 0; + public static final int LOWGRAVITY = -100; + public static final int CLEANROOM = -200; + + public static String translateGTItemStack(ItemStack itemStack) { + if (!GT_Utility.isStackValid(itemStack)) return "Not a Valid ItemStack:" + itemStack; + String ret = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack)); + if (!ret.contains("%material")) return ret; + String matname = ""; + if (BW_Util.checkStackAndPrefix(itemStack)) + matname = GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.mDefaultLocalName; + return ret.replace("%material", matname); + } + + public static void set2DCoordTo1DArray(int indexX, int indexY, int sizeY, Object value, Object[] array) { + int index = indexX * sizeY + indexY; + array[index] = value; + } + + public static Object get2DCoordFrom1DArray(int indexX, int indexY, int sizeY, Object[] array) { + int index = indexX * sizeY + indexY; + return array[index]; + } + + public static GT_Recipe copyAndSetTierToNewRecipe(GT_Recipe recipe, byte tier) { + byte oldTier = GT_Utility.getTier(recipe.mEUt); + int newTime = recipe.mDuration; + int newVoltage = recipe.mEUt; + if (tier < oldTier) { + newTime <<= oldTier - tier; + newVoltage >>= 2 * (oldTier - tier); + } else { + newTime >>= tier - oldTier; + newVoltage <<= 2 * (tier - oldTier); + } + recipe.mEUt = newVoltage; + recipe.mDuration = newTime; + return recipe; + } + + public static String subscriptNumbers(String b) { + char[] chars = b.toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2080'; + case '1' -> '\u2081'; + case '2' -> '\u2082'; + case '3' -> '\u2083'; + case '4' -> '\u2084'; + case '5' -> '\u2085'; + case '6' -> '\u2086'; + case '7' -> '\u2087'; + case '8' -> '\u2088'; + case '9' -> '\u2089'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static String subscriptNumber(Number b) { + char[] chars = Long.toString(b.longValue()) + .toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2080'; + case '1' -> '\u2081'; + case '2' -> '\u2082'; + case '3' -> '\u2083'; + case '4' -> '\u2084'; + case '5' -> '\u2085'; + case '6' -> '\u2086'; + case '7' -> '\u2087'; + case '8' -> '\u2088'; + case '9' -> '\u2089'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static String superscriptNumbers(String b) { + char[] chars = b.toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2070'; + case '1' -> '\u2071'; + case '2' -> '\u00B2'; + case '3' -> '\u00B3'; + case '4' -> '\u2074'; + case '5' -> '\u2075'; + case '6' -> '\u2076'; + case '7' -> '\u2077'; + case '8' -> '\u2078'; + case '9' -> '\u2079'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static String superscriptNumber(Number b) { + char[] chars = Long.toString(b.longValue()) + .toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2070'; + case '1' -> '\u2071'; + case '2' -> '\u00B2'; + case '3' -> '\u00B3'; + case '4' -> '\u2074'; + case '5' -> '\u2075'; + case '6' -> '\u2076'; + case '7' -> '\u2077'; + case '8' -> '\u2078'; + case '9' -> '\u2079'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static byte specialToByte(int aSpecialValue) { + byte special = 0; + switch (aSpecialValue) { + case LOWGRAVITY: + special = 1; + break; + case CLEANROOM: + special = 2; + break; + case LOWGRAVITY | CLEANROOM: + special = 3; + break; + default: + break; + } + return special; + } + + public static int calculateSv(Materials materials) { + for (BioVatLogicAdder.MaterialSvPair pair : BioVatLogicAdder.RadioHatch.getMaSv()) { + if (pair.getMaterials() + .equals(materials)) return pair.getSievert(); + } + return (int) (materials.getProtons() == 43L + ? materials.equals(Materials.NaquadahEnriched) ? 140 + : materials.equals(Materials.Naquadria) ? 150 : materials.equals(Materials.Naquadah) ? 130 : 43 + : materials.getProtons()); + } + + public static ItemStack setStackSize(ItemStack stack, int size) { + if (stack != null) stack.stackSize = size; + return stack; + } + + public static boolean checkStackAndPrefix(ItemStack itemStack) { + return itemStack != null && GT_OreDictUnificator.getAssociation(itemStack) != null + && GT_OreDictUnificator.getAssociation(itemStack).mPrefix != null + && GT_OreDictUnificator.getAssociation(itemStack).mMaterial != null + && GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial != null; + } + + public static int abstractHashGTRecipe(GT_Recipe recipe) { + int hash = 31; + hash += recipe.mDuration / 20 * 31; + hash += GT_Utility.getTier(recipe.mEUt) * 31; + hash += BW_Util.specialToByte(recipe.mSpecialValue) * 31; + hash += recipe.mInputs.length * 31; + for (ItemStack mInput : recipe.mInputs) { + if (mInput != null) { + hash += mInput.stackSize * 31; + hash += Item.getIdFromItem(mInput.getItem()) * 31; + } + } + hash += recipe.mOutputs.length * 31; + for (ItemStack mOutput : recipe.mOutputs) { + if (mOutput != null) { + hash += mOutput.stackSize * 31; + hash += Item.getIdFromItem(mOutput.getItem()) * 31; + } + } + hash += recipe.mFluidInputs.length * 31; + for (FluidStack mInput : recipe.mFluidInputs) { + if (mInput != null) { + hash += mInput.amount * 31; + hash += mInput.getFluidID() * 31; + } + } + hash += recipe.mFluidOutputs.length * 31; + for (FluidStack mOutput : recipe.mFluidOutputs) { + if (mOutput != null) { + hash += mOutput.amount * 31; + hash += mOutput.getFluidID() * 31; + } + } + return hash; + } + + @SuppressWarnings({ "unchecked" }) + public static T[] copyAndRemoveNulls(T[] input, Class clazz) { + List ret = Arrays.stream(input) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + if (ret.size() <= 0) return (T[]) Array.newInstance(clazz, 0); + + T[] retArr = (T[]) Array.newInstance(clazz, ret.size()); + + for (int i = 0; i < ret.size(); i++) retArr[i] = ret.get(i); + + return retArr; + } + + @Deprecated + public static int getMachineVoltageFromTier(int tier) { + return (int) (30 * Math.pow(4, tier - 1)); + } + + public static long getTierVoltage(int tier) { + return getTierVoltage((byte) tier); + } + + public static long getTierVoltage(byte tier) { + return 8L << 2 * tier; + } + + public static byte getTier(long voltage) { + if (voltage <= Integer.MAX_VALUE - 7) return GT_Utility.getTier(voltage); + byte t = 0; + while (voltage > 8L) { + voltage >>= 2; + t++; + } + return t; + } + + public static String getTierName(byte tier) { + if (VN.length - 1 <= tier) return "MAX+"; + return VN[tier]; + } + + public static String getTierNameFromVoltage(long voltage) { + return getTierName(getTier(voltage)); + } + + public static boolean areStacksEqualOrNull(ItemStack aStack1, ItemStack aStack2) { + return aStack1 == null && aStack2 == null || GT_Utility.areStacksEqual(aStack1, aStack2); + } + + public static boolean areStacksEqualOrEachNull(ItemStack aStack1, ItemStack aStack2) { + return aStack1 == null || aStack2 == null || GT_Utility.areStacksEqual(aStack1, aStack2); + } + + public static byte getByteFromRarity(EnumRarity rarity) { + if (EnumRarity.uncommon.equals(rarity)) return 1; + if (EnumRarity.epic.equals(rarity)) return 2; + else if (EnumRarity.rare.equals(rarity)) return 3; + return 0; + } + + /** + * @deprecated Use stuff in {@link com.github.bartimaeusnek.bartworks.API.BorosilicateGlass} instead + */ + @Deprecated + public static byte getTierFromGlasMeta(int meta) { + return switch (meta) { + case 1 -> 4; + case 2, 12 -> 5; + case 3 -> 6; + case 4 -> 7; + case 5 -> 8; + case 13 -> 9; + case 14 -> 10; + default -> 3; + }; + } + + public static EnumRarity getRarityFromByte(byte b) { + return switch (b) { + case 1 -> EnumRarity.uncommon; + case 2 -> EnumRarity.rare; + case 3 -> EnumRarity.epic; + default -> EnumRarity.common; + }; + } + + public static byte getCircuitTierFromOreDictName(String name) { + return switch (name) { + case "circuitPrimitive" -> 0; + case "circuitBasic" -> 1; + case "circuitGood" -> 2; + case "circuitAdvanced" -> 3; + case "circuitData" -> 4; + case "circuitElite" -> 5; + case "circuitMaster" -> 6; + case "circuitUltimate" -> 7; + case "circuitSuperconductor" -> 8; + case "circuitInfinite" -> 9; + case "circuitBio" -> 10; + case "circuitNano", "circuitOptical" -> 11; + case "circuitPiko", "circuitExotic" -> 12; + case "circuitQuantum", "circuitCosmic" -> 13; + case "circuitTranscendent" -> 14; + default -> -1; + }; + } + + public static byte getCircuitTierFromItemStack(ItemStack stack) { + for (String oreName : getOreNames(stack)) { + byte tier = getCircuitTierFromOreDictName(oreName); + if (tier != -1) { + return tier; + } + } + return -1; + } + + public static boolean isTieredCircuit(ItemStack stack) { + return getCircuitTierFromItemStack(stack) != -1; + } + + public static List getOreNames(ItemStack stack) { + List ret = new ArrayList<>(); + for (int oreID : OreDictionary.getOreIDs(stack)) { + ret.add(OreDictionary.getOreName(oreID)); + } + return ret; + } + + public static byte calculateGlassTier(@Nonnull Block block, @Nonnegative byte meta) { + + byte boroTier = BorosilicateGlass.getTier(block, meta); + if (boroTier != -1) return boroTier; + + if ("blockAlloyGlass".equals(block.getUnlocalizedName())) return 4; + + if (block.equals(Blocks.glass)) return 3; + + for (BioVatLogicAdder.BlockMetaPair B : BioVatLogicAdder.BioVatGlass.getGlassMap() + .keySet()) + if (B.getBlock() + .equals(block) + && B.getaByte() + .equals(meta)) + return BioVatLogicAdder.BioVatGlass.getGlassMap() + .get(B); + + if (block.getMaterial() + .equals(Material.glass)) return 3; + + return 0; + } + + public static IStructureElement ofGlassTiered(byte mintier, byte maxtier, byte notset, + BiConsumer setter, Function getter, int aDots) { + return new IStructureElement<>() { + + private final IStructureElement placementDelegate = BorosilicateGlass + .ofBoroGlass(notset, mintier, maxtier, setter, getter); + + @Override + public boolean check(T te, World world, int x, int y, int z) { + if (world.isAirBlock(x, y, z)) return false; + byte glasstier = BW_Util + .calculateGlassTier(world.getBlock(x, y, z), (byte) world.getBlockMetadata(x, y, z)); + // is not a glass ? + if (glasstier == 0 || glasstier == notset || glasstier < mintier || glasstier > maxtier) return false; + if (getter.apply(te) == notset) setter.accept(te, glasstier); + return getter.apply(te) == glasstier; + } + + @Override + public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemStack) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), aDots - 1); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return this.placementDelegate.placeBlock(t, world, x, y, z, trigger); + } + + @Override + public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + return this.placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); + } + }; + } + + public static IStructureElement ofGlassTieredMixed(byte mintier, byte maxtier, int aDots) { + return new IStructureElement<>() { + + private final IStructureElement placementDelegate = BorosilicateGlass + .ofBoroGlass((byte) 0, mintier, maxtier, (v1, v2) -> {}, v1 -> (byte) 0); + + @Override + public boolean check(T te, World world, int x, int y, int z) { + if (world.isAirBlock(x, y, z)) return false; + byte glasstier = BW_Util + .calculateGlassTier(world.getBlock(x, y, z), (byte) world.getBlockMetadata(x, y, z)); + if (glasstier == 0) return false; // is not a glass ? + return glasstier >= mintier && glasstier <= maxtier; + } + + @Override + public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemStack) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), aDots - 1); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return this.placementDelegate.placeBlock(t, world, x, y, z, trigger); + } + + @Override + public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + return this.placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); + } + }; + } + + private static Field sBufferedRecipeList; + + @SuppressWarnings("unchecked") + public static List getGTBufferedRecipeList() + throws SecurityException, IllegalArgumentException, IllegalAccessException { + if (sBufferedRecipeList == null) { + sBufferedRecipeList = FieldUtils.getDeclaredField(GT_ModHandler.class, "sBufferRecipeList", true); + } + if (sBufferedRecipeList == null) { + sBufferedRecipeList = FieldUtils.getField(GT_ModHandler.class, "sBufferRecipeList", true); + } + return (List) sBufferedRecipeList.get(null); + } + + public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) { + return createGTCraftingRecipe( + aResult, + new Enchantment[0], + new int[0], + (aBitMask & GT_ModHandler.RecipeBits.MIRRORED) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.BUFFERED) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.KEEPNBT) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.DISMANTLEABLE) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.NOT_REMOVABLE) == 0L, + (aBitMask & GT_ModHandler.RecipeBits.REVERSIBLE) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0L, + (aBitMask & GT_ModHandler.RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0L, + (aBitMask & GT_ModHandler.RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0L, + aRecipe); + } + + public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, + int[] aEnchantmentLevelsAdded, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, + boolean aRemovable, boolean aReversible, boolean aRemoveAllOthersWithSameOutput, + boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, boolean aRemoveAllOtherShapedsWithSameOutput, + boolean aRemoveAllOtherNativeRecipes, boolean aCheckForCollisions, + boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe) { + aResult = GT_OreDictUnificator.get(true, aResult); + if (aOnlyAddIfResultIsNotNull && aResult == null) return null; + if (aResult != null && Items.feather.getDamage(aResult) == W) Items.feather.setDamage(aResult, 0); + if (aRecipe == null || aRecipe.length <= 0) return null; + + boolean tThereWasARecipe = false; + + for (byte i = 0; i < aRecipe.length; i++) { + if (aRecipe[i] instanceof IItemContainer itemContainer) { + aRecipe[i] = itemContainer.get(1); + continue; + } + if (aRecipe[i] instanceof Enumenum_) { + aRecipe[i] = enum_.name(); + continue; + } + if (aRecipe[i] != null && !(aRecipe[i] instanceof ItemStack) + && !(aRecipe[i] instanceof ItemData) + && !(aRecipe[i] instanceof String) + && !(aRecipe[i] instanceof Character)) { + aRecipe[i] = aRecipe[i].toString(); + } + } + + try { + StringBuilder shape = new StringBuilder(E); + int idx = 0; + if (aRecipe[idx] instanceof Boolean) { + throw new IllegalArgumentException(); + } + + ArrayList tRecipeList = new ArrayList<>(Arrays.asList(aRecipe)); + + while (aRecipe[idx] instanceof String string) { + StringBuilder s = new StringBuilder(string); + idx++; + shape.append(s); + while (s.length() < 3) s.append(" "); + if (s.length() > 3) throw new IllegalArgumentException(); + + for (char c : s.toString() + .toCharArray()) { + switch (c) { + case 'b': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolBlade.name()); + break; + case 'c': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolCrowbar.name()); + break; + case 'd': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolScrewdriver.name()); + break; + case 'f': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolFile.name()); + break; + case 'h': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolHardHammer.name()); + break; + case 'i': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSolderingIron.name()); + break; + case 'j': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSolderingMetal.name()); + break; + case 'k': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolKnife.name()); + break; + case 'm': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolMortar.name()); + break; + case 'p': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolDrawplate.name()); + break; + case 'r': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSoftHammer.name()); + break; + case 's': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSaw.name()); + break; + case 'w': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolWrench.name()); + break; + case 'x': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolWireCutter.name()); + break; + } + } + } + + aRecipe = tRecipeList.toArray(); + + if (aRecipe[idx] instanceof Boolean) { + idx++; + } + Map tItemStackMap = new HashMap<>(); + Map tItemDataMap = new HashMap<>(); + tItemStackMap.put(' ', null); + + boolean tRemoveRecipe = true; + + for (; idx < aRecipe.length; idx += 2) { + if (aRecipe[idx] == null || aRecipe[idx + 1] == null) { + if (D1) { + GT_Log.err.println( + "WARNING: Missing Item for shaped Recipe: " + + (aResult == null ? "null" : aResult.getDisplayName())); + for (Object tContent : aRecipe) GT_Log.err.println(tContent); + } + return null; + } + Character chr = (Character) aRecipe[idx]; + Object in = aRecipe[idx + 1]; + if (in instanceof ItemStack) { + tItemStackMap.put(chr, GT_Utility.copy(in)); + tItemDataMap.put(chr, GT_OreDictUnificator.getItemData((ItemStack) in)); + } else if (in instanceof ItemData) { + String tString = in.toString(); + switch (tString) { + case "plankWood": + tItemDataMap.put(chr, new ItemData(Materials.Wood, M)); + break; + case "stoneNetherrack": + tItemDataMap.put(chr, new ItemData(Materials.Netherrack, M)); + break; + case "stoneObsidian": + tItemDataMap.put(chr, new ItemData(Materials.Obsidian, M)); + break; + case "stoneEndstone": + tItemDataMap.put(chr, new ItemData(Materials.Endstone, M)); + break; + default: + tItemDataMap.put(chr, (ItemData) in); + break; + } + ItemStack tStack = GT_OreDictUnificator.getFirstOre(in, 1); + if (tStack == null) tRemoveRecipe = false; + else tItemStackMap.put(chr, tStack); + aRecipe[idx + 1] = in.toString(); + } else if (in instanceof String) { + if (in.equals(OreDictNames.craftingChest.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Wood, M * 8)); + else if (in.equals(OreDictNames.craftingBook.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Paper, M * 3)); + else if (in.equals(OreDictNames.craftingPiston.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Stone, M * 4, Materials.Wood, M * 3)); + else if (in.equals(OreDictNames.craftingFurnace.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Stone, M * 8)); + else if (in.equals(OreDictNames.craftingIndustrialDiamond.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Diamond, M)); + else if (in.equals(OreDictNames.craftingAnvil.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Iron, M * 10)); + ItemStack tStack = GT_OreDictUnificator.getFirstOre(in, 1); + if (tStack == null) tRemoveRecipe = false; + else tItemStackMap.put(chr, tStack); + } else { + throw new IllegalArgumentException(); + } + } + + if (aReversible && aResult != null) { + ItemData[] tData = new ItemData[9]; + int x = -1; + for (char chr : shape.toString() + .toCharArray()) { + x++; + tData[x] = tItemDataMap.get(chr); + } + if (GT_Utility.arrayContainsNonNull(tData)) + GT_OreDictUnificator.addItemData(aResult, new ItemData(tData)); + } + + if (aCheckForCollisions && tRemoveRecipe) { + ItemStack[] tRecipe = new ItemStack[9]; + int x = -1; + for (char chr : shape.toString() + .toCharArray()) { + x++; + tRecipe[x] = tItemStackMap.get(chr); + if (tRecipe[x] != null && Items.feather.getDamage(tRecipe[x]) == W) + Items.feather.setDamage(tRecipe[x], 0); + } + tThereWasARecipe = GT_ModHandler.removeRecipe(tRecipe) != null; + } + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + + if (aResult == null || aResult.stackSize <= 0) return null; + + if (aRemoveAllOthersWithSameOutput || aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT + || aRemoveAllOtherShapedsWithSameOutput + || aRemoveAllOtherNativeRecipes) + tThereWasARecipe = GT_ModHandler.removeRecipeByOutput( + aResult, + !aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, + aRemoveAllOtherShapedsWithSameOutput, + aRemoveAllOtherNativeRecipes) || tThereWasARecipe; + + if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tThereWasARecipe) { + ArrayList tList = (ArrayList) CraftingManager.getInstance() + .getRecipeList(); + int tList_sS = tList.size(); + for (int i = 0; i < tList_sS && !tThereWasARecipe; i++) { + IRecipe tRecipe = tList.get(i); + if (GT_ModHandler.sSpecialRecipeClasses.contains( + tRecipe.getClass() + .getName())) + continue; + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tRecipe.getRecipeOutput()), aResult, true)) { + tList.remove(i); + i--; + tList_sS = tList.size(); + tThereWasARecipe = true; + } + } + } + + if (Items.feather.getDamage(aResult) == W || Items.feather.getDamage(aResult) < 0) + Items.feather.setDamage(aResult, 0); + + GT_Utility.updateItemStack(aResult); + + return new GT_Shaped_Recipe( + GT_Utility.copy(aResult), + aDismantleable, + aRemovable, + aKeepNBT, + aEnchantmentsAdded, + aEnchantmentLevelsAdded, + aRecipe).setMirrored(aMirrored); + } + + public static void shortSleep(long nanos) { + try { + long start = System.nanoTime(); + long end; + do { + end = System.nanoTime(); + } while (start + nanos >= end); + } catch (Exception e) { + MainMod.LOGGER.catching(e); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java new file mode 100644 index 0000000000..c4ff2f721c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.awt.Color; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Objects; + +import net.minecraft.item.EnumRarity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.util.GT_LanguageManager; + +public class BioCulture extends BioData implements IColorModulationContainer { + + public static final ArrayList BIO_CULTURE_ARRAY_LIST = new ArrayList<>(); + public static final BioCulture NULLCULTURE = BioCulture + .createAndRegisterBioCulture(Color.BLUE, "", BioPlasmid.NULLPLASMID, BioDNA.NULLDNA, false); // fallback + // NULL + // culture, + // also Blue =) + + public String getLocalisedName() { + return GT_LanguageManager.getTranslation(this.getName()); + } + + public void setLocalisedName(String localisedName) { + GT_LanguageManager.addStringLocalization(this.getName(), localisedName); + } + + Color color; + BioPlasmid plasmid; + BioDNA dDNA; + boolean bBreedable; + Fluid mFluid; + + protected BioCulture(Color color, String name, int ID, BioPlasmid plasmid, BioDNA dDNA, EnumRarity rarity, + boolean bBreedable) { + super(name, ID, rarity); + this.color = color; + this.plasmid = plasmid; + this.dDNA = dDNA; + this.bBreedable = bBreedable; + } + + protected BioCulture(Color color, String name, int ID, BioPlasmid plasmid, BioDNA dDNA) { + super(name, ID, dDNA.getRarity()); + this.color = color; + this.plasmid = plasmid; + this.dDNA = dDNA; + } + + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, + EnumRarity rarity, boolean breedable) { + BioCulture ret = new BioCulture(color, name, BIO_CULTURE_ARRAY_LIST.size(), plasmid, dna, rarity, breedable); + BIO_CULTURE_ARRAY_LIST.add(ret); + return ret; + } + + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, + boolean breedable) { + BioCulture ret = new BioCulture( + color, + name, + BIO_CULTURE_ARRAY_LIST.size(), + plasmid, + dna, + dna.getRarity(), + breedable); + BIO_CULTURE_ARRAY_LIST.add(ret); + return ret; + } + + public static NBTTagCompound getNBTTagFromCulture(BioCulture bioCulture) { + if (bioCulture == null) return new NBTTagCompound(); + NBTTagCompound ret = new NBTTagCompound(); + ret.setString("Name", bioCulture.name); + // ret.setInteger("ID", bioCulture.ID); + ret.setIntArray( + "Color", + new int[] { bioCulture.color.getRed(), bioCulture.color.getGreen(), bioCulture.color.getBlue() }); + ret.setTag("Plasmid", BioData.getNBTTagFromBioData(BioData.convertBioPlasmidToBioData(bioCulture.plasmid))); + ret.setTag("DNA", BioData.getNBTTagFromBioData(BioData.convertBioDNAToBioData(bioCulture.dDNA))); + ret.setBoolean("Breedable", bioCulture.bBreedable); + ret.setByte("Rarety", BW_Util.getByteFromRarity(bioCulture.rarity)); + if (bioCulture.bBreedable) ret.setString( + "Fluid", + bioCulture.getFluid() + .getName()); + return ret; + } + + public static BioCulture getBioCultureFromNBTTag(NBTTagCompound tag) { + if (tag == null || tag.getIntArray("Color").length == 0) return null; + BioCulture ret = getBioCulture(tag.getString("Name")); + + if (ret == null) ret = createAndRegisterBioCulture( + new Color(tag.getIntArray("Color")[0], tag.getIntArray("Color")[1], tag.getIntArray("Color")[2]), + tag.getString("Name"), + BioPlasmid.convertDataToPlasmid(getBioDataFromNBTTag(tag.getCompoundTag("Plasmid"))), + BioDNA.convertDataToDNA(getBioDataFromNBTTag(tag.getCompoundTag("DNA"))), + BW_Util.getRarityFromByte(tag.getByte("Rarety")), + tag.getBoolean("Breedable")); + if (ret.bBreedable) ret.setFluid(FluidRegistry.getFluid(tag.getString("Fluid"))); + if (ret.getFluidNotSet()) // should never happen, but better safe than sorry + ret.setbBreedable(false); + return ret; + } + + public static BioCulture getBioCulture(String Name) { + if (Name == null || Name.isEmpty()) return null; + for (BioCulture b : BIO_CULTURE_ARRAY_LIST) if (b.name.equals(Name)) return b; + return null; + } + + public static BioCulture getBioCulture(BioDNA DNA) { + for (BioCulture b : BIO_CULTURE_ARRAY_LIST) if (b.getdDNA() + .equals(DNA)) return b; + return null; + } + + public Fluid getFluid() { + if (this.mFluid == null) + throw new IllegalStateException("Fluid has not been set yet! The issuring Culture is: " + this.name); + return this.mFluid; + } + + public void setFluid(Fluid mFluid) { + this.mFluid = mFluid; + } + + public boolean getFluidNotSet() { + return this.mFluid == null && this.isBreedable(); + } + + public boolean isBreedable() { + return this.bBreedable; + } + + public void setbBreedable(boolean bBreedable) { + this.bBreedable = bBreedable; + } + + public int getColorRGB() { + return BW_ColorUtil + .getColorFromRGBArray(new int[] { this.color.getRed(), this.color.getGreen(), this.color.getBlue() }); + } + + public Color getColor() { + return this.color; + } + + public void setColor(Color color) { + this.color = color; + } + + public BioPlasmid getPlasmid() { + return this.plasmid; + } + + public BioCulture setPlasmid(BioPlasmid plasmid) { + return this.checkForExisting( + new BioCulture(this.color, this.name, this.ID, plasmid, this.dDNA, this.rarity, this.bBreedable)); + } + + private BioCulture checkForExisting(BioCulture culture) { + if (culture == null) return null; + for (BioCulture bc : BioCulture.BIO_CULTURE_ARRAY_LIST) if (culture.getdDNA() + .equals(bc.getdDNA()) + && culture.getPlasmid() + .equals(bc.getPlasmid())) + return bc; + return culture; + } + + public BioCulture setPlasmidUnsafe(BioPlasmid plasmid) { + this.plasmid = plasmid; + return this; + } + + public BioDNA getdDNA() { + return this.dDNA; + } + + public BioCulture setdDNA(BioDNA dDNA) { + return this.checkForExisting( + new BioCulture(this.color, this.name, this.ID, this.plasmid, dDNA, this.rarity, this.bBreedable)); + } + + public BioCulture setdDNAUnsafe(BioDNA dDNA) { + this.dDNA = dDNA; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass() || !super.equals(o)) return false; + BioCulture culture = (BioCulture) o; + return this.isBreedable() == culture.isBreedable() && Objects.equals(this.getColor(), culture.getColor()) + && Objects.equals(this.getPlasmid(), culture.getPlasmid()) + && Objects.equals(this.getdDNA(), culture.getdDNA()) + && Objects.equals(this.mFluid, culture.mFluid); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(17) + .putInt( + MurmurHash3.murmurhash3_x86_32( + this.getName(), + 0, + this.getName() + .length(), + 31)) + .putInt(this.getColorRGB()) + .putInt(this.getPlasmid().ID) + .putInt(this.getdDNA().ID) + .put((byte) (this.isBreedable() ? 1 : 0)) + .array(), + 0, + 17, + 31); + } + + @Override + public short[] getRGBA() { + return new short[] { (short) this.getColor() + .getRed(), + (short) this.getColor() + .getGreen(), + (short) this.getColor() + .getBlue(), + (short) this.getColor() + .getAlpha() }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java new file mode 100644 index 0000000000..22edd60170 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import net.minecraft.item.EnumRarity; + +public class BioDNA extends BioData { + + public static final BioDNA NULLDNA = createAndRegisterBioDNA("", EnumRarity.epic); + + protected BioDNA(String name, int ID, EnumRarity rarity) { + super(name, ID, rarity); + } + + protected BioDNA(BioData bioData) { + super(bioData); + this.name = bioData.name; + this.ID = bioData.ID; + this.rarity = bioData.rarity; + } + + public static BioDNA convertDataToDNA(BioData bioData) { + return new BioDNA(bioData); + } + + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity); + return new BioDNA(ret); + } + + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity, chance, tier); + return new BioDNA(ret); + } + + @Override + public String toString() { + return "BioDNA{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java new file mode 100644 index 0000000000..7a4c87f7d2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Objects; + +import net.minecraft.item.EnumRarity; +import net.minecraft.nbt.NBTTagCompound; + +public class BioData { + + public static final ArrayList BIO_DATA_ARRAY_LIST = new ArrayList<>(); + + protected String name; + protected int ID; + protected EnumRarity rarity; + protected int chance; + protected int tier; + + protected BioData(String name, int ID, EnumRarity rarity, int chance, int tier) { + this.name = name; + this.ID = ID; + this.rarity = rarity; + this.chance = chance; + this.tier = tier; + } + + protected BioData(String name, int ID, EnumRarity rarity) { + this.name = name; + this.ID = ID; + this.rarity = rarity; + this.chance = 7500; + this.tier = 0; + } + + protected BioData(BioData bioData) { + this.rarity = bioData.rarity; + this.name = bioData.name; + this.ID = bioData.ID; + this.chance = bioData.chance; + this.tier = bioData.tier; + } + + public static BioData convertBioPlasmidToBioData(BioPlasmid bioPlasmid) { + return new BioData(bioPlasmid.name, bioPlasmid.ID, bioPlasmid.rarity, bioPlasmid.chance, bioPlasmid.tier); + } + + public static BioData convertBioDNAToBioData(BioDNA bioDNA) { + return new BioData(bioDNA.name, bioDNA.ID, bioDNA.rarity, bioDNA.chance, bioDNA.tier); + } + + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = new BioData(aName, BIO_DATA_ARRAY_LIST.size(), rarity, chance, tier); + BIO_DATA_ARRAY_LIST.add(ret); + return ret; + } + + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity) { + BioData ret = new BioData(aName, BIO_DATA_ARRAY_LIST.size(), rarity); + BIO_DATA_ARRAY_LIST.add(ret); + return ret; + } + + public static NBTTagCompound getNBTTagFromBioData(BioData bioData) { + NBTTagCompound ret = new NBTTagCompound(); + ret.setByte("Rarity", BW_Util.getByteFromRarity(bioData.rarity)); + ret.setString("Name", bioData.name); + // ret.setInteger("ID", bioData.ID); buggy when load Order changes + ret.setInteger("Chance", bioData.chance); + ret.setInteger("Tier", bioData.tier); + return ret; + } + + public static BioData getBioDataFromNBTTag(NBTTagCompound tag) { + if (tag == null) return null; + return getBioDataFromName(tag.getString("Name")); + } + + public static BioData getBioDataFromName(String Name) { + for (BioData bd : BIO_DATA_ARRAY_LIST) if (bd.name.equals(Name)) return bd; + return null; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BioData bioData = (BioData) o; + return this.getID() == bioData.getID() + || this.getChance() == bioData.getChance() && this.getTier() == bioData.getTier() + && Objects.equals(this.getName(), bioData.getName()) + && this.getRarity() == bioData.getRarity(); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(13) + .putInt( + MurmurHash3.murmurhash3_x86_32( + this.getName(), + 0, + this.getName() + .length(), + 31)) + .put(BW_Util.getByteFromRarity(this.getRarity())) + .putInt(this.getChance()) + .putInt(this.getTier()) + .array(), + 0, + 13, + 31); + } + + public int getTier() { + return this.tier; + } + + public void setTier(int tier) { + this.tier = tier; + } + + @Override + public String toString() { + return "BioData{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; + } + + public EnumRarity getRarity() { + return this.rarity; + } + + public void setRarity(EnumRarity rarity) { + this.rarity = rarity; + } + + public int getChance() { + return this.chance; + } + + public void setChance(int chance) { + this.chance = chance; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * DO NOT USE GET ID TO GET THE OBJECT! THIS SHOULD ONLY BE USED FOR COMPARISON! + * + * @return the position in the loading list + */ + public int getID() { + return this.ID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java new file mode 100644 index 0000000000..0d40d9deca --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import net.minecraft.item.EnumRarity; + +public class BioPlasmid extends BioData { + + public static final BioPlasmid NULLPLASMID = convertDataToPlasmid(BioData.convertBioDNAToBioData(BioDNA.NULLDNA)); + + private BioPlasmid(String name, int ID, EnumRarity rarity) { + super(name, ID, rarity); + } + + protected BioPlasmid(BioData bioData) { + super(bioData); + this.name = bioData.name; + this.ID = bioData.ID; + this.rarity = bioData.rarity; + } + + public static BioPlasmid convertDataToPlasmid(BioData bioData) { + return new BioPlasmid(bioData); + } + + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity); + return new BioPlasmid(ret); + } + + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity, chance, tier); + return new BioPlasmid(ret); + } + + @Override + public String toString() { + return "BioPlasmid{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/CachedReflectionUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/CachedReflectionUtils.java new file mode 100644 index 0000000000..063a310db8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/CachedReflectionUtils.java @@ -0,0 +1,31 @@ +package com.github.bartimaeusnek.bartworks.util; + +import java.lang.reflect.Field; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.commons.lang3.reflect.FieldUtils; + +public class CachedReflectionUtils { + + private static final ClassValue> fields = new ConcurrentMapClassValue(); + private static final ClassValue> declaredFields = new ConcurrentMapClassValue(); + + public static Field getField(final Class cls, final String fieldName) { + return fields.get(cls) + .computeIfAbsent(fieldName, f -> FieldUtils.getField(cls, f, true)); + } + + public static Field getDeclaredField(final Class cls, final String fieldName) { + return declaredFields.get(cls) + .computeIfAbsent(fieldName, f -> FieldUtils.getDeclaredField(cls, f, true)); + } + + private static class ConcurrentMapClassValue extends ClassValue> { + + @Override + protected Map computeValue(Class type) { + return new ConcurrentHashMap<>(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java new file mode 100644 index 0000000000..f1d6eeedb3 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +public class ChatColorHelper { + + private ChatColorHelper() {} + + public static final String BLACK = (char) 167 + "0"; + public static final String DARKBLUE = (char) 167 + "1"; + public static final String DARKGREEN = (char) 167 + "2"; + public static final String DARKAQUA = (char) 167 + "3"; + public static final String DARKRED = (char) 167 + "4"; + public static final String DARKPURPLE = (char) 167 + "5"; + public static final String GOLD = (char) 167 + "6"; + public static final String GRAY = (char) 167 + "7"; + public static final String DARKGRAY = (char) 167 + "8"; + public static final String BLUE = (char) 167 + "9"; + public static final String GREEN = (char) 167 + "a"; + public static final String AQUA = (char) 167 + "b"; + public static final String RED = (char) 167 + "c"; + public static final String LIGHT_PURPLE = (char) 167 + "d"; + public static final String YELLOW = (char) 167 + "e"; + public static final String WHITE = (char) 167 + "f"; + public static final String OBFUSCATED = (char) 167 + "k"; + public static final String BOLD = (char) 167 + "l"; + public static final String STRIKETHROUGH = (char) 167 + "m"; + public static final String UNDERLINE = (char) 167 + "n"; + public static final String ITALIC = (char) 167 + "o"; + public static final String RESET = (char) 167 + "r"; +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java new file mode 100644 index 0000000000..9feb344fa0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.util.HashSet; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class ConnectedBlocksChecker { + + public final HashSet hashset = new HashSet<>(2048); + + public static byte check_sourroundings(Coords C, Block b) { + byte ret = 0; + World w = DimensionManager.getWorld(C.wID); + int x = C.x, y = C.y, z = C.z; + + if (w.getBlock(x + 1, y, z) + .equals(b)) ret = (byte) (ret | 0b000100); + + if (w.getBlock(x - 1, y, z) + .equals(b)) ret = (byte) (ret | 0b001000); + + if (w.getBlock(x, y, z + 1) + .equals(b)) ret = (byte) (ret | 0b010000); + + if (w.getBlock(x, y, z - 1) + .equals(b)) ret = (byte) (ret | 0b100000); + + if (w.getBlock(x, y + 1, z) + .equals(b)) ret = (byte) (ret | 0b000001); + + if (w.getBlock(x, y - 1, z) + .equals(b)) ret = (byte) (ret | 0b000010); + + return ret; + } + + public int get_connected(World w, int x, int y, int z, Block b) { + int ret = 0; + + int wID = w.provider.dimensionId; + + byte sides = this.check_sourroundings(w, x, y, z, b); + + if ((sides | 0b111011) == 0b111111 && !this.hashset.contains(new Coords(x + 1, y, z, wID))) { + ret++; + ret += this.get_connected(w, x + 1, y, z, b); + } + + if ((sides | 0b110111) == 0b111111 && !this.hashset.contains(new Coords(x - 1, y, z, wID))) { + ret++; + ret += this.get_connected(w, x - 1, y, z, b); + } + + if ((sides | 0b101111) == 0b111111 && !this.hashset.contains(new Coords(x, y, z + 1, wID))) { + ret++; + ret += this.get_connected(w, x, y, z + 1, b); + } + + if ((sides | 0b011111) == 0b111111 && !this.hashset.contains(new Coords(x, y, z - 1, wID))) { + ret++; + ret += this.get_connected(w, x, y, z - 1, b); + } + + if ((sides | 0b111110) == 0b111111 && !this.hashset.contains(new Coords(x, y + 1, z, wID))) { + ret++; + ret += this.get_connected(w, x, y + 1, z, b); + } + + if ((sides | 0b111101) == 0b111111 && !this.hashset.contains(new Coords(x, y - 1, z, wID))) { + ret++; + ret += this.get_connected(w, x, y - 1, z, b); + } + + return ret; + } + + public byte check_sourroundings(World w, int x, int y, int z, Block b) { + + byte ret = 0; + int wID = w.provider.dimensionId; + + if (this.hashset.contains(new Coords(x, y, z, wID))) return ret; + + this.hashset.add(new Coords(x, y, z, wID)); + + if (w.getBlock(x + 1, y, z) + .equals(b)) ret = (byte) (ret | 0b000100); + + if (w.getBlock(x - 1, y, z) + .equals(b)) ret = (byte) (ret | 0b001000); + + if (w.getBlock(x, y, z + 1) + .equals(b)) ret = (byte) (ret | 0b010000); + + if (w.getBlock(x, y, z - 1) + .equals(b)) ret = (byte) (ret | 0b100000); + + if (w.getBlock(x, y + 1, z) + .equals(b)) ret = (byte) (ret | 0b000001); + + if (w.getBlock(x, y - 1, z) + .equals(b)) ret = (byte) (ret | 0b000010); + + return ret; + } + + public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { + + int wID = w.provider.dimensionId; + Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); + + for (Coords C : this.hashset) { + if (GT) { + if (!new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y + 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y - 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y - 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x + 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x + 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x - 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x - 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z + 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z + 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z - 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z - 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + } else { + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + || n == w.getBlockMetadata(C.x, C.y - 1, C.z) + && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) + && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) + && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) + && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) + && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { + return true; + } + } + } + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java new file mode 100644 index 0000000000..cfd2c70d1d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Queue; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +/** + * This implementation is for some reason slower than the Recursive Check.... For ~3400 blocks this takes 8ms, the + * Recursive Check 5ms. + */ +public class ConnectedBlocksCheckerIteration { + + public final HashSet hashset = new HashSet<>(2048); + public final HashSet checked = new HashSet<>(4096); + private final Queue kwoe = new LinkedList<>(); + + public long get_connected(World w, int x, int y, int z, Block b) { + this.kwoe.add(new Coords(x, y, z, w.provider.dimensionId)); + this.hashset.add(new Coords(x, y, z, w.provider.dimensionId)); + while (!this.kwoe.isEmpty()) { + Coords tocheck = this.kwoe.poll(); + int wID = w.provider.dimensionId; + this.checked.add(tocheck); + Coords c; + if (!this.checked.contains(c = new Coords(tocheck.x + 1, tocheck.y, tocheck.z, wID)) + && w.getBlock(tocheck.x + 1, tocheck.y, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x - 1, tocheck.y, tocheck.z, wID)) + && w.getBlock(tocheck.x - 1, tocheck.y, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z + 1, wID)) + && w.getBlock(tocheck.x, tocheck.y, tocheck.z + 1) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z - 1, wID)) + && w.getBlock(tocheck.x, tocheck.y, tocheck.z - 1) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y + 1, tocheck.z, wID)) + && w.getBlock(tocheck.x, tocheck.y + 1, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y - 1, tocheck.z, wID)) + && w.getBlock(tocheck.x, tocheck.y - 1, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + } + return this.hashset.size(); + } + + public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { + + int wID = w.provider.dimensionId; + Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); + + for (Coords C : this.hashset) { + if (GT) { + if (!new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y + 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y - 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y - 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x + 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x + 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x - 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x - 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z + 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z + 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z - 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z - 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + } else { + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + || n == w.getBlockMetadata(C.x, C.y - 1, C.z) + && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) + && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) + && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) + && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) + && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { + return true; + } + } + } + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java new file mode 100644 index 0000000000..f8c33dd8e9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import net.minecraftforge.common.util.ForgeDirection; + +public class Coords { + + public int x, z, wID; + public short y; + + public Coords(int x, int y, int z, int wID) { + this(x, y, z); + this.wID = wID; + } + + public Coords(int x, int y, int z) { + this.x = x; + this.y = (short) y; + this.z = z; + this.wID = 0; + } + + public Coords getCoordsFromSide(ForgeDirection direction) { + return switch (direction) { + case UP -> new Coords(this.x, this.y + 1, this.z, this.wID); + case DOWN -> new Coords(this.x, this.y - 1, this.z, this.wID); + case WEST -> new Coords(this.x - 1, this.y, this.z, this.wID); + case EAST -> new Coords(this.x + 1, this.y, this.z, this.wID); + case NORTH -> new Coords(this.x, this.y, this.z - 1, this.wID); + case SOUTH -> new Coords(this.x, this.y, this.z + 1, this.wID); + default -> throw new UnsupportedOperationException("This is impossible."); + }; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + Coords coords = (Coords) o; + return this.x == coords.x && this.y == coords.y && this.z == coords.z && this.wID == coords.wID; + } + + @Override + public int hashCode() { + byte[] data = new byte[14]; + data[0] = (byte) (this.x & 0xff); + data[1] = (byte) (this.x >> 4 & 0xff); + data[2] = (byte) (this.x >> 8 & 0xff); + data[3] = (byte) (this.x >> 12 & 0xff); + data[4] = (byte) (this.y & 0xff); + data[5] = (byte) (this.y >> 4 & 0xff); + data[6] = (byte) (this.z & 0xff); + data[7] = (byte) (this.z >> 4 & 0xff); + data[8] = (byte) (this.z >> 8 & 0xff); + data[9] = (byte) (this.z >> 12 & 0xff); + data[10] = (byte) (this.wID & 0xff); + data[11] = (byte) (this.wID >> 4 & 0xff); + data[12] = (byte) (this.wID >> 8 & 0xff); + data[13] = (byte) (this.wID >> 12 & 0xff); + return MurmurHash3.murmurhash3_x86_32(data, 0, 14, 31); + } + + @Override + public String toString() { + return this.x + "," + this.y + "," + this.z + "," + this.wID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/EnumUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/EnumUtils.java new file mode 100644 index 0000000000..678f8facba --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/EnumUtils.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import net.minecraftforge.common.util.EnumHelper; + +import gregtech.api.enums.Element; +import gregtech.api.enums.OrePrefixes; + +public class EnumUtils { + + private EnumUtils() {} + + public static OrePrefixes addNewOrePrefix(String enumName, String aRegularLocalName, String aLocalizedMaterialPre, + String aLocalizedMaterialPost, boolean aIsUnificatable, boolean aIsMaterialBased, boolean aIsSelfReferencing, + boolean aIsContainer, boolean aDontUnificateActively, boolean aIsUsedForBlocks, boolean aAllowNormalRecycling, + boolean aGenerateDefaultItem, boolean aIsEnchantable, boolean aIsUsedForOreProcessing, + int aMaterialGenerationBits, long aMaterialAmount, int aDefaultStackSize, int aTextureindex) { + return EnumHelper.addEnum( + OrePrefixes.class, + enumName, + new Class[] { String.class, String.class, String.class, boolean.class, boolean.class, boolean.class, + boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, + int.class, long.class, int.class, int.class }, + new Object[] { aRegularLocalName, aLocalizedMaterialPre, aLocalizedMaterialPost, aIsUnificatable, + aIsMaterialBased, aIsSelfReferencing, aIsContainer, aDontUnificateActively, aIsUsedForBlocks, + aAllowNormalRecycling, aGenerateDefaultItem, aIsEnchantable, aIsUsedForOreProcessing, + aMaterialGenerationBits, aMaterialAmount, aDefaultStackSize, aTextureindex }); + } + + public static Element createNewElement(String enumName, long aProtons, long aNeutrons, long aAdditionalMass, + long aHalfLifeSeconds, String aDecayTo, String aName, boolean aIsIsotope) { + return EnumHelper.addEnum( + Element.class, + enumName, + new Class[] { long.class, long.class, long.class, long.class, String.class, String.class, boolean.class }, + new Object[] { aProtons, aNeutrons, aAdditionalMass, aHalfLifeSeconds, aDecayTo, aName, aIsIsotope }); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java new file mode 100644 index 0000000000..e8f4330ed3 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +/* + * Faster implementations for Math stuff + */ +@SuppressWarnings("unused") +public class MathUtils { + + public static long floorLong(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (long) x; + long xi = (long) x; + return x < xi ? xi - 1 : xi; + } + + public static long ceilLong(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (long) x; + long xi = (long) x; + return x > xi ? xi + 1 : xi; + } + + public static int floorInt(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (int) x; + int xi = (int) x; + return x < xi ? xi - 1 : xi; + } + + public static int ceilInt(float x) { + if (Float.isInfinite(x) || Float.isNaN(x)) return (int) x; + int xi = (int) x; + return x > xi ? xi + 1 : xi; + } + + public static int ceilInt(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (int) x; + int xi = (int) x; + return x > xi ? xi + 1 : xi; + } + + public static double floor(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return x; + int xi = (int) x; + return x < xi ? xi - 1 : xi; + } + + public static double ceil(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return x; + int xi = (int) x; + return x > xi ? xi + 1 : xi; + } + + public static byte clamp(byte amount, byte min, byte max) { + byte inner = amount <= max ? amount : max; + return min >= inner ? min : inner; + } + + public static short clamp(short amount, short min, short max) { + short inner = amount <= max ? amount : max; + return min >= inner ? min : inner; + } + + public static int clamp(int amount, int min, int max) { + return Math.max(min, Math.min(amount, max)); + } + + public static long clamp(long amount, long min, long max) { + return Math.max(min, Math.min(amount, max)); + } + + public static float clamp(float amount, float min, float max) { + return Math.max(min, Math.min(amount, max)); + } + + public static double clamp(double amount, double min, double max) { + return Math.max(min, Math.min(amount, max)); + } + + public static > T clamp(T val, T min, T max) { + return val.compareTo(min) < 0 ? min : val.compareTo(max) > 0 ? max : val; + } + + public static int wrap(int input, int bound) { + return (input % bound + bound) % bound; + } + + public static long wrap(long input, long bound) { + return (input % bound + bound) % bound; + } + + public static double wrap(double input, double bound) { + return (input % bound + bound) % bound; + } + + public static float wrap(float input, float bound) { + return (input % bound + bound) % bound; + } + + public static float tanh(float x) { + float x2 = x * x; + float a = x * (135135.0f + x2 * (17325.0f + x2 * (378.0f + x2))); + float b = 135135.0f + x2 * (62370.0f + x2 * (3150.0f + x2 * 28.0f)); + return clamp(a / b, -1, 1); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java new file mode 100644 index 0000000000..501b473d98 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java @@ -0,0 +1,309 @@ +/* + * The MurmurHash3 algorithm was created by Austin Appleby and placed in the public domain. This java port was authored + * by Yonik Seeley and also placed into the public domain. The author hereby disclaims copyright to this source code. + *

This produces exactly the same hash values as the final C++ version of MurmurHash3 and is thus suitable for + * producing the same hash values across platforms.

The 32 bit x86 version of this hash should be the fastest + * variant for relatively short keys like ids. murmurhash3_x64_128 is a good choice for longer strings or if you need + * more than 32 bits of hash.

Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms + * are optimized for their respective platforms.

See http://github.com/yonik/java_util for future updates to this + * file. Special Thanks to Austin Appleby and Yonik Seeley for placing this in the public domain and therefore allowing + * me to use it! + */ +package com.github.bartimaeusnek.bartworks.util; + +public final class MurmurHash3 { + + public static int fmix32(int h) { + h ^= h >>> 16; + h *= 0x85ebca6b; + h ^= h >>> 13; + h *= 0xc2b2ae35; + h ^= h >>> 16; + return h; + } + + public static long fmix64(long k) { + k ^= k >>> 33; + k *= 0xff51afd7ed558ccdL; + k ^= k >>> 33; + k *= 0xc4ceb9fe1a85ec53L; + k ^= k >>> 33; + return k; + } + + /** + * Gets a long from a byte buffer in little endian byte order. + */ + public static long getLongLittleEndian(byte[] buf, int offset) { + return (long) buf[offset + 7] << 56 // no mask needed + | (buf[offset + 6] & 0xffL) << 48 + | (buf[offset + 5] & 0xffL) << 40 + | (buf[offset + 4] & 0xffL) << 32 + | (buf[offset + 3] & 0xffL) << 24 + | (buf[offset + 2] & 0xffL) << 16 + | (buf[offset + 1] & 0xffL) << 8 + | buf[offset] & 0xffL; // no shift needed + } + + /** + * Returns the MurmurHash3_x86_32 hash. + */ + public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed) { + + final int c1 = 0xcc9e2d51; + final int c2 = 0x1b873593; + + int h1 = seed; + int roundedEnd = offset + (len & 0xfffffffc); // round down to 4 byte block + + for (int i = offset; i < roundedEnd; i += 4) { + // little endian load order + int k1 = data[i] & 0xff | (data[i + 1] & 0xff) << 8 | (data[i + 2] & 0xff) << 16 | data[i + 3] << 24; + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = h1 << 13 | h1 >>> 19; // ROTL32(h1,13); + h1 = h1 * 5 + 0xe6546b64; + } + + // tail + int k1 = 0; + + switch (len & 0x03) { + case 3: + k1 = (data[roundedEnd + 2] & 0xff) << 16; + // fallthrough + case 2: + k1 |= (data[roundedEnd + 1] & 0xff) << 8; + // fallthrough + case 1: + k1 |= data[roundedEnd] & 0xff; + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + h1 ^= k1; + } + + // finalization + h1 ^= len; + + // fmix(h1); + h1 ^= h1 >>> 16; + h1 *= 0x85ebca6b; + h1 ^= h1 >>> 13; + h1 *= 0xc2b2ae35; + h1 ^= h1 >>> 16; + + return h1; + } + + /** + * Returns the MurmurHash3_x86_32 hash of the UTF-8 bytes of the String without actually encoding the string to a + * temporary buffer. This is more than 2x faster than hashing the result of String.getBytes(). + */ + public static int murmurhash3_x86_32(CharSequence data, int offset, int len, int seed) { + + final int c1 = 0xcc9e2d51; + final int c2 = 0x1b873593; + + int h1 = seed; + + int pos = offset; + int end = offset + len; + int k1 = 0; + int k2 = 0; + int shift = 0; + int bits = 0; + int nBytes = 0; // length in UTF8 bytes + + while (pos < end) { + int code = data.charAt(pos); + pos++; + if (code < 0x80) { + k2 = code; + bits = 8; + + /*** + * // optimized ascii implementation (currently slower!!! code size?) if (shift == 24) { k1 = k1 | (code + * << 24); + * + * k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; + * + * h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); h1 = h1*5+0xe6546b64; + * + * shift = 0; nBytes += 4; k1 = 0; } else { k1 |= code << shift; shift += 8; } continue; + ***/ + } else if (code < 0x800) { + k2 = 0xC0 | code >> 6 | (0x80 | code & 0x3F) << 8; + bits = 16; + } else if (code < 0xD800 || code > 0xDFFF || pos >= end) { + // we check for pos>=end to encode an unpaired surrogate as 3 bytes. + k2 = 0xE0 | code >> 12 | (0x80 | code >> 6 & 0x3F) << 8 | (0x80 | code & 0x3F) << 16; + bits = 24; + } else { + // surrogate pair + // int utf32 = pos < end ? (int) data.charAt(pos++) : 0; + int utf32 = data.charAt(pos++); + utf32 = (code - 0xD7C0 << 10) + (utf32 & 0x3FF); + k2 = 0xff & (0xF0 | utf32 >> 18) | (0x80 | utf32 >> 12 & 0x3F) << 8 + | (0x80 | utf32 >> 6 & 0x3F) << 16 + | (0x80 | utf32 & 0x3F) << 24; + bits = 32; + } + + k1 |= k2 << shift; + + // int used_bits = 32 - shift; // how many bits of k2 were used in k1. + // int unused_bits = bits - used_bits; // (bits-(32-shift)) == bits+shift-32 == bits-newshift + + shift += bits; + if (shift >= 32) { + // mix after we have a complete word + + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = h1 << 13 | h1 >>> 19; // ROTL32(h1,13); + h1 = h1 * 5 + 0xe6546b64; + + shift -= 32; + // unfortunately, java won't let you shift 32 bits off, so we need to check for 0 + if (shift != 0) { + k1 = k2 >>> bits - shift; // bits used == bits - newshift + } else { + k1 = 0; + } + nBytes += 4; + } + } // inner + + // handle tail + if (shift > 0) { + nBytes += shift >> 3; + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + h1 ^= k1; + } + + // finalization + h1 ^= nBytes; + + // fmix(h1); + h1 ^= h1 >>> 16; + h1 *= 0x85ebca6b; + h1 ^= h1 >>> 13; + h1 *= 0xc2b2ae35; + h1 ^= h1 >>> 16; + + return h1; + } + + /** + * Returns the MurmurHash3_x64_128 hash, placing the result in "out". + */ + public static void murmurhash3_x64_128(byte[] key, int offset, int len, int seed, LongPair out) { + // The original algorithm does have a 32 bit unsigned seed. + // We have to mask to match the behavior of the unsigned types and prevent sign extension. + long h1 = seed & 0x00000000FFFFFFFFL; + long h2 = seed & 0x00000000FFFFFFFFL; + + final long c1 = 0x87c37b91114253d5L; + final long c2 = 0x4cf5ad432745937fL; + + int roundedEnd = offset + (len & 0xFFFFFFF0); // round down to 16 byte block + for (int i = offset; i < roundedEnd; i += 16) { + long k1 = getLongLittleEndian(key, i); + long k2 = getLongLittleEndian(key, i + 8); + k1 *= c1; + k1 = Long.rotateLeft(k1, 31); + k1 *= c2; + h1 ^= k1; + h1 = Long.rotateLeft(h1, 27); + h1 += h2; + h1 = h1 * 5 + 0x52dce729; + k2 *= c2; + k2 = Long.rotateLeft(k2, 33); + k2 *= c1; + h2 ^= k2; + h2 = Long.rotateLeft(h2, 31); + h2 += h1; + h2 = h2 * 5 + 0x38495ab5; + } + + long k1 = 0; + long k2 = 0; + + switch (len & 15) { + case 15: + k2 = (key[roundedEnd + 14] & 0xffL) << 48; + case 14: + k2 |= (key[roundedEnd + 13] & 0xffL) << 40; + case 13: + k2 |= (key[roundedEnd + 12] & 0xffL) << 32; + case 12: + k2 |= (key[roundedEnd + 11] & 0xffL) << 24; + case 11: + k2 |= (key[roundedEnd + 10] & 0xffL) << 16; + case 10: + k2 |= (key[roundedEnd + 9] & 0xffL) << 8; + case 9: + k2 |= key[roundedEnd + 8] & 0xffL; + k2 *= c2; + k2 = Long.rotateLeft(k2, 33); + k2 *= c1; + h2 ^= k2; + case 8: + k1 = (long) key[roundedEnd + 7] << 56; + case 7: + k1 |= (key[roundedEnd + 6] & 0xffL) << 48; + case 6: + k1 |= (key[roundedEnd + 5] & 0xffL) << 40; + case 5: + k1 |= (key[roundedEnd + 4] & 0xffL) << 32; + case 4: + k1 |= (key[roundedEnd + 3] & 0xffL) << 24; + case 3: + k1 |= (key[roundedEnd + 2] & 0xffL) << 16; + case 2: + k1 |= (key[roundedEnd + 1] & 0xffL) << 8; + case 1: + k1 |= key[roundedEnd] & 0xffL; + k1 *= c1; + k1 = Long.rotateLeft(k1, 31); + k1 *= c2; + h1 ^= k1; + } + + // ---------- + // finalization + + h1 ^= len; + h2 ^= len; + + h1 += h2; + h2 += h1; + + h1 = fmix64(h1); + h2 = fmix64(h2); + + h1 += h2; + h2 += h1; + + out.val1 = h1; + out.val2 = h2; + } + + /** + * 128 bits of state + */ + public static final class LongPair { + + public long val1; + public long val2; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java new file mode 100644 index 0000000000..753940f655 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util.NoiseUtil; + +import java.util.Random; + +import com.github.bartimaeusnek.bartworks.API.INoiseGen; +import com.github.bartimaeusnek.bartworks.util.MathUtils; + +import gregtech.api.objects.XSTR; + +public class BartsNoise implements INoiseGen { + + public void setUsePhase(boolean usePhase) { + this.usePhase = usePhase; + } + + public void setRandom(Random random) { + this.random = random; + } + + boolean usePhase; + int octaves; + double frequency; + double amplitude; + long seed; + Random random; + + public enum NoiseColor { + + Red(-1), + Pink(-0.5), + White(0), + Blue(0.5), + Violet(1); + + NoiseColor(double num) { + this.ampl = num; + } + + double ampl; + + public BartsNoise getColoredNoise() { + BartsNoise noise = new BartsNoise(); + noise.setAmplitude(this.ampl); + return noise; + } + } + + public BartsNoise(int octaves, double frequency, double amplitude, long seed) { + this.octaves = octaves; + this.frequency = frequency; + this.amplitude = amplitude; + this.seed = seed; + this.random = new XSTR(seed); + } + + public BartsNoise() { + this.seed = new XSTR().nextLong(); + this.random = new XSTR(this.seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise(long seed) { + this.seed = seed; + this.random = new XSTR(seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise copy() { + return new BartsNoise(this.octaves, this.frequency, this.amplitude, this.seed); + } + + public BartsNoise copy(long seed) { + return new BartsNoise(this.octaves, this.frequency, this.amplitude, seed); + } + + public double getCosNoise(double x, double y) { + double pr = x * this.frequency; + double r1 = Math.cos(pr); + if (r1 < 0) r1 = Math.abs(r1); + double result = Math.pow(r1, this.amplitude); + double pr2 = y * this.frequency; + double r2 = Math.cos(pr2); + if (r2 < 0) r2 = Math.abs(r2); + double result2 = Math.pow(r2, this.amplitude); + result *= result2; + if (result == Double.POSITIVE_INFINITY) result = Double.MAX_VALUE; + if (result == Double.NEGATIVE_INFINITY) result = Double.MIN_VALUE; + return MathUtils.wrap(result, 1D); + } + + double getNonOctavedNoise(double x, double y) { + double phase = SimplexNoise + .noise(Math.pow(x * this.frequency, this.amplitude), Math.pow(y * this.frequency, this.amplitude)); + return MathUtils.wrap(phase, 1); + } + + public double getNeighbouringNoise(int x, int y) { + return (this.getNoiseSingle(x - 1, y - 1) + this.getNoiseSingle(x, y - 1) + + this.getNoiseSingle(x - 1, y) + + this.getNoiseSingle(x + 1, y) + + this.getNoiseSingle(x, y + 1) + + this.getNoiseSingle(x + 1, y + 1) + + this.getNoiseSingle(x - 1, y + 1) + + this.getNoiseSingle(x + 1, y - 1)) / 8; + } + + public double getNoiseSingle(int x, int y) { + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d / i * this.getNonOctavedNoise(i * x, i * y); + } + return result; + } + + @Override + public double getNoise(int x, int y) { + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d / i * this.getNonOctavedNoise(i * x, y); + } + // result = (this.getNeighbouringNoise(x,y)+result)/2; + return MathUtils.wrap(result, 1D); + } + + @Override + public double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd) { + // double[][] results = new double[Math.abs(xEnd)-Math.abs(xStart)][Math.abs(zEnd)-Math.abs(zStart)]; + // for (int i = xStart; i < xEnd; i++) { + // for (int j = zStart; j < zEnd; j++) { + // results + // } + // } + return new double[0][0]; + } + + @Override + public void setAmplitude(double amplitude) { + this.amplitude = amplitude; + } + + @Override + public void setOctaves(int octaves) { + this.octaves = octaves; + } + + @Override + public void setFrequency(double freq) { + this.frequency = freq; + } + + @Override + public void setSeed(long seed) { + this.seed = seed; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java new file mode 100644 index 0000000000..ca318e17b9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java @@ -0,0 +1,396 @@ +package com.github.bartimaeusnek.bartworks.util.NoiseUtil; +/* + * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. Based on example code by Stefan Gustavson + * (stegu@itn.liu.se). Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). Better rank ordering method by + * Stefan Gustavson in 2012. This could be speeded up even further, but it's useful as it is. Version 2012-03-09 This + * code was placed in the public domain by its original author, Stefan Gustavson. You may use it as you see fit, but + * attribution is appreciated. + */ + +import com.github.bartimaeusnek.bartworks.util.MathUtils; + +public class SimplexNoise { // Simplex noise in 2D, 3D and 4D + + private static Grad[] grad3 = { new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0), + new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1), new Grad(0, 1, 1), + new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1) }; + + private static Grad[] grad4 = { new Grad(0, 1, 1, 1), new Grad(0, 1, 1, -1), new Grad(0, 1, -1, 1), + new Grad(0, 1, -1, -1), new Grad(0, -1, 1, 1), new Grad(0, -1, 1, -1), new Grad(0, -1, -1, 1), + new Grad(0, -1, -1, -1), new Grad(1, 0, 1, 1), new Grad(1, 0, 1, -1), new Grad(1, 0, -1, 1), + new Grad(1, 0, -1, -1), new Grad(-1, 0, 1, 1), new Grad(-1, 0, 1, -1), new Grad(-1, 0, -1, 1), + new Grad(-1, 0, -1, -1), new Grad(1, 1, 0, 1), new Grad(1, 1, 0, -1), new Grad(1, -1, 0, 1), + new Grad(1, -1, 0, -1), new Grad(-1, 1, 0, 1), new Grad(-1, 1, 0, -1), new Grad(-1, -1, 0, 1), + new Grad(-1, -1, 0, -1), new Grad(1, 1, 1, 0), new Grad(1, 1, -1, 0), new Grad(1, -1, 1, 0), + new Grad(1, -1, -1, 0), new Grad(-1, 1, 1, 0), new Grad(-1, 1, -1, 0), new Grad(-1, -1, 1, 0), + new Grad(-1, -1, -1, 0) }; + + private static short[] p = { 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, + 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, + 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, + 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, + 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, + 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, + 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, + 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, + 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, + 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, + 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 }; + // To remove the need for index wrapping, double the permutation table length + private static short[] perm = new short[512]; + private static short[] permMod12 = new short[512]; + + static { + for (int i = 0; i < 512; i++) { + perm[i] = p[i & 255]; + permMod12[i] = (short) (perm[i] % 12); + } + } + + // Skewing and unskewing factors for 2, 3, and 4 dimensions + private static final double F2 = 0.5 * (Math.sqrt(3.0) - 1.0); + private static final double G2 = (3.0 - Math.sqrt(3.0)) / 6.0; + private static final double F3 = 1.0 / 3.0; + private static final double G3 = 1.0 / 6.0; + private static final double F4 = (Math.sqrt(5.0) - 1.0) / 4.0; + private static final double G4 = (5.0 - Math.sqrt(5.0)) / 20.0; + + // This method is a *lot* faster than using (int)Math.floor(x) + private static int fastfloor(double x) { + return MathUtils.floorInt(x); + } + + private static double dot(Grad g, double x, double y) { + return g.x * x + g.y * y; + } + + private static double dot(Grad g, double x, double y, double z) { + return g.x * x + g.y * y + g.z * z; + } + + private static double dot(Grad g, double x, double y, double z, double w) { + return g.x * x + g.y * y + g.z * z + g.w * w; + } + + // 2D simplex noise + public static double noise(double xin, double yin) { + double n0, n1, n2; // Noise contributions from the three corners + // Skew the input space to determine which simplex cell we're in + double s = (xin + yin) * F2; // Hairy factor for 2D + int i = fastfloor(xin + s); + int j = fastfloor(yin + s); + double t = (i + j) * G2; + double X0 = i - t; // Unskew the cell origin back to (x,y) space + double Y0 = j - t; + double x0 = xin - X0; // The x,y distances from the cell origin + double y0 = yin - Y0; + // For the 2D case, the simplex shape is an equilateral triangle. + // Determine which simplex we are in. + int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords + if (x0 > y0) { + i1 = 1; + j1 = 0; + } // lower triangle, XY order: (0,0)->(1,0)->(1,1) + else { + i1 = 0; + j1 = 1; + } // upper triangle, YX order: (0,0)->(0,1)->(1,1) + // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and + // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where + // c = (3-sqrt(3))/6 + double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords + double y1 = y0 - j1 + G2; + double x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords + double y2 = y0 - 1.0 + 2.0 * G2; + // Work out the hashed gradient indices of the three simplex corners + int ii = i & 255; + int jj = j & 255; + int gi0 = permMod12[ii + perm[jj]]; + int gi1 = permMod12[ii + i1 + perm[jj + j1]]; + int gi2 = permMod12[ii + 1 + perm[jj + 1]]; + // Calculate the contribution from the three corners + double t0 = 0.5 - x0 * x0 - y0 * y0; + if (t0 < 0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient + } + double t1 = 0.5 - x1 * x1 - y1 * y1; + if (t1 < 0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1); + } + double t2 = 0.5 - x2 * x2 - y2 * y2; + if (t2 < 0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to return values in the interval [-1,1]. + return 70.0 * (n0 + n1 + n2); + } + + // 3D simplex noise + public static double noise(double xin, double yin, double zin) { + double n0, n1, n2, n3; // Noise contributions from the four corners + // Skew the input space to determine which simplex cell we're in + double s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D + int i = fastfloor(xin + s); + int j = fastfloor(yin + s); + int k = fastfloor(zin + s); + double t = (i + j + k) * G3; + double X0 = i - t; // Unskew the cell origin back to (x,y,z) space + double Y0 = j - t; + double Z0 = k - t; + double x0 = xin - X0; // The x,y,z distances from the cell origin + double y0 = yin - Y0; + double z0 = zin - Z0; + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // Determine which simplex we are in. + int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords + int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords + if (x0 >= y0) { + if (y0 >= z0) { + i1 = 1; + j1 = 0; + k1 = 0; + i2 = 1; + j2 = 1; + k2 = 0; + } // X Y Z order + else { + if (x0 >= z0) { + i1 = 1; + j1 = 0; + k1 = 0; + } // X Z Y order + else { + i1 = 0; + j1 = 0; + k1 = 1; + } + i2 = 1; + j2 = 0; + k2 = 1; + } // Z X Y order + } else if (y0 < z0) { + i1 = 0; + j1 = 0; + k1 = 1; + i2 = 0; + j2 = 1; + k2 = 1; + } // Z Y X order + else if (x0 < z0) { + i1 = 0; + j1 = 1; + k1 = 0; + i2 = 0; + j2 = 1; + k2 = 1; + } // Y Z X order + else { + i1 = 0; + j1 = 1; + k1 = 0; + i2 = 1; + j2 = 1; + k2 = 0; + } // Y X Z order + // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z), + // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and + // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where + // c = 1/6. + double x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords + double y1 = y0 - j1 + G3; + double z1 = z0 - k1 + G3; + double x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords + double y2 = y0 - j2 + 2.0 * G3; + double z2 = z0 - k2 + 2.0 * G3; + double x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords + double y3 = y0 - 1.0 + 3.0 * G3; + double z3 = z0 - 1.0 + 3.0 * G3; + // Work out the hashed gradient indices of the four simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int gi0 = permMod12[ii + perm[jj + perm[kk]]]; + int gi1 = permMod12[ii + i1 + perm[jj + j1 + perm[kk + k1]]]; + int gi2 = permMod12[ii + i2 + perm[jj + j2 + perm[kk + k2]]]; + int gi3 = permMod12[ii + 1 + perm[jj + 1 + perm[kk + 1]]]; + // Calculate the contribution from the four corners + double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0; + if (t0 < 0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0, z0); + } + double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1; + if (t1 < 0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1, z1); + } + double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2; + if (t2 < 0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2, z2); + } + double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3; + if (t3 < 0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad3[gi3], x3, y3, z3); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to stay just inside [-1,1] + return 32.0 * (n0 + n1 + n2 + n3); + } + + // 4D simplex noise, better simplex rank ordering method 2012-03-09 + public static double noise(double x, double y, double z, double w) { + + double n0, n1, n2, n3, n4; // Noise contributions from the five corners + // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in + double s = (x + y + z + w) * F4; // Factor for 4D skewing + int i = fastfloor(x + s); + int j = fastfloor(y + s); + int k = fastfloor(z + s); + int l = fastfloor(w + s); + double t = (i + j + k + l) * G4; // Factor for 4D unskewing + double X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space + double Y0 = j - t; + double Z0 = k - t; + double W0 = l - t; + double x0 = x - X0; // The x,y,z,w distances from the cell origin + double y0 = y - Y0; + double z0 = z - Z0; + double w0 = w - W0; + // For the 4D case, the simplex is a 4D shape I won't even try to describe. + // To find out which of the 24 possible simplices we're in, we need to + // determine the magnitude ordering of x0, y0, z0 and w0. + // Six pair-wise comparisons are performed between each possible pair + // of the four coordinates, and the results are used to rank the numbers. + int rankx = 0; + int ranky = 0; + int rankz = 0; + int rankw = 0; + if (x0 > y0) rankx++; + else ranky++; + if (x0 > z0) rankx++; + else rankz++; + if (x0 > w0) rankx++; + else rankw++; + if (y0 > z0) ranky++; + else rankz++; + if (y0 > w0) ranky++; + else rankw++; + if (z0 > w0) rankz++; + else rankw++; + int i1, j1, k1, l1; // The integer offsets for the second simplex corner + int i2, j2, k2, l2; // The integer offsets for the third simplex corner + int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner + // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. + // Many values of c will never occur, since e.g. x>y>z>w makes x= 3 ? 1 : 0; + j1 = ranky >= 3 ? 1 : 0; + k1 = rankz >= 3 ? 1 : 0; + l1 = rankw >= 3 ? 1 : 0; + // Rank 2 denotes the second largest coordinate. + i2 = rankx >= 2 ? 1 : 0; + j2 = ranky >= 2 ? 1 : 0; + k2 = rankz >= 2 ? 1 : 0; + l2 = rankw >= 2 ? 1 : 0; + // Rank 1 denotes the second smallest coordinate. + i3 = rankx >= 1 ? 1 : 0; + j3 = ranky >= 1 ? 1 : 0; + k3 = rankz >= 1 ? 1 : 0; + l3 = rankw >= 1 ? 1 : 0; + // The fifth corner has all coordinate offsets = 1, so no need to compute that. + double x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords + double y1 = y0 - j1 + G4; + double z1 = z0 - k1 + G4; + double w1 = w0 - l1 + G4; + double x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords + double y2 = y0 - j2 + 2.0 * G4; + double z2 = z0 - k2 + 2.0 * G4; + double w2 = w0 - l2 + 2.0 * G4; + double x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords + double y3 = y0 - j3 + 3.0 * G4; + double z3 = z0 - k3 + 3.0 * G4; + double w3 = w0 - l3 + 3.0 * G4; + double x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords + double y4 = y0 - 1.0 + 4.0 * G4; + double z4 = z0 - 1.0 + 4.0 * G4; + double w4 = w0 - 1.0 + 4.0 * G4; + // Work out the hashed gradient indices of the five simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int ll = l & 255; + int gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32; + int gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32; + int gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32; + int gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32; + int gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32; + // Calculate the contribution from the five corners + double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; + if (t0 < 0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0); + } + double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; + if (t1 < 0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1); + } + double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; + if (t2 < 0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2); + } + double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; + if (t3 < 0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3); + } + double t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; + if (t4 < 0) n4 = 0.0; + else { + t4 *= t4; + n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4); + } + // Sum up and scale the result to cover the range [-1,1] + return 27.0 * (n0 + n1 + n2 + n3 + n4); + } + + // Inner class to speed upp gradient computations + // (array access is a lot slower than member access) + private static class Grad { + + double x, y, z, w; + + Grad(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + Grad(double x, double y, double z, double w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashMap.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashMap.java new file mode 100644 index 0000000000..33173d19f2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashMap.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +public class NonNullWrappedHashMap extends HashMap { + + private static final long serialVersionUID = 46345163103910175L; + private V defaultValue; + + public NonNullWrappedHashMap(int initialCapacity, float loadFactor, V defaultValue) { + super(initialCapacity, loadFactor); + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + public NonNullWrappedHashMap(int initialCapacity, V defaultValue) { + super(initialCapacity); + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + public NonNullWrappedHashMap(V defaultValue) { + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + public NonNullWrappedHashMap(Map m, V defaultValue) { + super(m); + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + @Override + public V get(Object key) { + return this.getOrDefault(key, this.defaultValue); + } + + @Override + public V getOrDefault(Object key, V defaultValue) { + return Objects.requireNonNull( + Optional.ofNullable(super.getOrDefault(key, defaultValue)) + .orElse(this.defaultValue)); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java new file mode 100644 index 0000000000..5490c4bdaf --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.util.Collection; +import java.util.HashSet; + +public class NonNullWrappedHashSet extends HashSet { + + private static final long serialVersionUID = 8377161849188229010L; + + public NonNullWrappedHashSet() {} + + public NonNullWrappedHashSet(Collection c) { + this.addAll(c); + } + + public NonNullWrappedHashSet(int initialCapacity, float loadFactor) { + super(initialCapacity, loadFactor); + } + + public NonNullWrappedHashSet(int initialCapacity) { + super(initialCapacity); + } + + @Override + public boolean add(E e) { + if (e != null) return super.add(e); + return false; + } + + @Override + public boolean addAll(Collection c) { + boolean wasChanged = false; + for (E element : c) { + if (element != null) wasChanged |= this.add(element); + } + return wasChanged; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java new file mode 100644 index 0000000000..cd9bc1746e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Map; + +@SuppressWarnings("unchecked") +public class Pair implements Map.Entry { + + Object[] pair = new Object[2]; + + public Pair(Object[] pair) { + this.pair = pair; + } + + public Pair(A k, B v) { + this.pair[0] = k; + this.pair[1] = v; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Pair)) return false; + + Pair pair1 = (Pair) o; + + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(this.pair, pair1.pair); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(8) + .putInt(this.pair[0].hashCode()) + .putInt(this.pair[1].hashCode()) + .array(), + 0, + 8, + 31); + } + + @Override + public A getKey() { + return (A) this.pair[0]; + } + + @Override + public B getValue() { + return (B) this.pair[1]; + } + + @Override + public B setValue(Object value) { + this.pair[1] = value; + return (B) this.pair[1]; + } + + public Pair copyWithNewValue(B value) { + return new Pair<>((A) this.pair[0], value); + } + + public Pair replaceValue(B value) { + this.setValue(value); + return this; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java new file mode 100644 index 0000000000..d0850b20c5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java @@ -0,0 +1,187 @@ +package com.github.bartimaeusnek.bartworks.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +/** + * Handle the parallel more efficient. + * + * @author GlodBlock + */ +public class RecipeFinderForParallel { + + /** + * This method is used for mega multis which have extremely high parallel. Never use it for non parallel machines, + * it will have worse performance. It will auto consume the inputs. + * + * @param aRecipe The target recipe that you want calculate the parallel + * @param aFluidInputs The input fluid from machine + * @param aItemStacks The input item from machine + * @param aMaxParallel The max parallel that it can reach + * @return The parallel that it can reach + */ + public static int handleParallelRecipe(GT_Recipe aRecipe, FluidStack[] aFluidInputs, ItemStack[] aItemStacks, + int aMaxParallel) { + if (aFluidInputs == null) aFluidInputs = new FluidStack[0]; + if (aItemStacks == null) aItemStacks = new ItemStack[0]; + HashMap tCompressedFluidInput = compressFluid(aFluidInputs); + HashMap tCompressedItemInput = compressItem(aItemStacks); + HashMap tCompressedFluidRecipe = compressFluid(aRecipe.mFluidInputs); + HashMap tCompressedItemRecipe = compressItem(aRecipe.mInputs); + int tCurrentPara = aMaxParallel; + for (int tFluid : tCompressedFluidRecipe.keySet()) { + if (tCompressedFluidInput.containsKey(tFluid) && tCompressedFluidRecipe.get(tFluid) != 0) { + tCurrentPara = Math + .min(tCurrentPara, tCompressedFluidInput.get(tFluid) / tCompressedFluidRecipe.get(tFluid)); + } + } + for (int tItem : tCompressedItemRecipe.keySet()) { + /* Wildcard Stuff */ + if (tItem >> 16 == Short.MAX_VALUE) { + int tCountWildcard = 0; + for (int tInputItem : tCompressedItemInput.keySet()) { + if ((tInputItem & 0xffff) == (tItem & 0xffff)) { + tCountWildcard += tCompressedItemInput.get(tInputItem); + } + } + tCurrentPara = Math.min(tCurrentPara, tCountWildcard / tCompressedItemRecipe.get(tItem)); + } else if (tCompressedItemRecipe.get(tItem) != 0) { + /* OreDict Stuff */ + int tCountOre = 0; + ItemStack tRealRecipe = GT_Utility.intToStack(tItem); + for (int tInputItem : tCompressedItemInput.keySet()) { + ItemStack tRealStack = GT_Utility.intToStack(tInputItem); + if (GT_OreDictUnificator.isInputStackEqual(tRealStack, tRealRecipe)) { + tCountOre += tCompressedItemInput.get(tInputItem); + } + } + tCurrentPara = Math.min(tCurrentPara, tCountOre / tCompressedItemRecipe.get(tItem)); + } + } + + for (int tFluid : tCompressedFluidRecipe.keySet()) { + int tOldSize = tCompressedFluidRecipe.get(tFluid); + tCompressedFluidRecipe.put(tFluid, tOldSize * tCurrentPara); + } + for (int tItem : tCompressedItemRecipe.keySet()) { + int tOldSize = tCompressedItemRecipe.get(tItem); + tCompressedItemRecipe.put(tItem, tOldSize * tCurrentPara); + } + + for (FluidStack tFluid : aFluidInputs) { + if (tFluid != null && tCompressedFluidRecipe.containsKey(tFluid.getFluidID())) { + if (tFluid.amount >= tCompressedFluidRecipe.get(tFluid.getFluidID())) { + tFluid.amount -= tCompressedFluidRecipe.get(tFluid.getFluidID()); + tCompressedFluidRecipe.remove(tFluid.getFluidID()); + } else { + tCompressedFluidRecipe + .put(tFluid.getFluidID(), tCompressedFluidRecipe.get(tFluid.getFluidID()) - tFluid.amount); + tFluid.amount = 0; + } + } + } + + /* OreDict Stuff */ + /* Wildcard Stuff */ + for (Iterator i = tCompressedItemRecipe.keySet() + .iterator(); i.hasNext();) { + int tItem = i.next(); + if (tItem >> 16 == Short.MAX_VALUE) { + for (ItemStack tInputItem : aItemStacks) { + int InputID = GT_Utility.stackToInt(tInputItem); + if ((InputID & 0xffff) == (tItem & 0xffff)) { + if (tInputItem.stackSize >= tCompressedItemRecipe.get(tItem)) { + tInputItem.stackSize -= tCompressedItemRecipe.get(tItem); + i.remove(); + break; + } + tCompressedItemRecipe.put(tItem, tCompressedItemRecipe.get(tItem) - tInputItem.stackSize); + tInputItem.stackSize = 0; + } + } + } else { + ItemStack tRealRecipe = GT_Utility.intToStack(tItem); + int tTargetAmount = tCompressedItemRecipe.get(tItem); + for (ItemStack input : aItemStacks) { + if (GT_OreDictUnificator.isInputStackEqual(input, tRealRecipe)) { + int d = Math.min(tTargetAmount, input.stackSize); + tTargetAmount -= d; + tCompressedItemRecipe.put(tItem, tTargetAmount); + input.stackSize -= d; + } + if (tTargetAmount == 0) { + i.remove(); + break; + } + } + } + } + + return tCurrentPara; + } + + /** + * Get the proper packed output stacks + * + * @param aRecipe The target recipe + * @param aPall The parallel it has + * @return A pair of the output fluid and item stack, the first value is fluid, the second is item. + */ + public static Pair, ArrayList> getMultiOutput(GT_Recipe aRecipe, int aPall) { + ArrayList tFluidList = new ArrayList<>(); + ArrayList tItemList = new ArrayList<>(); + if (aRecipe == null) return new Pair<>(tFluidList, tItemList); + if (aRecipe.mFluidOutputs != null && aRecipe.mFluidOutputs.length > 0) { + for (FluidStack tFluid : aRecipe.mFluidOutputs) { + if (tFluid != null && tFluid.amount > 0) { + tFluidList.add(new FluidStack(tFluid.getFluid(), tFluid.amount * aPall)); + } + } + } + if (aRecipe.mOutputs != null && aRecipe.mOutputs.length > 0) { + for (ItemStack tItem : aRecipe.mOutputs) { + if (tItem != null && tItem.stackSize > 0) { + int tAmount = tItem.stackSize * aPall; + while (tAmount > tItem.getMaxStackSize()) { + tItemList.add(GT_Utility.copyAmount(tItem.getMaxStackSize(), tItem)); + tAmount -= tItem.getMaxStackSize(); + } + tItemList.add(GT_Utility.copyAmount(tAmount, tItem)); + } + } + } + return new Pair<>(tFluidList, tItemList); + } + + public static HashMap compressItem(ItemStack[] aItemStacks) { + HashMap tCompressed = new HashMap<>(); + for (ItemStack tItem : aItemStacks) { + if (tItem != null) { + int tItemID = GT_Utility.stackToInt(tItem); + int tItemSize = tItem.stackSize; + tCompressed.merge(tItemID, tItemSize, Integer::sum); + } + } + return tCompressed; + } + + public static HashMap compressFluid(FluidStack[] aFluidStack) { + HashMap tCompressed = new HashMap<>(); + for (FluidStack tFluid : aFluidStack) { + if (tFluid != null) { + int tFluidID = tFluid.getFluidID(); + int tFluidSize = tFluid.amount; + tCompressed.merge(tFluidID, tFluidSize, Integer::sum); + } + } + return tCompressed; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java new file mode 100644 index 0000000000..b6216f3c42 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java @@ -0,0 +1,82 @@ +package com.github.bartimaeusnek.bartworks.util; + +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.StatCollector; + +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.util.GT_Utility; + +public class ResultWrongSievert implements CheckRecipeResult { + + public enum NeededSievertType { + EXACTLY, + MINIMUM + } + + private NeededSievertType type; + private int required; + + public ResultWrongSievert(int required, NeededSievertType type) { + this.required = required; + this.type = type; + } + + public String getID() { + return "wrong_sievert"; + } + + @Override + public boolean wasSuccessful() { + return false; + } + + @Override + public String getDisplayString() { + return switch (this.type) { + case EXACTLY -> StatCollector.translateToLocalFormatted( + "GT5U.gui.text.wrong_sievert_exactly", + GT_Utility.formatNumbers(this.required)); + case MINIMUM -> StatCollector + .translateToLocalFormatted("GT5U.gui.text.wrong_sievert_min", GT_Utility.formatNumbers(this.required)); + }; + } + + @Override + public CheckRecipeResult newInstance() { + return new ResultWrongSievert(0, NeededSievertType.EXACTLY); + } + + @Override + public void encode(PacketBuffer buffer) { + buffer.writeVarIntToBuffer(this.required); + buffer.writeVarIntToBuffer(this.type.ordinal()); + } + + @Override + public void decode(PacketBuffer buffer) { + this.required = buffer.readVarIntFromBuffer(); + this.type = NeededSievertType.values()[buffer.readVarIntFromBuffer()]; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ResultWrongSievert that = (ResultWrongSievert) o; + return this.required == that.required; + } + + /** + * Cannot process recipe because the machine doesn't have the minimum amount of sievert + */ + public static CheckRecipeResult insufficientSievert(int required) { + return new ResultWrongSievert(required, NeededSievertType.MINIMUM); + } + + /** + * Cannot process recipe because the machine doesn't have the exact amount of sievert + */ + public static CheckRecipeResult wrongSievert(int required) { + return new ResultWrongSievert(required, NeededSievertType.EXACTLY); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/StreamUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/StreamUtils.java new file mode 100644 index 0000000000..4c1c82b9bf --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/StreamUtils.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.util.Optional; +import java.util.function.Predicate; + +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GT_Recipe; + +public class StreamUtils { + + private StreamUtils() {} + + public static Predicate> filterVisualMaps() { + return recipeMap -> { + Optional op = recipeMap.getAllRecipes() + .stream() + .findAny(); + return op.isPresent() && !op.get().mFakeRecipe; + }; + } + + public static boolean filterVisualMaps(RecipeMap recipeMap) { + return filterVisualMaps().test(recipeMap); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java new file mode 100644 index 0000000000..241f20c1f9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util.accessprioritylist; + +import java.util.Collection; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Set; +import java.util.Spliterator; + +import org.apache.commons.lang3.NotImplementedException; + +public class AccessPriorityList implements List, Deque, Set { + + transient int size = 0; + transient AccessPriorityListNode head; + transient AccessPriorityListNode tail; + + public static AccessPriorityList create() { + return new AccessPriorityList<>(); + } + + public AccessPriorityList() {} + + @Override + public void addFirst(E t) { + final AccessPriorityListNode first = this.head; + final AccessPriorityListNode newNode = new AccessPriorityListNode<>(null, t, first); + this.head = newNode; + if (first == null) this.tail = newNode; + else first.setBefore(newNode); + this.size++; + } + + @Override + public void addLast(E t) { + final AccessPriorityListNode last = this.tail; + final AccessPriorityListNode newNode = new AccessPriorityListNode<>(last, t, null); + this.tail = newNode; + if (last == null) this.head = newNode; + else last.setNext(newNode); + this.size++; + } + + @Override + public boolean offerFirst(E e) { + throw new NotImplementedException(""); + } + + @Override + public boolean offerLast(E e) { + throw new NotImplementedException(""); + } + + @Override + public E removeFirst() { + E first = this.head.getELEMENT(); + AccessPriorityListNode node = this.head; + this.head = node.getNext(); + this.head.setBefore(null); + node.destroy(); + node = null; + this.size--; + return first; + } + + @Override + public E removeLast() { + E last = this.tail.getELEMENT(); + AccessPriorityListNode node = this.tail; + this.tail = node.getBefore(); + this.tail.setNext(null); + node.destroy(); + node = null; + this.size--; + return last; + } + + @Override + public E pollFirst() { + throw new NotImplementedException(""); + } + + @Override + public E pollLast() { + throw new NotImplementedException(""); + } + + @Override + public E getFirst() { + return this.peekFirst(); + } + + @Override + public E getLast() { + return this.peekLast(); + } + + @Override + public E peekFirst() { + return this.head != null ? this.head.getELEMENT() : null; + } + + @Override + public E peekLast() { + return this.tail != null ? this.tail.getELEMENT() : null; + } + + @Override + public boolean removeFirstOccurrence(Object o) { + throw new NotImplementedException(""); + } + + @Override + public boolean removeLastOccurrence(Object o) { + throw new NotImplementedException(""); + } + + @Override + public int size() { + return this.size; + } + + @Override + public boolean isEmpty() { + return this.size == 0; + } + + @Override + public boolean contains(Object o) { + throw new NotImplementedException(""); + } + + @Override + public Iterator iterator() { + return new AccessPriorityListIterators.AccessPriorityListIterator<>(this.head); + } + + public Iterator> nodeIterator() { + return new AccessPriorityListIterators.AccessPriorityListNodeIterator<>(this.head); + } + + @Override + public Iterator descendingIterator() { + return new AccessPriorityListIterators.AccessPriorityListReverseIterator<>(this.tail); + } + + @Override + public Object[] toArray() { + Object[] ret = new Object[this.size]; + int index = 0; + for (Iterator it = this.iterator(); it.hasNext(); index++) ret[index] = it.next(); + return ret; + } + + @Override + public T[] toArray(T[] a) { + T[] ret = (T[]) new Object[this.size]; + int index = 0; + for (Iterator it = (Iterator) this.iterator(); it.hasNext(); index++) ret[index] = it.next(); + return ret; + } + + @Override + public boolean add(E e) { + this.addLast(e); + return true; + } + + private void moveNodeUp(AccessPriorityListNode node) { + if (node == this.head || node.getBefore() == null) return; + final AccessPriorityListNode before = node.getBefore(); + final AccessPriorityListNode beforeBefore = before.getBefore(); + final AccessPriorityListNode next = node.getNext(); + + // <0,1,2> <1,2,3> N<2,3,4> <3,4,5> + + node.setBefore(beforeBefore); + // <0,1,2> <1,2,3> N<0,3,4> <3,4,5> + + if (beforeBefore != null) beforeBefore.setNext(node); + else this.head = node; + // <0,1,3> <1,2,3> N<0,3,4> <3,4,5> + + before.setBefore(node); + // <0,1,3> <3,2,3> N<0,3,4> <3,4,5> + + before.setNext(next); + // <0,1,3> <3,2,4> N<0,3,4> <3,4,5> + + if (next != null) next.setBefore(before); + else this.tail = before; + // <0,1,3> N<0,3,4> <3,2,4> <2,4,5> + + node.setNext(before); + // <0,1,3> N<0,3,2> <3,2,4> <2,4,5> + } + + AccessPriorityListNode getNode(int index) { + if (index <= this.size / 2) { + AccessPriorityListNode x = this.head; + for (int i = 0; i < index; i++) x = x.getNext(); + return x; + } + AccessPriorityListNode x = this.tail; + for (int i = this.size - 1; i > index; i--) x = x.getBefore(); + return x; + } + + @Override + public boolean offer(E e) { + throw new NotImplementedException(""); + } + + private boolean isValidIndex(int index) { + if (index >= 0 && index < this.size) return true; + throw new ArrayIndexOutOfBoundsException("NOT A VAILD INDEX!"); + } + + @Override + public E remove() { + throw new NotImplementedException(""); + } + + @Override + public E poll() { + return this.removeFirst(); + } + + @Override + public E element() { + throw new NotImplementedException(""); + } + + @Override + public E peek() { + return this.getFirst(); + } + + @Override + public void push(E e) { + this.addFirst(e); + } + + @Override + public E pop() { + return this.removeFirst(); + } + + @Override + public boolean remove(Object o) { + // Object p; + // for (Iterator it = this.iterator(); it.hasNext(); o.equals(p)){ + // p = it.next(); + // } + throw new NotImplementedException(""); + } + + @Override + public boolean containsAll(Collection c) { + throw new NotImplementedException(""); + } + + @Override + public boolean addAll(Collection c) { + if (c == null) return false; + c.forEach(this::addLast); + return true; + } + + @Override + public boolean addAll(int index, Collection c) { + throw new NotImplementedException(""); + } + + @Override + public boolean removeAll(Collection c) { + throw new NotImplementedException(""); + } + + @Override + public boolean retainAll(Collection c) { + throw new NotImplementedException(""); + } + + @Override + public void clear() { + if (this.tail != null) { + AccessPriorityListNode node = this.tail; + while (node.getBefore() != null) { + node.setNext(null); + node.setPriority(0L); + node = node.getBefore(); + node.getNext() + .setBefore(null); + } + this.size = 0; + this.head = null; + this.tail = null; + } + } + + public void addPrioToNode(AccessPriorityListNode node) { + this.addPrioToNode(node, 1L); + } + + public void addPrioToNode(AccessPriorityListNode node, long prio) { + long current = node.getPriority(); + if (current == Long.MAX_VALUE || current > 0 && prio > 0 && prio + current < 0) + node.setPriority(Long.MAX_VALUE); + else node.setPriority(current + prio); + while (node.getBefore() != null && node.getPriority() >= node.getBefore() + .getPriority()) { + this.moveNodeUp(node); + } + } + + public void addPrioToNode(int index, long prio) { + if (!this.isValidIndex(index)) return; + AccessPriorityListNode node = this.getNode(index); + this.addPrioToNode(node, prio); + } + + public void addPrioToNode(int index) { + this.addPrioToNode(index, 1L); + } + + @Override + public E get(int index) { + if (!this.isValidIndex(index)) return null; + AccessPriorityListNode node = this.getNode(index); + return node.getELEMENT(); + } + + @Override + public E set(int index, E element) { + throw new NotImplementedException(""); + } + + @Override + public void add(int index, E element) { + throw new NotImplementedException(""); + } + + @Override + public E remove(int index) { + throw new NotImplementedException(""); + } + + @Override + public int indexOf(Object o) { + throw new NotImplementedException(""); + } + + @Override + public int lastIndexOf(Object o) { + throw new NotImplementedException(""); + } + + @Override + public ListIterator listIterator() { + return new AccessPriorityListIterators.AccessPriorityListListIterator<>(this.head, this.tail, false); + } + + @Override + public ListIterator listIterator(int index) { + return new AccessPriorityListIterators.AccessPriorityListListIterator<>(this, index); + } + + @Override + public List subList(int fromIndex, int toIndex) { + throw new NotImplementedException(""); + } + + @Override + public Spliterator spliterator() { + throw new NotImplementedException(""); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java new file mode 100644 index 0000000000..f24105db17 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util.accessprioritylist; + +import java.util.Iterator; +import java.util.ListIterator; + +import org.apache.commons.lang3.NotImplementedException; + +public class AccessPriorityListIterators { + + public static class AccessPriorityListListIterator implements ListIterator { + + final AccessPriorityListNode head; + final AccessPriorityListNode tail; + AccessPriorityListNode current; + int counter = 0; + boolean reverse; + + public AccessPriorityListListIterator(AccessPriorityListNode head, AccessPriorityListNode tail, + boolean reverse) { + this.head = head; + this.tail = tail; + this.current = reverse ? tail : head; + this.reverse = reverse; + } + + public AccessPriorityListListIterator(AccessPriorityList list, int index) { + this.head = list.head; + this.tail = list.tail; + this.current = list.getNode(index); + this.counter = index; + } + + @Override + public boolean hasNext() { + return this.reverse ? this.head != this.current : this.tail != this.current; + } + + @Override + public E next() { + this.counter++; + E ret = this.current.getELEMENT(); + this.current = this.current.getNext(); + return ret; + } + + @Override + public boolean hasPrevious() { + return !this.reverse ? this.head != this.current : this.tail != this.current; + } + + @Override + public E previous() { + this.counter--; + E ret = this.current.getELEMENT(); + this.current = this.current.getBefore(); + return ret; + } + + @Override + public int nextIndex() { + return this.counter + 1; + } + + @Override + public int previousIndex() { + return this.counter - 1; + } + + @Override + public void remove() { + throw new NotImplementedException("Not Implemented"); + } + + @Override + public void set(E e) { + throw new NotImplementedException("Not Implemented"); + } + + @Override + public void add(E e) { + throw new NotImplementedException("Not Implemented"); + } + } + + public static class AccessPriorityListIterator implements Iterator { + + final AccessPriorityListNode head; + AccessPriorityListNode current; + + public AccessPriorityListIterator(AccessPriorityListNode head) { + this.head = this.current = head; + } + + @Override + public boolean hasNext() { + return this.current != null; + } + + @Override + public E next() { + E ret = this.current.getELEMENT(); + this.current = this.current.getNext(); + return ret; + } + } + + public static class AccessPriorityListReverseIterator implements Iterator { + + final AccessPriorityListNode tail; + AccessPriorityListNode current; + + public AccessPriorityListReverseIterator(AccessPriorityListNode tail) { + this.tail = this.current = tail; + } + + @Override + public boolean hasNext() { + return this.current != null; + } + + @Override + public E next() { + E ret = this.current.getELEMENT(); + this.current = this.current.getBefore(); + return ret; + } + } + + public static class AccessPriorityListNodeIterator implements Iterator> { + + final AccessPriorityListNode head; + AccessPriorityListNode current; + + public AccessPriorityListNodeIterator(AccessPriorityListNode head) { + this.head = this.current = head; + } + + @Override + public boolean hasNext() { + return this.current != null; + } + + @Override + public AccessPriorityListNode next() { + AccessPriorityListNode ret = this.current; + this.current = this.current.getNext(); + return ret; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java new file mode 100644 index 0000000000..72b266917f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018-2019 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util.accessprioritylist; + +public class AccessPriorityListNode { + + public static final AccessPriorityListNode EMPTY_NODE = new AccessPriorityListNode<>(null); + + private final E ELEMENT; + private long priority = Long.MIN_VALUE; + private AccessPriorityListNode next; + private AccessPriorityListNode before; + + public AccessPriorityListNode(E element) { + this.ELEMENT = element; + } + + public AccessPriorityListNode(AccessPriorityListNode before, E element, AccessPriorityListNode next) { + this.ELEMENT = element; + this.connect(next, before); + } + + public void connect(AccessPriorityListNode next, AccessPriorityListNode before) { + this.setNext(next); + this.setBefore(before); + } + + public E getELEMENT() { + return this.ELEMENT; + } + + public long getPriority() { + return this.priority; + } + + public void setPriority(long priority) { + this.priority = priority; + } + + public AccessPriorityListNode getNext() { + return this.next; + } + + public void setNext(AccessPriorityListNode next) { + this.next = next; + } + + public AccessPriorityListNode getBefore() { + return this.before; + } + + public void setBefore(AccessPriorityListNode before) { + this.before = before; + } + + void destroy() { + this.before = null; + this.next = null; + this.priority = 0L; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java new file mode 100644 index 0000000000..d797e68d8a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util.flowerset; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; +import java.util.function.Function; + +public class FlowerSet implements Set { + + public FlowerSet(int petals, Function, Integer> comparerison) { + this.petals = petals; + this.comparerison = comparerison; + } + + final int petals; + final Function, Integer> comparerison; + + public static FlowerSet createBase64(Function, Integer> comparerison) { + return new FlowerSet<>(64, comparerison); + } + + public static FlowerSet createHexflower(Function, Integer> comparerison) { + return new FlowerSet<>(16, comparerison); + } + + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T1[] toArray(T1[] a) { + return null; + } + + @Override + public boolean add(T t) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public void clear() {} + + static class FlowerNode { + + private final FlowerSet map; + final V value; + final FlowerNode[] links; + + @SuppressWarnings("unchecked") + public FlowerNode(V value, FlowerSet map) { + this.value = value; + this.map = map; + this.links = new FlowerNode[map.petals]; + } + + private static final int DEPTH = 20480; + + public void TryToSetSingleNode(FlowerNode node, FlowerNode toset, int place, int depth) { + if (depth > DEPTH) throw new IllegalStateException("Recursive Call went too deep."); + if (node.links[place] == null) node.links[place] = toset; + else { + this.TryToSetSingleNode(node.links[place], toset, place, depth); + depth++; + } + } + + public void TryToSetSingleNode(FlowerNode node, FlowerNode toset, int place) { + if (node.links[place] == null) node.links[place] = toset; + else this.TryToSetSingleNode(node.links[place], toset, place, 0); + } + + @SafeVarargs + public final void SetUpLinks(FlowerNode... links) { + for (FlowerNode node : links) { + int place = this.map.comparerison.apply(node); + this.TryToSetSingleNode(this, node, place); + } + } + } + + static class Functions { + + public static Function, Integer> HashBasedFunction() { + return function -> function.hashCode() % function.map.petals; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/log/DebugLog.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/log/DebugLog.java new file mode 100644 index 0000000000..6ead05ce96 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/log/DebugLog.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util.log; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.FileHandler; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class DebugLog { + + private static boolean init; + static FileHandler fh; + private static Logger utilLog; + + public static void initDebugLog(FMLPreInitializationEvent event) throws IOException { + if (DebugLog.init) return; + DebugLog.fh = new FileHandler( + new File( + new File( + event.getModConfigurationDirectory() + .getParentFile(), + "logs"), + "BWLog.log").toString()); + DebugLog.utilLog = Logger.getLogger("DebugLog"); + DebugLog.utilLog.setUseParentHandlers(false); + DebugLog.utilLog.addHandler(DebugLog.fh); + Formatter formatter = new Formatter() { + + @Override + public String format(LogRecord record) { + SimpleDateFormat logTime = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + Calendar cal = new GregorianCalendar(); + cal.setTimeInMillis(record.getMillis()); + return "Level: " + record + .getLevel() + " at " + logTime.format(cal.getTime()) + " " + record.getMessage() + "\n"; + } + }; + DebugLog.fh.setFormatter(formatter); + DebugLog.init = true; + } + + public static void log(String record) { + if (!DebugLog.init) return; + DebugLog.utilLog.info(record); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/package-info.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/package-info.java new file mode 100644 index 0000000000..8d9d539524 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +@API(owner = Mods.Names.BART_WORKS, apiVersion = API_REFERENCE.VERSION, provides = "bartworks util") +package com.github.bartimaeusnek.bartworks.util; + +import com.github.bartimaeusnek.bartworks.API.API_REFERENCE; + +import cpw.mods.fml.common.API; +import gregtech.api.enums.Mods; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java new file mode 100644 index 0000000000..b1264fb9af --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod; + +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GalacticraftCore; +import static gregtech.api.enums.Mods.TecTech; + +import java.io.StringReader; + +import net.minecraft.util.StringTranslate; + +import org.apache.commons.io.input.ReaderInputStream; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.github.bartimaeusnek.bartworks.API.API_REFERENCE; +import com.github.bartimaeusnek.crossmod.GTpp.loader.RadioHatchCompat; +import com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy; +import com.github.bartimaeusnek.crossmod.tectech.TecTechResearchLoader; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; + +@Mod( + modid = BartWorksCrossmod.MOD_ID, + name = BartWorksCrossmod.NAME, + version = BartWorksCrossmod.VERSION, + dependencies = """ + required-after:IC2;\ + required-after:gregtech;\ + required-after:bartworks;\ + after:GalacticraftMars;\ + after:GalacticraftCore;\ + after:Micdoodlecore;\ + after:miscutils;\ + after:EMT;\ + after:tectech;""") +public class BartWorksCrossmod { + + public static final String NAME = "BartWorks Mod Additions"; + public static final String VERSION = API_REFERENCE.VERSION; + public static final String MOD_ID = "bartworkscrossmod"; + public static final Logger LOGGER = LogManager.getLogger(BartWorksCrossmod.NAME); + + @Mod.Instance(BartWorksCrossmod.MOD_ID) + public static BartWorksCrossmod instance; + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent preinit) { + if (GalacticraftCore.isModLoaded()) { + GalacticraftProxy.preInit(preinit); + } + } + + @Mod.EventHandler + public void init(FMLInitializationEvent init) { + if (GalacticraftCore.isModLoaded()) { + GalacticraftProxy.init(init); + } + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent init) { + if (GalacticraftCore.isModLoaded()) { + GalacticraftProxy.postInit(init); + } + if (GTPlusPlus.isModLoaded()) { + RadioHatchCompat.run(); + } + if (TecTech.isModLoaded()) { + TecTechResearchLoader.runResearches(); + } + } + + @Mod.EventHandler + public void onFMLServerStart(FMLServerStartingEvent event) { + if (GTPlusPlus.isModLoaded()) { + for (Object s : RadioHatchCompat.TranslateSet) { + StringTranslate.inject(new ReaderInputStream(new StringReader((String) s))); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java b/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java new file mode 100644 index 0000000000..b8fcdb9135 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.GTpp.loader; + +import static gregtech.api.enums.Mods.GTPlusPlus; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.RegistryNamespaced; +import net.minecraftforge.oredict.OreDictionary; + +import com.github.bartimaeusnek.bartworks.API.IRadMaterial; +import com.github.bartimaeusnek.bartworks.util.log.DebugLog; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.common.registry.GameRegistry; + +public class RadioHatchCompat { + + private static Class intf; + private static Class materialClass; + private static Class enu; + private static Class materialStackClass; + + private static Field isRadioactive; + private static Field f; + private static Field componentType; + private static Field radlevel; + private static Field protons; + + private static Field vMaterialInput; + private static Field stackMaterial; + private static Field RGBA; + private static Field localizedName; + private static Field unlocalizedName; + + private static Object rod; + private static Object longRod; + + public static HashSet TranslateSet = new HashSet<>(); + + static { + try { + RadioHatchCompat.intf = Class.forName("gtPlusPlus.core.item.base.BaseItemComponent"); + RadioHatchCompat.enu = Class.forName("gtPlusPlus.core.item.base.BaseItemComponent$ComponentTypes"); + RadioHatchCompat.materialClass = Class.forName("gtPlusPlus.core.material.Material"); + RadioHatchCompat.materialStackClass = Class.forName("gtPlusPlus.core.material.MaterialStack"); + + RadioHatchCompat.f = RadioHatchCompat.intf.getField("componentMaterial"); + RadioHatchCompat.isRadioactive = RadioHatchCompat.materialClass.getField("isRadioactive"); + RadioHatchCompat.componentType = RadioHatchCompat.intf.getDeclaredField("componentType"); + RadioHatchCompat.radlevel = RadioHatchCompat.materialClass.getField("vRadiationLevel"); + + RadioHatchCompat.vMaterialInput = RadioHatchCompat.materialClass.getDeclaredField("vMaterialInput"); + RadioHatchCompat.stackMaterial = RadioHatchCompat.materialStackClass.getDeclaredField("stackMaterial"); + RadioHatchCompat.protons = RadioHatchCompat.materialClass.getDeclaredField("vProtons"); + RadioHatchCompat.RGBA = RadioHatchCompat.materialClass.getDeclaredField("RGBA"); + RadioHatchCompat.localizedName = RadioHatchCompat.materialClass.getDeclaredField("localizedName"); + RadioHatchCompat.unlocalizedName = RadioHatchCompat.materialClass.getDeclaredField("unlocalizedName"); + + RadioHatchCompat.vMaterialInput.setAccessible(true); + RadioHatchCompat.stackMaterial.setAccessible(true); + RadioHatchCompat.protons.setAccessible(true); + RadioHatchCompat.RGBA.setAccessible(true); + RadioHatchCompat.localizedName.setAccessible(true); + RadioHatchCompat.unlocalizedName.setAccessible(true); + + Object[] arr = RadioHatchCompat.enu.getEnumConstants(); + for (Object o : arr) { + if (RadioHatchCompat.rod != null && RadioHatchCompat.longRod != null) break; + if ("ROD".equalsIgnoreCase(o.toString())) RadioHatchCompat.rod = o; + else if ("RODLONG".equalsIgnoreCase(o.toString())) RadioHatchCompat.longRod = o; + } + + } catch (NoSuchFieldException | ClassNotFoundException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + public static void run() { + DebugLog.log("Starting Generation of missing GT++ rods/longrods"); + try { + Class rodclass = (Class) Class + .forName("gtPlusPlus.core.item.base.rods.BaseItemRod"); + Class longrodclass = (Class) Class + .forName("gtPlusPlus.core.item.base.rods.BaseItemRodLong"); + Constructor c1 = rodclass.getConstructor(RadioHatchCompat.materialClass); + Constructor c2 = longrodclass.getConstructor(RadioHatchCompat.materialClass); + Field cOwners = GameData.class.getDeclaredField("customOwners"); + cOwners.setAccessible(true); + Field map = RegistryNamespaced.class.getDeclaredField("field_148758_b"); + map.setAccessible(true); + Map UniqueIdentifierMap = (Map) map.get(GameData.getItemRegistry()); + + Map ownerItems = (Map) cOwners + .get(null); + ModContainer gtpp = null; + ModContainer bartworks = null; + + for (ModContainer container : Loader.instance() + .getModList()) { + if (gtpp != null && bartworks != null) break; + if (BartWorksCrossmod.MOD_ID.equalsIgnoreCase(container.getModId())) bartworks = container; + else if (container.getModId() + .equalsIgnoreCase(GTPlusPlus.ID)) gtpp = container; + } + + for (Object mats : (Set) RadioHatchCompat.materialClass.getField("mMaterialMap") + .get(null)) { + if (RadioHatchCompat.isRadioactive.getBoolean(mats)) { + + if (OreDictionary.getOres("stick" + RadioHatchCompat.unlocalizedName.get(mats)) + .isEmpty()) { + Item it = c1.newInstance(mats); + UniqueIdentifierMap.replace(it, "miscutils:" + it.getUnlocalizedName()); + GameRegistry.UniqueIdentifier ui = GameRegistry.findUniqueIdentifierFor(it); + ownerItems.replace(ui, bartworks, gtpp); + + String tanslate = it.getUnlocalizedName() + ".name=" + + RadioHatchCompat.localizedName.get(mats) + + " Rod"; + RadioHatchCompat.TranslateSet.add(tanslate); + + DebugLog.log(tanslate); + DebugLog.log("Generate: " + RadioHatchCompat.rod + RadioHatchCompat.unlocalizedName.get(mats)); + } + if (OreDictionary.getOres("stickLong" + RadioHatchCompat.unlocalizedName.get(mats)) + .isEmpty()) { + Item it2 = c2.newInstance(mats); + UniqueIdentifierMap.replace(it2, "miscutils:" + it2.getUnlocalizedName()); + GameRegistry.UniqueIdentifier ui2 = GameRegistry.findUniqueIdentifierFor(it2); + ownerItems.replace(ui2, bartworks, gtpp); + + DebugLog + .log("Generate: " + RadioHatchCompat.longRod + RadioHatchCompat.unlocalizedName.get(mats)); + } + } + } + } catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException + | InstantiationException | ClassNotFoundException e) { + e.printStackTrace(); + } + } + + public static IRadMaterial GTppRadChecker(ItemStack lStack) { + try { + if (RadioHatchCompat.intf.isAssignableFrom( + lStack.getItem() + .getClass())) { + if (!RadioHatchCompat.isRadioactive.getBoolean(RadioHatchCompat.f.get(lStack.getItem()))) return null; + int amount = RadioHatchCompat.componentType.get(lStack.getItem()) + .equals(RadioHatchCompat.rod) ? 1 + : RadioHatchCompat.componentType.get(lStack.getItem()) + .equals(RadioHatchCompat.longRod) ? 2 : 0; + if (amount == 0) return null; + return new RadioHatchCompat.GTPPRadAdapter(amount, RadioHatchCompat.f.get(lStack.getItem())); + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } + + static class GTPPRadAdapter implements IRadMaterial { + + static final HashMap BUFFER = new HashMap<>(); + + GTPPRadAdapter(Object m) { + this.m = m; + } + + GTPPRadAdapter(int amount, Object m) { + this.amount = (byte) amount; + this.m = m; + } + + byte amount; + final Object m; + + private static ArrayList getMaterialInput(Object GTPPMaterial) throws IllegalAccessException { + Object ret = RadioHatchCompat.vMaterialInput.get(GTPPMaterial); + return ret instanceof ArrayList ? (ArrayList) ret : new ArrayList<>(); + } + + private static boolean isElement(Object GTPPMaterial) throws IllegalAccessException { + return RadioHatchCompat.GTPPRadAdapter.getMaterialInput(GTPPMaterial) + .isEmpty(); + } + + private static List getElemets(Object GTPPMaterial) throws IllegalAccessException { + ArrayList elements = new ArrayList<>(); + Queue toCheck = new LinkedList<>(); + ArrayList materialInputs = RadioHatchCompat.GTPPRadAdapter.getMaterialInput(GTPPMaterial); + if (materialInputs.isEmpty()) return Collections.singletonList(GTPPMaterial); + for (Object materialStack : materialInputs) { + if (!RadioHatchCompat.GTPPRadAdapter.isElement(RadioHatchCompat.stackMaterial.get(materialStack))) + toCheck.add(RadioHatchCompat.stackMaterial.get(materialStack)); + else elements.add(RadioHatchCompat.stackMaterial.get(materialStack)); + } + while (!toCheck.isEmpty()) { + elements.addAll(GTPPRadAdapter.getElemets(toCheck.poll())); + } + return elements; + } + + private static Integer calulateRad(Object m) { + int ret = 0; + try { + List pureElements = RadioHatchCompat.GTPPRadAdapter.getElemets(m); + for (Object materialObj : pureElements) if (RadioHatchCompat.isRadioactive.getBoolean(materialObj)) + ret += RadioHatchCompat.radlevel.getByte(m) + + RadioHatchCompat.GTPPRadAdapter.clampToZero(RadioHatchCompat.protons.getLong(materialObj)); + else ret += RadioHatchCompat.radlevel.getByte(m); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return ret; + } + + @Override + public int getRadiationLevel(ItemStack aStack) { + return RadioHatchCompat.GTPPRadAdapter.BUFFER + .computeIfAbsent(this.m, radlvl -> RadioHatchCompat.GTPPRadAdapter.calulateRad(this.m)); + } + + private static long clampToZero(long number) { + return number > 0 ? number : 0; + } + + @Override + public byte getAmountOfMaterial(ItemStack aStack) { + return this.amount; + } + + @Override + public short[] getColorForGUI(ItemStack aStack) { + short[] rgba = { 0, 0, 0, 0 }; + try { + rgba = (short[]) RadioHatchCompat.RGBA.get(this.m); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return rgba; + } + + @Override + public String getNameForGUI(ItemStack aStack) { + String ret = ""; + try { + ret = (String) RadioHatchCompat.localizedName.get(this.m); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return ret; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java b/src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java new file mode 100644 index 0000000000..adb3d42754 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.cls; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Optional; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; + +@SuppressWarnings({ "rawtypes", "unchecked" }) +public class CLSCompat { + + private CLSCompat() {} + + private static final long MINIMAL_UPDATE_INTERVAL = 1000 / 30; // target 30 fps + private static long lastUpdate = 0; + private static Class alexiilMinecraftDisplayer; + private static Class alexiilProgressDisplayer; + private static Method displayProgress; + private static Field isRegisteringBartWorks; + + static { + try { + alexiilMinecraftDisplayer = Class.forName("alexiil.mods.load.MinecraftDisplayer"); + alexiilProgressDisplayer = Class.forName("alexiil.mods.load.ProgressDisplayer"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + + Optional.ofNullable(alexiilMinecraftDisplayer) + .ifPresent(e -> { + try { + isRegisteringBartWorks = e.getField("isRegisteringBartWorks"); + } catch (NoSuchFieldException ex) { + ex.printStackTrace(); + } + }); + + Optional.ofNullable(alexiilProgressDisplayer) + .ifPresent(e -> { + try { + displayProgress = e.getMethod("displayProgress", String.class, float.class); + } catch (NoSuchMethodException ex) { + ex.printStackTrace(); + } + }); + } + + public static Integer[] initCls() { + int sizeStep; + int sizeStep2 = 1; + + try { + isRegisteringBartWorks.set(null, true); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + if (Werkstoff.werkstoffHashSet.size() >= 100) sizeStep = Werkstoff.werkstoffHashSet.size() / 100 - 1; + else sizeStep = sizeStep2 = Werkstoff.werkstoffHashSet.size(); + + return new Integer[] { sizeStep, sizeStep2, sizeStep }; + } + + public static int invokeStepSize(Werkstoff werkstoff, Integer[] steps, int size) { + --steps[0]; + + long time = System.currentTimeMillis(); + if (time - lastUpdate >= MINIMAL_UPDATE_INTERVAL) { + try { + displayProgress.invoke(null, werkstoff.getDefaultName(), (float) size / 10000); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + lastUpdate = time; + } + + if (steps[0] == 0 && Werkstoff.werkstoffHashSet.size() >= 100) steps[0] = steps[2]; + + size += steps[1]; + return size; + } + + public static void disableCls() { + try { + isRegisteringBartWorks.set(null, false); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java new file mode 100644 index 0000000000..da9bd49397 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticgreg; + +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.enums.GT_HatchElement.InputBus; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_HatchElement.OutputBus; +import static gregtech.api.enums.GT_Values.VN; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +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.gen.ChunkProviderServer; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.google.common.collect.ImmutableList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase; + +public abstract class GT_TileEntity_VoidMiner_Base extends GT_MetaTileEntity_DrillerBase { + + private VoidMinerUtility.DropMap dropMap = null; + private VoidMinerUtility.DropMap extraDropMap = null; + private float totalWeight; + private int multiplier = 1; + + protected final byte TIER_MULTIPLIER; + + private boolean mBlacklist = false; + + /** + * @Deprecated Use {@link VoidMinerUtility#addBlockToDimensionList} + */ + @Deprecated + public static void addBlockToDimensionList(int dimId, Block block, int meta, float weight) { + VoidMinerUtility.addBlockToDimensionList(dimId, block, meta, weight); + } + + public GT_TileEntity_VoidMiner_Base(int aID, String aName, String aNameRegional, int tier) { + super(aID, aName, aNameRegional); + this.TIER_MULTIPLIER = (byte) Math.max(tier, 1); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mBlacklist", this.mBlacklist); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mBlacklist = aNBT.getBoolean("mBlacklist"); + } + + public GT_TileEntity_VoidMiner_Base(String aName, int tier) { + super(aName); + this.TIER_MULTIPLIER = (byte) tier; + } + + @Override + protected int getMinTier() { + return this.TIER_MULTIPLIER + 5; // min tier = LuV + } + + @Override + protected boolean checkHatches() { + return true; + } + + @Override + protected void setElectricityStats() { + try { + this.mEUt = this.isPickingPipes ? 60 : Math.toIntExact(GT_Values.V[this.getMinTier()]); + } catch (ArithmeticException e) { + e.printStackTrace(); + this.mEUt = Integer.MAX_VALUE - 7; + } + this.mOutputItems = new ItemStack[0]; + this.mProgresstime = 0; + this.mMaxProgresstime = 10; + this.mEfficiency = this.getCurrentEfficiency(null); + this.mEfficiencyIncrease = 10000; + this.mEUt = this.mEUt > 0 ? -this.mEUt : this.mEUt; + } + + @Override + protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, + int yHead, int oldYHead) { + // if the dropMap has never been initialised or if the dropMap is empty + if (this.dropMap == null || this.totalWeight == 0) this.calculateDropMap(); + + if (this.totalWeight != 0.f) { + this.handleFluidConsumption(); + this.handleOutputs(); + return true; + } else { + this.stopMachine(ShutDownReasonRegistry.NONE); + return false; + } + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + String casings = this.getCasingBlockItem() + .get(0) + .getDisplayName(); + + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Miner") + .addInfo("Controller Block for the Void Miner " + GT_Values.VN[this.getMinTier()]) + .addInfo("Consumes " + GT_Values.V[this.getMinTier()] + "EU/t") + .addInfo( + "Can be supplied with 2L/s of Neon(x4), Krypton(x8), Xenon(x16) or Oganesson(x64) for higher outputs.") + .addInfo( + "Will output " + 2 * this.TIER_MULTIPLIER + + " Ores per Second depending on the Dimension it is build in") + .addInfo("Put the Ore into the input bus to set the Whitelist/Blacklist") + .addInfo("Use a screwdriver to toggle Whitelist/Blacklist") + .addInfo("Blacklist or non Whitelist Ore will be VOIDED") + .addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addOtherStructurePart(casings, "form the 3x1x3 Base") + .addOtherStructurePart(casings, "1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart( + this.getFrameMaterial().mName + " Frame Boxes", + "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[this.getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes or Ores, optional, any base casing") + .addInputHatch("Optional noble gas, any base casing") + .addOutputBus("Any base casing") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + protected List> getAllowedHatches() { + return ImmutableList.of(InputHatch, InputBus, OutputBus, Maintenance, Energy); + } + + /** + * method used to pick the next ore in the dropMap. + * + * @return the chosen ore + */ + private ItemStack nextOre() { + float currentWeight = 0.f; + while (true) { + float randomNumber = XSTR.XSTR_INSTANCE.nextFloat() * this.totalWeight; + for (Map.Entry entry : this.dropMap.getInternalMap() + .entrySet()) { + currentWeight += entry.getValue(); + if (randomNumber < currentWeight) return entry.getKey() + .getItemStack(); + } + for (Map.Entry entry : this.extraDropMap.getInternalMap() + .entrySet()) { + currentWeight += entry.getValue(); + if (randomNumber < currentWeight) return entry.getKey() + .getItemStack(); + } + } + } + + /** + * Method used to check the current gat and its corresponding multiplier + * + * @return the noble gas in the hatch. returns null if there is no noble gas found. + */ + private FluidStack getNobleGasInputAndSetMultiplier() { + for (FluidStack s : this.getStoredFluids()) { + for (int i = 0; i < VoidMinerUtility.NOBLE_GASSES.length; i++) { + FluidStack ng = VoidMinerUtility.NOBLE_GASSES[i]; + if (ng.isFluidEqual(s)) { + this.multiplier = this.TIER_MULTIPLIER * VoidMinerUtility.NOBEL_GASSES_MULTIPLIER[i]; + return s; + } + } + } + return null; + } + + /** + * method used to decrement the quantity of gas in the hatch + * + * @param gasToConsume the fluid stack in the hatch + * @return if yes or no it was able to decrement the quantity of the fluidStack + */ + private boolean consumeNobleGas(FluidStack gasToConsume) { + for (FluidStack s : this.getStoredFluids()) { + if (s.isFluidEqual(gasToConsume) && s.amount >= 1) { + s.amount -= 1; + this.updateSlots(); + return true; + } + } + return false; + } + + /** + * handler for the fluid consumption + */ + private void handleFluidConsumption() { + FluidStack storedNobleGas = this.getNobleGasInputAndSetMultiplier(); + if (storedNobleGas == null || !this.consumeNobleGas(storedNobleGas)) this.multiplier = this.TIER_MULTIPLIER; + } + + /** + * Handles the ores added manually with {@link VoidMinerUtility#addMaterialToDimensionList} + * + * @param id the specified dim id + */ + private void handleExtraDrops(int id) { + if (VoidMinerUtility.extraDropsDimMap.containsKey(id)) { + extraDropMap = VoidMinerUtility.extraDropsDimMap.get(id); + } + } + + /** + * Gets the DropMap of the dim for the specified dim id + * + * @param id the dim number + */ + private void handleModDimDef(int id) { + if (VoidMinerUtility.dropMapsByDimId.containsKey(id)) { + this.dropMap = VoidMinerUtility.dropMapsByDimId.get(id); + } else { + String chunkProviderName = ((ChunkProviderServer) this.getBaseMetaTileEntity() + .getWorld() + .getChunkProvider()).currentChunkProvider.getClass() + .getName(); + + if (VoidMinerUtility.dropMapsByChunkProviderName.containsKey(chunkProviderName)) { + this.dropMap = VoidMinerUtility.dropMapsByChunkProviderName.get(chunkProviderName); + } + } + } + + /** + * Computes first the ores related to the dim the VM is in, then the ores added manually, then it computes the + * totalWeight for normalisation + */ + private void calculateDropMap() { + this.dropMap = new VoidMinerUtility.DropMap(); + this.extraDropMap = new VoidMinerUtility.DropMap(); + int id = this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId; + this.handleModDimDef(id); + this.handleExtraDrops(id); + this.totalWeight = dropMap.getTotalWeight() + extraDropMap.getTotalWeight(); + } + + /** + * Output logic of the VM + */ + private void handleOutputs() { + final List inputOres = this.getStoredInputs() + .stream() + .filter(GT_Utility::isOre) + .collect(Collectors.toList());; + final ItemStack output = this.nextOre(); + output.stackSize = multiplier; + if (inputOres.size() == 0 || this.mBlacklist && inputOres.stream() + .noneMatch(is -> GT_Utility.areStacksEqual(is, output)) + || !this.mBlacklist && inputOres.stream() + .anyMatch(is -> GT_Utility.areStacksEqual(is, output))) + this.addOutput(output); + this.updateSlots(); + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mBlacklist = !this.mBlacklist; + GT_Utility.sendChatToPlayer(aPlayer, "Mode: " + (this.mBlacklist ? "Blacklist" : "Whitelist")); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiners.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiners.java new file mode 100644 index 0000000000..5f15bd6c09 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiners.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticgreg; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GT_TileEntity_VoidMiners { + + public static class VMLUV extends GT_TileEntity_VoidMiner_Base { + + public VMLUV(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 1); + } + + public VMLUV(String aName, int tier) { + super(aName, tier); + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_UV; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.Europium; + } + + @Override + protected int getCasingTextureIndex() { + return 8; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new VMLUV(this.mName, this.TIER_MULTIPLIER); + } + } + + public static class VMZPM extends GT_TileEntity_VoidMiner_Base { + + public VMZPM(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 2); + } + + public VMZPM(String aName, int tier) { + super(aName, tier); + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_MiningBlackPlutonium; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.BlackPlutonium; + } + + @Override + protected int getCasingTextureIndex() { + return 179; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new VMZPM(this.mName, this.TIER_MULTIPLIER); + } + } + + public static class VMUV extends GT_TileEntity_VoidMiner_Base { + + public VMUV(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 3); + } + + public VMUV(String aName, int tier) { + super(aName, tier); + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_MiningNeutronium; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.Neutronium; + } + + @Override + protected int getCasingTextureIndex() { + return 178; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new VMUV(this.mName, this.TIER_MULTIPLIER); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/VoidMinerUtility.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/VoidMinerUtility.java new file mode 100644 index 0000000000..5254da24f1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/VoidMinerUtility.java @@ -0,0 +1,316 @@ +package com.github.bartimaeusnek.crossmod.galacticgreg; + +import static bloodasp.galacticgreg.registry.GalacticGregRegistry.getModContainers; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_OreLayer; + +import bloodasp.galacticgreg.GT_Worldgen_GT_Ore_Layer_Space; +import bloodasp.galacticgreg.GT_Worldgen_GT_Ore_SmallPieces_Space; +import bloodasp.galacticgreg.GalacticGreg; +import bloodasp.galacticgreg.api.ModContainer; +import bloodasp.galacticgreg.api.ModDimensionDef; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_Layer_Space; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_SmallOre_Space; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; + +public class VoidMinerUtility { + + public static final FluidStack[] NOBLE_GASSES = { WerkstoffLoader.Neon.getFluidOrGas(1), + WerkstoffLoader.Krypton.getFluidOrGas(1), WerkstoffLoader.Xenon.getFluidOrGas(1), + WerkstoffLoader.Oganesson.getFluidOrGas(1) }; + public static final int[] NOBEL_GASSES_MULTIPLIER = { 4, 8, 16, 64 }; + + public static class DropMap { + + private float totalWeight; + private final Map internalMap; + + public DropMap() { + internalMap = new HashMap<>(); + totalWeight = 0; + } + + /** + * Method used to add an ore to the DropMap + * + * @param weight the non normalised weight + * @param isBWOres true for BW ores, false for GT ores + */ + public void addDrop(int meta, float weight, boolean isBWOres) { + if (isBWOres) { + addDrop(WerkstoffLoader.BWOres, meta, weight); + } else { + addDrop(GregTech_API.sBlockOres1, meta, weight); + } + } + + /** + * Method used to add any item to the DropMap. Will be blocked if blacklisted. + * + * @param weight the non normalised weight + */ + public void addDrop(Block block, int meta, float weight) { + if (ConfigHandler.voidMinerBlacklist.contains( + String.format( + "%s:%d", + GameRegistry.findUniqueIdentifierFor(block) + .toString(), + meta))) + return; + Item item = Item.getItemFromBlock(block); + addDrop(item, meta, weight); + } + + /** + * Method used to add any item to the DropMap. Will be blocked if blacklisted. + * + * @param weight the non normalised weight + */ + public void addDrop(ItemStack itemStack, float weight) { + Item item = itemStack.getItem(); + int meta = Items.feather.getDamage(itemStack); + if (ConfigHandler.voidMinerBlacklist.contains( + String.format( + "%s:%d", + GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)) + .toString(), + meta))) + return; + addDrop(item, meta, weight); + } + + private void addDrop(Item item, int meta, float weight) { + GT_Utility.ItemId ore = GT_Utility.ItemId.createNoCopy(item, meta, null); + internalMap.merge(ore, weight, Float::sum); + totalWeight += weight; + } + + public float getTotalWeight() { + return totalWeight; + } + + public Map getInternalMap() { + return internalMap; + } + } + + public static final Map dropMapsByDimId = new HashMap<>(); + public static final Map dropMapsByChunkProviderName = new HashMap<>(); + public static final Map extraDropsDimMap = new HashMap<>(); + + // Adds tellurium to OW to ensure a way to get it, as it's used in Magneto Resonatic + // Dust and Circuit Compound MK3 Dust + static { + addMaterialToDimensionList(0, Materials.Tellurium, 8.0f); + } + + /** + * Computes the ores of the dims + */ + public static void generateDropMaps() { + // vanilla dims + dropMapsByDimId.put(-1, getDropMapVanilla(-1)); + dropMapsByDimId.put(0, getDropMapVanilla(0)); + dropMapsByDimId.put(1, getDropMapVanilla(1)); + // Twilight Forest + dropMapsByDimId.put(7, getDropMapVanilla(7)); + + // ross dims + dropMapsByDimId.put(ConfigHandler.ross128BID, getDropMapRoss(ConfigHandler.ross128BID)); + dropMapsByDimId.put(ConfigHandler.ross128BAID, getDropMapRoss(ConfigHandler.ross128BAID)); + + // other space dims + for (ModContainer modContainer : getModContainers()) { + for (ModDimensionDef dimDef : modContainer.getDimensionList()) { + dropMapsByChunkProviderName.put(dimDef.getChunkProviderName(), getDropMapSpace(dimDef)); + } + } + } + + /** + * Method to generate a DropMap that contains ores of a vanilla GT worldgen + */ + private static DropMap getDropMapVanilla(int dimId) { + DropMap dropMap = new DropMap(); + + // Ore Veins + Predicate oreLayerPredicate = makeOreLayerPredicate(dimId); + GT_Worldgen_GT_Ore_Layer.sList.stream() + .filter(gt_worldgen -> gt_worldgen.mEnabled && oreLayerPredicate.test(gt_worldgen)) + .forEach(element -> { + dropMap.addDrop(element.mPrimaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSecondaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSporadicMeta, element.mWeight / 8f, false); + dropMap.addDrop(element.mBetweenMeta, element.mWeight / 8f, false); + }); + + // Small Ores + Predicate smallOresPredicate = makeSmallOresPredicate(dimId); + GT_Worldgen_GT_Ore_SmallPieces.sList.stream() + .filter(gt_worldgen -> gt_worldgen.mEnabled && smallOresPredicate.test(gt_worldgen)) + .forEach(element -> dropMap.addDrop(element.mMeta, element.mAmount, false)); + return dropMap; + } + + /** + * Makes a predicate for the GT normal ore veins worldgen + * + * @return the predicate + */ + private static Predicate makeOreLayerPredicate(int dimensionId) { + return switch (dimensionId) { + case -1 -> gt_worldgen -> gt_worldgen.mNether; + case 0 -> gt_worldgen -> gt_worldgen.mOverworld; + case 1 -> gt_worldgen -> gt_worldgen.mEnd || gt_worldgen.mEndAsteroid; + /* + * explicitly giving different dim numbers so that it default to false in the config, keeping compat with + * the current worldgen config + */ + case 7 -> gt_worldgen -> gt_worldgen.isGenerationAllowed("Twilight Forest", 0, 7); + default -> throw new IllegalStateException(); + }; + } + + /** + * Makes a predicate for the GT normal small ore worldgen + * + * @return the predicate + */ + private static Predicate makeSmallOresPredicate(int dimensionId) { + return switch (dimensionId) { + case -1 -> gt_worldgen -> gt_worldgen.mNether; + case 0 -> gt_worldgen -> gt_worldgen.mOverworld; + case 1 -> gt_worldgen -> gt_worldgen.mEnd; + /* + * explicitly giving different dim numbers so that it default to false in the config, keeping compat with + * the current worldgen config + */ + case 7 -> gt_worldgen -> gt_worldgen.isGenerationAllowed("Twilight Forest", 0, 7); + default -> throw new IllegalStateException(); + }; + } + + /** + * Create a DropMap that contains ores of Ross dims + * + * @param aID dim id of Ross128b or Ross128ba + */ + private static DropMap getDropMapRoss(int aID) { + DropMap dropMap = new DropMap(); + for (BW_OreLayer oreLayer : BW_OreLayer.sList) { + if (oreLayer.mEnabled && oreLayer.isGenerationAllowed("", aID, 0)) { + List data = oreLayer.getStacks(); + dropMap.addDrop(data.get(0), oreLayer.mWeight); + dropMap.addDrop(data.get(1), oreLayer.mWeight); + dropMap.addDrop(data.get(2), oreLayer.mWeight / 8f); + dropMap.addDrop(data.get(3), oreLayer.mWeight / 8f); + } + } + return dropMap; + } + + /** + * Create a DropMap contains the ores from the galacticGreg space worldgen corresponding to the target dim + * + * @param finalDef ModDimensionDef corresponding to the target dim + */ + private static DropMap getDropMapSpace(ModDimensionDef finalDef) { + DropMap dropMap = new DropMap(); + + // Normal Ore Veins + GalacticGreg.oreVeinWorldgenList.stream() + .filter( + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof GT_Worldgen_GT_Ore_Layer_Space oreLayerSpace + && oreLayerSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (GT_Worldgen_GT_Ore_Layer_Space) gt_worldgen) + .forEach(element -> { + dropMap.addDrop(element.mPrimaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSecondaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSporadicMeta, element.mWeight / 8f, false); + dropMap.addDrop(element.mBetweenMeta, element.mWeight / 8f, false); + }); + + // Normal Small Ores + GalacticGreg.smallOreWorldgenList.stream() + .filter( + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof GT_Worldgen_GT_Ore_SmallPieces_Space oreSmallPiecesSpace + && oreSmallPiecesSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (GT_Worldgen_GT_Ore_SmallPieces_Space) gt_worldgen) + .forEach(element -> dropMap.addDrop(element.mMeta, element.mAmount, false)); + + // BW Ore Veins + try { + GalacticGreg.oreVeinWorldgenList.stream() + .filter( + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof BW_Worldgen_Ore_Layer_Space oreLayerSpace + && oreLayerSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (BW_Worldgen_Ore_Layer_Space) gt_worldgen) + .forEach(oreLayer -> { + List data = oreLayer.getStacks(); + dropMap.addDrop(data.get(0), oreLayer.mWeight); + dropMap.addDrop(data.get(1), oreLayer.mWeight); + dropMap.addDrop(data.get(2), oreLayer.mWeight / 8f); + dropMap.addDrop(data.get(3), oreLayer.mWeight / 8f); + }); + } catch (NullPointerException ignored) {} + + // BW Small Ores + try { + GalacticGreg.smallOreWorldgenList.stream() + .filter( + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof BW_Worldgen_Ore_SmallOre_Space smallOreSpace + && smallOreSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (BW_Worldgen_Ore_SmallOre_Space) gt_worldgen) + .forEach(element -> dropMap.addDrop(element.mPrimaryMeta, element.mDensity, element.bwOres != 0)); + } catch (NullPointerException ignored) {} + return dropMap; + } + + public static void addBlockToDimensionList(int dimId, Block block, int meta, float weight) { + if (!extraDropsDimMap.containsKey(dimId)) { + extraDropsDimMap.put(dimId, new DropMap()); + } + extraDropsDimMap.get(dimId) + .addDrop(block, meta, weight); + } + + /** + * Public method giving other mods the ability to add manually a material with an ore version into the external + * dropMap for a specified dim id + * + * @param DimensionID the dim id targeted + * @param Material the material with an ore version + * @param weight the non normalised version of the given weight + */ + public static void addMaterialToDimensionList(int DimensionID, ISubTagContainer Material, float weight) { + if (Material instanceof Materials gtMaterial) { + addBlockToDimensionList(DimensionID, GregTech_API.sBlockOres1, gtMaterial.mMetaItemSubID, weight); + } else if (Material instanceof Werkstoff werkstoff) { + addBlockToDimensionList(DimensionID, WerkstoffLoader.BWOres, werkstoff.getmID(), weight); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java new file mode 100644 index 0000000000..972254e2d9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft; + +import java.io.File; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.Configuration; + +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_WorldGenRoss128b; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_WorldGenRoss128ba; +import com.github.bartimaeusnek.crossmod.galacticraft.atmosphere.BWAtmosphereManager; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gregtech.api.objects.GT_UO_DimensionList; + +public class GalacticraftProxy { + + public static GT_UO_DimensionList uo_dimensionList = new GT_UO_DimensionList(); + static Configuration gtConf; + + private GalacticraftProxy() {} + + public static void postInit(FMLPostInitializationEvent e) { + if (SideReference.Side.Server || SideReference.EffectiveSide.Server) { + GalacticraftProxy.serverPostInit(e); + } else { + GalacticraftProxy.clientPostInit(e); + } + GalacticraftProxy.commonPostInit(e); + } + + public static void preInit(FMLPreInitializationEvent e) { + if (SideReference.Side.Server || SideReference.EffectiveSide.Server) { + GalacticraftProxy.serverpreInit(e); + } else { + GalacticraftProxy.clientpreInit(e); + } + GalacticraftProxy.commonpreInit(e); + } + + private static void serverpreInit(FMLPreInitializationEvent e) {} + + private static void clientpreInit(FMLPreInitializationEvent e) {} + + private static void commonpreInit(FMLPreInitializationEvent e) { + GalacticraftProxy.gtConf = new Configuration( + new File(new File(e.getModConfigurationDirectory(), "GregTech"), "GregTech.cfg")); + GalacticraftProxy.uo_dimensionList.getConfig(GalacticraftProxy.gtConf, "undergroundfluid"); + BW_WorldGenRoss128b.initundergroundFluids(); + BW_WorldGenRoss128ba.init_undergroundFluids(); + if (GalacticraftProxy.gtConf.hasChanged()) GalacticraftProxy.gtConf.save(); + BW_WorldGenRoss128b.initOres(); + BW_WorldGenRoss128ba.init_Ores(); + MinecraftForge.EVENT_BUS.register(BWAtmosphereManager.INSTANCE); + } + + public static void init(FMLInitializationEvent e) { + if (SideReference.Side.Server || SideReference.EffectiveSide.Server) { + GalacticraftProxy.serverInit(e); + } else { + GalacticraftProxy.clientInit(e); + } + GalacticraftProxy.commonInit(e); + } + + private static void serverInit(FMLInitializationEvent e) {} + + private static void clientInit(FMLInitializationEvent e) {} + + private static void commonInit(FMLInitializationEvent e) { + if (ConfigHandler.Ross128Enabled) Ross128SolarSystem.init(); + } + + private static void serverPostInit(FMLPostInitializationEvent e) {} + + private static void clientPostInit(FMLPostInitializationEvent e) {} + + private static void commonPostInit(FMLPostInitializationEvent e) {} +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java new file mode 100644 index 0000000000..c9cff6cd9e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft; + +import net.minecraft.entity.player.EntityPlayerMP; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + +import micdoodle8.mods.galacticraft.core.entities.EntityLander; +import micdoodle8.mods.galacticraft.core.entities.EntityLanderBase; +import micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityEntryPod; +import micdoodle8.mods.galacticraft.planets.mars.entities.EntityLandingBalloons; + +public class PlanetsHelperClass { + + public static EntityLanderBase getLanderType(EntityPlayerMP player) { + return switch (ConfigHandler.landerType) { + case 1 -> new EntityLander(player); + case 2 -> new EntityLandingBalloons(player); + default -> new EntityEntryPod(player); + }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java new file mode 100644 index 0000000000..b6fa575b5c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft; + +import static gregtech.api.enums.Mods.GalacticraftMars; + +import java.util.Random; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.api.world.ITeleportType; +import micdoodle8.mods.galacticraft.core.entities.EntityLander; +import micdoodle8.mods.galacticraft.core.entities.EntityLanderBase; +import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats; + +public class UniversalTeleportType implements ITeleportType { + + @Override + public boolean useParachute() { + return false; + } + + @Override + public Vector3 getPlayerSpawnLocation(WorldServer world, EntityPlayerMP player) { + return this.getEntitySpawnLocation(world, player); + } + + @Override + public Vector3 getEntitySpawnLocation(WorldServer world, Entity entity) { + if (entity instanceof EntityPlayerMP) { + GCPlayerStats stats = GCPlayerStats.get((EntityPlayerMP) entity); + return new Vector3(stats.coordsTeleportedFromX, 500D, stats.coordsTeleportedFromZ); + } + return new Vector3(entity.posX, 500D, entity.posZ); + } + + @Override + public Vector3 getParaChestSpawnLocation(WorldServer world, EntityPlayerMP player, Random rand) { + return null; + } + + @Override + public void onSpaceDimensionChanged(World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) { + if (ridingAutoRocket) return; + if (player != null && GCPlayerStats.get(player).teleportCooldown <= 0) { + if (player.capabilities.isFlying) { + player.capabilities.isFlying = false; + } + + EntityLanderBase elb; + if (GalacticraftMars.isModLoaded()) elb = PlanetsHelperClass.getLanderType(player); + else elb = new EntityLander(player); + + if (!newWorld.isRemote) { + newWorld.spawnEntityInWorld(elb); + } + GCPlayerStats.get(player).teleportCooldown = 10; + } + } + + @Override + public void setupAdventureSpawn(EntityPlayerMP player) {} +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java new file mode 100644 index 0000000000..fa6d2db382 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.atmosphere; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.google.common.collect.ArrayListMultimap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import micdoodle8.mods.galacticraft.api.galaxies.GalaxyRegistry; +import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; + +public final class BWAtmosphereManager { + + private static final Map COEFFICIENT_MAP = new HashMap<>(); + + private BWAtmosphereManager() { + BWAtmosphereManager.COEFFICIENT_MAP.put(1, new Integer[] { 100 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(2, new Integer[] { 70, 30 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(3, new Integer[] { 60, 25, 15 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(4, new Integer[] { 50, 25, 15, 10 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(5, new Integer[] { 45, 25, 15, 10, 5 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(6, new Integer[] { 45, 20, 15, 10, 5, 5 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(7, new Integer[] { 40, 20, 15, 10, 5, 5, 5 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(8, new Integer[] { 35, 20, 15, 10, 5, 5, 5, 5 }); + BWAtmosphereManager.COEFFICIENT_MAP.put(9, new Integer[] { 35, 15, 15, 10, 5, 5, 5, 5, 5 }); + } + + public static final BWAtmosphereManager INSTANCE = new BWAtmosphereManager(); + + private static final ArrayListMultimap> gasConcentration = ArrayListMultimap + .create(); + + public static List> getGasFromWorldID(int worldID) { + return BWAtmosphereManager.gasConcentration.get(worldID); + } + + public static void removeGasFromWorld(int worldID, ISubTagContainer gas) { + for (Pair pair : BWAtmosphereManager.gasConcentration.get(worldID)) { + if (pair.getKey() + .equals(gas)) { + BWAtmosphereManager.gasConcentration.get(worldID) + .remove(pair); + return; + } + } + } + + public static void addGasToWorld(int worldID, ISubTagContainer gas, int amount) { + Pair toadd = new Pair<>(gas, amount); + BWAtmosphereManager.gasConcentration.put(worldID, toadd); + } + + public static void addGasToWorld(int worldID, Pair toPut) { + BWAtmosphereManager.gasConcentration.put(worldID, toPut); + } + + @SafeVarargs + public static void addGasToWorld(int worldID, Pair... toPut) { + Arrays.stream(toPut) + .forEach(toadd -> BWAtmosphereManager.gasConcentration.put(worldID, toadd)); + } + + private static boolean addGCGasToWorld(int worldID, IAtmosphericGas gas, int aNumber, int aMaxNumber) { + if (IAtmosphericGas.CO2.equals(gas)) { + BWAtmosphereManager.addGasToWorld( + worldID, + Materials.CarbonDioxide, + BWAtmosphereManager.COEFFICIENT_MAP.get(aMaxNumber)[aNumber]); + return true; + } + String name = gas.toString(); + name = name.charAt(0) + name.substring(1) + .toLowerCase(Locale.US); + ISubTagContainer mat = Materials.get(name); + if (mat == Materials._NULL) { + mat = WerkstoffLoader.getWerkstoff(name); + } + if (mat == Werkstoff.default_null_Werkstoff) { + return false; + } + BWAtmosphereManager.addGasToWorld(worldID, mat, BWAtmosphereManager.COEFFICIENT_MAP.get(aMaxNumber)[aNumber]); + return true; + } + + @SubscribeEvent + public void gcAutoRegister(GalaxyRegistry.PlanetRegisterEvent event) { + CelestialBody planet = GalaxyRegistry.getRegisteredPlanets() + .get(event.planetName); + for (int i = 0; i < planet.atmosphere.size(); i++) { + if (!BWAtmosphereManager + .addGCGasToWorld(planet.getDimensionID(), planet.atmosphere.get(i), i, planet.atmosphere.size())) + BartWorksCrossmod.LOGGER.warn( + "Unidentified Fluid (" + planet.atmosphere.get(i) + + ") in the Atmosphere of: " + + planet.getLocalizedName()); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java new file mode 100644 index 0000000000..af9d9647af --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.world.IBlockAccess; + +import com.github.bartimaeusnek.bartworks.common.blocks.BW_Blocks; +import com.github.bartimaeusnek.crossmod.galacticraft.creativetabs.SpaceTab; + +public class UniversalSpaceBlocks extends BW_Blocks { + + public UniversalSpaceBlocks(String name, String[] texture) { + super(name, texture, SpaceTab.getInstance(), Material.rock); + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java new file mode 100644 index 0000000000..5d9b9c3cc1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; + +public class SpaceTab extends CreativeTabs { + + private static final SpaceTab instance = new SpaceTab("SpaceTab"); + + private SpaceTab(String label) { + super(label); + } + + public static SpaceTab getInstance() { + return SpaceTab.instance; + } + + @Override + public Item getTabIconItem() { + return ItemRegistry.DESTRUCTOPACK; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/AbstractWorldProviderSpace.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/AbstractWorldProviderSpace.java new file mode 100644 index 0000000000..61c52865cf --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/AbstractWorldProviderSpace.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets; + +import micdoodle8.mods.galacticraft.api.prefab.world.gen.WorldProviderSpace; +import micdoodle8.mods.galacticraft.api.world.IExitHeight; +import micdoodle8.mods.galacticraft.api.world.ISolarLevel; + +public abstract class AbstractWorldProviderSpace extends WorldProviderSpace implements IExitHeight, ISolarLevel { + + @Override + public boolean canRainOrSnow() { + return false; + } + + @Override + public String getDimensionName() { + return this.getCelestialBody() + .getLocalizedName(); + } + + @Override + public boolean hasSunset() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java new file mode 100644 index 0000000000..b477154d39 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128b; + +import static gregtech.api.enums.Mods.Thaumcraft; +import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE; +import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderGenerate; +import net.minecraft.world.gen.MapGenBase; +import net.minecraft.world.gen.MapGenCaves; +import net.minecraft.world.gen.MapGenRavine; +import net.minecraft.world.gen.feature.WorldGenLakes; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.PopulateChunkEvent; +import net.minecraftforge.event.terraingen.TerrainGen; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_WordGenerator; +import com.github.bartimaeusnek.bartworks.system.worldgen.MapGenRuins; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; + +import gregtech.api.objects.XSTR; + +public class ChunkProviderRoss128b extends ChunkProviderGenerate { + + XSTR rand = new XSTR(); + private BiomeGenBase[] biomesForGeneration; + public static final BW_WordGenerator BWOreGen = new BW_WordGenerator(); + private final World worldObj; + private final MapGenBase caveGenerator = new MapGenCaves(); + private final MapGenBase ravineGenerator = new MapGenRavine(); + private final MapGenRuins.RuinsBase ruinsBase = new MapGenRuins.RuinsBase(); + + public ChunkProviderRoss128b(World par1World, long seed, boolean mapFeaturesEnabled) { + super(par1World, seed, mapFeaturesEnabled); + this.worldObj = par1World; + } + + @Override + public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, + int p_73155_4_) { + return null; + } + + @Override + public Chunk provideChunk(int p_73154_1_, int p_73154_2_) { + this.rand.setSeed(p_73154_1_ * 341873128712L + p_73154_2_ * 132897987541L); + Block[] ablock = new Block[65536]; + byte[] abyte = new byte[65536]; + this.func_147424_a(p_73154_1_, p_73154_2_, ablock); + this.biomesForGeneration = this.worldObj.getWorldChunkManager() + .loadBlockGeneratorData(this.biomesForGeneration, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16); + for (int i = 0; i < this.biomesForGeneration.length; i++) { + BiomeGenBase biomeGenBase = this.biomesForGeneration[i]; + if (biomeGenBase.biomeID == BiomeGenBase.mushroomIsland.biomeID) { + this.biomesForGeneration[i] = BiomeGenBase.taiga; + } else if (biomeGenBase.biomeID == BiomeGenBase.mushroomIslandShore.biomeID) { + this.biomesForGeneration[i] = BiomeGenBase.stoneBeach; + } + if (Thaumcraft.isModLoaded()) { + if (ThaumcraftHandler.isTaintBiome(biomeGenBase.biomeID)) + this.biomesForGeneration[i] = BiomeGenBase.taiga; + else if (ConfigHandler.disableMagicalForest + && ThaumcraftHandler.isMagicalForestBiome(biomeGenBase.biomeID)) + this.biomesForGeneration[i] = BiomeGenBase.birchForest; + } + } + this.replaceBlocksForBiome(p_73154_1_, p_73154_2_, ablock, abyte, this.biomesForGeneration); + this.caveGenerator.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, ablock); + this.ravineGenerator.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, ablock); + + Chunk chunk = new Chunk(this.worldObj, ablock, abyte, p_73154_1_, p_73154_2_); + byte[] abyte1 = chunk.getBiomeArray(); + + for (int k = 0; k < abyte1.length; ++k) { + abyte1[k] = (byte) this.biomesForGeneration[k].biomeID; + } + + chunk.generateSkylightMap(); + return chunk; + } + + @Override + public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { + BlockFalling.fallInstantly = true; + int k = p_73153_2_ * 16; + int l = p_73153_3_ * 16; + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); + this.rand.setSeed(this.worldObj.getSeed()); + if (p_73153_2_ % 4 == 0 || p_73153_3_ % 4 == 0) { + long i1 = this.rand.nextLong() / 2L * 2L + 1L; + long j1 = this.rand.nextLong() / 2L * 2L + 1L; + this.rand.setSeed(p_73153_2_ * i1 + p_73153_3_ * j1 ^ this.worldObj.getSeed()); + } + + MinecraftForge.EVENT_BUS + .post(new PopulateChunkEvent.Pre(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false)); + + int x1; + int y1; + int z1; + if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills + && TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, LAKE)) { + x1 = k + this.rand.nextInt(16) + 8; + y1 = this.rand.nextInt(256); + z1 = l + this.rand.nextInt(16) + 8; + int rni = this.rand.nextInt(8); + if (rni == 0) new WorldGenLakes(Blocks.ice).generate(this.worldObj, this.rand, x1, y1, z1); + else if (rni == 4) new WorldGenLakes(Blocks.water).generate(this.worldObj, this.rand, x1, y1, z1); + } + if (biomegenbase != BiomeGenBase.ocean && biomegenbase != BiomeGenBase.deepOcean + && biomegenbase != BiomeGenBase.river + && biomegenbase != BiomeGenBase.frozenOcean + && biomegenbase != BiomeGenBase.frozenRiver + && this.rand.nextInt(ConfigHandler.ross128bRuinChance) == 0) { + x1 = k + this.rand.nextInt(16) + 3; + y1 = this.rand.nextInt(256); + z1 = l + this.rand.nextInt(16) + 3; + this.ruinsBase.generate(this.worldObj, this.rand, x1, y1, z1); + } + + biomegenbase.decorate(this.worldObj, this.rand, k, l); + + k += 8; + l += 8; + + boolean doGen = TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, ICE); + for (x1 = 0; doGen && x1 < 16; ++x1) { + for (y1 = 0; y1 < 16; ++y1) { + z1 = this.worldObj.getPrecipitationHeight(k + x1, l + y1); + + if (this.worldObj.isBlockFreezable(x1 + k, z1 - 1, y1 + l)) { + this.worldObj.setBlock(x1 + k, z1 - 1, y1 + l, Blocks.ice, 0, 2); + } + + if (this.worldObj.func_147478_e(x1 + k, z1, y1 + l, true)) { + this.worldObj.setBlock(x1 + k, z1, y1 + l, Blocks.snow_layer, 0, 2); + } + } + } + + BWOreGen.generate(this.rand, p_73153_2_, p_73153_3_, this.worldObj, this, this); + MinecraftForge.EVENT_BUS + .post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false)); + + BlockFalling.fallInstantly = false; + } + + @Override + public void recreateStructures(int p_82695_1_, int p_82695_2_) {} + + @Override + public void replaceBlocksForBiome(int p_147422_1_, int p_147422_2_, Block[] blocks, byte[] metas, + BiomeGenBase[] p_147422_5_) { + super.replaceBlocksForBiome(p_147422_1_, p_147422_2_, blocks, metas, p_147422_5_); + for (int i = 0; i < blocks.length; i++) { + if (blocks[i] == Blocks.grass) { + blocks[i] = Blocks.dirt; + metas[i] = 2; + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/SkyProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/SkyProviderRoss128b.java new file mode 100644 index 0000000000..d5368b3f0d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/SkyProviderRoss128b.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128b; + +import net.minecraft.util.ResourceLocation; + +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; + +public class SkyProviderRoss128b { + + // ASM enables this texture + public static final ResourceLocation sunTex = new ResourceLocation( + BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/World/SunRoss128.png"); +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java new file mode 100644 index 0000000000..7a0c9a743c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128b; + +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.chunk.IChunkProvider; + +import com.github.bartimaeusnek.crossmod.galacticraft.planets.AbstractWorldProviderSpace; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import micdoodle8.mods.galacticraft.api.vector.Vector3; + +public class WorldProviderRoss128b extends AbstractWorldProviderSpace { + + @Override + public boolean canRespawnHere() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float cy, float noidea) { + float angle = MathHelper.cos(cy * (float) Math.PI * 2.0F) * 2.0F + 0.5F; + + if (angle < 0.0F) { + angle = 0.0F; + } + + if (angle > 1.0F) { + angle = 1.0F; + } + + float red = 200 / 255f; + float green = 80 / 255f; + float blue = 0.0F; + red *= angle * 0.94F + 0.06F; + green *= angle * 0.94F + 0.06F; + return Vec3.createVectorHelper(red, green, blue); + } + + @Override + public Vector3 getFogColor() { + // unused + return null; + } + + @Override + public float getSunBrightness(float par1) { + return super.getSunBrightness(par1) * 0.975f; + } + + @Override + public float calculateCelestialAngle(long par1, float par3) { + return super.calculateCelestialAngle(par1, par3); + } + + @Override + public Vector3 getSkyColor() { + float red = 200 / 255f; + float green = 120 / 255f; + float blue = 0.0F; + return new Vector3(red, green, blue); + } + + @Override + public long getDayLength() { + return (long) (24000 * 9.9f); + } + + @Override + public Class getChunkProviderClass() { + return ChunkProviderRoss128b.class; + } + + @Override + public Class getWorldChunkManagerClass() { + return WorldChunkManager.class; + } + + @Override + public float getGravity() { + return -0.0035F; + } + + @Override + public double getMeteorFrequency() { + return 0D; + } + + @Override + public double getFuelUsageMultiplier() { + return 1.35D; + } + + @Override + public boolean canSpaceshipTierPass(int tier) { + return Ross128SolarSystem.Ross128b.getTierRequirement() <= tier; + } + + @Override + public float getFallDamageModifier() { + return 1.35F; + } + + @Override + public float getSoundVolReductionAmount() { + return 1F; + } + + @Override + public float getThermalLevelModifier() { + return 0.01f; + } + + @Override + public float getWindLevel() { + return 1.35f; + } + + @Override + public CelestialBody getCelestialBody() { + return Ross128SolarSystem.Ross128b; + } + + @Override + public double getYCoordinateToTeleport() { + return 500D; + } + + @Override + public double getSolarEnergyMultiplier() { + return 1.38D; + } + + @Override + public boolean hasBreathableAtmosphere() { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java new file mode 100644 index 0000000000..18a8eadd2c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba; + +import java.util.Arrays; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; + +import com.github.bartimaeusnek.bartworks.util.NoiseUtil.BartsNoise; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128b.ChunkProviderRoss128b; + +import gregtech.api.objects.XSTR; +import micdoodle8.mods.galacticraft.api.prefab.world.gen.MapGenBaseMeta; +import micdoodle8.mods.galacticraft.core.blocks.GCBlocks; +import micdoodle8.mods.galacticraft.core.world.gen.BiomeGenBaseMoon; +import micdoodle8.mods.galacticraft.core.world.gen.ChunkProviderMoon; +import micdoodle8.mods.galacticraft.core.world.gen.MapGenCavesMoon; + +public class ChunkProviderRoss128ba extends ChunkProviderMoon { + + private final XSTR rand = new XSTR(); + private final World worldObj; + private BiomeGenBase[] biomesForGeneration; + private final MapGenBaseMeta caveGenerator; + + public ChunkProviderRoss128ba(World world, long seed, boolean mapFeaturesEnabled) { + super(world, seed, mapFeaturesEnabled); + this.biomesForGeneration = new BiomeGenBase[] { BiomeGenBaseMoon.moonFlat }; + this.caveGenerator = new MapGenCavesMoon(); + this.worldObj = world; + } + + @Override + public Chunk provideChunk(int cx, int cz) { + this.rand.setSeed(cx * 341873128712L + cz * 132897987541L); + Block[] ids = new Block[65536]; + byte[] meta = new byte[65536]; + Arrays.fill(ids, Blocks.air); + this.generateTerrain(cx, cz, ids, meta); + this.biomesForGeneration = this.worldObj.getWorldChunkManager() + .loadBlockGeneratorData(this.biomesForGeneration, cx * 16, cz * 16, 16, 16); + this.createCraters(cx, cz, ids, meta); + this.replaceBlocksForBiome(cx, cz, ids, meta, this.biomesForGeneration); + this.caveGenerator.generate(this, this.worldObj, cx, cz, ids, meta); + Chunk Chunk = new Chunk(this.worldObj, ids, meta, cx, cz); + Chunk.generateSkylightMap(); + return Chunk; + } + + @Override + public void decoratePlanet(World par1World, Random par2Random, int par3, int par4) {} + + @Override + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) { + super.populate(par1IChunkProvider, par2, par3); + BlockFalling.fallInstantly = true; + ChunkProviderRoss128b.BWOreGen.generate(this.rand, par2, par3, this.worldObj, this, this); + BlockFalling.fallInstantly = false; + } + + private int getIndex(int x, int y, int z) { + return (x * 16 + z) * 256 + y; + } + + final Block lowerBlockID = GCBlocks.blockMoon; + final BartsNoise noiseGen = new BartsNoise(2, 0.008F, 1D, System.nanoTime()); + final BartsNoise noiseGen2 = new BartsNoise(2, 0.01F, 1D, System.nanoTime()); + final BartsNoise noiseGen3 = new BartsNoise(2, 0.002F, 1D, System.nanoTime()); + + @Override + public void generateTerrain(int chunkX, int chunkZ, Block[] idArray, byte[] metaArray) { + for (int x = 0; x < 16; ++x) { + for (int z = 0; z < 16; ++z) { + double d = this.noiseGen.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d2 = this.noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d3 = this.noiseGen3.getCosNoise(x + chunkX * 16, z + chunkZ * 16); + + double yDev = d * 4 + d2 * 2 + d3; + + for (int y = 0; y < 128; ++y) { + if (y < 60.0D + yDev) { + idArray[this.getIndex(x, y, z)] = this.lowerBlockID; + int var10001 = this.getIndex(x, y, z); + metaArray[var10001] = 4; + } + } + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128ba.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128ba.java new file mode 100644 index 0000000000..38c014a467 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128ba.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba; + +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.chunk.IChunkProvider; + +import com.github.bartimaeusnek.bartworks.util.MathUtils; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.AbstractWorldProviderSpace; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; + +import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.core.world.gen.WorldChunkManagerMoon; + +public class WorldProviderRoss128ba extends AbstractWorldProviderSpace { + + @Override + public Vector3 getFogColor() { + return new Vector3(0, 0, 0); + } + + @Override + public Vector3 getSkyColor() { + return new Vector3(0, 0, 0); + } + + @Override + public long getDayLength() { + return MathUtils.floorLong(24000f * 9.9f / 100f); + } + + @Override + public boolean hasSunset() { + return false; + } + + @Override + public Class getChunkProviderClass() { + return ChunkProviderRoss128ba.class; + } + + @Override + public Class getWorldChunkManagerClass() { + return WorldChunkManagerMoon.class; + } + + @Override + public double getYCoordinateToTeleport() { + return 500; + } + + @Override + public float getGravity() { + return 0.060f; + } + + @Override + public double getMeteorFrequency() { + return 9D; + } + + @Override + public double getFuelUsageMultiplier() { + return 0.7D; + } + + @Override + public boolean canSpaceshipTierPass(int i) { + return i >= Ross128SolarSystem.Ross128ba.getTierRequirement(); + } + + @Override + public float getFallDamageModifier() { + return 0.2f; + } + + @Override + public float getSoundVolReductionAmount() { + return 20f; + } + + @Override + public float getThermalLevelModifier() { + return 0; + } + + @Override + public float getWindLevel() { + return 0; + } + + @Override + public CelestialBody getCelestialBody() { + return Ross128SolarSystem.Ross128ba; + } + + @Override + public double getSolarEnergyMultiplier() { + return 1.9D; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java new file mode 100644 index 0000000000..f7bdec79eb --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.solarsystems; + +import static gregtech.api.enums.Mods.GalaxySpace; + +import java.util.Arrays; + +import net.minecraft.util.ResourceLocation; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.github.bartimaeusnek.crossmod.galacticraft.UniversalTeleportType; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128b.WorldProviderRoss128b; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba.WorldProviderRoss128ba; + +import micdoodle8.mods.galacticraft.api.GalacticraftRegistry; +import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import micdoodle8.mods.galacticraft.api.galaxies.GalaxyRegistry; +import micdoodle8.mods.galacticraft.api.galaxies.Moon; +import micdoodle8.mods.galacticraft.api.galaxies.Planet; +import micdoodle8.mods.galacticraft.api.galaxies.SolarSystem; +import micdoodle8.mods.galacticraft.api.galaxies.Star; +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; +import micdoodle8.mods.galacticraft.core.GalacticraftCore; + +public class Ross128SolarSystem { + + public static SolarSystem Ross128System; + public static Star Ross128; + public static Planet Ross128b; + public static Moon Ross128ba; + + private Ross128SolarSystem() {} + + public static void init() { + + Ross128SolarSystem.Ross128System = new SolarSystem("Ross128System", "milkyWay") + .setMapPosition(new Vector3(-0.5D, 0.65D, 0.0D)); + Ross128SolarSystem.Ross128 = (Star) new Star("Ross128").setParentSolarSystem(Ross128SolarSystem.Ross128System) + .setTierRequired(-1); + Ross128SolarSystem.Ross128.setUnreachable(); + Ross128SolarSystem.Ross128 + .setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128.png")); + Ross128SolarSystem.Ross128System.setMainStar(Ross128SolarSystem.Ross128); + + Ross128SolarSystem.Ross128b = new Planet("Ross128b").setParentSolarSystem(Ross128SolarSystem.Ross128System); + Ross128SolarSystem.Ross128b.setRingColorRGB(0x9F / 255f, 0x8A / 255f, 0x79 / 255f); + Ross128SolarSystem.Ross128b.setPhaseShift(1.25F); + Ross128SolarSystem.Ross128b.setBodyIcon( + new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128b.png")); + Ross128SolarSystem.Ross128b.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(0.75F, 1.75F)); + Ross128SolarSystem.Ross128b.setRelativeOrbitTime(0.65F); + Ross128SolarSystem.Ross128b.atmosphere + .addAll(Arrays.asList(IAtmosphericGas.OXYGEN, IAtmosphericGas.NITROGEN, IAtmosphericGas.ARGON)); + Ross128SolarSystem.Ross128b.setDimensionInfo(ConfigHandler.ross128BID, WorldProviderRoss128b.class); + Ross128SolarSystem.Ross128b.setTierRequired(ConfigHandler.ross128btier); + + Ross128SolarSystem.Ross128ba = new Moon("Ross128ba").setParentPlanet(Ross128SolarSystem.Ross128b); + Ross128SolarSystem.Ross128ba.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(10f, 15f)) + .setRelativeOrbitTime(1 / 0.01F); + Ross128SolarSystem.Ross128ba.setBodyIcon( + new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128ba.png")); + Ross128SolarSystem.Ross128ba.setDimensionInfo(ConfigHandler.ross128BAID, WorldProviderRoss128ba.class); + Ross128SolarSystem.Ross128ba + .setTierRequired(GalaxySpace.isModLoaded() ? Math.min(ConfigHandler.ross128btier + 2, 8) : 3); + + GalaxyRegistry.registerSolarSystem(Ross128SolarSystem.Ross128System); + GalaxyRegistry.registerPlanet(Ross128SolarSystem.Ross128b); + GalaxyRegistry.registerMoon(Ross128SolarSystem.Ross128ba); + GalacticraftRegistry.registerRocketGui( + WorldProviderRoss128b.class, + new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/overworldRocketGui.png")); + GalacticraftRegistry.registerRocketGui( + WorldProviderRoss128ba.class, + new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/moonRocketGui.png")); + GalacticraftRegistry.registerTeleportType(WorldProviderRoss128b.class, new UniversalTeleportType()); + GalacticraftRegistry.registerTeleportType(WorldProviderRoss128ba.class, new UniversalTeleportType()); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java new file mode 100644 index 0000000000..cc9b1dcc2d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.openComputers; + +import net.minecraft.nbt.NBTTagCompound; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +public class GT_NBT_DataBase { + + private static final BiMap tagIdBiMap = HashBiMap.create(); + private static final BiMap GTNBTBIMAP = HashBiMap.create(); + + private static long maxID = Long.MIN_VALUE + 1; + + private final NBTTagCompound tagCompound; + + private final String mDataName; + private final String mDataTitle; + private long id; + + GT_NBT_DataBase(String mDataName, String mDataTitle, NBTTagCompound tagCompound) { + this.mDataName = mDataName; + this.mDataTitle = mDataTitle; + this.tagCompound = tagCompound; + this.id = GT_NBT_DataBase.maxID; + GT_NBT_DataBase.tagIdBiMap.put(tagCompound, this.id); + GT_NBT_DataBase.GTNBTBIMAP.put(this, this.id); + ++GT_NBT_DataBase.maxID; + } + + static GT_NBT_DataBase getGTTagFromId(Long id) { + return GT_NBT_DataBase.GTNBTBIMAP.inverse() + .get(id); + } + + static Long getIdFromGTTag(GT_NBT_DataBase tagCompound) { + return GT_NBT_DataBase.GTNBTBIMAP.get(tagCompound); + } + + static NBTTagCompound getTagFromId(Long id) { + return GT_NBT_DataBase.tagIdBiMap.inverse() + .get(id); + } + + static Long getIdFromTag(NBTTagCompound tagCompound) { + return GT_NBT_DataBase.tagIdBiMap.get(tagCompound); + } + + public NBTTagCompound getTagCompound() { + return this.tagCompound; + } + + public String getmDataName() { + return this.mDataName; + } + + static long getMaxID() { + return GT_NBT_DataBase.maxID; + } + + public String getmDataTitle() { + return this.mDataTitle; + } + + public long getId() { + return this.id; + } + + public void setId(long id) { + this.id = id; + } + + private GT_NBT_DataBase(NBTTagCompound tagCompound, String mDataName, String mDataTitle, long id) { + this.tagCompound = tagCompound; + this.mDataName = mDataName; + this.mDataTitle = mDataTitle; + this.id = id; + } + + public static GT_NBT_DataBase makeNewWithoutRegister(String mDataName, String mDataTitle, + NBTTagCompound tagCompound) { + return new GT_NBT_DataBase(tagCompound, mDataName, mDataTitle, Long.MIN_VALUE); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java new file mode 100644 index 0000000000..fdfe3d7ee9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.openComputers; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; +import com.github.bartimaeusnek.bartworks.API.SideReference; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import cpw.mods.fml.common.Optional; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Mods; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; +import li.cil.oc.api.machine.Arguments; +import li.cil.oc.api.machine.Callback; +import li.cil.oc.api.machine.Context; +import li.cil.oc.api.network.SimpleComponent; + +@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = Mods.Names.OPEN_COMPUTERS) +public class TileEntity_GTDataServer extends TileEntity + implements ISidedInventory, ITileAddsInformation, ITileHasDifferentTextureSides, SimpleComponent { + + private final BiMap OrbDataBase = HashBiMap.create(); + + private ItemStack[] mItems = new ItemStack[2]; + private byte TickTimer; + + @Optional.Method(modid = Mods.Names.OPEN_COMPUTERS) + public String getComponentName() { + return "GT-Data Server"; + } + + @Optional.Method(modid = Mods.Names.OPEN_COMPUTERS) + @Callback + public Object[] listData(Context context, Arguments args) { + Set ret = new HashSet<>(); + for (Map.Entry entry : this.OrbDataBase.entrySet()) { + ret.add( + entry.getValue() + .getId() + Long.MAX_VALUE + + ". " + + entry.getValue() + .getmDataTitle()); + } + return ret.toArray(new String[0]); + } + + @Optional.Method(modid = Mods.Names.OPEN_COMPUTERS) + @Callback + public Object[] imprintOrb(Context context, Arguments args) { + return new Object[] { false }; + } + + private boolean isServerSide() { + return !this.worldObj.isRemote || SideReference.Side.Server; + } + + @Override + public void updateEntity() { + if (this.TickTimer++ % 20 != 0) return; + + if (this.isServerSide()) { + if (GT_Utility.areStacksEqual(this.mItems[0], ItemList.Tool_DataOrb.get(1)) + && this.mItems[0].hasTagCompound()) { + if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { + this.OrbDataBase.put( + GT_NBT_DataBase.getMaxID(), + new GT_NBT_DataBase( + Behaviour_DataOrb.getDataName(this.mItems[0]), + Behaviour_DataOrb.getDataTitle(this.mItems[0]), + this.mItems[0].getTagCompound())); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id, GT_NBT_DataBase.getGTTagFromId(id)); + } + } + if (GT_Utility.areStacksEqual(this.mItems[0], ItemList.Tool_DataStick.get(1)) + && this.mItems[0].hasTagCompound()) { + + String bookTitle = GT_Utility.ItemNBT.getBookTitle(this.mItems[0]); + String punchcardData = GT_Utility.ItemNBT.getPunchCardData(this.mItems[0]); + short mapID = GT_Utility.ItemNBT.getMapID(this.mItems[0]); + byte data = (byte) (bookTitle.isEmpty() ? punchcardData.isEmpty() ? mapID != -1 ? 3 : -1 : 2 : 1); + + String title = data == 1 ? bookTitle + : data == 2 ? punchcardData : data == 3 ? "" + mapID : "Custom Data"; + String name = data == 1 ? "eBook" + : data == 2 ? "Punch Card Data" : data == 3 ? "Map Data" : "Custom Data"; + if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { + this.OrbDataBase.put( + GT_NBT_DataBase.getMaxID(), + new GT_NBT_DataBase(name, title, this.mItems[0].getTagCompound())); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id, GT_NBT_DataBase.getGTTagFromId(id)); + } + } + } + } + + @Override + public String[] getInfoData() { + return new String[0]; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) {} + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return this.mItems.length; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + return slotIn == 0 ? this.mItems[0] : this.mItems[1]; + } + + @Override + public ItemStack decrStackSize(int index, int count) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int index) { + return null; + } + + @Override + public void setInventorySlotContents(int index, ItemStack stack) { + if (index > 1 || index < 0) return; + this.mItems[index] = stack; + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + return index == 0; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java new file mode 100644 index 0000000000..a760c5e256 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.tectech; + +import static gregtech.api.enums.Mods.GalactiGreg; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.technus.tectech.recipe.TT_recipeAdder; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_OreDictUnificator; + +public class TecTechResearchLoader { + + public static void runResearches() { + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + + if (GalactiGreg.isModLoaded()) { + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemRegistry.voidminer[0].copy(), + 1024000, + 256, + (int) TierEU.RECIPE_ZPM, + 24, + new Object[] { ItemRegistry.voidminer[0].copy(), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.BlackPlutonium, 9L), + Materials.BlackPlutonium.getPlates(3), ItemList.Electric_Motor_ZPM.get(9L), + ItemList.Sensor_ZPM.get(9L), ItemList.Field_Generator_ZPM.get(9L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.BlackPlutonium, 36L) }, + new FluidStack[] { new FluidStack(solderIndalloy, 1440), WerkstoffLoader.Krypton.getFluidOrGas(20000) }, + ItemRegistry.voidminer[1].copy(), + 5 * MINUTES, + (int) TierEU.RECIPE_ZPM); + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemRegistry.voidminer[1].copy(), + 8192000, + 512, + (int) TierEU.RECIPE_UV, + 64, + new Object[] { ItemRegistry.voidminer[1].copy(), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Neutronium, 9L), + Materials.Neutronium.getPlates(3), ItemList.Electric_Motor_UV.get(9L), ItemList.Sensor_UV.get(9L), + ItemList.Field_Generator_UV.get(9L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Neutronium, 36L) }, + new FluidStack[] { new FluidStack(solderIndalloy, 1440), + WerkstoffLoader.Oganesson.getFluidOrGas(20000) }, + ItemRegistry.voidminer[2].copy(), + 5 * MINUTES, + (int) TierEU.RECIPE_UV); + } + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Machine_Multi_ImplosionCompressor.get(1L), + 64000, + 48, + (int) TierEU.RECIPE_UV, + 8, + new Object[] { ItemList.Machine_Multi_ImplosionCompressor.get(1L), Materials.Neutronium.getBlocks(5), + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Osmium, 64), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Osmium, 64), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUHV, 64), + ItemList.Electric_Piston_UV.get(64), }, + new FluidStack[] { new FluidStack(solderIndalloy, 1440), Materials.Osmium.getMolten(1440), + Materials.Neutronium.getMolten(1440) }, + ItemRegistry.eic.copy(), + 5 * MINUTES, + (int) TierEU.RECIPE_UV); + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java new file mode 100644 index 0000000000..e3a2065ed5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered; + +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Energy; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public interface LowPowerLaser extends IMetaTileEntity, IConnectsToEnergyTunnel { + + boolean isSender(); + + boolean isReceiver(); + + boolean isTunnel(); + + default boolean isConnectedCorrectly(ForgeDirection side) { + return false; + } + + default void setEUVar(long aEnergy) {} + + default long getAMPERES() { + return -1; + } + + default long maxEUInput() { + return -1; + } + + default long maxEUOutput() { + return -1; + } + + default long maxEUStore() { + return -1; + } + + default long getTotalPower() { + return this.getAMPERES() * Math.max(this.maxEUOutput(), this.maxEUInput()) - this.getAMPERES() / 20; + } + + default void moveAroundLowPower(IGregTechTileEntity aBaseMetaTileEntity) { + byte color = this.getBaseMetaTileEntity() + .getColorization(); + if (color >= 0) { + ForgeDirection front = aBaseMetaTileEntity.getFrontFacing(); + ForgeDirection opposite = front.getOpposite(); + + for (short dist = 1; dist < 250; ++dist) { + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity + .getIGregTechTileEntityAtSideAndDistance(front, dist); + if (tGTTileEntity == null || tGTTileEntity.getColorization() != color) { + return; + } + + IMetaTileEntity aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return; + } + + if (aMetaTileEntity instanceof LowPowerLaser lowPowerLaser && lowPowerLaser.isReceiver() + && opposite == tGTTileEntity.getFrontFacing()) { + if (this.maxEUOutput() > lowPowerLaser.maxEUInput() + || this.getAMPERES() > lowPowerLaser.getAMPERES()) { + aMetaTileEntity.doExplosion(this.maxEUOutput()); + this.setEUVar(aBaseMetaTileEntity.getStoredEU() - this.maxEUOutput()); + return; + } + + if (this.maxEUOutput() == lowPowerLaser.maxEUInput()) { + long diff = Math.min( + this.getAMPERES() * 20L * this.maxEUOutput(), + Math.min( + lowPowerLaser.maxEUStore() - aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU(), + aBaseMetaTileEntity.getStoredEU())); + this.setEUVar(aBaseMetaTileEntity.getStoredEU() - diff); + lowPowerLaser.setEUVar( + aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU() + diff); + } + return; + } + + if ((!(aMetaTileEntity instanceof LowPowerLaser lowPowerLaser) || !lowPowerLaser.isTunnel()) + && !(aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy)) { + return; + } + + if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy tePipeEnergy) { + if (tePipeEnergy.connectionCount < 2) { + return; + } + tePipeEnergy.markUsed(); + return; + } + + if (aMetaTileEntity instanceof LowPowerLaser lowPowerLaser && lowPowerLaser.isTunnel() + && !lowPowerLaser.isConnectedCorrectly(front)) { + return; + } + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java new file mode 100644 index 0000000000..c1d751739f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered; + +import java.util.Optional; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; + +public abstract class TT_Abstract_LowPowerLaserThingy extends GT_MetaTileEntity_TieredMachineBlock + implements LowPowerLaser { + + protected long AMPERES; + + public TT_Abstract_LowPowerLaserThingy(int aID, String aName, String aNameRegional, int aTier, long aAmperes, + int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + this.AMPERES = aAmperes; + } + + public TT_Abstract_LowPowerLaserThingy(int aID, String aName, String aNameRegional, int aTier, long aAmperes, + int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + this.AMPERES = aAmperes; + } + + public TT_Abstract_LowPowerLaserThingy(String aName, int aTier, long aAmperes, int aInvSlotCount, + String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + this.AMPERES = aAmperes; + } + + public TT_Abstract_LowPowerLaserThingy(String aName, int aTier, long aAmperes, int aInvSlotCount, + String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + this.AMPERES = aAmperes; + } + + @Override + public long getAMPERES() { + return this.AMPERES; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return true; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return true; + } + + @Override + public boolean shouldJoinIc2Enet() { + return true; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) { + Optional.ofNullable(nbtTagCompound) + .ifPresent(tag -> tag.setLong("AMPERES", this.AMPERES)); + } + + @Override + public void loadNBTData(NBTTagCompound nbtTagCompound) { + if (nbtTagCompound != null && nbtTagCompound.hasKey("AMPERES")) { + this.AMPERES = nbtTagCompound.getLong("AMPERES"); + } + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return GT_Values.V[this.mTier]; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier + 1]; + } + + @Override + public long maxEUStore() { + return 512L + GT_Values.V[this.mTier + 1] * 24L * this.AMPERES; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java new file mode 100644 index 0000000000..b79ddb4a44 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered; + +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; + +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.util.GT_Utility; + +public class TT_MetaTileEntity_LowPowerLaserBox extends TT_Abstract_LowPowerLaserThingy { + + public TT_MetaTileEntity_LowPowerLaserBox(int aID, String aName, String aNameRegional, int aTier, long aAmperes, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aAmperes, 0, new String[0], aTextures); + } + + public TT_MetaTileEntity_LowPowerLaserBox(String aName, int aTier, long aAmperes, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aAmperes, 0, aDescription, aTextures); + } + + @Override + public boolean isSender() { + return this.getBaseMetaTileEntity() + .isAllowedToWork(); + } + + @Override + public boolean isReceiver() { + return !this.getBaseMetaTileEntity() + .isAllowedToWork(); + } + + @Override + public boolean isTunnel() { + return false; + } + + @Override + public long maxAmperesOut() { + return !this.getBaseMetaTileEntity() + .isAllowedToWork() ? this.AMPERES : 0; + } + + @Override + public long maxAmperesIn() { + return this.getBaseMetaTileEntity() + .isAllowedToWork() ? this.AMPERES + this.AMPERES / 4 : 0; + } + + @Override + public boolean hasAlternativeModeText() { + return true; + } + + @Override + public String getAlternativeModeText() { + return this.isReceiver() ? "Set to receiving mode" : "Set to sending mode"; + } + + @Override + public boolean isEnetInput() { + return this.getBaseMetaTileEntity() + .isAllowedToWork(); + } + + @Override + public boolean isEnetOutput() { + return !this.getBaseMetaTileEntity() + .isAllowedToWork(); + } + + @Override + public boolean canConnect(ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new TT_MetaTileEntity_LowPowerLaserBox( + this.mName, + this.mTier, + this.AMPERES, + this.mDescriptionArray, + this.mTextures); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork()); + + byte Tick = (byte) (int) (aTick % 20L); + if (16 == Tick) { + if (aBaseMetaTileEntity.getStoredEU() > 0L) { + this.setEUVar(aBaseMetaTileEntity.getStoredEU() - this.AMPERES); + if (aBaseMetaTileEntity.getStoredEU() < 0L) { + this.setEUVar(0L); + } + } + if (this.getBaseMetaTileEntity() + .isAllowedToWork() && aBaseMetaTileEntity.getStoredEU() > this.getMinimumStoredEU()) { + this.moveAroundLowPower(aBaseMetaTileEntity); + } + } + } + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[this.mTier] }; + rTextures[1][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[this.mTier] }; + rTextures[2][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[this.mTier] }; + rTextures[3][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT[this.mTier] }; + rTextures[4][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT[this.mTier] }; + rTextures[5][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT[this.mTier] }; + rTextures[6][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + rTextures[7][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + rTextures[8][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + rTextures[9][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT[this.mTier] }; + rTextures[10][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT[this.mTier] }; + rTextures[11][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT[this.mTier] }; + } + + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + return this.mTextures[Math.min(2, side.ordinal()) + (side == facing ? 3 : 0) + (aActive ? 0 : 6)][aColorIndex + + 1]; + } + + @Override + public String[] getDescription() { + return new String[] { "Like a Tranformer... but for LAZORZ", + "Transfer rate: " + ChatColorHelper.YELLOW + + GT_Utility.formatNumbers(this.getTotalPower()) + + ChatColorHelper.WHITE + + " EU/t", + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java new file mode 100644 index 0000000000..5a9cd8048b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +import org.apache.commons.lang3.ArrayUtils; + +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoTunnel; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; + +public class TT_MetaTileEntity_LowPowerLaserDynamo extends GT_MetaTileEntity_Hatch_DynamoTunnel + implements LowPowerLaser { + + public TT_MetaTileEntity_LowPowerLaserDynamo(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super(aID, aName, aNameRegional, aTier, aAmp); + } + + public TT_MetaTileEntity_LowPowerLaserDynamo(String aName, int aTier, int aAmp, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new TT_MetaTileEntity_LowPowerLaserDynamo( + this.mName, + this.mTier, + this.Amperes, + this.mDescriptionArray, + this.mTextures); + } + + @Override + public boolean isSender() { + return true; + } + + @Override + public boolean isReceiver() { + return false; + } + + @Override + public boolean isTunnel() { + return false; + } + + @Override + public long getAMPERES() { + return this.Amperes; + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + StatCollector.translateToLocal("gt.blockmachines.hatch.dynamotunnel.desc.1") + ": " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getTotalPower()) + + EnumChatFormatting.RESET + + " EU/t", + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + byte Tick = (byte) (int) (aTick % 20L); + if (16 == Tick && aBaseMetaTileEntity.getStoredEU() > 0L) { + this.setEUVar(aBaseMetaTileEntity.getStoredEU() - this.Amperes); + if (aBaseMetaTileEntity.getStoredEU() < 0L) { + this.setEUVar(0L); + } + } + if (aBaseMetaTileEntity.getStoredEU() > this.getMinimumStoredEU()) { + this.moveAroundLowPower(aBaseMetaTileEntity); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserHatch.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserHatch.java new file mode 100644 index 0000000000..6b6b6c3558 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserHatch.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +import org.apache.commons.lang3.ArrayUtils; + +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; + +public class TT_MetaTileEntity_LowPowerLaserHatch extends GT_MetaTileEntity_Hatch_EnergyTunnel + implements LowPowerLaser { + + public TT_MetaTileEntity_LowPowerLaserHatch(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super(aID, aName, aNameRegional, aTier, aAmp); + } + + public TT_MetaTileEntity_LowPowerLaserHatch(String aName, int aTier, int aAmp, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + StatCollector.translateToLocal("gt.blockmachines.hatch.energytunnel.desc.1") + ": " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(this.getTotalPower()) + + EnumChatFormatting.RESET + + " EU/t", + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new TT_MetaTileEntity_LowPowerLaserHatch( + this.mName, + this.mTier, + this.Amperes, + this.mDescriptionArray, + this.mTextures); + } + + @Override + public boolean isSender() { + return false; + } + + @Override + public boolean isReceiver() { + return true; + } + + @Override + public boolean isTunnel() { + return false; + } + + @Override + public long getAMPERES() { + return this.Amperes; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java new file mode 100644 index 0000000000..38ad31688d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered; + +import java.util.ArrayList; +import java.util.HashSet; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; + +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.common.GT_Client; +import ic2.core.Ic2Items; + +public class TT_MetaTileEntity_Pipe_Energy_LowPower extends GT_MetaPipeEntity_Cable implements LowPowerLaser { + + public TT_MetaTileEntity_Pipe_Energy_LowPower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0.25f, Materials.BorosilicateGlass, 0, 0, 0, false, false); + } + + public TT_MetaTileEntity_Pipe_Energy_LowPower(String aName, float aThickNess, Materials aMaterial, + long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { + super(aName, aThickNess, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new TT_MetaTileEntity_Pipe_Energy_LowPower( + this.mName, + this.mThickNess, + this.mMaterial, + this.mCableLossPerMeter, + this.mAmperage, + this.mVoltage, + this.mInsulated, + this.mCanShock); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aTick % 20 == 13 && aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { + aBaseMetaTileEntity.issueTextureUpdate(); + } + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection siide, byte aConnections, + int aColorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { TextureFactory.of( + Block.getBlockFromItem(Ic2Items.glassFiberCableBlock.getItem()), + Ic2Items.glassFiberCableBlock.getItemDamage(), + siide) }; + } + + @Override + public String[] getDescription() { + return new String[] { "Primitive Laser Cable intended for Low Power Applications", "Does not auto-connect", + "Does not turn or bend", + ChatColorHelper.WHITE + "Must be " + + ChatColorHelper.YELLOW + + "c" + + ChatColorHelper.RED + + "o" + + ChatColorHelper.BLUE + + "l" + + ChatColorHelper.DARKPURPLE + + "o" + + ChatColorHelper.GOLD + + "r" + + ChatColorHelper.DARKRED + + "e" + + ChatColorHelper.DARKGREEN + + "d" + + ChatColorHelper.WHITE + + " in order to work", + BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }; + } + + @Override + public boolean isSender() { + return false; + } + + @Override + public boolean isReceiver() { + return false; + } + + @Override + public boolean isTunnel() { + return true; + } + + public boolean canConnect(ForgeDirection side) { + return true; + } + + @Override + public boolean isGivingInformation() { + return false; + } + + @Override + public boolean isConnectedCorrectly(ForgeDirection side) { + return this.isConnectedAtSide(side) && this.isConnectedAtSide(side.getOpposite()); + } + + @Override + public boolean shouldJoinIc2Enet() { + return false; + } + + @Override + public long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { + return 0L; + } + + @Override + @Deprecated + public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, + ArrayList aAlreadyPassedTileEntityList) { + return 0L; + } + + @Override + public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, + HashSet aAlreadyPassedSet) { + return 0L; + } + + @Override + public boolean letsIn(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsOut(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, + ICoverable aTileEntity) { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java b/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java new file mode 100644 index 0000000000..2959bc2fb2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java @@ -0,0 +1,82 @@ +package com.github.bartimaeusnek.crossmod.tgregworks; + +import static gregtech.api.enums.Mods.TinkersGregworks; + +import net.minecraftforge.common.config.Property; + +import com.github.bartimaeusnek.bartworks.API.API_REFERENCE; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import vexatos.tgregworks.TGregworks; +import vexatos.tgregworks.item.ItemTGregPart; +import vexatos.tgregworks.reference.Config; + +@Mod( + modid = MaterialsInjector.MOD_ID, + name = MaterialsInjector.NAME, + version = MaterialsInjector.VERSION, + dependencies = """ + required-after:IC2;\ + required-after:gregtech;\ + required-after:bartworks;\ + before:TGregworks;\ + before:miscutils;""") +public class MaterialsInjector { + + public static final String NAME = "BartWorks Mod Additions - TGregworks Container"; + public static final String VERSION = API_REFERENCE.VERSION; + public static final String MOD_ID = "bartworkscrossmodtgregworkscontainer"; + + @Mod.EventHandler + public void init(FMLInitializationEvent init) { + if (TinkersGregworks.isModLoaded()) { + MaterialsInjector.run(); + } + } + + public static void run() { + MainMod.LOGGER.info("Registering TGregworks - BartWorks tool parts."); + Werkstoff.werkstoffHashSet.stream() + .filter(x -> x.hasItemType(OrePrefixes.gem) || x.hasItemType(OrePrefixes.plate)) + .map(Werkstoff::getBridgeMaterial) + .filter(x -> x.mMetaItemSubID == -1) + .filter(x -> x.mDurability != 0) + .forEach(m -> { + setConfigProps(m); + registerParts(m); + }); + + TGregworks.registry.configProps.clear(); + TGregworks.registry.configIDs.clear(); + + ItemTGregPart.toolMaterialNames = TGregworks.registry.toolMaterialNames; + } + + private static void registerParts(Materials m) { + TGregworks.registry.toolMaterialNames.add(m.mDefaultLocalName); + int matID = TGregworks.registry.getMaterialID(m); + + TGregworks.registry.addToolMaterial(matID, m); + TGregworks.registry.addBowMaterial(matID, m); + TGregworks.registry.addArrowMaterial(matID, m); + + TGregworks.registry.matIDs.put(m, matID); + TGregworks.registry.materialIDMap.put(matID, m); + } + + private static void setConfigProps(Materials m) { + if (TGregworks.config.get(Config.Category.Enable, m.mName, true) + .getBoolean(true)) { + TGregworks.registry.toolMaterials.add(m); + Property configProp = TGregworks.config + .get(Config.onMaterial(Config.MaterialID), m.mName, 0, null, 0, 100000); + TGregworks.registry.configProps.put(m, configProp); + TGregworks.registry.configIDs.add(configProp.getInt()); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_Multi_IndustrialCrucible.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_Multi_IndustrialCrucible.java new file mode 100644 index 0000000000..c52e440383 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_Multi_IndustrialCrucible.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.thaumcraft.tile; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; + +public class GT_Multi_IndustrialCrucible extends GT_MetaTileEntity_MultiBlockBase { + + public GT_Multi_IndustrialCrucible(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_Multi_IndustrialCrucible(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return false; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 0; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return null; + } + + @Override + public String[] getDescription() { + return new String[0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity iGregTechTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean b3, boolean b4) { + return new ITexture[0]; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java new file mode 100644 index 0000000000..79e606d536 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.thaumcraft.tile; + +import net.minecraft.item.ItemStack; + +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatteryBuffer; +import gregtech.api.util.GT_ModHandler; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class GT_WandBuffer extends GT_MetaTileEntity_BasicBatteryBuffer { + + public GT_WandBuffer(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); + } + + public GT_WandBuffer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + } + + public GT_WandBuffer(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mBatteryCount = 0; + this.mChargeableCount = 0; + + for (ItemStack tStack : this.mInventory) { + if (ThaumcraftHandler.isWand(tStack)) { + ++this.mBatteryCount; + ++this.mChargeableCount; + } + } + } + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return ThaumcraftHandler.isWand(aStack); + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return ThaumcraftHandler.isWand(aStack); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public long[] getStoredEnergy() { + boolean scaleOverflow = false; + boolean storedOverflow = false; + long tScale = this.getBaseMetaTileEntity() + .getEUCapacity(); + long tStored = this.getBaseMetaTileEntity() + .getStoredEU(); + long tStep; + if (this.mInventory != null) { + + for (ItemStack aStack : this.mInventory) { + if (GT_ModHandler.isElectricItem(aStack)) { + if (aStack.getItem() instanceof GT_MetaBase_Item) { + Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); + if (stats != null) { + if (stats[0] > 4611686018427387903L) { + scaleOverflow = true; + } + + tScale += stats[0]; + tStep = ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack); + if (tStep > 4611686018427387903L) { + storedOverflow = true; + } + + tStored += tStep; + } + } else if (aStack.getItem() instanceof IElectricItem) { + tStored += (long) ElectricItem.manager.getCharge(aStack); + tScale += (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack); + } + } + } + } + + if (scaleOverflow) { + tScale = 9223372036854775807L; + } + + if (storedOverflow) { + tStored = 9223372036854775807L; + } + + return new long[] { tStored, tScale }; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java new file mode 100644 index 0000000000..9492a6c077 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.thaumcraft.util; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.biome.BiomeGenBase; + +import com.github.bartimaeusnek.bartworks.API.API_ConfigValues; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.bartworks.util.log.DebugLog; + +import gregtech.api.enums.TC_Aspects; + +public class ThaumcraftHandler { + + private ThaumcraftHandler() {} + + private static Integer taintBiomeID; + private static Integer magicalForestBiomeID; + private static Class mWandInterface; + + static { + try { + ThaumcraftHandler.mWandInterface = Class.forName("thaumcraft.common.items.wands.ItemWandCasting"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + public static boolean isWand(ItemStack aStack) { + try { + return aStack != null && ThaumcraftHandler.mWandInterface.isAssignableFrom( + aStack.getItem() + .getClass()); + } catch (Throwable var3) { + return false; + } + } + + public static boolean isMagicalForestBiome(int biomeID) { + if (ThaumcraftHandler.magicalForestBiomeID == null) { + try { + BiomeGenBase biome = (BiomeGenBase) Class + .forName("thaumcraft.common.lib.world.ThaumcraftWorldGenerator") + .getField("biomeMagicalForest") + .get(null); + return biomeID == (ThaumcraftHandler.magicalForestBiomeID = biome.biomeID); + } catch (ClassCastException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + return false; + } + } + return biomeID == ThaumcraftHandler.magicalForestBiomeID; + } + + public static boolean isTaintBiome(int biomeID) { + if (ThaumcraftHandler.taintBiomeID == null) { + try { + BiomeGenBase TaintBiome = (BiomeGenBase) Class + .forName("thaumcraft.common.lib.world.ThaumcraftWorldGenerator") + .getField("biomeTaint") + .get(null); + return biomeID == (ThaumcraftHandler.taintBiomeID = TaintBiome.biomeID); + } catch (ClassCastException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + return false; + } + } + return biomeID == ThaumcraftHandler.taintBiomeID; + } + + public static class AspectAdder { + + public static Class mAspectListClass; + public static Class mAspectClass; + public static Method registerObjectTag; + public static Method addToList; + public static Method getName; + public static Method writeAspectListToNBT; + public static Method readAspectListFromNBT; + public static Method add; + public static Method getAmount; + public static Method getAspects; + public static Method isResearchComplete; + public static Field linkedAspektList; + + static { + try { + ThaumcraftHandler.AspectAdder.mAspectListClass = Class.forName("thaumcraft.api.aspects.AspectList"); + ThaumcraftHandler.AspectAdder.mAspectClass = Class.forName("thaumcraft.api.aspects.Aspect"); + ThaumcraftHandler.AspectAdder.addToList = ThaumcraftHandler.AspectAdder.mAspectListClass + .getMethod("add", ThaumcraftHandler.AspectAdder.mAspectClass, int.class); + ThaumcraftHandler.AspectAdder.registerObjectTag = Class.forName("thaumcraft.api.ThaumcraftApi") + .getMethod("registerObjectTag", ItemStack.class, ThaumcraftHandler.AspectAdder.mAspectListClass); + ThaumcraftHandler.AspectAdder.getName = ThaumcraftHandler.AspectAdder.mAspectClass.getMethod("getName"); + ThaumcraftHandler.AspectAdder.writeAspectListToNBT = ThaumcraftHandler.AspectAdder.mAspectListClass + .getMethod("writeToNBT", NBTTagCompound.class); + ThaumcraftHandler.AspectAdder.add = ThaumcraftHandler.AspectAdder.mAspectListClass + .getMethod("add", ThaumcraftHandler.AspectAdder.mAspectListClass); + ThaumcraftHandler.AspectAdder.getAmount = ThaumcraftHandler.AspectAdder.mAspectListClass + .getMethod("getAmount", ThaumcraftHandler.AspectAdder.mAspectClass); + ThaumcraftHandler.AspectAdder.getAspects = ThaumcraftHandler.AspectAdder.mAspectListClass + .getMethod("getAspects"); + ThaumcraftHandler.AspectAdder.readAspectListFromNBT = ThaumcraftHandler.AspectAdder.mAspectListClass + .getMethod("readFromNBT", NBTTagCompound.class); + ThaumcraftHandler.AspectAdder.isResearchComplete = Class + .forName("thaumcraft.common.lib.research.ResearchManager") + .getMethod("isResearchComplete", String.class, String.class); + ThaumcraftHandler.AspectAdder.linkedAspektList = ThaumcraftHandler.AspectAdder.mAspectListClass + .getField("aspects"); + } catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException e) { + e.printStackTrace(); + } + } + + @SafeVarargs + public static void addAspectViaBW(ItemStack stack, Pair... aspectPair) { + if (stack == null || stack.getItem() == null || stack.getUnlocalizedName() == null) return; + try { + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.getConstructor() + .newInstance(); + for (Pair a : aspectPair) { + if (API_ConfigValues.debugLog) DebugLog.log( + "Stack:" + stack.getDisplayName() + + " Damage:" + + stack.getItemDamage() + + " aspectPair: " + + ThaumcraftHandler.AspectAdder.getName.invoke(a.getKey()) + + " / " + + a.getValue()); + ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, a.getKey(), a.getValue()); + } + ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void addAspectViaGT(ItemStack stack, TC_Aspects.TC_AspectStack... tc_aspectStacks) { + try { + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.getConstructor() + .newInstance(); + for (TC_Aspects.TC_AspectStack tc_aspects : tc_aspectStacks) ThaumcraftHandler.AspectAdder.addToList + .invoke(aspectList, tc_aspects.mAspect.mAspect, (int) tc_aspects.mAmount); + ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/Reference.java b/src/main/java/com/github/technus/tectech/Reference.java new file mode 100644 index 0000000000..928a4a4e0f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/Reference.java @@ -0,0 +1,15 @@ +package com.github.technus.tectech; + +import gregtech.api.enums.Mods; + +public final class Reference { + + public static final String MODID = Mods.Names.TECTECH; + public static final String NAME = "TecTech - Tec Technology!"; + public static final String VERSION = Tags.VERSION; + public static final String COLLECTIONNAME = "TecTech"; + public static final String CLIENTSIDE = "com.github.technus.tectech.proxy.ClientProxy"; + public static final String SERVERSIDE = "com.github.technus.tectech.proxy.CommonProxy"; + + private Reference() {} +} diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java new file mode 100644 index 0000000000..593f5f9627 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -0,0 +1,119 @@ +package com.github.technus.tectech; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static gregtech.api.enums.Mods.COFHCore; + +import net.minecraftforge.common.MinecraftForge; + +import com.github.technus.tectech.loader.MainLoader; +import com.github.technus.tectech.loader.TecTechConfig; +import com.github.technus.tectech.loader.gui.CreativeTabTecTech; +import com.github.technus.tectech.loader.thing.MuTeLoader; +import com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData; +import com.github.technus.tectech.proxy.CommonProxy; +import com.github.technus.tectech.recipe.EyeOfHarmonyRecipeStorage; +import com.github.technus.tectech.recipe.TecTechRecipeMaps; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import eu.usrv.yamcore.auxiliary.IngameErrorLog; +import eu.usrv.yamcore.auxiliary.LogHelper; +import gregtech.api.objects.XSTR; + +@Mod( + modid = Reference.MODID, + name = Reference.NAME, + version = Reference.VERSION, + dependencies = "required-after:Forge@[10.13.4.1614,);" + "required-after:YAMCore@[0.5.70,);" + + "required-after:structurelib;" + + "after:ComputerCraft;" + + "after:OpenComputers;" + + "required-after:gtneioreplugin;" + + "required-after:gregtech;" + + "after:dreamcraft;" + + "after:appliedenergistics2;" + + "after:CoFHCore;" + + "after:Thaumcraft;") +public class TecTech { + + @SidedProxy(clientSide = Reference.CLIENTSIDE, serverSide = Reference.SERVERSIDE) + public static CommonProxy proxy; + + @Mod.Instance(Reference.MODID) + public static TecTech instance; + + public static final XSTR RANDOM = XSTR.XSTR_INSTANCE; + public static final LogHelper LOGGER = new LogHelper(Reference.MODID); + public static CreativeTabTecTech creativeTabTecTech; + + public static TecTechConfig configTecTech; + + public static EnderWorldSavedData enderWorldSavedData; + + /** + * For Loader.isModLoaded checks during the runtime + */ + public static boolean hasCOFH = false; + + public static final byte tectechTexturePage1 = 8; + + @Mod.EventHandler + @SuppressWarnings("unused") + public void PreLoad(FMLPreInitializationEvent PreEvent) { + LOGGER.setDebugOutput(true); + + configTecTech = new TecTechConfig( + PreEvent.getModConfigurationDirectory(), + Reference.COLLECTIONNAME, + Reference.MODID); + + if (!configTecTech.LoadConfig()) { + LOGGER.error(Reference.MODID + " could not load its config file. Things are going to be weird!"); + } + + if (configTecTech.MOD_ADMIN_ERROR_LOGS) { + LOGGER.setDebugOutput(DEBUG_MODE); + LOGGER.debug("moduleAdminErrorLogs is enabled"); + IngameErrorLog moduleAdminErrorLogs = new IngameErrorLog(); + } + + enderWorldSavedData = new EnderWorldSavedData(); + FMLCommonHandler.instance() + .bus() + .register(enderWorldSavedData); + MinecraftForge.EVENT_BUS.register(enderWorldSavedData); + + TecTechRecipeMaps.init(); + MainLoader.preLoad(); + new MuTeLoader().run(); + } + + @Mod.EventHandler + @SuppressWarnings("unused") + public void Load(FMLInitializationEvent event) { + hasCOFH = COFHCore.isModLoaded(); + + MainLoader.load(); + MainLoader.addAfterGregTechPostLoadRunner(); + } + + @Mod.EventHandler + @SuppressWarnings("unused") + public void PostLoad(FMLPostInitializationEvent PostEvent) { + MainLoader.postLoad(); + } + + @Mod.EventHandler + @SuppressWarnings("unused") + public void onLoadCompleted(FMLLoadCompleteEvent event) { + eyeOfHarmonyRecipeStorage = new EyeOfHarmonyRecipeStorage(); + } + + public static EyeOfHarmonyRecipeStorage eyeOfHarmonyRecipeStorage = null; + +} diff --git a/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java b/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java new file mode 100644 index 0000000000..74e7a26839 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java @@ -0,0 +1,307 @@ +package com.github.technus.tectech.compatibility.openComputers; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import org.apache.commons.compress.utils.IOUtils; + +import com.github.technus.avrClone.AvrCore; +import com.github.technus.avrClone.instructions.ExecutionEvent; +import com.github.technus.avrClone.instructions.InstructionRegistry; +import com.github.technus.avrClone.instructions.exceptions.DebugEvent; +import com.github.technus.avrClone.instructions.exceptions.DelayEvent; +import com.github.technus.avrClone.memory.EepromMemory; +import com.github.technus.avrClone.memory.RemovableMemory; +import com.github.technus.avrClone.memory.program.ProgramMemory; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.util.Converter; + +import li.cil.oc.Settings; +import li.cil.oc.api.Driver; +import li.cil.oc.api.driver.Item; +import li.cil.oc.api.driver.item.Memory; +import li.cil.oc.api.machine.Architecture; +import li.cil.oc.api.machine.ExecutionResult; +import li.cil.oc.api.machine.Machine; +import li.cil.oc.api.machine.Signal; +import li.cil.oc.common.SaveHandler; + +@Architecture.Name("AVR 32Bit Clone") +@Architecture.NoMemoryRequirements +public class AvrArchitecture implements Architecture { + + private final Machine machine; + private AvrCore core; + private boolean debugRun; + private int delay; + private int[] tempData; + private int memSize; + + public AvrArchitecture(Machine machine) { + this.machine = machine; + } + + @Override + public boolean isInitialized() { + return core != null && core.checkValid(); + } + + @Override + public boolean recomputeMemory(Iterable components) { + computeMemory(components); + return true; + } + + private void computeMemory(Iterable components) { + int memory = 0; + for (ItemStack component : components) { + Item driver = Driver.driverFor(component); + if (driver instanceof Memory memoryDriver) { + memory += memoryDriver.amount(component) * 256; // in integers + } // else if (driver instanceof DriverEEPROM$) { + + // } + } + memory = Math.min( + Math.max(memory, 0), + Settings.get() + .maxTotalRam()); + if (memory != memSize) {} + } + + @Override + public boolean initialize() { + core = new AvrCore(); + + computeMemory( + this.machine.host() + .internalComponents()); + + if (isInitialized()) { + machine.beep("."); + return true; + } + return false; + } + + @Override + public void close() { + core = null; + tempData = null; + delay = 0; + } + + @Override + public void runSynchronized() { + core.cycle(); + } + + @Override + public ExecutionResult runThreaded(boolean isSynchronizedReturn) { + if (core.awoken) { + delay = 0; + for (int load = 0; load < 512;) { + load += core.getInstruction() + .getCost(core); + ExecutionEvent executionEvent = core.cpuCycleForce(); + if (executionEvent != null) { + if (executionEvent.throwable instanceof DelayEvent) { + delay = executionEvent.data[0]; + break; + } else if (executionEvent.throwable instanceof DebugEvent) { + if (debugRun) { + // aBaseMetaTileEntity.setActive(false); + break; + } + } + } + } + } else if (delay > 0) { + delay--; + if (delay == 0) { + core.awoken = true; + } + } + return null; + } + + @Override + public void onSignal() { + Signal signal = machine.popSignal(); + + core.interruptsHandle(); + } + + @Override + public void onConnect() { + // init network components, in case init was called from load logic (pre first tick?) + } + + @Override + public void load(NBTTagCompound avr) { + debugRun = avr.getBoolean("debugRun"); + delay = avr.getInteger("delay"); + core.active = avr.getBoolean("active"); + core.awoken = (avr.getBoolean("awoken")); + core.programCounter = avr.getInteger("programCounter"); + InstructionRegistry registry = InstructionRegistry.REGISTRIES.get(avr.getString("instructionRegistry")); + if (registry != null) { + byte[] instructions = SaveHandler.load( + avr, + this.machine.node() + .address() + "_instructionsMemory"); + byte[] param0 = SaveHandler.load( + avr, + this.machine.node() + .address() + "_param0Memory"); + byte[] param1 = SaveHandler.load( + avr, + this.machine.node() + .address() + "_param1Memory"); + if (instructions != null && param0 != null + && param1 != null + && instructions.length > 0 + && param0.length > 0 + && param1.length > 0) { + int[] instr = null, par0 = null, par1 = null; + try { + GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(instructions)); + instr = Converter.readInts(IOUtils.toByteArray(gzis)); + IOUtils.closeQuietly(gzis); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to decompress instructions memory from disk."); + e.printStackTrace(); + } + try { + GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(param0)); + par0 = Converter.readInts(IOUtils.toByteArray(gzis)); + IOUtils.closeQuietly(gzis); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to decompress param0 memory from disk."); + e.printStackTrace(); + } + try { + GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(param1)); + par1 = Converter.readInts(IOUtils.toByteArray(gzis)); + IOUtils.closeQuietly(gzis); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to decompress param1 memory from disk."); + e.printStackTrace(); + } + if (instr != null && par0 != null + && par1 != null + && instr.length == par0.length + && instr.length == par1.length) { + core.setProgramMemory(new ProgramMemory(registry, avr.getBoolean("immersive"), instr, par0, par1)); + } + } + } + if (avr.hasKey("eepromSize")) { + core.restoreEepromDefinition(EepromMemory.make(avr.getInteger("eepromSize"))); + } + byte[] data = SaveHandler.load( + avr, + this.machine.node() + .address() + "_dataMemory"); + if (data != null && data.length > 0) { + try { + GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(data)); + tempData = Converter.readInts(IOUtils.toByteArray(gzis)); + IOUtils.closeQuietly(gzis); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to decompress data memory from disk."); + e.printStackTrace(); + } + } + core.checkValid(); + } + + @Override + public void save(NBTTagCompound avr) { + avr.setBoolean("debugRun", debugRun); + avr.setInteger("delay", delay); + avr.setBoolean("active", core.active); + avr.setBoolean("awoken", core.awoken); + avr.setInteger("programCounter", core.programCounter); + ProgramMemory programMemory = core.getProgramMemory(); + if (programMemory != null) { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + GZIPOutputStream gzos = new GZIPOutputStream(baos); + gzos.write(Converter.writeInts(programMemory.instructions)); + gzos.close(); + SaveHandler.scheduleSave( + machine.host(), + avr, + machine.node() + .address() + "_instructionsMemory", + baos.toByteArray()); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to compress instructions memory to disk"); + e.printStackTrace(); + } + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + GZIPOutputStream gzos = new GZIPOutputStream(baos); + gzos.write(Converter.writeInts(programMemory.param0)); + gzos.close(); + SaveHandler.scheduleSave( + machine.host(), + avr, + machine.node() + .address() + "_param0Memory", + baos.toByteArray()); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to compress param0 memory to disk"); + e.printStackTrace(); + } + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + GZIPOutputStream gzos = new GZIPOutputStream(baos); + gzos.write(Converter.writeInts(programMemory.param1)); + gzos.close(); + SaveHandler.scheduleSave( + machine.host(), + avr, + machine.node() + .address() + "_param1Memory", + baos.toByteArray()); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to compress param1 memory to disk"); + e.printStackTrace(); + } + avr.setBoolean("immersive", programMemory.immersiveOperands); + avr.setString("instructionRegistry", programMemory.registry.toString()); + } + RemovableMemory eeprom = core.getEepromMemory(); + if (eeprom != null) { + avr.setInteger( + "eepromSize", + eeprom.getDefinition() + .getSize()); + } + if (core.dataMemory != null) { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + GZIPOutputStream gzos = new GZIPOutputStream(baos); + gzos.write(Converter.writeInts(core.dataMemory)); + gzos.close(); + SaveHandler.scheduleSave( + machine.host(), + avr, + machine.node() + .address() + "_dataMemory", + baos.toByteArray()); + } catch (IOException e) { + TecTech.LOGGER.error("Failed to compress data memory to disk"); + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java new file mode 100644 index 0000000000..01d63392e5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -0,0 +1,202 @@ +package com.github.technus.tectech.loader; + +import static com.github.technus.tectech.TecTech.LOGGER; +import static com.github.technus.tectech.TecTech.configTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.proxy; +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.Mods.TwilightForest; + +import java.util.HashMap; + +import net.minecraft.block.Block; +import net.minecraft.util.DamageSource; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.gui.CreativeTabTecTech; +import com.github.technus.tectech.loader.recipe.BaseRecipeLoader; +import com.github.technus.tectech.loader.thing.CoverLoader; +import com.github.technus.tectech.loader.thing.MachineLoader; +import com.github.technus.tectech.loader.thing.ThingsLoader; +import com.github.technus.tectech.thing.casing.TT_Container_Casings; +import com.github.technus.tectech.thing.metaTileEntity.Textures; + +import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_Recipe; + +@SuppressWarnings("deprecation") +public final class MainLoader { + + public static DamageSource microwaving; + + private MainLoader() {} + + public static void preLoad() { + creativeTabTecTech = new CreativeTabTecTech("TecTech"); + + // set expanded texture arrays for tiers + try { + Textures.run(); + } catch (Throwable t) { + LOGGER.error("Loading textures...", t); + } + } + + public static void load() { + ProgressManager.ProgressBar progressBarLoad = ProgressManager.push("TecTech Loader", 6); + + progressBarLoad.step("Regular Things"); + new ThingsLoader().run(); + LOGGER.info("Block/Item Init Done"); + + progressBarLoad.step("Machine Things"); + new MachineLoader().run(); + LOGGER.info("Machine Init Done"); + + progressBarLoad.step("Cover Things"); + new CoverLoader().run(); + LOGGER.info("Cover Init Done"); + + progressBarLoad.step("Add damage types"); + microwaving = new DamageSource("microwaving").setDamageBypassesArmor(); + LOGGER.info("Damage types addition Done"); + + progressBarLoad.step("Register Packet Dispatcher"); + new NetworkDispatcher(); + LOGGER.info("Packet Dispatcher registered"); + + progressBarLoad.step("Register GUI Handler"); + proxy.registerRenderInfo(); + LOGGER.info("GUI Handler registered"); + + ProgressManager.pop(progressBarLoad); + } + + public static void postLoad() { + ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 4); + + progressBarPostLoad.step("Dreamcraft Compatibility"); + if (NewHorizonsCoreMod.isModLoaded()) { + try { + Class clazz = Class.forName("com.dreammaster.gthandler.casings.GT_Container_CasingsNH"); + TT_Container_Casings.sBlockCasingsNH = (Block) clazz.getField("sBlockCasingsNH") + .get(null); + + if (TT_Container_Casings.sBlockCasingsNH == null) { + throw new NullPointerException("sBlockCasingsNH Is not set at this time"); + } + } catch (Exception e) { + throw new Error("Unable to get NH casings", e); + } + } + + progressBarPostLoad.step("Recipes"); + new BaseRecipeLoader().run(); + TecTech.LOGGER.info("Recipe Init Done"); + + if (!configTecTech.DISABLE_BLOCK_HARDNESS_NERF) { + progressBarPostLoad.step("Nerf blocks blast resistance"); + adjustTwilightBlockResistance(); + TecTech.LOGGER.info("Blocks nerf done"); + } else { + progressBarPostLoad.step("Do not nerf blocks blast resistance"); + TecTech.LOGGER.info("Blocks were not nerfed"); + } + + // ProgressManager.pop(progressBarPostLoad); + } + + public static void addAfterGregTechPostLoadRunner() { + GregTech_API.sAfterGTPostload.add(() -> { + if (TecTech.configTecTech.NERF_FUSION) { + FixBrokenFusionRecipes(); + } + }); + } + + private static void FixBrokenFusionRecipes() { + HashMap binds = new HashMap<>(); + for (Materials material : Materials.values()) { + FluidStack p = material.getPlasma(1); + if (p != null) { + if (DEBUG_MODE) { + LOGGER.info("Found Plasma of " + material.mName); + } + if (material.mElement != null && (material.mElement.mProtons >= Materials.Iron.mElement.mProtons + || -material.mElement.mProtons >= Materials.Iron.mElement.mProtons + || material.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons + || -material.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons)) { + if (DEBUG_MODE) { + LOGGER.info("Attempting to bind " + material.mName); + } + if (material.getMolten(1) != null) { + binds.put( + p.getFluid(), + material.getMolten(1) + .getFluid()); + } else if (material.getGas(1) != null) { + binds.put( + p.getFluid(), + material.getGas(1) + .getFluid()); + } else if (material.getFluid(1) != null) { + binds.put( + p.getFluid(), + material.getFluid(1) + .getFluid()); + } else { + binds.put( + p.getFluid(), + Materials.Iron.getMolten(1) + .getFluid()); + } + } + } + } + for (GT_Recipe r : RecipeMaps.fusionRecipes.getAllRecipes()) { + Fluid fluid = binds.get(r.mFluidOutputs[0].getFluid()); + if (fluid != null) { + if (DEBUG_MODE) { + LOGGER.info("Nerfing Recipe " + r.mFluidOutputs[0].getUnlocalizedName()); + } + r.mFluidOutputs[0] = new FluidStack(fluid, r.mFluidOutputs[0].amount); + } + fluid = binds.get(r.mFluidInputs[0].getFluid()); + if (fluid != null) { + if (DEBUG_MODE) { + LOGGER.info("Fixing plasma use in Recipe " + r.mFluidInputs[0].getUnlocalizedName()); + } + r.mFluidInputs[0] = new FluidStack(fluid, r.mFluidInputs[0].amount); + } + fluid = binds.get(r.mFluidInputs[1].getFluid()); + if (fluid != null) { + if (DEBUG_MODE) { + LOGGER.info("Fixing plasma use in Recipe " + r.mFluidInputs[1].getUnlocalizedName()); + } + r.mFluidInputs[1] = new FluidStack(fluid, r.mFluidInputs[1].amount); + } + } + } + + private static void safeSetResistance(Block block, float resistance) { + if (block != null) { + block.setResistance(resistance); + } + } + + private static void adjustTwilightBlockResistance() { + if (TwilightForest.isModLoaded()) { + safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFShield"), 30); + safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFThorns"), 10); + safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFTowerTranslucent"), 30); + safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFDeadrock"), 5); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java new file mode 100644 index 0000000000..c195364d91 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java @@ -0,0 +1,25 @@ +package com.github.technus.tectech.loader; + +import static com.github.technus.tectech.Reference.MODID; + +import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; +import com.github.technus.tectech.mechanics.spark.RendererMessage; + +public class NetworkDispatcher extends eu.usrv.yamcore.network.PacketDispatcher { + + public static NetworkDispatcher INSTANCE; + + public NetworkDispatcher() { + super(MODID); + INSTANCE = this; + registerPackets(); + } + + @Override + public void registerPackets() { + registerMessage(PipeActivityMessage.ServerHandler.class, PipeActivityMessage.PipeActivityQuery.class); + registerMessage(PipeActivityMessage.ClientHandler.class, PipeActivityMessage.PipeActivityData.class); + + registerMessage(RendererMessage.ClientHandler.class, RendererMessage.RendererData.class); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java new file mode 100644 index 0000000000..cb27933eb7 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -0,0 +1,257 @@ +package com.github.technus.tectech.loader; + +import java.io.File; + +import eu.usrv.yamcore.config.ConfigManager; + +public class TecTechConfig extends ConfigManager { + + public TecTechConfig(File pConfigBaseDirectory, String pModCollectionDirectory, String pModID) { + super(pConfigBaseDirectory, pModCollectionDirectory, pModID); + } + + // final static to allow compiler to remove the debug code when this is false + public static boolean DEBUG_MODE = false; + public static boolean POWERLESS_MODE = false; + public boolean BOOM_ENABLE; + public boolean DISABLE_BLOCK_HARDNESS_NERF; + public boolean EASY_SCAN; + public boolean NERF_FUSION; + public boolean ENABLE_TURRET_EXPLOSIONS; + public float TURRET_DAMAGE_FACTOR; + public float TURRET_EXPLOSION_FACTOR; + + public boolean MOD_ADMIN_ERROR_LOGS; + + public boolean TESLA_MULTI_GAS_OUTPUT; + public float TESLA_MULTI_LOSS_FACTOR_OVERDRIVE; + public int TESLA_MULTI_LOSS_PER_BLOCK_T0; + public int TESLA_MULTI_LOSS_PER_BLOCK_T1; + public int TESLA_MULTI_LOSS_PER_BLOCK_T2; + public int TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM; + public int TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN; + public int TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON; + public int TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1; + public int TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2; + public int TESLA_MULTI_RANGE_COVER; + public int TESLA_MULTI_RANGE_TOWER; + public int TESLA_MULTI_RANGE_TRANSCEIVER; + public float TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE; + public int TESLA_SINGLE_LOSS_PER_BLOCK; + public int TESLA_SINGLE_RANGE; + public boolean TESLA_VISUAL_EFFECT; + + /** + * This loading phases do not correspond to mod loading phases! + */ + @Override + protected void PreInit() { + + BOOM_ENABLE = true; + DISABLE_BLOCK_HARDNESS_NERF = false; + EASY_SCAN = false; + NERF_FUSION = false; + ENABLE_TURRET_EXPLOSIONS = true; + TURRET_DAMAGE_FACTOR = 10; + TURRET_EXPLOSION_FACTOR = 1; + + MOD_ADMIN_ERROR_LOGS = false; + + TESLA_MULTI_GAS_OUTPUT = false; + TESLA_MULTI_LOSS_FACTOR_OVERDRIVE = 0.25F; + TESLA_MULTI_LOSS_PER_BLOCK_T0 = 1; + TESLA_MULTI_LOSS_PER_BLOCK_T1 = 1; + TESLA_MULTI_LOSS_PER_BLOCK_T2 = 1; + TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM = 100; + TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN = 50; + TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON = 50; + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1 = 2; + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2 = 4; + TESLA_MULTI_RANGE_COVER = 16; + TESLA_MULTI_RANGE_TOWER = 32; + TESLA_MULTI_RANGE_TRANSCEIVER = 16; + TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE = 0.25F; + TESLA_SINGLE_LOSS_PER_BLOCK = 1; + TESLA_SINGLE_RANGE = 20; + TESLA_VISUAL_EFFECT = true; + } + + /** + * This loading phases do not correspond to mod loading phases! + */ + @Override + protected void Init() { + DEBUG_MODE = _mainConfig + .getBoolean("DebugMode", "debug", DEBUG_MODE, "Enables logging and other purely debug features"); + POWERLESS_MODE = _mainConfig + .getBoolean("PowerlessMode", "debug", POWERLESS_MODE, "Enables 0EU/t multi block machinery"); + + BOOM_ENABLE = _mainConfig.getBoolean( + "BoomEnable", + "features", + BOOM_ENABLE, + "Set to false to disable explosions on everything bad that you can do"); + DISABLE_BLOCK_HARDNESS_NERF = _mainConfig.getBoolean( + "DisableBlockHardnessNerf", + "features", + DISABLE_BLOCK_HARDNESS_NERF, + "Set to true to disable the block hardness nerf"); + EASY_SCAN = _mainConfig.getBoolean( + "EasyScan", + "features", + EASY_SCAN, + "Enables tricorder to scan EM i/o hatches directly, too CHEEKY"); + NERF_FUSION = _mainConfig.getBoolean( + "NerfFusion", + "features", + NERF_FUSION, + "Set to true to enable removal of plasmas heavier than Fe and other weird ones"); + ENABLE_TURRET_EXPLOSIONS = _mainConfig.getBoolean( + "TurretBoomEnable", + "features", + ENABLE_TURRET_EXPLOSIONS, + "Set to false to disable explosions caused by EM turrets"); + TURRET_DAMAGE_FACTOR = _mainConfig.getFloat( + "TurretDamageFactor", + "features", + TURRET_DAMAGE_FACTOR, + 0, + Short.MAX_VALUE, + "Damage is multiplied by this number"); + TURRET_EXPLOSION_FACTOR = _mainConfig.getFloat( + "TurretExplosionFactor", + "features", + TURRET_EXPLOSION_FACTOR, + 0, + Short.MAX_VALUE, + "Explosion strength is multiplied by this number"); + + MOD_ADMIN_ERROR_LOGS = _mainConfig.getBoolean( + "AdminErrorLog", + "modules", + MOD_ADMIN_ERROR_LOGS, + "If set to true, every op/admin will receive all errors occurred during the startup phase as in game message on join"); + + TESLA_MULTI_GAS_OUTPUT = _mainConfig.getBoolean( + "TeslaMultiGasOutput", + "tesla_tweaks", + TESLA_MULTI_GAS_OUTPUT, + "Set to true to enable outputting plasmas as gasses from the tesla tower with a 1:1 ratio"); + TESLA_MULTI_LOSS_FACTOR_OVERDRIVE = _mainConfig.getFloat( + "TeslaMultiLossFactorOverdrive", + "tesla_tweaks", + TESLA_MULTI_LOSS_FACTOR_OVERDRIVE, + 0, + 1, + "Additional Tesla Tower power loss per amp as a factor of the tier voltage"); + TESLA_MULTI_LOSS_PER_BLOCK_T0 = _mainConfig.getInt( + "TeslaMultiLossPerBlockT0", + "tesla_tweaks", + TESLA_MULTI_LOSS_PER_BLOCK_T0, + 0, + Integer.MAX_VALUE, + "Tesla Tower power transmission loss per block per amp using no plasmas"); + TESLA_MULTI_LOSS_PER_BLOCK_T1 = _mainConfig.getInt( + "TeslaMultiLossPerBlockT1", + "tesla_tweaks", + TESLA_MULTI_LOSS_PER_BLOCK_T1, + 0, + Integer.MAX_VALUE, + "Tesla Tower power transmission loss per block per amp using helium or nitrogen plasma"); + TESLA_MULTI_LOSS_PER_BLOCK_T2 = _mainConfig.getInt( + "TeslaMultiLossPerBlockT2", + "tesla_tweaks", + TESLA_MULTI_LOSS_PER_BLOCK_T2, + 0, + Integer.MAX_VALUE, + "Tesla Tower power transmission loss per block per amp using radon plasma"); + TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM = _mainConfig.getInt( + "TeslaMultiPlasmaPerSecondT1Helium", + "tesla_tweaks", + TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM, + 0, + Integer.MAX_VALUE, + "Tesla Tower helium plasma consumed each second the tesla tower is active"); + TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN = _mainConfig.getInt( + "TeslaMultiPlasmaPerSecondT1Nitrogen", + "tesla_tweaks", + TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN, + 0, + Integer.MAX_VALUE, + "Tesla Tower nitrogen plasma consumed each second the tesla tower is active"); + TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON = _mainConfig.getInt( + "TeslaMultiPlasmaPerSecondT2Radon", + "tesla_tweaks", + TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON, + 0, + Integer.MAX_VALUE, + "Tesla Tower radon plasma consumed each second the tesla tower is active"); + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1 = _mainConfig.getInt( + "TeslaMultiRangeCoefficientPlasmaT1", + "tesla_tweaks", + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1, + 0, + Integer.MAX_VALUE, + "Tesla Tower T1 Plasmas Range Multiplier"); + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2 = _mainConfig.getInt( + "TeslaMultiRangeCoefficientPlasmaT2", + "tesla_tweaks", + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2, + 0, + Integer.MAX_VALUE, + "Tesla Tower T2 Plasmas Range Multiplier"); + TESLA_MULTI_RANGE_COVER = _mainConfig.getInt( + "TeslaMultiRangeCover", + "tesla_tweaks", + TESLA_MULTI_RANGE_COVER, + 0, + Integer.MAX_VALUE, + "Tesla Tower to Tesla Coil Rich Edition Cover max range"); + TESLA_MULTI_RANGE_TOWER = _mainConfig.getInt( + "TeslaMultiRangeTower", + "tesla_tweaks", + TESLA_MULTI_RANGE_TOWER, + 0, + Integer.MAX_VALUE, + "Tesla Tower to Tower max range"); + TESLA_MULTI_RANGE_TRANSCEIVER = _mainConfig.getInt( + "TeslaMultiRangeTransceiver", + "tesla_tweaks", + TESLA_MULTI_RANGE_TRANSCEIVER, + 0, + Integer.MAX_VALUE, + "Tesla Tower to Transceiver max range"); + TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE = _mainConfig.getFloat( + "TeslaSingleLossFactorOverdrive", + "tesla_tweaks", + TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE, + 0, + 1, + "Additional Tesla Transceiver power loss per amp as a factor of the tier voltage"); + TESLA_SINGLE_LOSS_PER_BLOCK = _mainConfig.getInt( + "TeslaSingleLossPerBlock", + "tesla_tweaks", + TESLA_SINGLE_LOSS_PER_BLOCK, + 0, + Integer.MAX_VALUE, + "Tesla Transceiver power transmission loss per block per amp"); + TESLA_SINGLE_RANGE = _mainConfig.getInt( + "TeslaSingleRange", + "tesla_tweaks", + TESLA_SINGLE_RANGE, + 0, + Integer.MAX_VALUE, + "Tesla Transceiver to max range"); + TESLA_VISUAL_EFFECT = _mainConfig.getBoolean( + "EnableTeslaVisualEffect", + "tesla_tweaks", + TESLA_VISUAL_EFFECT, + "Set true to enable the cool visual effect when tesla tower running."); + } + + /** + * This loading phases do not correspond to mod loading phases! + */ + @Override + protected void PostInit() {} +} diff --git a/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java new file mode 100644 index 0000000000..56a125b8f4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java @@ -0,0 +1,37 @@ +package com.github.technus.tectech.loader.gui; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import com.github.technus.tectech.thing.CustomItemList; +import com.github.technus.tectech.thing.casing.TT_Container_Casings; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; + +public class CreativeTabTecTech extends CreativeTabs { + + public CreativeTabTecTech(String name) { + super(name); + } + + @SideOnly(Side.CLIENT) + @Override + public Item getTabIconItem() { + return Item.getItemFromBlock(TT_Container_Casings.sBlockCasingsTT); // High power casing + } + + @Override + public void displayAllReleventItems(List stuffToShow) { + for (CustomItemList item : CustomItemList.values()) { + if (item.hasBeenSet() && item.getBlock() == GregTech_API.sBlockMachines) { + stuffToShow.add(item.get(1)); + } + } + super.displayAllReleventItems(stuffToShow); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/Assembler.java b/src/main/java/com/github/technus/tectech/loader/recipe/Assembler.java new file mode 100644 index 0000000000..7467343599 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/Assembler.java @@ -0,0 +1,3029 @@ +package com.github.technus.tectech.loader.recipe; + +import static com.github.technus.tectech.loader.recipe.BaseRecipeLoader.getItemContainer; +import static com.github.technus.tectech.loader.recipe.BaseRecipeLoader.getOrDefault; +import static gregtech.api.enums.GT_Values.RA; +import static gregtech.api.enums.Mods.BartWorks; +import static gregtech.api.util.GT_ModHandler.getModItem; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.thing.CustomItemList; +import com.github.technus.tectech.thing.block.QuantumGlassBlock; +import com.gtnewhorizon.structurelib.StructureLibAPI; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public class Assembler implements Runnable { + + @Override + public void run() { + + cleanroomRecipes(); + + for (int i = 0; i <= 15; i++) { + RA.addAssemblerRecipe( + new ItemStack[] { GT_Utility.getIntegratedCircuit(i + 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cobalt, 1) }, + Materials.Aluminium.getMolten(864), + new ItemStack(StructureLibAPI.getBlockHint(), 1, i), + 32, + 120); + } + + // Quantum Glass + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.eM_Containment.get(1), GT_ModHandler.getIC2Item("reinforcedGlass", 1L) }, + getOrDefault("Trinium", Materials.Osmium).getMolten(576), + new ItemStack(QuantumGlassBlock.INSTANCE, 1), + 200, + 500000); + + // recipe for assline data hatches + RA.addAssemblerRecipe( + ItemList.Hatch_DataAccess_EV.get(1), + CustomItemList.dataIn_Hatch.get(1), + CustomItemList.dataInAss_Hatch.get(1), + 2048, + 12000); + RA.addAssemblerRecipe( + ItemList.Hatch_DataAccess_EV.get(1), + CustomItemList.dataOut_Hatch.get(1), + CustomItemList.dataOutAss_Hatch.get(1), + 2048, + 12000); + + // High Power Casing + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Iridium, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Iridium, 6), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 1), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 16), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Copper, 16), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NiobiumTitanium, 2) }, + Materials.TungstenSteel.getMolten(576), + CustomItemList.eM_Power.get(1), + 100, + 30720); + + // Computer Casing + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.eM_Power.get(1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 8), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NiobiumTitanium, 2) }, + Materials.Aluminium.getMolten(1296), + CustomItemList.eM_Computer_Casing.get(1), + 200, + 122880); + // Computer Vent Casing + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.StainlessSteel, 1), + ItemList.Electric_Motor_IV.get(2), + GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.StainlessSteel, 2), + GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.StainlessSteel, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Copper, 16), + GT_OreDictUnificator + .get(OrePrefixes.wireGt01, getOrDefault("SuperconductorIV", Materials.SuperconductorUHV), 1) }, + Materials.SolderingAlloy.getMolten(1296), + CustomItemList.eM_Computer_Vent.get(1), + 100, + 1920); + + // Molecular Casing + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.eM_Power.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Osmiridium, 6), + GT_OreDictUnificator.get(OrePrefixes.foil, getOrDefault("Trinium", Materials.Osmium), 12), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.TungstenSteel, 24), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.TungstenSteel, 24), + ItemList.Field_Generator_IV.get(1) }, + Materials.Osmium.getMolten(1296), + CustomItemList.eM_Containment.get(1), + 800, + 500000); + + // Tesla Base + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 6), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.NickelZincFerrite, 1) }, + null, + CustomItemList.tM_TeslaBase.get(1), + 50, + 16); + + // Tesla Toroid + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 6), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Aluminium, 1) }, + null, + CustomItemList.tM_TeslaToroid.get(1), + 50, + 16); + + // Tesla Secondary Windings + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.teslaComponent.getWithDamage(8, 0), + getItemContainer("MicaInsulatorFoil").get(12) }, + Materials.Silver.getMolten(144), + CustomItemList.tM_TeslaSecondary.get(1), + 200, + 120); + + // Tesla Primary Coils T0 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.RedstoneAlloy, 8), + getItemContainer("MicaInsulatorFoil").get(8) }, + Materials.RedAlloy.getMolten(144), + CustomItemList.tM_TeslaPrimary_0.get(1), + 200, + 30); + + // Tesla Primary Coils T1 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorMV, 8), + getItemContainer("MicaInsulatorFoil").get(12) }, + Materials.Magnesium.getMolten(144), + CustomItemList.tM_TeslaPrimary_1.get(1), + 200, + 120); + + // Tesla Primary Coils T2 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorHV, 8), + getItemContainer("MicaInsulatorFoil").get(16) }, + Materials.Barium.getMolten(144), + CustomItemList.tM_TeslaPrimary_2.get(1), + 200, + 480); + + // Tesla Primary Coils T3 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorEV, 8), + getItemContainer("MicaInsulatorFoil").get(20) }, + Materials.Platinum.getMolten(144), + CustomItemList.tM_TeslaPrimary_3.get(1), + 200, + 1920); + + // Tesla Primary Coils T4 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorIV, 8), + getItemContainer("MicaInsulatorFoil").get(24) }, + Materials.Vanadium.getMolten(144), + CustomItemList.tM_TeslaPrimary_4.get(1), + 200, + 7680); + + // Tesla Primary Coils T5 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorLuV, 8), + getItemContainer("MicaInsulatorFoil").get(28) }, + Materials.Indium.getMolten(144), + CustomItemList.tM_TeslaPrimary_5.get(1), + 200, + 30720); + + // Tesla Primary Coils T6 + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorZPM, 8), + getItemContainer("MicaInsulatorFoil").get(32) }, + Materials.Naquadah.getMolten(144), + CustomItemList.tM_TeslaPrimary_6.get(1), + 200, + 122880); + + // Dynamo Hatches + { + // Dynamo Hatches 4A + { + // Dynamo EV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Dynamo_EV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Aluminium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 2) }, + Materials.Silver.getMolten(144), + CustomItemList.eM_dynamoMulti4_EV.get(1), + 100, + 480); + + // Dynamo IV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Dynamo_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Tungsten, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 2) }, + Materials.Silver.getMolten(144), + CustomItemList.eM_dynamoMulti4_IV.get(1), + 100, + 1920); + + // Dynamo LuV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Dynamo_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome), 2) }, + Materials.Silver.getMolten(288), + CustomItemList.eM_dynamoMulti4_LuV.get(1), + 100, + 7680); + + // Dynamo ZPM 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Dynamo_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 2) }, + Materials.Silver.getMolten(576), + CustomItemList.eM_dynamoMulti4_ZPM.get(1), + 100, + 30720); + + // Dynamo UV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Dynamo_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2) }, + Materials.Silver.getMolten(1152), + CustomItemList.eM_dynamoMulti4_UV.get(1), + 100, + 122880); + + // Dynamo UHV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Dynamo_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUHV, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2) }, + Materials.Silver.getMolten(2304), + CustomItemList.eM_dynamoMulti4_UHV.get(1), + 100, + 500000); + + // Dynamo UEV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Dynamo_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Bedrockium", Materials.Neutronium), 2) }, + Materials.Silver.getMolten(4608), + CustomItemList.eM_dynamoMulti4_UEV.get(1), + 100, + 2000000); + + // Dynamo UIV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Dynamo_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Neutronium), 2) }, + Materials.Silver.getMolten(9216), + CustomItemList.eM_dynamoMulti4_UIV.get(1), + 100, + 8000000); + + // Dynamo UMV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Dynamo_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Quantium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 2) }, + Materials.Silver.getMolten(9216), + CustomItemList.eM_dynamoMulti4_UMV.get(1), + 100, + 32000000); + + // Dynamo UXV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Dynamo_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.BlackPlutonium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 1), + GT_OreDictUnificator.get("plateShirabon", 1L) }, + Materials.Silver.getMolten(9216), + CustomItemList.eM_dynamoMulti4_UXV.get(1), + 100, + (int) TierEU.RECIPE_UMV); + } + + // Dynamo Hatches 16A + { + // Dynamo EV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_IV_EV.get(1), CustomItemList.eM_dynamoMulti4_EV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Aluminium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 4) }, + Materials.Electrum.getMolten(144), + CustomItemList.eM_dynamoMulti16_EV.get(1), + 200, + 480); + + // Dynamo IV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_LuV_IV.get(1), CustomItemList.eM_dynamoMulti4_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Tungsten, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 4) }, + Materials.Electrum.getMolten(144), + CustomItemList.eM_dynamoMulti16_IV.get(1), + 200, + 1920); + + // Dynamo LuV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_ZPM_LuV.get(1), CustomItemList.eM_dynamoMulti4_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome), 4) }, + Materials.Electrum.getMolten(288), + CustomItemList.eM_dynamoMulti16_LuV.get(1), + 200, + 7680); + + // Dynamo ZPM 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_UV_ZPM.get(1), CustomItemList.eM_dynamoMulti4_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 4) }, + Materials.Electrum.getMolten(576), + CustomItemList.eM_dynamoMulti16_ZPM.get(1), + 200, + 30720); + + // Dynamo UV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_MAX_UV.get(1), CustomItemList.eM_dynamoMulti4_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4) }, + Materials.Electrum.getMolten(1152), + CustomItemList.eM_dynamoMulti16_UV.get(1), + 200, + 122880); + + // Dynamo UHV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UEV_UHV").get(1), + CustomItemList.eM_dynamoMulti4_UHV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.SuperconductorUHV, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4) }, + Materials.Electrum.getMolten(2304), + CustomItemList.eM_dynamoMulti16_UHV.get(1), + 200, + 500000); + + // Dynamo UEV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UIV_UEV").get(1), + CustomItemList.eM_dynamoMulti4_UEV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Bedrockium", Materials.Neutronium), 4) }, + Materials.Electrum.getMolten(4608), + CustomItemList.eM_dynamoMulti16_UEV.get(1), + 200, + 2000000); + + // Dynamo UIV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UMV_UIV").get(1), + CustomItemList.eM_dynamoMulti4_UIV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Neutronium), 4) }, + Materials.Electrum.getMolten(9216), + CustomItemList.eM_dynamoMulti16_UIV.get(1), + 200, + 8000000); + + // Dynamo UMV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UXV_UMV").get(1), + CustomItemList.eM_dynamoMulti4_UMV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Quantium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 4) }, + Materials.Electrum.getMolten(9216), + CustomItemList.eM_dynamoMulti16_UMV.get(1), + 200, + 32000000); + + // Dynamo UXV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_MAX_UXV").get(1), + CustomItemList.eM_dynamoMulti4_UXV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.BlackPlutonium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 2), + GT_OreDictUnificator.get("plateShirabon", 2L) }, + Materials.Electrum.getMolten(9216), + CustomItemList.eM_dynamoMulti16_UXV.get(1), + 200, + (int) TierEU.RECIPE_UMV); + } + + // Dynamo Hatches 64A + { + // Dynamo EV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_IV_EV").get(1), + CustomItemList.eM_dynamoMulti16_EV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Aluminium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 6) }, + Materials.Tungsten.getMolten(144), + CustomItemList.eM_dynamoMulti64_EV.get(1), + 400, + 480); + + // Dynamo IV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_LuV_IV").get(1), + CustomItemList.eM_dynamoMulti16_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Tungsten, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 6) }, + Materials.Tungsten.getMolten(144), + CustomItemList.eM_dynamoMulti64_IV.get(1), + 400, + 1920); + + // Dynamo LuV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_ZPM_LuV").get(1), + CustomItemList.eM_dynamoMulti16_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.VanadiumGallium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome), 6) }, + Materials.Tungsten.getMolten(288), + CustomItemList.eM_dynamoMulti64_LuV.get(1), + 400, + 7680); + + // Dynamo ZPM 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UV_ZPM").get(1), + CustomItemList.eM_dynamoMulti16_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Naquadah, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 6) }, + Materials.Tungsten.getMolten(576), + CustomItemList.eM_dynamoMulti64_ZPM.get(1), + 400, + 30720); + + // Dynamo UV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UHV_UV").get(1), + CustomItemList.eM_dynamoMulti16_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6) }, + Materials.Tungsten.getMolten(1152), + CustomItemList.eM_dynamoMulti64_UV.get(1), + 400, + 122880); + + // Dynamo UHV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UEV_UHV").get(1), + CustomItemList.eM_dynamoMulti16_UHV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.SuperconductorUHV, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6) }, + Materials.Tungsten.getMolten(2304), + CustomItemList.eM_dynamoMulti64_UHV.get(1), + 400, + 2000000); + + // Dynamo UEV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UIV_UEV").get(1), + CustomItemList.eM_dynamoMulti16_UEV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Draconium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Bedrockium", Materials.Neutronium), 6) }, + Materials.Tungsten.getMolten(4608), + CustomItemList.eM_dynamoMulti64_UEV.get(1), + 400, + 2000000); + + // Dynamo UIV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UMV_UIV").get(1), + CustomItemList.eM_dynamoMulti16_UIV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NetherStar, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Neutronium), 6) }, + Materials.Tungsten.getMolten(9216), + CustomItemList.eM_dynamoMulti64_UIV.get(1), + 400, + 8000000); + + // Dynamo UMV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UXV_UMV").get(1), + CustomItemList.eM_dynamoMulti16_UMV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Quantium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 6) }, + Materials.Tungsten.getMolten(9216), + CustomItemList.eM_dynamoMulti64_UMV.get(1), + 400, + 32000000); + + // Dynamo UXV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_MAX_UXV").get(1), + CustomItemList.eM_dynamoMulti16_UXV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.BlackPlutonium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 3), + GT_OreDictUnificator.get("plateShirabon", 3L) }, + Materials.Tungsten.getMolten(9216), + CustomItemList.eM_dynamoMulti64_UXV.get(1), + 400, + (int) TierEU.RECIPE_UMV); + } + } + + // Energy Hatches + { + // Energy Hatches 4A + { + // Energy Hatch EV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Energy_EV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Aluminium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 2) }, + Materials.Silver.getMolten(144), + CustomItemList.eM_energyMulti4_EV.get(1), + 100, + 480); + + // Energy Hatch IV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Energy_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Tungsten, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 2) }, + Materials.Silver.getMolten(144), + CustomItemList.eM_energyMulti4_IV.get(1), + 100, + 1920); + + // Energy Hatch LuV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Energy_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome), 2) }, + Materials.Silver.getMolten(288), + CustomItemList.eM_energyMulti4_LuV.get(1), + 100, + 7680); + + // Energy Hatch ZPM 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Energy_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 2) }, + Materials.Silver.getMolten(576), + CustomItemList.eM_energyMulti4_ZPM.get(1), + 100, + 30720); + + // Energy Hatch UV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Energy_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2) }, + Materials.Silver.getMolten(1152), + CustomItemList.eM_energyMulti4_UV.get(1), + 100, + 122880); + + // Energy Hatch UHV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Energy_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUHV, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2) }, + Materials.Silver.getMolten(2304), + CustomItemList.eM_energyMulti4_UHV.get(1), + 100, + 500000); + + // Energy Hatch UEV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Energy_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Bedrockium", Materials.Neutronium), 2) }, + Materials.Silver.getMolten(4608), + CustomItemList.eM_energyMulti4_UEV.get(1), + 100, + 2000000); + + // Energy Hatch UIV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Energy_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Neutronium), 2) }, + Materials.Silver.getMolten(9216), + CustomItemList.eM_energyMulti4_UIV.get(1), + 100, + 8000000); + + // Energy Hatch UMV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Energy_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Quantium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 2) }, + Materials.Silver.getMolten(9216), + CustomItemList.eM_energyMulti4_UMV.get(1), + 100, + 32000000); + + // Energy Hatch UXV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hatch_Energy_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.BlackPlutonium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 1), + GT_OreDictUnificator.get("plateShirabon", 1L) }, + Materials.Silver.getMolten(9216), + CustomItemList.eM_energyMulti4_UXV.get(1), + 100, + (int) TierEU.RECIPE_UMV); + } + + // Energy Hatches 16A + { + // Energy Hatch EV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_IV_EV.get(1), CustomItemList.eM_energyMulti4_EV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Aluminium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 4) }, + Materials.Electrum.getMolten(144), + CustomItemList.eM_energyMulti16_EV.get(1), + 200, + 480); + + // Energy Hatch IV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_LuV_IV.get(1), CustomItemList.eM_energyMulti4_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Tungsten, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 4) }, + Materials.Electrum.getMolten(144), + CustomItemList.eM_energyMulti16_IV.get(1), + 200, + 1920); + + // Energy Hatch LuV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_ZPM_LuV.get(1), CustomItemList.eM_energyMulti4_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome), 4) }, + Materials.Electrum.getMolten(288), + CustomItemList.eM_energyMulti16_LuV.get(1), + 200, + 7680); + + // Energy Hatch ZPM 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_UV_ZPM.get(1), CustomItemList.eM_energyMulti4_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 4) }, + Materials.Electrum.getMolten(576), + CustomItemList.eM_energyMulti16_ZPM.get(1), + 200, + 30720); + + // Energy Hatch UV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_MAX_UV.get(1), CustomItemList.eM_energyMulti4_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4) }, + Materials.Electrum.getMolten(1152), + CustomItemList.eM_energyMulti16_UV.get(1), + 200, + 122880); + + // Energy Hatch UHV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UEV_UHV").get(1), + CustomItemList.eM_energyMulti4_UHV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.SuperconductorUHV, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4) }, + Materials.Electrum.getMolten(2304), + CustomItemList.eM_energyMulti16_UHV.get(1), + 200, + 500000); + + // Energy Hatch UEV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UIV_UEV").get(1), + CustomItemList.eM_energyMulti4_UEV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Bedrockium", Materials.Neutronium), 4) }, + Materials.Electrum.getMolten(4608), + CustomItemList.eM_energyMulti16_UEV.get(1), + 200, + 2000000); + + // Energy Hatch UIV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UMV_UIV").get(1), + CustomItemList.eM_energyMulti4_UIV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Neutronium), 4) }, + Materials.Electrum.getMolten(9216), + CustomItemList.eM_energyMulti16_UIV.get(1), + 200, + 8000000); + + // Energy Hatch UMV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UXV_UMV").get(1), + CustomItemList.eM_energyMulti4_UMV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Quantium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 4) }, + Materials.Electrum.getMolten(9216), + CustomItemList.eM_energyMulti16_UMV.get(1), + 200, + 32000000); + + // Energy Hatch UXV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_MAX_UXV").get(1), + CustomItemList.eM_energyMulti4_UXV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.BlackPlutonium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 2), + GT_OreDictUnificator.get("plateShirabon", 2L) }, + Materials.Electrum.getMolten(9216), + CustomItemList.eM_energyMulti16_UXV.get(1), + 200, + (int) TierEU.RECIPE_UMV); + } + + // Energy Hatches 64A + { + // Energy Hatch EV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_IV_EV").get(1), + CustomItemList.eM_energyMulti16_EV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Aluminium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 6) }, + Materials.Tungsten.getMolten(144), + CustomItemList.eM_energyMulti64_EV.get(1), + 400, + 480); + + // Energy Hatch IV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_LuV_IV").get(1), + CustomItemList.eM_energyMulti16_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Tungsten, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 6) }, + Materials.Tungsten.getMolten(144), + CustomItemList.eM_energyMulti64_IV.get(1), + 400, + 1920); + + // Energy Hatch LuV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_ZPM_LuV").get(1), + CustomItemList.eM_energyMulti16_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.VanadiumGallium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome), 6) }, + Materials.Tungsten.getMolten(288), + CustomItemList.eM_energyMulti64_LuV.get(1), + 400, + 7680); + + // Energy Hatch ZPM 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UV_ZPM").get(1), + CustomItemList.eM_energyMulti16_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Naquadah, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 6) }, + Materials.Tungsten.getMolten(576), + CustomItemList.eM_energyMulti64_ZPM.get(1), + 400, + 30720); + + // Energy Hatch UV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UHV_UV").get(1), + CustomItemList.eM_energyMulti16_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6) }, + Materials.Tungsten.getMolten(1152), + CustomItemList.eM_energyMulti64_UV.get(1), + 400, + 122880); + + // Energy Hatch UHV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UEV_UHV").get(1), + CustomItemList.eM_energyMulti16_UHV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.SuperconductorUHV, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6) }, + Materials.Tungsten.getMolten(2304), + CustomItemList.eM_energyMulti64_UHV.get(1), + 400, + 500000); + + // Energy Hatch UEV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UIV_UEV").get(1), + CustomItemList.eM_energyMulti16_UEV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Draconium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Bedrockium", Materials.Neutronium), 6) }, + Materials.Tungsten.getMolten(4608), + CustomItemList.eM_energyMulti64_UEV.get(1), + 400, + 2000000); + + // Energy Hatch UIV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UMV_UIV").get(1), + CustomItemList.eM_energyMulti16_UIV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NetherStar, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Neutronium), 6) }, + Materials.Tungsten.getMolten(9216), + CustomItemList.eM_energyMulti64_UIV.get(1), + 400, + 8000000); + + // Energy Hatch UMV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_UXV_UMV").get(1), + CustomItemList.eM_energyMulti16_UMV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Quantium, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 6) }, + Materials.Tungsten.getMolten(9216), + CustomItemList.eM_energyMulti64_UMV.get(1), + 400, + 32000000); + + // Energy Hatch UXV 64A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_MAX_UXV").get(1), + CustomItemList.eM_energyMulti16_UXV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.BlackPlutonium, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 3), + GT_OreDictUnificator.get("plateShirabon", 3L) }, + Materials.Tungsten.getMolten(9216), + CustomItemList.eM_energyMulti64_UXV.get(1), + 400, + (int) TierEU.RECIPE_UMV); + + } + } + + // Buck Converter IV-UIV + if (BartWorks.isModLoaded()) { + // Buck Converter IV + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_LuV_IV.get(1), getItemContainer("Display").get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 2), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 4), + getModItem(BartWorks.ID, "BW_GlasBlocks", 2L, 2) }, + Materials.TungstenSteel.getMolten(288), + CustomItemList.Machine_BuckConverter_IV.get(1), + 100, + 7680); + + // Buck Converter LuV + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_ZPM_LuV.get(1), getItemContainer("Display").get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome), 2), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NiobiumTitanium, 4), + getModItem(BartWorks.ID, "BW_GlasBlocks", 2L, 3) }, + new FluidStack(FluidRegistry.getFluid("molten.rhodium-plated palladium"), 288), + CustomItemList.Machine_BuckConverter_LuV.get(1), + 100, + 30720); + + // Buck Converter ZPM + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_UV_ZPM.get(1), getItemContainer("Display").get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 2), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 4), + getModItem(BartWorks.ID, "BW_GlasBlocks", 2L, 4) }, + Materials.Iridium.getMolten(288), + CustomItemList.Machine_BuckConverter_ZPM.get(1), + 100, + 122880); + + // Buck Converter UV + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Transformer_MAX_UV.get(1), getItemContainer("Display").get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.SuperconductorUHV, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Naquadah, 4), + getModItem(BartWorks.ID, "BW_GlasBlocks", 2L, 5) }, + Materials.Osmium.getMolten(288), + CustomItemList.Machine_BuckConverter_UV.get(1), + 100, + 500000); + + // Buck Converter UHV + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UEV_UHV").get(1), getItemContainer("Display").get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Infinite, 2), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.ElectrumFlux, 4), + getModItem(BartWorks.ID, "BW_GlasBlocks", 4L, 5) }, + Materials.Neutronium.getMolten(288), + CustomItemList.Machine_BuckConverter_UHV.get(1), + 100, + 2000000); + + // Buck Converter UEV + GT_Values.RA + .addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UIV_UEV").get(1), + getItemContainer("Display").get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Bio, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("Bedrockium", Materials.Neutronium), 2), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Bedrockium, 4), + getModItem(BartWorks.ID, "BW_GlasBlocks", 8L, 5) }, + getOrDefault("Bedrockium", Materials.Neutronium).getMolten(288), + CustomItemList.Machine_BuckConverter_UEV.get(1), + 100, + 8000000); + + // Buck Converter UIV + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Transformer_UMV_UIV").get(1), getItemContainer("Display").get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Optical, 2), + GT_OreDictUnificator + .get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Neutronium), 2), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Draconium, 4), + getModItem(BartWorks.ID, "BW_GlasBlocks", 16L, 5) }, + getOrDefault("BlackPlutonium", Materials.Neutronium).getMolten(288), + CustomItemList.Machine_BuckConverter_UIV.get(1), + 200, + 8000000); + } + + // Laser Dynamo + { + // Laser Dynamo IV-UXV 256/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_IV.get(1), + ItemList.Electric_Pump_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.TungstenSteel, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_IV.get(1), + 1000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_LuV.get(1), + ItemList.Electric_Pump_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.VanadiumGallium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_LuV.get(1), + 1000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_ZPM.get(1), + ItemList.Electric_Pump_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Naquadah, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_ZPM.get(1), + 1000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UV.get(1), + ItemList.Electric_Pump_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NaquadahAlloy, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_UV.get(1), + 1000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UHV.get(1), + ItemList.Electric_Pump_UHV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Bedrockium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_UHV.get(1), + 1000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UEV.get(1), + ItemList.Electric_Pump_UEV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Draconium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_UEV.get(1), + 1000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UIV.get(1), + ItemList.Electric_Pump_UIV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NetherStar, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_UIV.get(1), + 1000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UMV.get(1), + ItemList.Electric_Pump_UMV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Quantium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_UMV.get(1), + 1000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UXV.get(1), + ItemList.Electric_Pump_UXV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.BlackPlutonium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_dynamoTunnel1_UXV.get(1), + 1000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Dynamo IV-UXV 1024/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_IV.get(2), + ItemList.Electric_Pump_IV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.TungstenSteel, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_IV.get(1), + 2000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_LuV.get(2), + ItemList.Electric_Pump_LuV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.VanadiumGallium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_LuV.get(1), + 2000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_ZPM.get(2), + ItemList.Electric_Pump_ZPM.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Naquadah, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_ZPM.get(1), + 2000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UV.get(2), + ItemList.Electric_Pump_UV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NaquadahAlloy, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_UV.get(1), + 2000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UHV.get(2), + ItemList.Electric_Pump_UHV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Bedrockium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_UHV.get(1), + 2000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UEV.get(2), + ItemList.Electric_Pump_UEV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Draconium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_UEV.get(1), + 2000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UIV.get(2), + ItemList.Electric_Pump_UIV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NetherStar, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_UIV.get(1), + 2000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UMV.get(2), + ItemList.Electric_Pump_UMV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Quantium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_UMV.get(1), + 2000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UXV.get(2), + ItemList.Electric_Pump_UXV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.BlackPlutonium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_dynamoTunnel2_UXV.get(1), + 2000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Dynamo IV-UXV 4096/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_IV.get(4), + ItemList.Electric_Pump_IV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_IV.get(1), + 4000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_LuV.get(4), + ItemList.Electric_Pump_LuV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_LuV.get(1), + 4000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_ZPM.get(4), + ItemList.Electric_Pump_ZPM.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_ZPM.get(1), + 4000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UV.get(4), + ItemList.Electric_Pump_UV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_UV.get(1), + 4000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UHV.get(4), + ItemList.Electric_Pump_UHV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_UHV.get(1), + 4000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UEV.get(4), + ItemList.Electric_Pump_UEV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_UEV.get(1), + 4000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UIV.get(4), + ItemList.Electric_Pump_UIV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_UIV.get(1), + 4000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UMV.get(4), + ItemList.Electric_Pump_UMV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Quantium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_UMV.get(1), + 4000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UXV.get(4), + ItemList.Electric_Pump_UXV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.BlackPlutonium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_dynamoTunnel3_UXV.get(1), + 4000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Dynamo IV-UXV 16384/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_IV.get(8), + ItemList.Electric_Pump_IV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_IV.get(1), + 8000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_LuV.get(8), + ItemList.Electric_Pump_LuV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_LuV.get(1), + 8000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_ZPM.get(8), + ItemList.Electric_Pump_ZPM.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_ZPM.get(1), + 8000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UV.get(8), + ItemList.Electric_Pump_UV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_UV.get(1), + 8000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UHV.get(8), + ItemList.Electric_Pump_UHV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_UHV.get(1), + 8000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UEV.get(8), + ItemList.Electric_Pump_UEV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_UEV.get(1), + 8000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UIV.get(8), + ItemList.Electric_Pump_UIV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_UIV.get(1), + 8000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UMV.get(8), + ItemList.Electric_Pump_UMV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Quantium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_UMV.get(1), + 8000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UXV.get(8), + ItemList.Electric_Pump_UXV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.BlackPlutonium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_dynamoTunnel4_UXV.get(1), + 8000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Dynamo IV-UXV 65536/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_IV.get(16), + ItemList.Electric_Pump_IV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_IV.get(1), + 16000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_LuV.get(16), + ItemList.Electric_Pump_LuV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_LuV.get(1), + 16000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_ZPM.get(16), + ItemList.Electric_Pump_ZPM.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_ZPM.get(1), + 16000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UV.get(16), + ItemList.Electric_Pump_UV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_UV.get(1), + 16000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UHV.get(16), + ItemList.Electric_Pump_UHV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_UHV.get(1), + 16000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UEV.get(16), + ItemList.Electric_Pump_UEV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_UEV.get(1), + 16000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UIV.get(16), + ItemList.Electric_Pump_UIV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_UIV.get(1), + 16000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UMV.get(16), + ItemList.Electric_Pump_UMV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Quantium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_UMV.get(1), + 16000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UXV.get(16), + ItemList.Electric_Pump_UXV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.BlackPlutonium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_dynamoTunnel5_UXV.get(1), + 16000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Dynamo IV-UXV 262144/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_IV.get(32), + ItemList.Electric_Pump_IV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_IV.get(1), + 32000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_LuV.get(32), + ItemList.Electric_Pump_LuV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_LuV.get(1), + 32000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_ZPM.get(32), + ItemList.Electric_Pump_ZPM.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_ZPM.get(1), + 32000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UV.get(32), + ItemList.Electric_Pump_UV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_UV.get(1), + 32000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UHV.get(32), + ItemList.Electric_Pump_UHV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_UHV.get(1), + 32000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UEV.get(32), + ItemList.Electric_Pump_UEV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_UEV.get(1), + 32000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UIV.get(32), + ItemList.Electric_Pump_UIV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_UIV.get(1), + 32000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UMV.get(32), + ItemList.Electric_Pump_UMV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Quantium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_UMV.get(1), + 32000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UXV.get(32), + ItemList.Electric_Pump_UXV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.BlackPlutonium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_dynamoTunnel6_UXV.get(1), + 32000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Dynamo IV-UXV 1048576/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_IV.get(64), + ItemList.Electric_Pump_IV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_IV.get(1), + 64000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_LuV.get(64), + ItemList.Electric_Pump_LuV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.VanadiumGallium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_LuV.get(1), + 64000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_ZPM.get(64), + ItemList.Electric_Pump_ZPM.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Naquadah, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_ZPM.get(1), + 64000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UV.get(64), + ItemList.Electric_Pump_UV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NaquadahAlloy, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_UV.get(1), + 64000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UHV.get(64), + ItemList.Electric_Pump_UHV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Bedrockium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_UHV.get(1), + 64000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UEV.get(64), + ItemList.Electric_Pump_UEV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Draconium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_UEV.get(1), + 64000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UIV.get(64), + ItemList.Electric_Pump_UIV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NetherStar, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_UIV.get(1), + 64000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UMV.get(64), + ItemList.Electric_Pump_UMV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Quantium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_UMV.get(1), + 64000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UXV.get(64), + ItemList.Electric_Pump_UXV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.BlackPlutonium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_dynamoTunnel7_UXV.get(1), + 64000, + (int) TierEU.RECIPE_UXV); + } + } + + // Laser Target + { + // Laser Target IV-UXV 256/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_IV.get(1), + ItemList.Electric_Pump_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.TungstenSteel, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_IV.get(1), + 1000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_LuV.get(1), + ItemList.Electric_Pump_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.VanadiumGallium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_LuV.get(1), + 1000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_ZPM.get(1), + ItemList.Electric_Pump_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Naquadah, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_ZPM.get(1), + 1000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UV.get(1), + ItemList.Electric_Pump_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NaquadahAlloy, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_UV.get(1), + 1000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UHV.get(1), + ItemList.Electric_Pump_UHV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Bedrockium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_UHV.get(1), + 1000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UEV.get(1), + ItemList.Electric_Pump_UEV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Draconium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_UEV.get(1), + 1000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UIV.get(1), + ItemList.Electric_Pump_UIV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NetherStar, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_UIV.get(1), + 1000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UMV.get(1), + ItemList.Electric_Pump_UMV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Quantium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_UMV.get(1), + 1000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UXV.get(1), + ItemList.Electric_Pump_UXV.get(1), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.BlackPlutonium, 2), + GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.eM_energyTunnel1_UXV.get(1), + 1000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Target IV-UXV 1024/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_IV.get(2), + ItemList.Electric_Pump_IV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.TungstenSteel, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_IV.get(1), + 2000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_LuV.get(2), + ItemList.Electric_Pump_LuV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.VanadiumGallium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_LuV.get(1), + 2000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_ZPM.get(2), + ItemList.Electric_Pump_ZPM.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Naquadah, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_ZPM.get(1), + 2000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UV.get(2), + ItemList.Electric_Pump_UV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NaquadahAlloy, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_UV.get(1), + 2000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UHV.get(2), + ItemList.Electric_Pump_UHV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Bedrockium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_UHV.get(1), + 2000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UEV.get(2), + ItemList.Electric_Pump_UEV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Draconium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_UEV.get(1), + 2000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UIV.get(2), + ItemList.Electric_Pump_UIV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NetherStar, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_UIV.get(1), + 2000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UMV.get(2), + ItemList.Electric_Pump_UMV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Quantium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_UMV.get(1), + 2000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UXV.get(2), + ItemList.Electric_Pump_UXV.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.BlackPlutonium, 4), + GT_Utility.getIntegratedCircuit(2) }, + null, + CustomItemList.eM_energyTunnel2_UXV.get(1), + 2000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Target IV-UXV 4096/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_IV.get(4), + ItemList.Electric_Pump_IV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_IV.get(1), + 4000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_LuV.get(4), + ItemList.Electric_Pump_LuV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_LuV.get(1), + 4000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_ZPM.get(4), + ItemList.Electric_Pump_ZPM.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_ZPM.get(1), + 4000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UV.get(4), + ItemList.Electric_Pump_UV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_UV.get(1), + 4000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UHV.get(4), + ItemList.Electric_Pump_UHV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_UHV.get(1), + 4000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UEV.get(4), + ItemList.Electric_Pump_UEV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_UEV.get(1), + 4000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UIV.get(4), + ItemList.Electric_Pump_UIV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_UIV.get(1), + 4000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UMV.get(4), + ItemList.Electric_Pump_UMV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Quantium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_UMV.get(1), + 4000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UXV.get(4), + ItemList.Electric_Pump_UXV.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.BlackPlutonium, 4), + GT_Utility.getIntegratedCircuit(3) }, + null, + CustomItemList.eM_energyTunnel3_UXV.get(1), + 4000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Target IV-UXV 16384/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_IV.get(8), + ItemList.Electric_Pump_IV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_IV.get(1), + 8000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_LuV.get(8), + ItemList.Electric_Pump_LuV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_LuV.get(1), + 8000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_ZPM.get(8), + ItemList.Electric_Pump_ZPM.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_ZPM.get(1), + 8000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UV.get(8), + ItemList.Electric_Pump_UV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_UV.get(1), + 8000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UHV.get(8), + ItemList.Electric_Pump_UHV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_UHV.get(1), + 8000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UEV.get(8), + ItemList.Electric_Pump_UEV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_UEV.get(1), + 8000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UIV.get(8), + ItemList.Electric_Pump_UIV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_UIV.get(1), + 8000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UMV.get(8), + ItemList.Electric_Pump_UMV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Quantium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_UMV.get(1), + 8000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UXV.get(8), + ItemList.Electric_Pump_UXV.get(8), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.BlackPlutonium, 8), + GT_Utility.getIntegratedCircuit(4) }, + null, + CustomItemList.eM_energyTunnel4_UXV.get(1), + 8000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Target IV-UXV 65536/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_IV.get(16), + ItemList.Electric_Pump_IV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_IV.get(1), + 16000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_LuV.get(16), + ItemList.Electric_Pump_LuV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_LuV.get(1), + 16000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_ZPM.get(16), + ItemList.Electric_Pump_ZPM.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_ZPM.get(1), + 16000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UV.get(16), + ItemList.Electric_Pump_UV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_UV.get(1), + 16000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UHV.get(16), + ItemList.Electric_Pump_UHV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_UHV.get(1), + 16000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UEV.get(16), + ItemList.Electric_Pump_UEV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_UEV.get(1), + 16000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UIV.get(16), + ItemList.Electric_Pump_UIV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_UIV.get(1), + 16000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UMV.get(16), + ItemList.Electric_Pump_UMV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Quantium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_UMV.get(1), + 16000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UXV.get(16), + ItemList.Electric_Pump_UXV.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.BlackPlutonium, 8), + GT_Utility.getIntegratedCircuit(5) }, + null, + CustomItemList.eM_energyTunnel5_UXV.get(1), + 16000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Target IV-UXV 262144/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_IV.get(32), + ItemList.Electric_Pump_IV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_IV.get(1), + 32000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_LuV.get(32), + ItemList.Electric_Pump_LuV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_LuV.get(1), + 32000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_ZPM.get(32), + ItemList.Electric_Pump_ZPM.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_ZPM.get(1), + 32000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UV.get(32), + ItemList.Electric_Pump_UV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_UV.get(1), + 32000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UHV.get(32), + ItemList.Electric_Pump_UHV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_UHV.get(1), + 32000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UEV.get(32), + ItemList.Electric_Pump_UEV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_UEV.get(1), + 32000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UIV.get(32), + ItemList.Electric_Pump_UIV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_UIV.get(1), + 32000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UMV.get(32), + ItemList.Electric_Pump_UMV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Quantium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_UMV.get(1), + 32000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UXV.get(32), + ItemList.Electric_Pump_UXV.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.BlackPlutonium, 16), + GT_Utility.getIntegratedCircuit(6) }, + null, + CustomItemList.eM_energyTunnel6_UXV.get(1), + 32000, + (int) TierEU.RECIPE_UXV); + } + + // Laser Target IV-UXV 1048576/t + { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_IV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_IV.get(64), + ItemList.Electric_Pump_IV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_IV.get(1), + 64000, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_LuV.get(64), + ItemList.Electric_Pump_LuV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.VanadiumGallium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_LuV.get(1), + 64000, + 30720); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_ZPM.get(64), + ItemList.Electric_Pump_ZPM.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Naquadah, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_ZPM.get(1), + 64000, + 122880); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_UV.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UV.get(64), + ItemList.Electric_Pump_UV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NaquadahAlloy, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_UV.get(1), + 64000, + 500000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hull_MAX.get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UHV.get(64), + ItemList.Electric_Pump_UHV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Bedrockium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_UHV.get(1), + 64000, + 2000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UEV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UEV.get(64), + ItemList.Electric_Pump_UEV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Draconium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_UEV.get(1), + 64000, + 8000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UIV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UIV.get(64), + ItemList.Electric_Pump_UIV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NetherStar, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_UIV.get(1), + 64000, + 32000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UMV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UMV.get(64), + ItemList.Electric_Pump_UMV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Quantium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_UMV.get(1), + 64000, + 128000000); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("Hull_UXV").get(1), + GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UXV.get(64), + ItemList.Electric_Pump_UXV.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.BlackPlutonium, 16), + GT_Utility.getIntegratedCircuit(7) }, + null, + CustomItemList.eM_energyTunnel7_UXV.get(1), + 64000, + (int) TierEU.RECIPE_UXV); + } + } + + // Tesla Capacitor + { + // LV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Tin, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 4), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 8), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 8), }, + Materials.Epoxid.getMolten(72), + CustomItemList.teslaCapacitor.getWithDamage(1, 0), + 320, + 30); + // MV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Copper, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 6), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 12), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 12), }, + Materials.Epoxid.getMolten(144), + CustomItemList.teslaCapacitor.getWithDamage(1, 1), + 320, + 120); + // HV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Gold, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 8), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 16), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 16), }, + Materials.Epoxid.getMolten(216), + CustomItemList.teslaCapacitor.getWithDamage(1, 2), + 320, + 480); + // EV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Aluminium, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 10), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 20), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 20), }, + Materials.Epoxid.getMolten(288), + CustomItemList.teslaCapacitor.getWithDamage(1, 3), + 320, + 1920); + // IV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Tungsten, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 12), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 24), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 24), }, + Materials.Epoxid.getMolten(360), + CustomItemList.teslaCapacitor.getWithDamage(1, 4), + 320, + 7680); + // LuV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.HSSG, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 14), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 28), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 28), }, + Materials.Epoxid.getMolten(432), + CustomItemList.teslaCapacitor.getWithDamage(1, 5), + 320, + 30720); + // ZPM Tesla Capacitor + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Naquadah, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 16), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 32), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 32), }, + Materials.Epoxid.getMolten(504), + CustomItemList.teslaCapacitor.getWithDamage(1, 6), + 320, + 122880); + } + + // Tesla Cover + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.teslaComponent.getWithDamage(4, 0), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Gold, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 2), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 8), }, + Materials.Lead.getMolten(288), + CustomItemList.teslaCover.getWithDamage(1, 0), + 320, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.teslaComponent.getWithDamage(4, 0), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Gold, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 2), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 8), }, + Materials.Tin.getMolten(144), + CustomItemList.teslaCover.getWithDamage(1, 0), + 320, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.teslaComponent.getWithDamage(4, 0), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Gold, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 2), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 8), }, + Materials.SolderingAlloy.getMolten(72), + CustomItemList.teslaCover.getWithDamage(1, 0), + 320, + 480); + // Ultimate Tesla Cover + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.teslaComponent.getWithDamage(4, 1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tungsten, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 2), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 8), }, + Materials.Lead.getMolten(288), + CustomItemList.teslaCover.getWithDamage(1, 1), + 320, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.teslaComponent.getWithDamage(4, 1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tungsten, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 2), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 8), }, + Materials.Tin.getMolten(144), + CustomItemList.teslaCover.getWithDamage(1, 1), + 320, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.teslaComponent.getWithDamage(4, 1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tungsten, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 2), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 8), }, + Materials.SolderingAlloy.getMolten(72), + CustomItemList.teslaCover.getWithDamage(1, 1), + 320, + 7680); + + // Ender Fluid Link Cover + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Enderium, 4), + ItemList.Sensor_LuV.get(1), ItemList.Emitter_LuV.get(1), ItemList.Electric_Pump_LuV.get(1), }, + getOrDefault("Rhodium-PlatedPalladium", Materials.Chrome).getMolten(288), + CustomItemList.enderLinkFluidCover.getWithDamage(1, 0), + 320, + 30720); + + // Power Pass Upgrade Cover + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.Machine_Multi_Transformer.get(1), GT_Utility.getIntegratedCircuit(1) }, + null, + CustomItemList.powerPassUpgradeCover.getWithDamage(1, 0), + 320, + 30720); + + // Tesla Winding Components + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Electrum, 32), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.NickelZincFerrite, 8), }, + Materials.Epoxid.getMolten(288), + CustomItemList.teslaComponent.getWithDamage(1, 0), + 320, + 30); + + // Tesla Winding Components Ultimate (ADD BLOOD VARIANT) + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorLuV, 4), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.NickelZincFerrite, 8), }, + Materials.Epoxid.getMolten(576), + CustomItemList.teslaComponent.getWithDamage(1, 1), + 320, + 7680); + + // Tesla Transceiver LV 1A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_1by1_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_1by1_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_1by1_LV.get(1), + 400, + 30); + // Tesla Transceiver MV 1A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_1by1_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_1by1_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_1by1_MV.get(1), + 400, + 120); + // Tesla Transceiver HV 1A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_1by1_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_1by1_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_1by1_HV.get(1), + 400, + 480); + // Tesla Transceiver EV 1A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_1by1_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_1by1_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_1by1_EV.get(1), + 400, + 1920); + // Tesla Transceiver IV 1A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_1by1_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_1by1_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_1by1_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_1by1_IV.get(1), + 400, + 7680); + // Tesla Transceiver LV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_2by2_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_2by2_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_2by2_LV.get(1), + 400, + 30); + // Tesla Transceiver MV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_2by2_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_2by2_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_2by2_MV.get(1), + 400, + 120); + // Tesla Transceiver HV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_2by2_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_2by2_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_2by2_HV.get(1), + 400, + 480); + // Tesla Transceiver EV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_2by2_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_2by2_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_2by2_EV.get(1), + 400, + 1920); + // Tesla Transceiver IV 4A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_2by2_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_2by2_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_2by2_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_2by2_IV.get(1), + 400, + 7680); + // Tesla Transceiver LV 9A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_3by3_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_3by3_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_3by3_LV.get(1), + 400, + 30); + // Tesla Transceiver MV 9A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_3by3_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_3by3_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_3by3_MV.get(1), + 400, + 120); + // Tesla Transceiver HV 9A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_3by3_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_3by3_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_3by3_HV.get(1), + 400, + 480); + // Tesla Transceiver EV 9A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_3by3_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_3by3_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_3by3_EV.get(1), + 400, + 1920); + // Tesla Transceiver IV 9A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_3by3_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_3by3_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_3by3_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_3by3_IV.get(1), + 400, + 7680); + // Tesla Transceiver LV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_4by4_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_4by4_LV.get(1), + 400, + 30); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_LV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_4by4_LV.get(1), + 400, + 30); + // Tesla Transceiver MV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_4by4_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_4by4_MV.get(1), + 400, + 120); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_MV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_4by4_MV.get(1), + 400, + 120); + // Tesla Transceiver HV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_4by4_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_4by4_HV.get(1), + 400, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_HV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_4by4_HV.get(1), + 400, + 480); + // Tesla Transceiver EV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_4by4_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_4by4_EV.get(1), + 400, + 1920); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_EV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_4by4_EV.get(1), + 400, + 1920); + // Tesla Transceiver IV 16A + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Lead.getMolten(576), + CustomItemList.Machine_TeslaCoil_4by4_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.Tin.getMolten(288), + CustomItemList.Machine_TeslaCoil_4by4_IV.get(1), + 400, + 7680); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Battery_Buffer_4by4_IV.get(1), CustomItemList.teslaCover.getWithDamage(1, 0) }, + Materials.SolderingAlloy.getMolten(144), + CustomItemList.Machine_TeslaCoil_4by4_IV.get(1), + 400, + 7680); + + // Tesla Tower + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { GT_ModHandler.getIC2Item("teslaCoil", 1), CustomItemList.tM_TeslaSecondary.get(4), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 4), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 4), + ItemList.Upgrade_Overclocker.get(4), }, + Materials.Silver.getMolten(576), + CustomItemList.Machine_Multi_TeslaCoil.get(1), + 800, + 480); + + // Microwave Grinder + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Machine_HV_Microwave.get(1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 4), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 4), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.AnnealedCopper, 16), + ItemList.Upgrade_Overclocker.get(4), }, + Materials.Copper.getMolten(576), + CustomItemList.Machine_Multi_Microwave.get(1), + 800, + 480); + + // Active Transformer + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { getItemContainer("WetTransformer_ZPM_LuV").get(1), + getItemContainer("HighEnergyFlowCircuit").get(1), + GT_OreDictUnificator + .get(OrePrefixes.wireGt01, getOrDefault("SuperconductorLuV", Materials.SuperconductorUHV), 16), + ItemList.valueOf("Circuit_Chip_UHPIC") + .get(2), }, + Materials.TungstenSteel.getMolten(576), + CustomItemList.Machine_Multi_Transformer.get(1), + 400, + 30720); + + // Network Switch + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { CustomItemList.Machine_Multi_Transformer.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 4), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 64), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Copper, 64), CustomItemList.DATApipe.get(4), }, + Materials.Iridium.getMolten(1296), + CustomItemList.Machine_Multi_Switch.get(1), + 800, + 122880); + + } + + public void cleanroomRecipes() { + // Data + addAssemblerRecipeWithCleanroom( + new ItemStack[] { ItemList.Circuit_Parts_GlassFiber.get(8), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silver, 8) }, + Materials.Polytetrafluoroethylene.getMolten(144), + CustomItemList.DATApipe.get(1), + 200, + 30720); + + // Data Casing + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.DATApipe.get(1), ItemList.Casing_LuV.get(1) }, + null, + CustomItemList.DATApipeBlock.get(1), + 20, + 30720); + + // Laser + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.DATApipe.get(1), GT_ModHandler.getIC2Item("reinforcedGlass", 1L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmiridium, 2) }, + null, + CustomItemList.LASERpipe.get(1), + 100, + 500000); + + // Laser Casing + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.LASERpipe.get(1), ItemList.Casing_LuV.get(1) }, + null, + CustomItemList.LASERpipeBlock.get(1), + 20, + 30720); + + // Advanced Computer Casing + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.eM_Computer_Casing.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 64), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Electrum, 64), + GT_OreDictUnificator + .get(OrePrefixes.wireGt02, getOrDefault("SuperconductorLuV", Materials.SuperconductorUHV), 4) }, + Materials.Iridium.getMolten(1296), + CustomItemList.eM_Computer_Bus.get(1), + 200, + 122880); + + // Data Input + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.eM_Computer_Casing.get(1), ItemList.Hatch_Input_Bus_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 1), CustomItemList.DATApipe.get(2) }, + Materials.Iridium.getMolten(1296), + CustomItemList.dataIn_Hatch.get(1), + 200, + 122880); + + // Data Output + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.eM_Computer_Casing.get(1), ItemList.Hatch_Output_Bus_LuV.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 1), CustomItemList.DATApipe.get(2) }, + Materials.Iridium.getMolten(1296), + CustomItemList.dataOut_Hatch.get(1), + 200, + 122880); + + // Rack + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.eM_Computer_Bus.get(1), ItemList.Hatch_Input_Bus_ZPM.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), CustomItemList.DATApipe.get(4) }, + Materials.Iridium.getMolten(1296), + CustomItemList.rack_Hatch.get(1), + 800, + 122880); + + // Uncertainty + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.eM_Computer_Casing.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), CustomItemList.DATApipe.get(16), + ItemList.Cover_Screen.get(1), new ItemStack(Blocks.stone_button, 16), + GT_Utility.getIntegratedCircuit(4), }, + Materials.Iridium.getMolten(2592), + CustomItemList.Uncertainty_Hatch.get(1), + 1200, + 122880); + + // Uncertainty X + addAssemblerRecipeWithCleanroom( + new ItemStack[] { CustomItemList.eM_Computer_Casing.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Bio, 1), CustomItemList.DATApipe.get(32), + ItemList.Cover_Screen.get(1), new ItemStack(Blocks.stone_button, 16), + GT_Utility.getIntegratedCircuit(5), }, + Materials.Iridium.getMolten(2592), + CustomItemList.UncertaintyX_Hatch.get(1), + 1200, + 122880); + + // Capacitor Hatch + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Input_Bus_HV.get(1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Gold, 4), }, + Materials.Silver.getMolten(576), + CustomItemList.capacitor_Hatch.get(1), + 800, + 480); + GT_Values.RA.addAssemblerRecipe( + new ItemStack[] { ItemList.Hatch_Output_Bus_HV.get(1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.NickelZincFerrite, 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Gold, 4), }, + Materials.Silver.getMolten(576), + CustomItemList.capacitor_Hatch.get(1), + 800, + 480); + + } + + private void addAssemblerRecipeWithCleanroom(ItemStack[] items, FluidStack fluid, ItemStack output, int time, + int eut) { + GT_Values.RA.addAssemblerRecipe(items, fluid, output, time, eut, true); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/AssemblyLine.java b/src/main/java/com/github/technus/tectech/loader/recipe/AssemblyLine.java new file mode 100644 index 0000000000..cd8ea21b51 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/AssemblyLine.java @@ -0,0 +1,128 @@ +package com.github.technus.tectech.loader.recipe; + +import static com.github.technus.tectech.loader.recipe.BaseRecipeLoader.getItemContainer; +import static com.github.technus.tectech.loader.recipe.BaseRecipeLoader.getOrDefault; +import static gregtech.api.enums.GT_Values.RA; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.thing.CustomItemList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +public class AssemblyLine implements Runnable { + + @Override + public void run() { + // Data Bank + RA.addAssemblylineRecipe( + ItemList.Hatch_DataAccess_EV.get(1), + 20000, + new Object[] { CustomItemList.Machine_Multi_Switch.get(1), + new Object[] { OrePrefixes.circuit.get(Materials.Master), 2 }, ItemList.Tool_DataOrb.get(1), + ItemList.Cover_Screen.get(1), }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), + Materials.Hydrogen.getGas(1000), }, + CustomItemList.Machine_Multi_DataBank.get(1), + 12000, + 14000); + + // Hollow Casing + GT_Values.RA.addAssemblylineRecipe( + CustomItemList.eM_Containment.get(1), + 7500, + new ItemStack[] { CustomItemList.eM_Containment.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Europium, 2), + GT_OreDictUnificator.get(OrePrefixes.plateQuadruple, Materials.Plutonium, 4), + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Lead, 8), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Uranium, 16), + GT_OreDictUnificator.get(OrePrefixes.screw, getOrDefault("Quantium", Materials.Europium), 16), }, + new FluidStack[] { getOrDefault("Trinium", Materials.Osmium).getMolten(1296), + Materials.Osmium.getMolten(1296), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), + Materials.Argon.getGas(1000), }, + CustomItemList.eM_Hollow.get(2), + 200, + 200000); + + // EM Coil + GT_Values.RA.addAssemblylineRecipe( + CustomItemList.eM_Hollow.get(1), + 7500, + new ItemStack[] { CustomItemList.eM_Hollow.get(1), ItemList.Casing_Fusion_Coil.get(2), + ItemList.Casing_Coil_NaquadahAlloy.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Europium, 64), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Europium, 64), }, + new FluidStack[] { Materials.Glass.getMolten(2304), Materials.Silicone.getMolten(1872), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), + getOrDefault("Trinium", Materials.Osmium).getMolten(1296), }, + CustomItemList.eM_Coil.get(4), + 800, + 200000); + + // Object Holder + GT_Values.RA.addAssemblylineRecipe( + ItemList.Hatch_Input_Bus_ZPM.get(1), + 10000, + new Object[] { ItemList.Hatch_Input_Bus_ZPM.get(1), CustomItemList.eM_Computer_Bus.get(1), + ItemList.Emitter_ZPM.get(8), ItemList.Robot_Arm_ZPM.get(1), ItemList.Electric_Motor_ZPM.get(2), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 1 }, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt02, Materials.Naquadah, 2) }, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Naquadah, 16) }, + CustomItemList.DATApipe.get(2), }, + new FluidStack[] { Materials.UUMatter.getFluid(500), Materials.Iridium.getMolten(1296), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 1000) }, + CustomItemList.holder_Hatch.get(1), + 1200, + 100000); + + // Quantum Computer + GT_Values.RA.addAssemblylineRecipe( + ItemList.Tool_DataOrb.get(1), + 20000, + new Object[] { CustomItemList.Machine_Multi_Switch.get(1), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 2 }, ItemList.Tool_DataOrb.get(1), + ItemList.Cover_Screen.get(1), + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUV, 8) }, + CustomItemList.DATApipe.get(8), }, + new FluidStack[] { Materials.UUMatter.getFluid(1000), Materials.Iridium.getMolten(1296), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), Materials.Hydrogen.getGas(1000), }, + CustomItemList.Machine_Multi_Computer.get(1), + 12000, + 100000); + + // Research Station + GT_Values.RA.addAssemblylineRecipe( + getItemContainer("ScannerZPM").get(1), + 80000, + new Object[] { CustomItemList.Machine_Multi_Switch.get(1), ItemList.Sensor_ZPM.get(8), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4 }, + ItemList.Field_Generator_ZPM.get(1), ItemList.Electric_Motor_ZPM.get(2), + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.cableGt02, Materials.Naquadah, 4) }, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Naquadah, 32) }, + CustomItemList.DATApipe.get(16), }, + new FluidStack[] { Materials.UUMatter.getFluid(1000), Materials.Iridium.getMolten(1296), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), Materials.Osmium.getMolten(1296), }, + CustomItemList.Machine_Multi_Research.get(1), + 12000, + 100000); + + // Multi Infuser + GT_Values.RA.addAssemblylineRecipe( + CustomItemList.Machine_Multi_Transformer.get(1), + 7500, + new ItemStack[] { CustomItemList.Machine_Multi_Transformer.get(1), CustomItemList.eM_Coil.get(8), + CustomItemList.eM_Power.get(8), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.NeodymiumMagnetic, 16), }, + new FluidStack[] { Materials.Electrum.getMolten(2592), Materials.Europium.getMolten(1872), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), }, + CustomItemList.Machine_Multi_Infuser.get(1), + 8000, + 200000); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java new file mode 100644 index 0000000000..3c75b38465 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java @@ -0,0 +1,49 @@ +package com.github.technus.tectech.loader.recipe; + +import static com.github.technus.tectech.TecTech.LOGGER; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; + +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.IItemContainer; + +/** + * Created by danie_000 on 16.11.2016. + */ +public class BaseRecipeLoader { + + @SuppressWarnings("rawtypes") + private static Class CUSTOM_ITEM_LIST; + + static { + try { + CUSTOM_ITEM_LIST = Class.forName("com.dreammaster.gthandler.CustomItemList"); + } catch (Exception e) { + LOGGER.error("NHCoreMod not present. Disabling all the recipes"); + } + } + + @SuppressWarnings("unchecked") + public static IItemContainer getItemContainer(String name) { + // must never be called before the try catch block is ran + return (IItemContainer) Enum.valueOf(CUSTOM_ITEM_LIST, name); + } + + public static Materials getOrDefault(String name, Materials def) { + Materials mat = Materials.get(name); + return mat == Materials._NULL || mat == null ? def : mat; + } + + public void run() { + // todo: Move those recipes in NHCore + if (NewHorizonsCoreMod.isModLoaded()) { + new Assembler().run(); + new AssemblyLine().run(); + new CircuitAssembler().run(); + new Crafting().run(); + new Extractor().run(); + new ResearchStationAssemblyLine().run(); + } else { + new Godforge().run(); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/CircuitAssembler.java b/src/main/java/com/github/technus/tectech/loader/recipe/CircuitAssembler.java new file mode 100644 index 0000000000..ff6f4694ce --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/CircuitAssembler.java @@ -0,0 +1,46 @@ +package com.github.technus.tectech.loader.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.thing.CustomItemList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +public class CircuitAssembler implements Runnable { + + @Override + public void run() { + Fluid solderUEV = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + + // Optical Processor + GT_Values.RA.addCircuitAssemblerRecipe( + new ItemStack[] { ItemList.Optically_Perfected_CPU.get(1L), ItemList.Optically_Compatible_Memory.get(2L), + ItemList.Circuit_Parts_CapacitorXSMD.get(16L), ItemList.Circuit_Parts_DiodeXSMD.get(16L), + CustomItemList.DATApipe.get(4L), + GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.EnrichedHolmium, 16) }, + new FluidStack(solderUEV, 288), + ItemList.Circuit_OpticalProcessor.get(1L), + 20 * 20, + 614400, + true); + + // Parametrizer Memory Card + GT_Values.RA.addCircuitAssemblerRecipe( + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Basic, 2), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Gold, 4), }, + Materials.Plastic.getMolten(72), + CustomItemList.parametrizerMemory.get(1), + 200, + 480, + true); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/Crafting.java b/src/main/java/com/github/technus/tectech/loader/recipe/Crafting.java new file mode 100644 index 0000000000..73afec47ff --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/Crafting.java @@ -0,0 +1,57 @@ +package com.github.technus.tectech.loader.recipe; + +import net.minecraft.item.ItemStack; + +import com.github.technus.tectech.thing.CustomItemList; +import com.github.technus.tectech.thing.item.EuMeterGT; +import com.gtnewhorizon.structurelib.StructureLibAPI; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; + +public class Crafting implements Runnable { + + @Override + public void run() { + + // Front Rotation Tool + GT_ModHandler.addCraftingRecipe( + GT_ModHandler.getModItem(StructureLibAPI.MOD_ID, "item.structurelib.frontRotationTool", 1L, 0), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "fPR", " RP", "S h", 'P', OrePrefixes.plate.get(Materials.Cobalt), 'R', + OrePrefixes.stick.get(Materials.Cobalt), 'S', OrePrefixes.stick.get(Materials.Wood), }); + + // GT EU reader + GT_ModHandler.addCraftingRecipe( + new ItemStack(EuMeterGT.INSTANCE, 1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "PGW", "SCW", "BRN", 'P', OrePrefixes.plateDouble.get(Materials.Steel), 'G', + OrePrefixes.plate.get(Materials.Glass), 'W', OrePrefixes.cableGt01.get(Materials.Copper), 'S', + OrePrefixes.stick.get(Materials.Brass), 'C', ItemList.Casing_Coil_Cupronickel.get(1), 'B', Dyes.dyeBlue, + 'R', Dyes.dyeRed, 'N', Dyes.dyeBlack, }); + + // Owner detector + GT_ModHandler.addCraftingRecipe( + CustomItemList.Machine_OwnerDetector.get(1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "PPP", "GEG", "PPP", 'P', OrePrefixes.plate.get(Materials.IronMagnetic), 'G', + OrePrefixes.plate.get(Materials.Glass), 'E', OrePrefixes.gem.get(Materials.EnderPearl) }); + + // Tesla Base + GT_ModHandler.addCraftingRecipe( + CustomItemList.tM_TeslaBase.get(1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "PhP", "PFP", "PwP", 'P', OrePrefixes.plate.get(Materials.NickelZincFerrite), 'F', + OrePrefixes.frameGt.get(Materials.NickelZincFerrite) }); + + // Tesla Toroid + GT_ModHandler.addCraftingRecipe( + CustomItemList.tM_TeslaToroid.get(1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "PhP", "PFP", "PwP", 'P', OrePrefixes.foil.get(Materials.Aluminium), 'F', + OrePrefixes.frameGt.get(Materials.Aluminium) }); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/Extractor.java b/src/main/java/com/github/technus/tectech/loader/recipe/Extractor.java new file mode 100644 index 0000000000..4ec2b55122 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/Extractor.java @@ -0,0 +1,57 @@ +package com.github.technus.tectech.loader.recipe; + +import com.github.technus.tectech.thing.CustomItemList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +public class Extractor implements Runnable { + + @Override + public void run() { + // LV Tesla Capacitor + GT_Values.RA.addExtractorRecipe( + CustomItemList.teslaCapacitor.getWithDamage(1, 0), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 4), + 300, + 2); + // MV Tesla Capacitor + GT_Values.RA.addExtractorRecipe( + CustomItemList.teslaCapacitor.getWithDamage(1, 1), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 6), + 300, + 2); + // HV Tesla Capacitor + GT_Values.RA.addExtractorRecipe( + CustomItemList.teslaCapacitor.getWithDamage(1, 2), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 8), + 300, + 2); + // EV Tesla Capacitor + GT_Values.RA.addExtractorRecipe( + CustomItemList.teslaCapacitor.getWithDamage(1, 3), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 10), + 300, + 2); + // IV Tesla Capacitor + GT_Values.RA.addExtractorRecipe( + CustomItemList.teslaCapacitor.getWithDamage(1, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 12), + 300, + 2); + // LuV Tesla Capacitor + GT_Values.RA.addExtractorRecipe( + CustomItemList.teslaCapacitor.getWithDamage(1, 5), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 14), + 300, + 2); + // ZPM Tesla Capacitor + GT_Values.RA.addExtractorRecipe( + CustomItemList.teslaCapacitor.getWithDamage(1, 6), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 16), + 300, + 2); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/Godforge.java b/src/main/java/com/github/technus/tectech/loader/recipe/Godforge.java new file mode 100644 index 0000000000..4df4e4f209 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/Godforge.java @@ -0,0 +1,563 @@ +package com.github.technus.tectech.loader.recipe; + +import static com.github.technus.tectech.util.GodforgeMath.getRandomIntInRange; +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.recipe.TT_recipeAdder; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.material.ELEMENT; + +public class Godforge implements Runnable { + + public static final ArrayList plasmaGTMaterialList = new ArrayList<>(); + public static final ArrayList plasmaGTWeightList = new ArrayList<>(); + public static final HashMap exoticModulePlasmaItemMap = new HashMap<>(); + public static final HashMap exoticModulePlasmaFluidMap = new HashMap<>(); + public static final HashMap exoticModuleMagmatterItemMap = new HashMap<>(); + public static final List quarkGluonFluidItemsForNEI = new ArrayList<>(); + public static final List quarkGluonItemsForNEI = new ArrayList<>(); + public static final List magmatterTimeFluidItemsForNEI = new ArrayList<>(); + public static final List magmatterSpaceFluidItemsForNEI = new ArrayList<>(); + public static final List magmatterItemsForNEI = new ArrayList<>(); + + @Override + public void run() { + + if (GTPlusPlus.isModLoaded()) { + // Solid to plasma recipes + { + // Fusion tier 1-3 + { + // Single step + ItemStack[] solids_t0_1step = { Materials.Aluminium.getDust(1), Materials.Iron.getDust(1), + Materials.Calcium.getDust(1), Materials.Sulfur.getDust(1), Materials.Zinc.getDust(1), + Materials.Niobium.getDust(1), Materials.Tin.getDust(1), Materials.Titanium.getDust(1), + Materials.Nickel.getDust(1), Materials.Silver.getDust(1), Materials.Americium.getDust(1), + Materials.Antimony.getDust(1), Materials.Ardite.getDust(1), Materials.Arsenic.getDust(1), + Materials.Barium.getDust(1), Materials.Beryllium.getDust(1), Materials.Caesium.getDust(1), + Materials.Cadmium.getDust(1), Materials.Carbon.getDust(1), Materials.Cerium.getDust(1), + Materials.Cobalt.getDust(1), Materials.Copper.getDust(1), Materials.Desh.getDust(1), + Materials.Dysprosium.getDust(1), Materials.Erbium.getDust(1), Materials.Europium.getDust(1), + Materials.Gadolinium.getDust(1), Materials.Gallium.getDust(1), Materials.Gold.getDust(1), + Materials.Holmium.getDust(1), Materials.Indium.getDust(1), Materials.Lanthanum.getDust(1), + Materials.Lithium.getDust(1), Materials.Lutetium.getDust(1), Materials.Magnesium.getDust(1), + Materials.Manganese.getDust(1), Materials.MeteoricIron.getDust(1), + Materials.Molybdenum.getDust(1), Materials.Neodymium.getDust(1), + Materials.Oriharukon.getDust(1), Materials.Palladium.getDust(1), + Materials.Phosphorus.getDust(1), Materials.Potassium.getDust(1), + Materials.Praseodymium.getDust(1), Materials.Promethium.getDust(1), + Materials.Rubidium.getDust(1), Materials.Samarium.getDust(1), Materials.Silicon.getDust(1), + Materials.Sodium.getDust(1), Materials.Strontium.getDust(1), Materials.Tantalum.getDust(1), + Materials.Tellurium.getDust(1), Materials.Terbium.getDust(1), Materials.Thulium.getDust(1), + Materials.Tungsten.getDust(1), Materials.Uranium.getDust(1), Materials.Uranium235.getDust(1), + Materials.Vanadium.getDust(1), Materials.Ytterbium.getDust(1), Materials.Yttrium.getDust(1), + ELEMENT.getInstance().ZIRCONIUM.getDust(1), ELEMENT.getInstance().THORIUM232.getDust(1), + ELEMENT.getInstance().GERMANIUM.getDust(1), ELEMENT.getInstance().THALLIUM.getDust(1), + ELEMENT.getInstance().RUTHENIUM.getDust(1), ELEMENT.getInstance().RHENIUM.getDust(1), + ELEMENT.getInstance().RHODIUM.getDust(1), ELEMENT.getInstance().IODINE.getDust(1), + ELEMENT.getInstance().HAFNIUM.getDust(1), ELEMENT.getInstance().CURIUM.getDust(1) }; + FluidStack[] solid_plasmas_t0_1step = { Materials.Aluminium.getPlasma(144), + Materials.Iron.getPlasma(144), Materials.Calcium.getPlasma(144), + Materials.Sulfur.getPlasma(144), Materials.Zinc.getPlasma(144), + Materials.Niobium.getPlasma(144), Materials.Tin.getPlasma(144), + Materials.Titanium.getPlasma(144), Materials.Nickel.getPlasma(144), + Materials.Silver.getPlasma(144), Materials.Americium.getPlasma(144), + Materials.Antimony.getPlasma(144), Materials.Ardite.getPlasma(144), + Materials.Arsenic.getPlasma(144), Materials.Barium.getPlasma(144), + Materials.Beryllium.getPlasma(144), Materials.Caesium.getPlasma(144), + Materials.Cadmium.getPlasma(144), Materials.Carbon.getPlasma(144), + Materials.Cerium.getPlasma(144), Materials.Cobalt.getPlasma(144), + Materials.Copper.getPlasma(144), Materials.Desh.getPlasma(144), + Materials.Dysprosium.getPlasma(144), Materials.Erbium.getPlasma(144), + Materials.Europium.getPlasma(144), Materials.Gadolinium.getPlasma(144), + Materials.Gallium.getPlasma(144), Materials.Gold.getPlasma(144), + Materials.Holmium.getPlasma(144), Materials.Indium.getPlasma(144), + Materials.Lanthanum.getPlasma(144), Materials.Lithium.getPlasma(144), + Materials.Lutetium.getPlasma(144), Materials.Magnesium.getPlasma(144), + Materials.Manganese.getPlasma(144), Materials.MeteoricIron.getPlasma(144), + Materials.Molybdenum.getPlasma(144), Materials.Neodymium.getPlasma(144), + Materials.Oriharukon.getPlasma(144), Materials.Palladium.getPlasma(144), + Materials.Phosphorus.getPlasma(144), Materials.Potassium.getPlasma(144), + Materials.Praseodymium.getPlasma(144), Materials.Promethium.getPlasma(144), + Materials.Rubidium.getPlasma(144), Materials.Samarium.getPlasma(144), + Materials.Silicon.getPlasma(144), Materials.Sodium.getPlasma(144), + Materials.Strontium.getPlasma(144), Materials.Tantalum.getPlasma(144), + Materials.Tellurium.getPlasma(144), Materials.Terbium.getPlasma(144), + Materials.Thulium.getPlasma(144), Materials.Tungsten.getPlasma(144), + Materials.Uranium.getPlasma(144), Materials.Uranium235.getPlasma(144), + Materials.Vanadium.getPlasma(144), Materials.Ytterbium.getPlasma(144), + Materials.Yttrium.getPlasma(144), + new FluidStack(ELEMENT.getInstance().ZIRCONIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().THORIUM232.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().GERMANIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().THALLIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().RUTHENIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().RHENIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().RHODIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().IODINE.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().HAFNIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().CURIUM.getPlasma(), 144) }; + + for (int i = 0; i < solids_t0_1step.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new ItemStack[] { solids_t0_1step[i] }, + new FluidStack[] { solid_plasmas_t0_1step[i] }, + 1 * SECONDS, + (int) TierEU.RECIPE_MAX, + false, + 0); + } + + // Multi-step + ItemStack[] solids_t0_xstep = { Materials.Force.getDust(1), Materials.Bismuth.getDust(1), + ELEMENT.STANDALONE.ADVANCED_NITINOL.getDust(1), Materials.Boron.getDust(1), + ELEMENT.STANDALONE.ASTRAL_TITANIUM.getDust(1), ELEMENT.STANDALONE.RUNITE.getDust(1), + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getDust(1), Materials.Iridium.getDust(1), + Materials.Naquadah.getDust(1), Materials.Osmium.getDust(1), Materials.Platinum.getDust(1), + Materials.Plutonium.getDust(1), ELEMENT.getInstance().CALIFORNIUM.getDust(1), + Materials.Chrome.getDust(1) }; + FluidStack[] solid_plasmas_t0_xstep = { new FluidStack(ELEMENT.STANDALONE.FORCE.getPlasma(), 144), + Materials.Bismuth.getPlasma(144), + new FluidStack(ELEMENT.STANDALONE.ADVANCED_NITINOL.getPlasma(), 144), + Materials.Boron.getPlasma(144), + new FluidStack(ELEMENT.STANDALONE.ASTRAL_TITANIUM.getPlasma(), 144), + new FluidStack(ELEMENT.STANDALONE.RUNITE.getPlasma(), 144), + new FluidStack(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getPlasma(), 144), + Materials.Iridium.getPlasma(144), Materials.Naquadah.getPlasma(144), + Materials.Osmium.getPlasma(144), Materials.Platinum.getPlasma(144), + Materials.Plutonium.getPlasma(144), + new FluidStack(ELEMENT.getInstance().CALIFORNIUM.getPlasma(), 144), + Materials.Chrome.getPlasma(144), }; + + for (int i = 0; i < solids_t0_xstep.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new ItemStack[] { solids_t0_xstep[i] }, + new FluidStack[] { solid_plasmas_t0_xstep[i] }, + 3 * SECONDS, + (int) TierEU.RECIPE_MAX, + true, + 0); + } + } + // Fusion tier 4-5 + { + // Single step + ItemStack[] solids_t1_1step = { Materials.Lead.getDust(1), Materials.Plutonium241.getDust(1), + Materials.Thorium.getDust(1) }; + FluidStack[] solid_plasmas_t1_1step = { Materials.Lead.getPlasma(144), + Materials.Plutonium241.getPlasma(144), Materials.Thorium.getPlasma(144) }; + + for (int i = 0; i < solids_t1_1step.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new ItemStack[] { solids_t1_1step[i] }, + new FluidStack[] { solid_plasmas_t1_1step[i] }, + 5 * SECONDS, + (int) TierEU.RECIPE_MAX, + false, + 1); + } + + // Multi-step + ItemStack[] solids_t1_xstep = { ELEMENT.getInstance().NEPTUNIUM.getDust(1), + ELEMENT.getInstance().FERMIUM.getDust(1) }; + FluidStack[] solid_plasmas_t1_xstep = { + new FluidStack(ELEMENT.getInstance().NEPTUNIUM.getPlasma(), 144), + new FluidStack(ELEMENT.getInstance().FERMIUM.getPlasma(), 144) }; + + for (int i = 0; i < solids_t1_xstep.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new ItemStack[] { solids_t1_xstep[i] }, + new FluidStack[] { solid_plasmas_t1_xstep[i] }, + 7 * SECONDS, + (int) TierEU.RECIPE_MAX, + true, + 1); + } + } + // Exotic Plasmas + { + // Single step + ItemStack[] solids_t2_1step = { ELEMENT.STANDALONE.RHUGNOR.getDust(1), + ELEMENT.STANDALONE.DRAGON_METAL.getDust(1), ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getDust(1), + Materials.CosmicNeutronium.getDust(1), Materials.Draconium.getDust(1), + Materials.DraconiumAwakened.getDust(1), Materials.Ichorium.getDust(1) }; + FluidStack[] solid_plasmas_t2_1step = { new FluidStack(ELEMENT.STANDALONE.RHUGNOR.getPlasma(), 144), + new FluidStack(ELEMENT.STANDALONE.DRAGON_METAL.getPlasma(), 144), + new FluidStack(ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getPlasma(), 144), + Materials.CosmicNeutronium.getPlasma(144), Materials.Draconium.getPlasma(144), + Materials.DraconiumAwakened.getPlasma(144), Materials.Ichorium.getPlasma(144) }; + + for (int i = 0; i < solids_t2_1step.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new ItemStack[] { solids_t2_1step[i] }, + new FluidStack[] { solid_plasmas_t2_1step[i] }, + 15 * SECONDS, + (int) TierEU.RECIPE_MAX, + false, + 2); + } + + // Multi-step + ItemStack[] solids_t2_xstep = { ELEMENT.STANDALONE.HYPOGEN.getDust(1), + Materials.Tritanium.getDust(1), Materials.Flerovium.getDust(1), + Materials.Neutronium.getDust(1), }; + FluidStack[] solid_plasmas_t2_xstep = { new FluidStack(ELEMENT.STANDALONE.HYPOGEN.getPlasma(), 144), + Materials.Tritanium.getPlasma(144), Materials.Flerovium.getPlasma(144), + Materials.Neutronium.getPlasma(144), }; + + for (int i = 0; i < solids_t2_xstep.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new ItemStack[] { solids_t2_xstep[i] }, + new FluidStack[] { solid_plasmas_t2_xstep[i] }, + 25 * SECONDS, + (int) TierEU.RECIPE_MAX, + true, + 2); + } + + } + + } + + // Fluid to plasma recipes + { + // Fusion tier 1-3 + { + // Single step + FluidStack[] fluids_t0_1step = { Materials.Helium.getGas(1000), Materials.Nitrogen.getGas(1000), + Materials.Argon.getGas(1000), Materials.Chlorine.getGas(1000), Materials.Deuterium.getGas(1000), + Materials.Fluorine.getGas(1000), Materials.Hydrogen.getGas(1000), Materials.Radon.getGas(1000), + Materials.Tritium.getGas(1000), Materials.Mercury.getFluid(1000) }; + FluidStack[] fluid_plasmas_t0_1step = { Materials.Helium.getPlasma(1000), + Materials.Nitrogen.getPlasma(1000), Materials.Argon.getPlasma(1000), + Materials.Chlorine.getPlasma(1000), Materials.Deuterium.getPlasma(1000), + Materials.Fluorine.getPlasma(1000), Materials.Hydrogen.getPlasma(1000), + Materials.Radon.getPlasma(1000), Materials.Tritium.getPlasma(1000), + Materials.Mercury.getPlasma(1000) }; + + for (int i = 0; i < fluids_t0_1step.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new FluidStack[] { fluids_t0_1step[i] }, + new FluidStack[] { fluid_plasmas_t0_1step[i] }, + 1 * SECONDS, + (int) TierEU.RECIPE_MAX, + false, + 0); + } + + // Multi-step + FluidStack[] fluids_t0_xstep = { ELEMENT.getInstance().NEON.getFluidStack(1000), + Materials.Oxygen.getGas(1000), ELEMENT.getInstance().KRYPTON.getFluidStack(1000), + ELEMENT.getInstance().XENON.getFluidStack(1000) }; + FluidStack[] fluid_plasmas_t0_xstep = { + new FluidStack(ELEMENT.getInstance().NEON.getPlasma(), 1000), Materials.Oxygen.getPlasma(1000), + new FluidStack(ELEMENT.getInstance().KRYPTON.getPlasma(), 1000), + new FluidStack(ELEMENT.getInstance().XENON.getPlasma(), 1000) }; + + for (int i = 0; i < fluids_t0_xstep.length; i++) { + TT_recipeAdder.addFOGPlasmaRecipe( + new FluidStack[] { fluids_t0_xstep[i] }, + new FluidStack[] { fluid_plasmas_t0_xstep[i] }, + 3 * SECONDS, + (int) TierEU.RECIPE_MAX, + true, + 0); + } + } + // Fusion tier 4-5 + { + // Single step + // None yet + + // Multi-step + // None yet + } + // Exotic + { + // None yet + } + } + + // Exotic module fake recipes + { + TT_recipeAdder.addFOGExoticFakeRecipe( + new ItemStack[] { Materials.Iron.getDust(1) }, + new FluidStack[] { Materials.Iron.getMolten(1) }, + new FluidStack[] { MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000) }, + 10 * SECONDS, + (int) TierEU.RECIPE_MAX, + 1); + + TT_recipeAdder.addFOGExoticFakeRecipe( + new ItemStack[] { Materials.Iron.getDust(1) }, + new FluidStack[] { Materials.Iron.getMolten(1), Materials.Bismuth.getMolten(1) }, + new FluidStack[] { MaterialsUEVplus.MagMatter.getMolten(144) }, + 10 * SECONDS, + (int) TierEU.RECIPE_MAX, + 1); + } + } + + // Exotic module plasma material maps + // GT materials + plasmaGTMaterialList.addAll( + Arrays.asList( + Materials.Aluminium, + Materials.Americium, + Materials.Antimony, + Materials.Ardite, + Materials.Argon, + Materials.Arsenic, + Materials.Barium, + Materials.Beryllium, + Materials.Bismuth, + Materials.Boron, + Materials.Caesium, + Materials.Calcium, + Materials.Cadmium, + Materials.Carbon, + Materials.Cerium, + Materials.Chlorine, + Materials.Chrome, + Materials.Cobalt, + Materials.Copper, + Materials.Desh, + Materials.Deuterium, + Materials.Dysprosium, + Materials.Erbium, + Materials.Europium, + Materials.Fluorine, + Materials.Gadolinium, + Materials.Gallium, + Materials.Gold, + Materials.Helium, + Materials.Holmium, + Materials.Hydrogen, + Materials.Indium, + Materials.Iridium, + Materials.Iron, + Materials.Lanthanum, + Materials.Lead, + Materials.Lithium, + Materials.Lutetium, + Materials.Magnesium, + Materials.Manganese, + Materials.MeteoricIron, + Materials.Molybdenum, + Materials.Naquadah, + Materials.Neodymium, + Materials.Nickel, + Materials.Niobium, + Materials.Nitrogen, + Materials.Oriharukon, + Materials.Osmium, + Materials.Oxygen, + Materials.Palladium, + Materials.Phosphorus, + Materials.Platinum, + Materials.Plutonium, + Materials.Plutonium241, + Materials.Potassium, + Materials.Praseodymium, + Materials.Promethium, + Materials.Radon, + Materials.Rubidium, + Materials.Samarium, + Materials.Silicon, + Materials.Silver, + Materials.Sodium, + Materials.Strontium, + Materials.Sulfur, + Materials.Tantalum, + Materials.Tellurium, + Materials.Terbium, + Materials.Thorium, + Materials.Thulium, + Materials.Tin, + Materials.Titanium, + Materials.Tritium, + Materials.Tungsten, + Materials.Uranium235, + Materials.Uranium, + Materials.Vanadium, + Materials.Ytterbium, + Materials.Yttrium, + Materials.Zinc)); + + plasmaGTWeightList.addAll( + Arrays.asList( + 6000 /* Aluminium */, + 10000 /* Americium */, + 6000 /* Antimony */, + 6000 /* Ardite */, + 6000 /* Argon */, + 6000 /* Arsenic */, + 6000 /* Barium */, + 6000 /* Beryllium */, + 8000 /* Bismuth */, + 8000 /* Boron */, + 6000 /* Caesium */, + 10000 /* Calcium */, + 6000 /* Cadmium */, + 6000 /* Carbon */, + 6000 /* Cerium */, + 6000 /* Chlorine */, + 6000 /* Chrome */, + 6000 /* Cobalt */, + 6000 /* Copper */, + 6000 /* Desh */, + 6000 /* Deuterium */, + 2000 /* Dysprosium */, + 2000 /* Erbium */, + 6000 /* Europium */, + 6000 /* Fluorine */, + 2000 /* Gadolinium */, + 6000 /* Gallium */, + 6000 /* Gold */, + 10000 /* Helium */, + 6000 /* Holmium */, + 10000 /* Hydrogen */, + 6000 /* Indium */, + 6000 /* Iridium */, + 10000 /* Iron */, + 6000 /* Lanthanum */, + 500 /* Lead */, + 6000 /* Lithium */, + 6000 /* Lutetium */, + 6000 /* Magnesium */, + 6000 /* Manganese */, + 6000 /* Meteoric Iron */, + 6000 /* Molybdenum */, + 6000 /* Naquadah */, + 6000 /* Neodymium */, + 10000 /* Nickel */, + 10000 /* Niobium */, + 10000 /* Nitrogen */, + 6000 /* Oriharukon */, + 6000 /* Osmium */, + 8000 /* Oxygen */, + 6000 /* Palladium */, + 6000 /* Phosphorus */, + 6000 /* Platinum */, + 6000 /* Plutonium 239 */, + 500 /* Plutonium 241 */, + 6000 /* Potassium */, + 6000 /* Praseodymium */, + 2000 /* Promethium */, + 10000 /* Radon */, + 2000 /* Rubidium */, + 6000 /* Samarium */, + 6000 /* Raw Silicon */, + 10000 /* Silver */, + 6000 /* Sodium */, + 2000 /* Strontium */, + 10000 /* Sulfur */, + 6000 /* Tantalum */, + 2000 /* Tellurium */, + 1000 /* Terbium */, + 500 /* Thorium */, + 6000 /* Thulium */, + 10000 /* Tin */, + 10000 /* Titanium */, + 6000 /* Tritium */, + 6000 /* Tungsten */, + 6000 /* Uranium 235 */, + 6000 /* Uranium 238 */, + 6000 /* Vanadium */, + 2000 /* Ytterbium */, + 6000 /* Yttrium */, + 6000 /* Zinc */)); + + // GT++ materials + if (GTPlusPlus.isModLoaded()) { + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().ZIRCONIUM.getTinyDust(1), 6000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().THORIUM232.getTinyDust(1), 6000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().GERMANIUM.getTinyDust(1), 2000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().THALLIUM.getTinyDust(1), 2000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().RUTHENIUM.getTinyDust(1), 6000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().RHENIUM.getTinyDust(1), 2000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().RHODIUM.getTinyDust(1), 6000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().IODINE.getTinyDust(1), 6000); + exoticModulePlasmaItemMap.put(ELEMENT.STANDALONE.ASTRAL_TITANIUM.getTinyDust(1), 8000); + exoticModulePlasmaItemMap.put(ELEMENT.STANDALONE.ADVANCED_NITINOL.getTinyDust(1), 8000); + exoticModulePlasmaItemMap.put(ELEMENT.STANDALONE.FORCE.getTinyDust(1), 8000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().HAFNIUM.getTinyDust(1), 6000); + exoticModulePlasmaItemMap.put(ELEMENT.getInstance().CALIFORNIUM.getTinyDust(1), 1000); + exoticModulePlasmaItemMap.put(ELEMENT.STANDALONE.RUNITE.getTinyDust(1), 8000); + + exoticModulePlasmaFluidMap.put(new FluidStack(ELEMENT.getInstance().XENON.getFluid(), 1), 8000); + exoticModulePlasmaFluidMap.put(new FluidStack(ELEMENT.getInstance().KRYPTON.getFluid(), 1), 8000); + exoticModulePlasmaFluidMap.put(new FluidStack(ELEMENT.getInstance().NEON.getFluid(), 1), 8000); + // These are here because they cant be solidified + exoticModulePlasmaFluidMap.put(new FluidStack(ELEMENT.getInstance().CURIUM.getFluid(), 1), 10000); + exoticModulePlasmaFluidMap.put(new FluidStack(ELEMENT.getInstance().NEPTUNIUM.getFluid(), 1), 800); + exoticModulePlasmaFluidMap.put(new FluidStack(ELEMENT.getInstance().FERMIUM.getFluid(), 1), 800); + } + // Mercury is weird, it has neither dust nor gas, so it needs to be added separately + exoticModulePlasmaFluidMap.put(Materials.Mercury.getFluid(1), 6000); + + // Loop for adding all GT plasma materials + for (int i = 0; i < plasmaGTMaterialList.size(); i++) { + if (plasmaGTMaterialList.get(i) + .getDustTiny(1) != null) { + exoticModulePlasmaItemMap.put( + plasmaGTMaterialList.get(i) + .getDustTiny(1), + plasmaGTWeightList.get(i)); + } else { + exoticModulePlasmaFluidMap.put( + plasmaGTMaterialList.get(i) + .getGas(1), + plasmaGTWeightList.get(i)); + } + } + + // Magmatter map + // GT materials + exoticModuleMagmatterItemMap.put(Materials.CosmicNeutronium.getDustTiny(1), 100000); + exoticModuleMagmatterItemMap.put(Materials.Draconium.getDustTiny(1), 100000); + exoticModuleMagmatterItemMap.put(Materials.DraconiumAwakened.getDustTiny(1), 100000); + exoticModuleMagmatterItemMap.put(Materials.Ichorium.getDustTiny(1), 100000); + exoticModuleMagmatterItemMap.put(Materials.Neutronium.getDustTiny(1), 100000); + exoticModuleMagmatterItemMap.put(Materials.Flerovium.getDustTiny(1), 100000); + + // GT++ materials + if (GTPlusPlus.isModLoaded()) { + exoticModuleMagmatterItemMap.put(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getTinyDust(1), 100000); + exoticModuleMagmatterItemMap.put(ELEMENT.STANDALONE.HYPOGEN.getTinyDust(1), 100000); + exoticModuleMagmatterItemMap.put(ELEMENT.STANDALONE.RHUGNOR.getTinyDust(1), 100000); + exoticModuleMagmatterItemMap.put(ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getTinyDust(1), 100000); + exoticModuleMagmatterItemMap.put(ELEMENT.STANDALONE.DRAGON_METAL.getTinyDust(1), 100000); + } + + // For NEI + for (FluidStack fluid : exoticModulePlasmaFluidMap.keySet()) { + fluid.amount = getRandomIntInRange(1, 64); + quarkGluonFluidItemsForNEI.add(GT_Utility.getFluidDisplayStack(fluid, true)); + } + for (ItemStack item : exoticModulePlasmaItemMap.keySet()) { + item.stackSize = getRandomIntInRange(1, 64); + quarkGluonItemsForNEI.add(item); + } + for (int i = 0; i < 21; i++) { + magmatterTimeFluidItemsForNEI.add( + GT_Utility.getFluidDisplayStack(MaterialsUEVplus.Time.getMolten(getRandomIntInRange(1, 50)), true)); + magmatterSpaceFluidItemsForNEI.add( + GT_Utility.getFluidDisplayStack(MaterialsUEVplus.Space.getMolten(getRandomIntInRange(51, 100)), true)); + } + magmatterItemsForNEI.addAll(exoticModuleMagmatterItemMap.keySet()); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java b/src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java new file mode 100644 index 0000000000..63885b5b7d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java @@ -0,0 +1,3272 @@ +package com.github.technus.tectech.loader.recipe; + +import static com.github.technus.tectech.loader.recipe.BaseRecipeLoader.getItemContainer; +import static com.google.common.math.LongMath.pow; +import static gregtech.api.enums.Mods.Avaritia; +import static gregtech.api.enums.Mods.AvaritiaAddons; +import static gregtech.api.enums.Mods.BartWorks; +import static gregtech.api.enums.Mods.BloodMagic; +import static gregtech.api.enums.Mods.DraconicEvolution; +import static gregtech.api.enums.Mods.EternalSingularity; +import static gregtech.api.enums.Mods.ExtraUtilities; +import static gregtech.api.enums.Mods.GTNHIntergalactic; +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GTPlusPlusEverglades; +import static gregtech.api.enums.Mods.GalaxySpace; +import static gregtech.api.enums.Mods.GoodGenerator; +import static gregtech.api.enums.Mods.GraviSuite; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.enums.Mods.IndustrialCraft2; +import static gregtech.api.enums.Mods.KekzTech; +import static gregtech.api.enums.Mods.KubaTech; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.Mods.SGCraft; +import static gregtech.api.enums.Mods.SuperSolarPanels; +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.enums.Mods.TinkersGregworks; +import static gregtech.api.util.GT_ModHandler.getModItem; +import static gregtech.api.util.GT_RecipeBuilder.INGOTS; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.recipe.TT_recipeAdder; +import com.github.technus.tectech.thing.CustomItemList; +import com.rwtema.extrautils.ExtraUtils; + +import fox.spiteful.avaritia.compat.ticon.Tonkers; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsBotania; +import gregtech.api.enums.MaterialsKevlar; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import tconstruct.tools.TinkerTools; +import vexatos.tgregworks.reference.PartTypes; +import vexatos.tgregworks.util.TGregUtils; + +public class ResearchStationAssemblyLine implements Runnable { + + @Override + public void run() { + itemPartsUHVAsslineRecipes(); + itemPartsUEVAsslineRecipes(); + itemPartsUIVAsslineRecipes(); + itemPartsUMVAsslineRecipes(); + itemPartsUXVAsslineRecipes(); + addWirelessEnergyRecipes(); + + if (TinkersGregworks.isModLoaded() && GoodGenerator.isModLoaded() // Shirabon + && Avaritia.isModLoaded() // Infinity, Cosmic Neutronium + && ExtraUtilities.isModLoaded() // Bedrockium + ) { + addEOHRecipes(); + } + + Fluid solderUEV = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + + // Infinite Oil Rig + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.OilDrill4.get(1), + 16777216, + 2048, + 2000000, + 4, + new Object[] { ItemList.OilDrill4.get(1), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Neutronium, 4), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 4L }, ItemList.Electric_Motor_UHV.get(4), + ItemList.Electric_Pump_UHV.get(4), + GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Neutronium, 4), ItemList.Sensor_UHV.get(3), + ItemList.Field_Generator_UHV.get(3), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Neutronium, 12) }, + new FluidStack[] { new FluidStack(solderUEV, 1296), Materials.Neutronium.getMolten(576) }, + ItemList.OilDrillInfinite.get(1), + 6000, + 2000000); + + // Infinity Coil + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Coil_AwakenedDraconium.get(1), + 16_777_216, + 2048, + 8_000_000, + 1, + new Object[] { new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 1L }, + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Infinity, 8), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Infinity, 8), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 32, 0) }, + new FluidStack[] { Materials.DraconiumAwakened.getMolten(576), }, + ItemList.Casing_Coil_Infinity.get(1), + 60 * 20, + 8_000_000); + + if (GTPlusPlus.isModLoaded()) { + // Hypogen Coil + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Coil_Infinity.get(1), + 16_777_216 * 2, + 2048 * 2, + 32_000_000, + 1, + new Object[] { new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + GT_OreDictUnificator.get("wireGt02Hypogen", 8L), + getModItem(GTPlusPlus.ID, "itemScrewHypogen", 8, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), }, + new FluidStack[] { Materials.Infinity.getMolten(576), }, + ItemList.Casing_Coil_Hypogen.get(1), + 60 * 20, + 8000000 * 4); + + // Eternal coil + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Coil_Hypogen.get(1), + 16_777_216 * 4, + 8_192, + 128_000_000, + 1, + new Object[] { new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + GT_OreDictUnificator.get(OrePrefixes.wireGt02, MaterialsUEVplus.SpaceTime, 8), + GT_OreDictUnificator.get(OrePrefixes.screw, MaterialsUEVplus.SpaceTime, 8), + getModItem(EternalSingularity.ID, "eternal_singularity", 1L), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), + getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 64, 0), }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("molten.hypogen"), 576), }, + ItemList.Casing_Coil_Eternal.get(1), + 60 * 20, + 8_000_000 * 16); + } + + // UHV-UMV Energy Hatch & Dynamo + { + // Energy Hatches + { + // Energy Hatch UHV + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Hatch_Energy_UV.get(1L), + 24000, + 16, + 50000, + 2, + new Object[] { ItemList.Hull_MAX.get(1L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUHV, 2L), + ItemList.Circuit_Chip_QPIC.get(2L), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 2L }, ItemList.UHV_Coil.get(2L), + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + ItemList.Electric_Pump_UHV.get(1L) }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("ic2coolant"), 16000), + new FluidStack(solderIndalloy, 40 * 144) }, + ItemList.Hatch_Energy_MAX.get(1L), + 1000, + 2000000); + + // Energy Hatch UEV + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Hatch_Energy_MAX.get(1L), + 48000, + 32, + 100000, + 4, + new Object[] { getItemContainer("Hull_UEV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUEV, 2L), + ItemList.Circuit_Chip_QPIC.get(4L), new Object[] { OrePrefixes.circuit.get(Materials.Bio), 2L }, + ItemList.UHV_Coil.get(4L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Electric_Pump_UEV.get(1L) }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("ic2coolant"), 32000), + new FluidStack(solderUEV, 20 * 144), Materials.UUMatter.getFluid(8000L) }, + getItemContainer("Hatch_Energy_UEV").get(1L), + 1000, + 8000000); + + // Energy Hatch UIV + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("Hatch_Energy_UEV").get(1L), + 96_000, + 64, + 200_000, + 8, + new Object[] { getItemContainer("Hull_UIV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUIV, 2L), + ItemList.Circuit_Chip_QPIC.get(4L), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 2L }, ItemList.UHV_Coil.get(8L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Electric_Pump_UIV.get(1L) }, + new FluidStack[] { Materials.SuperCoolant.getFluid(16_000L), new FluidStack(solderUEV, 20 * 144), + Materials.UUMatter.getFluid(16_000L) }, + getItemContainer("Hatch_Energy_UIV").get(1L), + 1000, + 32_000_000); + + // Energy Hatch UMV + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("Hatch_Energy_UIV").get(1L), + 192000, + 128, + 400000, + 16, + new Object[] { getItemContainer("Hull_UMV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUMV, 2L), + ItemList.Circuit_Chip_QPIC.get(4L), getItemContainer("PikoCircuit").get(2), + ItemList.UHV_Coil.get(16L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Electric_Pump_UMV.get(1L) }, + new FluidStack[] { Materials.SuperCoolant.getFluid(32_000L), new FluidStack(solderUEV, 40 * 144), + Materials.UUMatter.getFluid(32000L) }, + getItemContainer("Hatch_Energy_UMV").get(1L), + 1000, + 128_000_000); + + // Energy Hatch UXV + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("Hatch_Energy_UMV").get(1L), + 384000, + 256, + 800000, + 32, + new Object[] { getItemContainer("Hull_UXV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.SuperconductorUMV, 4L), + ItemList.Circuit_Chip_QPIC.get(16L), getItemContainer("QuantumCircuit").get(2), + ItemList.UHV_Coil.get(32L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Electric_Pump_UXV.get(1L) }, + new FluidStack[] { Materials.SuperCoolant.getFluid(64_000L), new FluidStack(solderUEV, 80 * 144), + Materials.UUMatter.getFluid(64000L) }, + getItemContainer("Hatch_Energy_UXV").get(1L), + 1000, + 512_000_000); + } + + // Dynamo Hatch + { + // Dynamo Hatch UHV + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Hatch_Dynamo_UV.get(1L), + 48000, + 32, + 100000, + 4, + new Object[] { ItemList.Hull_MAX.get(1L), + GT_OreDictUnificator.get(OrePrefixes.spring, Materials.Longasssuperconductornameforuhvwire, 8L), + ItemList.Circuit_Chip_QPIC.get(2L), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 2L }, ItemList.UHV_Coil.get(2L), + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + new ItemStack[] { ItemList.Reactor_Coolant_He_6.get(1L), ItemList.Reactor_Coolant_NaK_6.get(1L), + ItemList.Reactor_Coolant_Sp_2.get(1L) }, + ItemList.Electric_Pump_UHV.get(1L) }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("ic2coolant"), 16000), + new FluidStack(solderIndalloy, 40 * 144) }, + ItemList.Hatch_Dynamo_MAX.get(1L), + 1000, + 2000000); + + // Dynamo Hatch UEV + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Hatch_Dynamo_MAX.get(1L), + 96000, + 64, + 200000, + 8, + new Object[] { getItemContainer("Hull_UEV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.spring, Materials.SuperconductorUEVBase, 8L), + ItemList.Circuit_Chip_QPIC.get(4L), new Object[] { OrePrefixes.circuit.get(Materials.Bio), 2L }, + ItemList.UHV_Coil.get(4L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Electric_Pump_UEV.get(1L) }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("ic2coolant"), 32000), + new FluidStack(solderUEV, 20 * 144), Materials.UUMatter.getFluid(8000L) }, + getItemContainer("Hatch_Dynamo_UEV").get(1L), + 1000, + 8000000); + + // Dynamo Hatch UIV + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("Hatch_Dynamo_UEV").get(1L), + 192_000, + 128, + 400_000, + 16, + new Object[] { getItemContainer("Hull_UIV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.spring, Materials.SuperconductorUIVBase, 8L), + ItemList.Circuit_Chip_QPIC.get(4L), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 2L }, ItemList.UHV_Coil.get(8L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Electric_Pump_UIV.get(1L) }, + new FluidStack[] { Materials.SuperCoolant.getFluid(16_000L), new FluidStack(solderUEV, 20 * 144), + Materials.UUMatter.getFluid(16_000L) }, + getItemContainer("Hatch_Dynamo_UIV").get(1L), + 1000, + 32_000_000); + + // Dynamo Hatch UMV + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("Hatch_Dynamo_UIV").get(1L), + 384000, + 256, + 800000, + 32, + new Object[] { getItemContainer("Hull_UMV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.spring, Materials.SuperconductorUMVBase, 8L), + ItemList.Circuit_Chip_QPIC.get(4L), getItemContainer("PikoCircuit").get(2), + ItemList.UHV_Coil.get(16L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Electric_Pump_UMV.get(1L) }, + new FluidStack[] { Materials.SuperCoolant.getFluid(32_000L), new FluidStack(solderUEV, 40 * 144), + Materials.UUMatter.getFluid(32000L) }, + getItemContainer("Hatch_Dynamo_UMV").get(1L), + 1000, + 128_000_000); + + // Dynamo Hatch UXV + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("Hatch_Dynamo_UMV").get(1L), + 384000, + 256, + 800000, + 32, + new Object[] { getItemContainer("Hull_UXV").get(1L), + GT_OreDictUnificator.get(OrePrefixes.spring, Materials.SuperconductorUMVBase, 16L), + ItemList.Circuit_Chip_QPIC.get(16L), getItemContainer("QuantumCircuit").get(2), + ItemList.UHV_Coil.get(32L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Electric_Pump_UXV.get(1L) }, + new FluidStack[] { Materials.SuperCoolant.getFluid(64_000L), new FluidStack(solderUEV, 80 * 144), + Materials.UUMatter.getFluid(64000L) }, + getItemContainer("Hatch_Dynamo_UXV").get(1L), + 1000, + 512_000_000); + } + } + + // UHV Circuit Wetwaremainframe + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Circuit_Wetwaresupercomputer.get(1L), + 24000, + 64, + 50000, + 4, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Tritanium, 2), + ItemList.Circuit_Wetwaresupercomputer.get(2L), + new ItemStack[] { ItemList.Circuit_Parts_InductorASMD.get(16L), + ItemList.Circuit_Parts_InductorXSMD.get(4L) }, + new ItemStack[] { ItemList.Circuit_Parts_CapacitorASMD.get(16L), + ItemList.Circuit_Parts_CapacitorXSMD.get(4L) }, + new ItemStack[] { ItemList.Circuit_Parts_ResistorASMD.get(16L), + ItemList.Circuit_Parts_ResistorXSMD.get(4L) }, + new ItemStack[] { ItemList.Circuit_Parts_TransistorASMD.get(16L), + ItemList.Circuit_Parts_TransistorXSMD.get(4L) }, + new ItemStack[] { ItemList.Circuit_Parts_DiodeASMD.get(16L), ItemList.Circuit_Parts_DiodeXSMD.get(4L) }, + ItemList.Circuit_Chip_Ram.get(48L), + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorZPM, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUV, 32L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUHV, 16L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUEV, 8L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUIV, 4L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUMV, 2L) }, + new Object[] { OrePrefixes.foil.get(Materials.AnySyntheticRubber), 64L }, }, + new FluidStack[] { new FluidStack(solderIndalloy, 2880), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 10000), Materials.Radon.getGas(2500L), }, + ItemList.Circuit_Wetwaremainframe.get(1L), + 2000, + 300000); + + // Bioware SuperComputer + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Circuit_Biowarecomputer.get(1L), + 48000, + 128, + 500000, + 8, + new Object[] { ItemList.Circuit_Board_Bio_Ultra.get(2L), ItemList.Circuit_Biowarecomputer.get(2L), + new ItemStack[] { ItemList.Circuit_Parts_TransistorASMD.get(16L), + ItemList.Circuit_Parts_TransistorXSMD.get(4L) }, + new ItemStack[] { ItemList.Circuit_Parts_ResistorASMD.get(16L), + ItemList.Circuit_Parts_ResistorXSMD.get(4L) }, + new ItemStack[] { ItemList.Circuit_Parts_CapacitorASMD.get(16L), + ItemList.Circuit_Parts_CapacitorXSMD.get(4L) }, + new ItemStack[] { ItemList.Circuit_Parts_DiodeASMD.get(16L), ItemList.Circuit_Parts_DiodeXSMD.get(4L) }, + ItemList.Circuit_Chip_NOR.get(32L), ItemList.Circuit_Chip_Ram.get(64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.NiobiumTitanium, 32L), + new Object[] { OrePrefixes.foil.get(Materials.AnySyntheticRubber), 64L }, }, + new FluidStack[] { new FluidStack(solderUEV, 1440), Materials.BioMediumSterilized.getFluid(1440L), + Materials.SuperCoolant.getFluid(10_000L), }, + ItemList.Circuit_Biowaresupercomputer.get(1L), + 4000, + 500000); + + // Bio Mainframe + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Circuit_Biowaresupercomputer.get(1L), + 96000, + 256, + 1000000, + 16, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Tritanium, 4L), + ItemList.Circuit_Biowaresupercomputer.get(2L), + new ItemStack[] { ItemList.Circuit_Parts_InductorASMD.get(24L), + ItemList.Circuit_Parts_InductorXSMD.get(6L) }, + new ItemStack[] { ItemList.Circuit_Parts_TransistorASMD.get(24L), + ItemList.Circuit_Parts_TransistorXSMD.get(6L) }, + new ItemStack[] { ItemList.Circuit_Parts_ResistorASMD.get(24L), + ItemList.Circuit_Parts_ResistorXSMD.get(6L) }, + new ItemStack[] { ItemList.Circuit_Parts_CapacitorASMD.get(24L), + ItemList.Circuit_Parts_CapacitorXSMD.get(6L) }, + new ItemStack[] { ItemList.Circuit_Parts_DiodeASMD.get(24L), ItemList.Circuit_Parts_DiodeXSMD.get(6L) }, + ItemList.Circuit_Chip_Ram.get(64L), + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUHV, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUEV, 32L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUIV, 16L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUMV, 8L) }, + new Object[] { OrePrefixes.foil.get(Materials.AnySyntheticRubber), 64L }, + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Polybenzimidazole, 64) }, + new FluidStack[] { new FluidStack(solderUEV, 2880), Materials.BioMediumSterilized.getFluid(2880L), + Materials.SuperCoolant.getFluid(20_000L), }, + ItemList.Circuit_Biomainframe.get(1L), + 6000, + 2000000); + + // Optical Assembly + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Circuit_OpticalProcessor.get(1L), + 192_000, + 256, + 2_000_000, + 16, + new Object[] { ItemList.Circuit_Board_Optical.get(1L), ItemList.Circuit_OpticalProcessor.get(2L), + ItemList.Circuit_Parts_InductorXSMD.get(16L), ItemList.Circuit_Parts_CapacitorXSMD.get(20L), + ItemList.Circuit_Parts_ResistorXSMD.get(20L), ItemList.Circuit_Chip_NOR.get(32L), + ItemList.Circuit_Chip_Ram.get(64L), + GT_ModHandler.getModItem(BartWorks.ID, "gt.bwMetaGeneratedwireFine", 24L, 10101), // Fine + // Lumiium + // Wire + new Object[] { OrePrefixes.foil.get(Materials.AnySyntheticRubber), 64L }, }, + new FluidStack[] { new FluidStack(solderUEV, 1440), Materials.Radon.getPlasma(1440L), + Materials.SuperCoolant.getFluid(10_000L), new FluidStack(FluidRegistry.getFluid("oganesson"), 500) }, + ItemList.Circuit_OpticalAssembly.get(1L), + 20 * 20, + 2_000_000); + + // Optical Computer + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Circuit_OpticalAssembly.get(1L), + 384_000, + 512, + 4_000_000, + 32, + new Object[] { ItemList.Circuit_Board_Optical.get(2L), ItemList.Circuit_OpticalAssembly.get(2L), + ItemList.Circuit_Parts_TransistorXSMD.get(24L), ItemList.Circuit_Parts_ResistorXSMD.get(24L), + ItemList.Circuit_Parts_CapacitorXSMD.get(24L), ItemList.Circuit_Parts_DiodeXSMD.get(24L), + ItemList.Circuit_Chip_NOR.get(64L), ItemList.Circuit_Chip_SoC2.get(32L), + GT_ModHandler.getModItem(BartWorks.ID, "gt.bwMetaGeneratedwireFine", 32L, 10101), // Fine + // Lumiium + // Wire + new Object[] { OrePrefixes.foil.get(Materials.AnySyntheticRubber), 64L }, + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Polybenzimidazole, 64), }, + new FluidStack[] { new FluidStack(solderUEV, 1440 * 2), Materials.Radon.getPlasma(1440L * 2), + Materials.SuperCoolant.getFluid(10_000L * 2), + new FluidStack(FluidRegistry.getFluid("oganesson"), 500 * 2) }, + ItemList.Circuit_OpticalComputer.get(1L), + 200 * 20, + 2_000_000); + + // Optical Mainframe + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Circuit_OpticalComputer.get(1L), + 768_000, + 1024, + 8_000_000, + 64, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Tritanium, 8), + ItemList.Circuit_OpticalComputer.get(2L), ItemList.Circuit_Parts_InductorXSMD.get(32L), + ItemList.Circuit_Parts_TransistorXSMD.get(32L), ItemList.Circuit_Parts_ResistorXSMD.get(32L), + ItemList.Circuit_Parts_CapacitorXSMD.get(32L), ItemList.Circuit_Parts_DiodeXSMD.get(32L), + ItemList.Circuit_Chip_SoC2.get(64L), + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUEV, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUIV, 32L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUMV, 16L) }, + new Object[] { OrePrefixes.foil.get(Materials.AnySyntheticRubber), 64L }, + new Object[] { OrePrefixes.foil.get(Materials.AnySyntheticRubber), 64L }, + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Polybenzimidazole, 64), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Polybenzimidazole, 64) }, + new FluidStack[] { new FluidStack(solderUEV, 1440 * 4), Materials.Radon.getPlasma(1440L * 4), + Materials.SuperCoolant.getFluid(10_000L * 4), + new FluidStack(FluidRegistry.getFluid("oganesson"), 500 * 4) }, + ItemList.Circuit_OpticalMainframe.get(1L), + 300 * 20, + 8_000_000); + + // Piko Circuit + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Circuit_OpticalMainframe.get(1L), + 384000, + 1024, + 4000000, + 64, + new Object[] { ItemList.Circuit_Board_Optical.get(1L), getItemContainer("PicoWafer").get(4L), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 2L }, + ItemList.Circuit_Parts_TransistorXSMD.get(48L), ItemList.Circuit_Parts_ResistorXSMD.get(48L), + ItemList.Circuit_Parts_CapacitorXSMD.get(48L), ItemList.Circuit_Parts_DiodeXSMD.get(48L), + ItemList.Circuit_Chip_PPIC.get(64L), GT_OreDictUnificator.get("foilRadoxPoly", 16L), + GT_OreDictUnificator.get(OrePrefixes.bolt, MaterialsUEVplus.TranscendentMetal, 32), + GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.Neutronium, 16), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Lanthanum, 64) }, + new FluidStack[] { new FluidStack(solderUEV, 3744), Materials.UUMatter.getFluid(8000L), + Materials.Osmium.getMolten(1152L) }, + getItemContainer("PikoCircuit").get(1L), + 10000, + 128_000_000); + + // Quantum Circuit + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("PikoCircuit").get(1L), + 720000, + 2048, + 8000000, + 128, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Neutronium, 16), + getItemContainer("PikoCircuit").get(2L), ItemList.Circuit_Parts_CapacitorXSMD.get(64L), + ItemList.Circuit_Parts_DiodeXSMD.get(64L), ItemList.Circuit_Parts_TransistorXSMD.get(64L), + ItemList.Circuit_Parts_ResistorXSMD.get(64L), ItemList.Circuit_Chip_QPIC.get(64L), + GT_OreDictUnificator.get("foilShirabon", 64), + GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.Indium, 64), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, MaterialsUEVplus.SpaceTime, 8), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Lanthanum, 16) }, + new FluidStack[] { new FluidStack(solderUEV, 3744), Materials.UUMatter.getFluid(24000L), + Materials.Osmium.getMolten(2304L) }, + getItemContainer("QuantumCircuit").get(1L), + 20000, + (int) TierEU.RECIPE_UMV); + + // Transcendent Plasma Mixer - TPM. + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.eM_energyTunnel7_UV.get(1), + 32_000_000, + 4096, + (int) TierEU.RECIPE_UIV, + 1, + new Object[] { CustomItemList.eM_energyTunnel7_UV.get(32), + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 32L }, ItemList.Electric_Pump_UIV.get(16), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.TranscendentMetal, 64), + + GT_OreDictUnificator.get(OrePrefixes.gearGt, MaterialsUEVplus.TranscendentMetal, 16), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, MaterialsUEVplus.TranscendentMetal, 64), + GT_OreDictUnificator.get(OrePrefixes.screw, MaterialsUEVplus.TranscendentMetal, 64), + ItemList.EnergisedTesseract.get(32), + + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), }, + new FluidStack[] { MaterialsUEVplus.ExcitedDTCC.getFluid(2_048_000), + MaterialsUEVplus.ExcitedDTPC.getFluid(2_048_000), MaterialsUEVplus.ExcitedDTRC.getFluid(2_048_000), + MaterialsUEVplus.ExcitedDTEC.getFluid(2_048_000), }, + ItemList.Machine_Multi_TranscendentPlasmaMixer.get(1), + 5 * MINUTES, + (int) TierEU.RECIPE_UIV); + + // Stargate Recipes + if (EternalSingularity.isModLoaded() && SGCraft.isModLoaded()) { + + final int baseStargateTime = 125_000 * 20; + + // Stargate shield foil + TT_recipeAdder.addResearchableAssemblylineRecipe( + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 1L), + (int) TierEU.RECIPE_MAX, + 32768, + (int) TierEU.RECIPE_UXV, + 64, + new ItemStack[] { ItemList.Casing_Dim_Bridge.get(64), + CustomItemList.StabilisationFieldGeneratorTier8.get(64), + GT_OreDictUnificator.get("blockShirabon", 64L), GT_OreDictUnificator.get("blockShirabon", 64L), + GT_OreDictUnificator.get(OrePrefixes.block, MaterialsUEVplus.SpaceTime, 64L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Quantum, 16L), + GT_OreDictUnificator.get(OrePrefixes.plateDense, MaterialsUEVplus.SpaceTime, 8L), + GT_OreDictUnificator.get(OrePrefixes.plateDense, MaterialsUEVplus.Universium, 8L), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Infinity, 8L), + GT_OreDictUnificator.get("plateDenseShirabon", 8L), ItemList.Sensor_UXV.get(16L), + ItemList.Emitter_UXV.get(16L), getModItem(EternalSingularity.ID, "eternal_singularity", 16L), + MaterialsUEVplus.Universium.getNanite(16), MaterialsUEVplus.BlackDwarfMatter.getNanite(16), + MaterialsUEVplus.WhiteDwarfMatter.getNanite(16) }, + new FluidStack[] { Materials.Neutronium.getMolten(32_768_000L), + MaterialsUEVplus.SpaceTime.getMolten(4 * 36864L), + Materials.SuperconductorUMVBase.getMolten(4 * 36864L), + MaterialsUEVplus.ExcitedDTEC.getFluid(4 * 36864L) }, + getItemContainer("StargateShieldingFoil").get(1L), + baseStargateTime, + (int) TierEU.RECIPE_UMV); + + // Stargate chevron + TT_recipeAdder.addResearchableAssemblylineRecipe( + getItemContainer("StargateShieldingFoil").get(1L), + (int) TierEU.RECIPE_MAX, + 32_768, + (int) TierEU.RECIPE_UXV, + 64, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.block, MaterialsUEVplus.TranscendentMetal, 64L), + GT_OreDictUnificator.get("blockShirabon", 64), CustomItemList.EOH_Reinforced_Spatial_Casing.get(64), + CustomItemList.EOH_Reinforced_Spatial_Casing.get(64), + + GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.SpaceTime, 16L), + GT_OreDictUnificator + .get(OrePrefixes.frameGt, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 16L), + GT_OreDictUnificator.get(OrePrefixes.gemExquisite, Materials.Ruby, 16L), + GT_OreDictUnificator.get(OrePrefixes.gemExquisite, Materials.Jasper, 16L), + + GT_OreDictUnificator.get(OrePrefixes.gemExquisite, Materials.Opal, 16L), + GT_OreDictUnificator.get(OrePrefixes.gemExquisite, Materials.Sapphire, 16L), + GT_OreDictUnificator + .get(OrePrefixes.plateDense, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8L), + GT_OreDictUnificator.get("plateDenseShirabon", 8), + + ItemList.Electric_Motor_UXV.get(64L), ItemList.Electric_Piston_UXV.get(64L), + ItemList.Field_Generator_UXV.get(16L), getItemContainer("QuantumCircuit").get(1L) + .splitStack(32) }, + new FluidStack[] { Materials.Neutronium.getMolten(32_768_000L), + MaterialsUEVplus.SpaceTime.getMolten(4 * 36864L), + MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(36864L), + MaterialsUEVplus.ExcitedDTEC.getFluid(4 * 36864L) }, + getItemContainer("StargateChevron").get(1L), + baseStargateTime, + (int) TierEU.RECIPE_UMV); + + // Stargate Frame Part + TT_recipeAdder.addResearchableAssemblylineRecipe( + GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.SpaceTime, 1L), + (int) TierEU.RECIPE_MAX, + 32_768, + 500_000_000, + 64, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, MaterialsUEVplus.SpaceTime, 64L), + GT_OreDictUnificator + .get(OrePrefixes.stickLong, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Neutronium, 64L), + + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Osmiridium, 64L), + GT_OreDictUnificator.get("stickLongShirabon", 64), + getModItem(BartWorks.ID, "gt.bwMetaGeneratedstickLong", 64L, 39), + getModItem(GTPlusPlus.ID, "itemRodLongQuantum", 64L), + + getModItem(GTPlusPlus.ID, "itemRodLongHypogen", 64L), + getModItem(GTPlusPlus.ID, "itemRodLongCelestialTungsten", 64L), + getModItem(BartWorks.ID, "gt.bwMetaGeneratedstickLong", 64L, 10106), + getModItem(GTPlusPlus.ID, "itemRodLongAstralTitanium", 64L), + + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.SuperconductorUMVBase, 64L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, MaterialsUEVplus.Universium, 64L), + getModItem(GTPlusPlus.ID, "itemRodLongAbyssalAlloy", 64L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, MaterialsUEVplus.TranscendentMetal, 64L), }, + new FluidStack[] { Materials.Neutronium.getMolten(32_768_000L), + MaterialsUEVplus.SpaceTime.getMolten(4 * 36864L), MaterialsUEVplus.Universium.getMolten(4 * 36864L), + MaterialsUEVplus.ExcitedDTEC.getFluid(4 * 36864L) }, + getItemContainer("StargateFramePart").get(1L), + baseStargateTime, + (int) TierEU.RECIPE_UMV); + } + + // Dimensionally Transcendent Plasma Forge (DTPF) + if (EternalSingularity.isModLoaded()) { + + // DTPF Controller. + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Dim_Bridge.get(1), + 32_000_000, + 4096, + 32_000_000, + 1, + new Object[] { ItemList.Casing_Dim_Bridge.get(4), + getModItem(GregTech.ID, "gt.blockmachines", 16L, 12730), + getItemContainer("Hatch_Energy_UEV").get(4L), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUEV, 6), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + ItemList.Reactor_Coolant_Sp_6.get(1L), ItemList.Reactor_Coolant_Sp_6.get(1L), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 20L }, + ItemList.Field_Generator_UEV.get(4), getModItem(EternalSingularity.ID, "eternal_singularity", 4L), + getModItem(GTPlusPlus.ID, "MU-metaitem.01", 1L, 32105), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmiridium, 64L), + ItemList.Electric_Pump_UEV.get(4), ItemList.ZPM3.get(1), + getModItem(IndustrialCraft2.ID, "blockMachine2", 1, 0) }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("oganesson"), 128000), + new FluidStack(solderUEV, 36864 * 2), + new FluidStack(FluidRegistry.getFluid("molten.californium"), 36864), + Materials.NaquadahEnriched.getMolten(36864L) }, + ItemList.Machine_Multi_PlasmaForge.get(1), + 5 * MINUTES, + (int) TierEU.RECIPE_UIV); + + // Dimensional bridge. + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Dim_Injector.get(1), + 8_000_000, + 4096, + 32_000_000, + 1, + new Object[] { ItemList.Casing_Dim_Trans.get(1), ItemList.MicroTransmitter_UV.get(1), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 2L }, + getModItem(Avaritia.ID, "Singularity", 2L, 0), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUHV, 6), + getModItem(NewHorizonsCoreMod.ID, "item.PicoWafer", 2, 0), ItemList.Field_Generator_UHV.get(1L) }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("oganesson"), 8000), + new FluidStack(solderUEV, 1152 * 8), Materials.NaquadahEnriched.getMolten(1296L) }, + ItemList.Casing_Dim_Bridge.get(1), + 240 * 20, + 32_000_000); + + // Dimensional injection casing. + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Dim_Trans.get(1), + 2_000_000, + 2048, + 32_000_000, + 1, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmiridium, 4), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Ledox, 1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.CallistoIce, 1), + ItemList.Reactor_Coolant_Sp_6.get(1L), getModItem(GTPlusPlus.ID, "itemScrewLaurenium", 12, 0), + new Object[] { OrePrefixes.circuit.get(Materials.Elite), 2L }, + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUHV, 2), + ItemList.Super_Chest_IV.get(1), ItemList.Super_Tank_IV.get(1), + getModItem(NewHorizonsCoreMod.ID, "item.PicoWafer", 1, 0), }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("oganesson"), 1000), + new FluidStack(solderUEV, 576), Materials.NaquadahEnriched.getMolten(288L) }, + ItemList.Casing_Dim_Injector.get(1), + 20 * 20, + 32_000_000); + + // Dimensionally Transcendent Casing. + TT_recipeAdder.addResearchableAssemblylineRecipe( + getModItem(Avaritia.ID, "Singularity", 1L, 0), + 2_000_000, + 2048, + 32_000_000, + 1, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmiridium, 6), + getModItem(GTPlusPlus.ID, "itemScrewLaurenium", 12, 0), ItemList.Reactor_Coolant_Sp_6.get(1L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUHV, 1), }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("oganesson"), 500), + new FluidStack(solderUEV, 288), Materials.NaquadahEnriched.getMolten(144L) }, + ItemList.Casing_Dim_Trans.get(1), + 20 * 20, + 32_000_000); + } + + // Deep Dark Portal + if (BartWorks.isModLoaded()) { + TT_recipeAdder.addResearchableAssemblylineRecipe( + getModItem(NewHorizonsCoreMod.ID, "item.HeavyDutyPlateTier8", 1, 0), + 16_777_216, + 2048, + 2_000_000, + 64, + new Object[] { getModItem(ExtraUtilities.ID, "cobblestone_compressed", 1, 7), + getModItem(IndustrialCraft2.ID, "blockMachine2", 1, 0), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Infinity, 4L), + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, + getModItem(NewHorizonsCoreMod.ID, "item.PicoWafer", 32, 0), ItemList.Robot_Arm_UMV.get(4), + ItemList.Emitter_UMV.get(4), ItemList.Sensor_UMV.get(4), }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("oganesson"), 50000), + Materials.Infinity.getMolten(144L * 512), Materials.Cheese.getMolten(232000L), }, + ItemList.Block_BedrockiumCompressed.get(1), + 10000, + 5000000); + } + + // Batteries + { + + // Ultimate Battery + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Energy_Cluster.get(1L), + 12000, + 16, + 100000, + 3, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Tritanium, 64L), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 1L }, ItemList.Energy_Cluster.get(8L), + ItemList.Field_Generator_UV.get(2), ItemList.Circuit_Wafer_HPIC.get(64), + ItemList.Circuit_Wafer_HPIC.get(64), ItemList.Circuit_Parts_DiodeASMD.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.SuperconductorUHV, 32), }, + new FluidStack[] { new FluidStack(solderIndalloy, 2880), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 16000) }, + ItemList.ZPM2.get(1), + 3000, + 400000); + + // Really Ultimate Battery + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.ZPM2.get(1L), + 24000, + 64, + 200000, + 6, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Neutronium, 32L), + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Neutronium, 32L), + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, ItemList.ZPM2.get(8), + ItemList.Field_Generator_UHV.get(4), ItemList.Circuit_Wafer_UHPIC.get(64), + ItemList.Circuit_Wafer_UHPIC.get(64), ItemList.Circuit_Wafer_SoC2.get(32), + ItemList.Circuit_Parts_DiodeASMD.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorUHV, 64), }, + new FluidStack[] { new FluidStack(solderUEV, 4608), Materials.Naquadria.getMolten(9216), + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 32000) }, + ItemList.ZPM3.get(1), + 4000, + 1600000); + + // Extremely Ultimate Battery + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.ZPM3.get(1L), + 1_200_000, + 128, + 8_000_000, + 16, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.InfinityCatalyst, 32L), + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.InfinityCatalyst, 32L), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, ItemList.ZPM3.get(8), + ItemList.Field_Generator_UEV.get(4), ItemList.Circuit_Wafer_PPIC.get(64), + ItemList.Circuit_Wafer_PPIC.get(64), ItemList.Circuit_Wafer_SoC2.get(64), + ItemList.Circuit_Parts_DiodeXSMD.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUEV, 64), }, + new FluidStack[] { new FluidStack(solderUEV, 9216), Materials.Quantium.getMolten(18_432), + Materials.Naquadria.getMolten(9_216 * 2), Materials.SuperCoolant.getFluid(64_000) }, + ItemList.ZPM4.get(1), + 250 * 20, + 6_400_000); + + if (GTPlusPlusEverglades.isModLoaded()) { + // Insanely Ultimate Battery + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.ZPM4.get(1), + 24_000_000, + 1_280, + 32_000_000, + 32, + new Object[] { ELEMENT.STANDALONE.HYPOGEN.getPlateDouble(32), + ELEMENT.STANDALONE.HYPOGEN.getPlateDouble(32), + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 1 }, ItemList.ZPM4.get(8L), + ItemList.Field_Generator_UIV.get(4), ItemList.Circuit_Wafer_QPIC.get(64), + ItemList.Circuit_Wafer_QPIC.get(64), + GT_ModHandler.getModItem(NewHorizonsCoreMod.ID, "item.RawPicoWafer", 64), + ItemList.Circuit_Parts_DiodeXSMD.get(64), ItemList.Circuit_Parts_InductorXSMD.get(32), + GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.SuperconductorUIV, 64) }, + new FluidStack[] { new FluidStack(solderUEV, 18_432), + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getFluidStack(18_432), + Materials.Quantium.getMolten(18_432), Materials.SuperCoolant.getFluid(128_000) }, + ItemList.ZPM5.get(1), + 300 * 20, + (int) TierEU.RECIPE_UIV); + + // Mega Ultimate Battery + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.ZPM5.get(1L), + 480_000_000, + 12_288, + 128_000_000, + 64, + new Object[] { ELEMENT.STANDALONE.DRAGON_METAL.getPlateDouble(32), + ELEMENT.STANDALONE.DRAGON_METAL.getPlateDouble(32), + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1 }, ItemList.ZPM5.get(8L), + ItemList.Field_Generator_UMV.get(4), ItemList.Circuit_Wafer_QPIC.get(64), + ItemList.Circuit_Wafer_QPIC.get(64), + GT_ModHandler.getModItem(NewHorizonsCoreMod.ID, "item.PicoWafer", 64), + ItemList.Circuit_Parts_DiodeXSMD.get(64), ItemList.Circuit_Parts_InductorXSMD.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUMV, 64) }, + new FluidStack[] { new FluidStack(solderUEV, 36_864), + ELEMENT.STANDALONE.ASTRAL_TITANIUM.getFluidStack(36_864), + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getFluidStack(36_864), + Materials.SuperCoolant.getFluid(256_000) }, + ItemList.ZPM6.get(1), + 350 * 20, + (int) TierEU.RECIPE_UMV); + } + } + + if (GTPlusPlus.isModLoaded()) { + // MK4 Computer + TT_recipeAdder.addResearchableAssemblylineRecipe( + GregtechItemList.Compressed_Fusion_Reactor.get(1), + 320000, + 512, + 2000000, + 1, + new Object[] { GregtechItemList.Casing_Fusion_Internal.get(1), + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Neutronium, 4), + ItemList.Field_Generator_UHV.get(2), ItemList.Circuit_Wafer_QPIC.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUHV, 32) }, + new FluidStack[] { Materials.UUMatter.getFluid(50000), ALLOY.CINOBITE.getFluidStack(9216), + ALLOY.OCTIRON.getFluidStack(9216), ELEMENT.STANDALONE.ASTRAL_TITANIUM.getFluidStack(9216), }, + GregtechItemList.FusionComputer_UV2.get(1), + 6000, + 2000000); + + // MK4 Coils + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Fusion_Coil.get(1L), + 160000, + 512, + 2000000, + 1, + new Object[] { ItemList.Energy_LapotronicOrb2.get(16L), + new Object[] { OrePrefixes.circuit.get(Materials.Master), 16L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 8L }, + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 8), ItemList.Emitter_UHV.get(1), + ItemList.Sensor_UHV.get(1), ItemList.Casing_Fusion_Coil.get(1L), }, + new FluidStack[] { Materials.UUMatter.getFluid(8000L), ALLOY.CINOBITE.getFluidStack(2304), + ALLOY.OCTIRON.getFluidStack(2304), ELEMENT.STANDALONE.ASTRAL_TITANIUM.getFluidStack(2304), }, + GregtechItemList.Casing_Fusion_Internal.get(1), + 1200, + 2000000); + + // MK4 Casing + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Casing_Fusion2.get(1L), + 80000, + 512, + 2000000, + 1, + new Object[] { new Object[] { OrePrefixes.circuit.get(Materials.Data), 16L }, + new Object[] { OrePrefixes.circuit.get(Materials.Elite), 8L }, + GT_OreDictUnificator.get(OrePrefixes.block, Materials.TungstenCarbide, 8), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 8), + ItemList.Electric_Motor_UHV.get(2), ItemList.Electric_Piston_UHV.get(1), + ItemList.Casing_Fusion2.get(1L), }, + new FluidStack[] { Materials.UUMatter.getFluid(1000L), ALLOY.CINOBITE.getFluidStack(576), + ALLOY.OCTIRON.getFluidStack(576), ELEMENT.STANDALONE.ASTRAL_TITANIUM.getFluidStack(576), }, + GregtechItemList.Casing_Fusion_External.get(1), + 300, + 2000000); + + // MK5 Computer + TT_recipeAdder.addResearchableAssemblylineRecipe( + GregtechItemList.FusionComputer_UV2.get(1), + 2560000, + 4096, + (int) TierEU.RECIPE_UEV, + 8, + new Object[] { GregtechItemList.Casing_Fusion_Internal2.get(1), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, + GT_OreDictUnificator.get("plateDenseMetastableOganesson", 4), ItemList.Field_Generator_UEV.get(2), + getItemContainer("PicoWafer").get(64L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.SuperconductorUEV, 32) }, + new FluidStack[] { ELEMENT.getInstance().CURIUM.getFluidStack(9216), + ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getFluidStack(9216), ALLOY.ABYSSAL.getFluidStack(9216), + ELEMENT.STANDALONE.DRAGON_METAL.getFluidStack(9216) }, + GregtechItemList.FusionComputer_UV3.get(1), + 6000, + (int) TierEU.RECIPE_UEV); + + // MK5 Coils + TT_recipeAdder.addResearchableAssemblylineRecipe( + GregtechItemList.Casing_Fusion_Internal.get(1), + 2560000, + 4096, + (int) TierEU.RECIPE_UEV, + 8, + new Object[] { ItemList.Energy_Module.get(16), + new Object[] { OrePrefixes.circuit.get(Materials.Ultimate), 16L }, + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 8L }, + ELEMENT.STANDALONE.RHUGNOR.getPlate(8), ItemList.Emitter_UEV.get(1), ItemList.Sensor_UEV.get(1), + getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 2) }, + new FluidStack[] { ELEMENT.getInstance().NEPTUNIUM.getFluidStack(2304), + ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getFluidStack(2304), ALLOY.ABYSSAL.getFluidStack(2304), + ELEMENT.STANDALONE.DRAGON_METAL.getFluidStack(2304) }, + GregtechItemList.Casing_Fusion_Internal2.get(1), + 1200, + (int) TierEU.RECIPE_UEV); + + // MK5 Casing + TT_recipeAdder.addResearchableAssemblylineRecipe( + GregtechItemList.Casing_Fusion_External.get(1L), + 2560000, + 4096, + (int) TierEU.RECIPE_UEV, + 8, + new Object[] { new Object[] { OrePrefixes.circuit.get(Materials.Elite), 16L }, + new Object[] { OrePrefixes.circuit.get(Materials.Master), 8L }, + GT_OreDictUnificator.get(OrePrefixes.block, Materials.NaquadahAlloy, 8), + ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getPlate(8), ItemList.Electric_Motor_UEV.get(2), + ItemList.Electric_Piston_UEV.get(1), GregtechItemList.Casing_Fusion_External.get(1L) }, + new FluidStack[] { ELEMENT.getInstance().FERMIUM.getFluidStack(1152), + ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getFluidStack(1152), ALLOY.ABYSSAL.getFluidStack(1152), + ELEMENT.STANDALONE.DRAGON_METAL.getFluidStack(1152) }, + GregtechItemList.Casing_Fusion_External2.get(1), + 300, + (int) TierEU.RECIPE_UEV); + } + + if (BloodMagic.isModLoaded() && KubaTech.isModLoaded() && DraconicEvolution.isModLoaded()) { + // Draconic Evolution Fusion Crafter Controller + TT_recipeAdder.addResearchableAssemblylineRecipe( + getModItem(KubaTech.ID, "defc.casing", 1, 8), + 16_777_216, + 1024, + 2_000_000, + 8, + new Object[] { getModItem(GregTech.ID, "gt.blockmachines", 1, 10783), + getModItem(KubaTech.ID, "defc.casing", 1, 8), + GT_OreDictUnificator.get(OrePrefixes.plateDense, MaterialsBotania.GaiaSpirit, 1L), + ItemList.Casing_Coil_AwakenedDraconium.get(8L), ItemList.Electric_Motor_UHV.get(8L), + ItemList.Robot_Arm_UHV.get(4L), new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 4 }, + ItemList.Gravistar.get(4, new Object() {}), getModItem(Thaumcraft.ID, "ItemEldritchObject", 1, 3), + getModItem(BloodMagic.ID, "bloodMagicBaseItems", 8, 29), + getModItem(BloodMagic.ID, "bloodMagicBaseItems", 8, 28), }, + new FluidStack[] { new FluidStack(solderIndalloy, 2880), Materials.Void.getMolten(2880L), + Materials.DraconiumAwakened.getMolten(1440), }, + getModItem(GregTech.ID, "gt.blockmachines", 1, 5001), + 1500, + 8_000_000); + // DE Schematics Cores Tier 1 + TT_recipeAdder.addResearchableAssemblylineRecipe( + getModItem(KubaTech.ID, "defc.casing", 1, 9), + 5_000_000, + 512, + 1_000_000, + 4, + new Object[] { getModItem(DraconicEvolution.ID, "draconicCore", 1, 0), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Draconium, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Ichorium, 1L), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 1 }, }, + new FluidStack[] { Materials.Sunnarium.getMolten(14400L), Materials.Void.getMolten(28800L), }, + getModItem(KubaTech.ID, "kubaitems", 1, 38), + 6000, + 500_000); + + // DE Schematics Cores Tier 2 + TT_recipeAdder.addResearchableAssemblylineRecipe( + getModItem(DraconicEvolution.ID, "draconicCore", 1, 0), + 10_000_000, + 1024, + 4_000_000, + 8, + new Object[] { getModItem(DraconicEvolution.ID, "draconicCore", 4, 0), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Draconium, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 1L), + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1 }, }, + new FluidStack[] { Materials.Neutronium.getMolten(14400L), Materials.Void.getMolten(57600L), }, + getModItem(KubaTech.ID, "kubaitems", 1, 39), + 12000, + 2_000_000); + + // DE Schematics Cores Tier 3 + TT_recipeAdder.addResearchableAssemblylineRecipe( + getModItem(DraconicEvolution.ID, "wyvernCore", 1, 0), + 20_000_000, + 2048, + 16_000_000, + 16, + new Object[] { getModItem(DraconicEvolution.ID, "wyvernCore", 4, 0), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.DraconiumAwakened, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 1L), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L } }, + new FluidStack[] { Materials.Infinity.getMolten(14400L), Materials.Void.getMolten(115200L), }, + getModItem(KubaTech.ID, "kubaitems", 1, 40), + 24000, + 8_000_000); + + // DE Schematics Cores Tier 4 + TT_recipeAdder.addResearchableAssemblylineRecipe( + getModItem(DraconicEvolution.ID, "awakenedCore", 1, 0), + 40_000_000, + 4096, + 64_000_000, + 64, + new Object[] { getModItem(DraconicEvolution.ID, "awakenedCore", 8, 0), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.DraconiumAwakened, 4L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 1L), + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 1 }, }, + new FluidStack[] { MaterialsUEVplus.SpaceTime.getMolten(14400L), Materials.Void.getMolten(230400L), }, + getModItem(KubaTech.ID, "kubaitems", 1, 41), + 36000, + 32_000_000); + } + + // Debug maintenance hatch + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Hatch_AutoMaintenance.get(1L), + 2764800, + 128, + 500000, + 6, + new Object[] { ItemList.Hatch_AutoMaintenance.get(1L), ItemList.Robot_Arm_UV.get(1L), + ItemList.Electric_Pump_UV.get(1L), ItemList.Conveyor_Module_UV.get(1L), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + ItemList.Energy_LapotronicOrb2.get(1L), ItemList.Duct_Tape.get(64L), ItemList.Duct_Tape.get(64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Americium, 64L), }, + new FluidStack[] { Materials.Lubricant.getFluid(256000), new FluidStack(solderIndalloy, 1296), }, + CustomItemList.hatch_CreativeMaintenance.get(1), + 6000, + 500000); + + if (GTPlusPlus.isModLoaded()) { + // Debug uncertainty resolver + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.UncertaintyX_Hatch.get(1L), + 72_000_000, + 5_120, + 16_000_000, + 6, + new Object[] { CustomItemList.eM_Computer_Bus.get(1), CustomItemList.hatch_CreativeMaintenance.get(1), + ItemList.Field_Generator_UIV.get(1L), GregtechItemList.Laser_Lens_Special.get(4), + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 2 }, CustomItemList.DATApipe.get(64), + CustomItemList.DATApipe.get(64), ItemList.Cover_Screen.get(1) }, + new FluidStack[] { Materials.Iridium.getMolten(INGOTS * 100), new FluidStack(solderUEV, 2592), + new FluidStack(ELEMENT.getInstance().NEPTUNIUM.getPlasma(), 20000), + new FluidStack(ELEMENT.getInstance().FERMIUM.getPlasma(), 20000) }, + CustomItemList.hatch_CreativeUncertainty.get(1), + 200 * 20, + (int) TierEU.RECIPE_UIV); + } + } + + private void itemPartsUHVAsslineRecipes() { + + // ---------------------------------------------------------------------- + // ------------------------- Set up information ------------------------- + // ---------------------------------------------------------------------- + + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + + int total_computation = 24000; + int comp_per_second = 32; + int research_eu_per_tick = 500_000; + int research_amperage = 1; + + FluidStack fluid_0 = Materials.Naquadria.getMolten(2592); + FluidStack fluid_1 = new FluidStack(solderIndalloy, 2592); + FluidStack fluid_2 = Materials.Lubricant.getFluid(4000); + + int crafting_time_in_ticks = 1000; + int crafting_eu_per_tick = 500_000; + + // ------------------------------------------------------------- + + // ------------------------- UHV Motor ------------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Motor_UV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.SamariumMagnetic, 4L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.CosmicNeutronium, 8L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.CosmicNeutronium, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, Materials.CosmicNeutronium, 32L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Motor_UHV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // --------------------- UHV Electric Pump --------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Pump_UV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UHV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Neutronium, 2L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CosmicNeutronium, 4L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.CosmicNeutronium, 16L), + new Object[] { OrePrefixes.ring.get(Materials.AnySyntheticRubber), 32L }, + GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.CosmicNeutronium, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Pump_UHV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ----------------------- UHV Conveyor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Conveyor_Module_UV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UHV.get(2L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CosmicNeutronium, 2L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.CosmicNeutronium, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 2L), + new Object[] { OrePrefixes.plate.get(Materials.AnySyntheticRubber), 40L } }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Conveyor_Module_UHV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UHV Robot Arm -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Robot_Arm_UV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.CosmicNeutronium, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, Materials.CosmicNeutronium, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.CosmicNeutronium, 6L), + ItemList.Electric_Motor_UHV.get(2L), ItemList.Electric_Piston_UHV.get(1L), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 2L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.Ultimate), 8L }, + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 6L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Robot_Arm_UHV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UHV Electric Piston -------------------- + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Piston_UV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { ItemList.Electric_Motor_UHV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CosmicNeutronium, 6L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.CosmicNeutronium, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.CosmicNeutronium, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, Materials.CosmicNeutronium, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.CosmicNeutronium, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 4L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Piston_UHV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UHV Emitter ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Emitter_UV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 1L), + ItemList.Electric_Motor_UHV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.CosmicNeutronium, 8L), ItemList.Gravistar.get(8L), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 4L }, + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 7L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Emitter_UHV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UHV Sensor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Sensor_UV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 1L), + ItemList.Electric_Motor_UHV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CosmicNeutronium, 8L), ItemList.Gravistar.get(8L), + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 4L }, + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.ElectrumFlux, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 7L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Sensor_UHV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // --------------------------------------------------------------------- + + // ------------------------ UHV Field Generator ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Field_Generator_UV.get(1), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CosmicNeutronium, 6L), ItemList.Gravistar.get(4L), + ItemList.Emitter_UHV.get(4L), new Object[] { OrePrefixes.circuit.get(Materials.Bio), 4L }, + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Bedrockium, 8L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Field_Generator_UHV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + } + + private void itemPartsUEVAsslineRecipes() { + + // ---------------------------------------------------------------------- + // ------------------------- Set up information ------------------------- + // ---------------------------------------------------------------------- + + Fluid mutated_living_solder = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + + int total_computation = 48_000; + int comp_per_second = 64; + int research_eu_per_tick = 2_000_000; + int research_amperage = 1; + + FluidStack fluid_0 = Materials.Quantium.getMolten(2592); + FluidStack fluid_1 = new FluidStack(mutated_living_solder, 2592); + FluidStack fluid_2 = Materials.Lubricant.getFluid(4000); + + int crafting_time_in_ticks = 1000; + int crafting_eu_per_tick = 2_000_000; + + // ------------------------------------------------------------- + + // ------------------------- UEV Motor ------------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Motor_UHV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TengamAttuned, 8L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Infinity, 16L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Infinity, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, Materials.Infinity, 32L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.CosmicNeutronium, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Motor_UEV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // --------------------- UEV Electric Pump --------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Pump_UHV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UEV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.NetherStar, 2L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 4L), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Infinity, 16L), + new Object[] { OrePrefixes.ring.get(Materials.AnySyntheticRubber), 64L }, + GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.Infinity, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Pump_UEV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ----------------------- UEV Conveyor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Conveyor_Module_UHV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UEV.get(2L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 2L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Infinity, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 2L), + new Object[] { OrePrefixes.plate.get(Materials.AnySyntheticRubber), 64L }, + new Object[] { OrePrefixes.plate.get(Materials.AnySyntheticRubber), 16L } }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Conveyor_Module_UEV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UEV Robot Arm -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Robot_Arm_UHV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Infinity, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, Materials.Infinity, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Infinity, 6L), + ItemList.Electric_Motor_UEV.get(2L), ItemList.Electric_Piston_UEV.get(1L), + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 2L }, + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 8L }, + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 6L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Robot_Arm_UEV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UEV Electric Piston -------------------- + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Piston_UHV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { ItemList.Electric_Motor_UEV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 6L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Infinity, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Infinity, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, Materials.Infinity, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Infinity, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 4L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Piston_UEV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UEV Emitter ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Emitter_UHV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Infinity, 1L), + ItemList.Electric_Motor_UEV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Infinity, 16L), ItemList.Gravistar.get(16L), + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 4L }, + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 7L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Emitter_UEV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UEV Sensor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Sensor_UHV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Infinity, 1L), + ItemList.Electric_Motor_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 8L), + ItemList.Gravistar.get(16), new Object[] { OrePrefixes.circuit.get(Materials.Bio), 4L }, + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.InfinityCatalyst, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 7L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Sensor_UEV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // --------------------------------------------------------------------- + + // ------------------------ UEV Field Generator ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Field_Generator_UHV.get(1), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Infinity, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 6L), ItemList.Gravistar.get(8L), + ItemList.Emitter_UEV.get(4L), new Object[] { OrePrefixes.circuit.get(Materials.Optical), 4L }, + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Draconium, 8L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Field_Generator_UEV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + } + + private void itemPartsUIVAsslineRecipes() { + + // ---------------------------------------------------------------------- + // ------------------------- Set up information ------------------------- + // ---------------------------------------------------------------------- + + Fluid mutated_living_solder = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + Fluid celestialTungsten = FluidRegistry.getFluid("molten.celestialtungsten"); + + int total_computation = 96_000; + int comp_per_second = 128; + int research_eu_per_tick = 8_000_000; + int research_amperage = 1; + + FluidStack fluid_0 = celestialTungsten != null ? new FluidStack(celestialTungsten, 576) : null; + FluidStack fluid_1 = new FluidStack(mutated_living_solder, 2592); + FluidStack fluid_2 = Materials.Lubricant.getFluid(4000); + + int crafting_time_in_ticks = 1000; + int crafting_eu_per_tick = 8_000_000; + + // ------------------------------------------------------------- + + // ------------------------- UIV Motor ------------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Motor_UEV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TengamAttuned, 16L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, MaterialsUEVplus.TranscendentMetal, 16L), + GT_OreDictUnificator.get(OrePrefixes.ring, MaterialsUEVplus.TranscendentMetal, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, MaterialsUEVplus.TranscendentMetal, 32L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Motor_UIV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // --------------------- UIV Electric Pump --------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Pump_UEV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UIV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.DraconiumAwakened, 2L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.TranscendentMetal, 4L), + GT_OreDictUnificator.get(OrePrefixes.screw, MaterialsUEVplus.TranscendentMetal, 16L), + new Object[] { OrePrefixes.ring.get(Materials.AnySyntheticRubber), 64L }, + GT_OreDictUnificator.get(OrePrefixes.rotor, MaterialsUEVplus.TranscendentMetal, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Pump_UIV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ----------------------- UIV Conveyor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Conveyor_Module_UEV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UIV.get(2L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.TranscendentMetal, 2L), + GT_OreDictUnificator.get(OrePrefixes.ring, MaterialsUEVplus.TranscendentMetal, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, MaterialsUEVplus.TranscendentMetal, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 2L), + new Object[] { OrePrefixes.plate.get(Materials.AnySyntheticRubber), 64L }, + new Object[] { OrePrefixes.plate.get(Materials.AnySyntheticRubber), 16L } }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Conveyor_Module_UIV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UIV Robot Arm -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Robot_Arm_UEV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, MaterialsUEVplus.TranscendentMetal, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, MaterialsUEVplus.TranscendentMetal, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, MaterialsUEVplus.TranscendentMetal, 6L), + ItemList.Electric_Motor_UIV.get(2L), ItemList.Electric_Piston_UIV.get(1L), + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 2L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 8L }, + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 6L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Robot_Arm_UIV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UIV Electric Piston -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Piston_UEV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { ItemList.Electric_Motor_UIV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.TranscendentMetal, 6L), + GT_OreDictUnificator.get(OrePrefixes.ring, MaterialsUEVplus.TranscendentMetal, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, MaterialsUEVplus.TranscendentMetal, 64L), + GT_OreDictUnificator.get(OrePrefixes.stick, MaterialsUEVplus.TranscendentMetal, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, MaterialsUEVplus.TranscendentMetal, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, MaterialsUEVplus.TranscendentMetal, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 4L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Electric_Piston_UIV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UIV Emitter ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Emitter_UEV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.TranscendentMetal, 1L), + ItemList.Electric_Motor_UIV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.stick, MaterialsUEVplus.TranscendentMetal, 16L), + ItemList.Gravistar.get(32L), new Object[] { OrePrefixes.circuit.get(Materials.Optical), 4L }, + getModItem(GTPlusPlus.ID, "itemFoilArceusAlloy2B", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilLafiumCompound", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilCinobiteA243", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilPikyonium64B", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 7L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Emitter_UIV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UIV Sensor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Sensor_UEV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.TranscendentMetal, 1L), + ItemList.Electric_Motor_UIV.get(1), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.TranscendentMetal, 8L), + ItemList.Gravistar.get(32), new Object[] { OrePrefixes.circuit.get(Materials.Optical), 4L }, + getModItem(GTPlusPlus.ID, "itemFoilArceusAlloy2B", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilLafiumCompound", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilCinobiteA243", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilPikyonium64B", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 7L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Sensor_UIV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // --------------------------------------------------------------------- + + // ------------------------ UIV Field Generator ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Field_Generator_UEV.get(1), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.TranscendentMetal, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.TranscendentMetal, 6L), + ItemList.Gravistar.get(16L), ItemList.Emitter_UIV.get(4L), + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 4 }, + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Infinity, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NetherStar, 8L) }, + new FluidStack[] { fluid_0, fluid_1 }, + ItemList.Field_Generator_UIV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // --------------------------------------------------------------------- + + } + + private void itemPartsUMVAsslineRecipes() { + + // ---------------------------------------------------------------------- + // ------------------------- Set up information ------------------------- + // ---------------------------------------------------------------------- + + Fluid mutated_living_solder = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + Fluid hypogen = FluidRegistry.getFluid("molten.hypogen"); + Fluid celestialTungsten = FluidRegistry.getFluid("molten.celestialtungsten"); + + int total_computation = 192_000; + int comp_per_second = 256; + int research_eu_per_tick = 32_000_000; + int research_amperage = 1; + + FluidStack fluid_0 = hypogen != null ? new FluidStack(hypogen, 576) : null; + FluidStack fluid_1 = celestialTungsten != null ? new FluidStack(celestialTungsten, 576) : null; + FluidStack fluid_2 = new FluidStack(mutated_living_solder, 2592); + FluidStack fluid_3 = Materials.Lubricant.getFluid(4000); + + int crafting_time_in_ticks = 1000; + int crafting_eu_per_tick = 32_000_000; + + // ------------------------------------------------------------- + + // ------------------------- UMV Motor ------------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Motor_UIV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TengamAttuned, 32L), + GT_OreDictUnificator.get(OrePrefixes.stickLong, MaterialsUEVplus.SpaceTime, 16L), + GT_OreDictUnificator.get(OrePrefixes.ring, MaterialsUEVplus.SpaceTime, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, MaterialsUEVplus.SpaceTime, 32L), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2, fluid_3 }, + ItemList.Electric_Motor_UMV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // --------------------- UMV Electric Pump --------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Pump_UIV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UMV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Infinity, 2L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 4L), + GT_OreDictUnificator.get(OrePrefixes.screw, MaterialsUEVplus.SpaceTime, 16L), + new Object[] { OrePrefixes.ring.get(Materials.AnySyntheticRubber), 64L }, + GT_OreDictUnificator.get(OrePrefixes.rotor, MaterialsUEVplus.SpaceTime, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 2L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2, fluid_3 }, + ItemList.Electric_Pump_UMV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ----------------------- UMV Conveyor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Conveyor_Module_UIV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { ItemList.Electric_Motor_UMV.get(2L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 2L), + GT_OreDictUnificator.get(OrePrefixes.ring, MaterialsUEVplus.SpaceTime, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, MaterialsUEVplus.SpaceTime, 64L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 2L), + new Object[] { OrePrefixes.plate.get(Materials.AnySyntheticRubber), 64L }, + new Object[] { OrePrefixes.plate.get(Materials.AnySyntheticRubber), 16L } }, + new FluidStack[] { fluid_0, fluid_1, fluid_2, fluid_3 }, + ItemList.Conveyor_Module_UMV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UMV Robot Arm -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Robot_Arm_UIV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.stickLong, MaterialsUEVplus.SpaceTime, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, MaterialsUEVplus.SpaceTime, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, MaterialsUEVplus.SpaceTime, 6L), + ItemList.Electric_Motor_UMV.get(2L), ItemList.Electric_Piston_UMV.get(1L), + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 2L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 8L }, + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 6L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2, fluid_3 }, + ItemList.Robot_Arm_UMV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // -------------------- UMV Electric Piston -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Piston_UIV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new ItemStack[] { ItemList.Electric_Motor_UMV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 6L), + GT_OreDictUnificator.get(OrePrefixes.ring, MaterialsUEVplus.SpaceTime, 8L), + GT_OreDictUnificator.get(OrePrefixes.round, MaterialsUEVplus.SpaceTime, 64L), + GT_OreDictUnificator.get(OrePrefixes.stick, MaterialsUEVplus.SpaceTime, 8L), + GT_OreDictUnificator.get(OrePrefixes.gear, MaterialsUEVplus.SpaceTime, 2L), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, MaterialsUEVplus.SpaceTime, 4L), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 4L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2, fluid_3 }, + ItemList.Electric_Piston_UMV.get(1), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UMV Emitter ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Emitter_UIV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.SpaceTime, 1L), + ItemList.Electric_Motor_UMV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.stick, MaterialsUEVplus.SpaceTime, 16L), + ItemList.Gravistar.get(64), new Object[] { OrePrefixes.circuit.get(Materials.Piko), 4L }, + getModItem(GTPlusPlus.ID, "itemFoilCelestialTungsten", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilQuantum", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilAstralTitanium", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilTitansteel", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 7L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Emitter_UMV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // ------------------------------------------------------------- + + // ------------------------ UMV Sensor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Sensor_UIV.get(1L), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.SpaceTime, 1L), + ItemList.Electric_Motor_UMV.get(1), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 8L), ItemList.Gravistar.get(64), + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 4L }, + getModItem(GTPlusPlus.ID, "itemFoilCelestialTungsten", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilQuantum", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilAstralTitanium", 64, 0), + getModItem(GTPlusPlus.ID, "itemFoilTitansteel", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 7L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Sensor_UMV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // --------------------------------------------------------------------- + + // ------------------------ UMV Field Generator ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Field_Generator_UIV.get(1), + total_computation, + comp_per_second, + research_eu_per_tick, + research_amperage, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.SpaceTime, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, MaterialsUEVplus.SpaceTime, 6L), + ItemList.Gravistar.get(32L), ItemList.Emitter_UMV.get(4L), + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 4 }, + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + getModItem(GTPlusPlus.ID, "itemFineWireHypogen", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Quantium, 8L) }, + new FluidStack[] { fluid_0, fluid_1, fluid_2 }, + ItemList.Field_Generator_UMV.get(1L), + crafting_time_in_ticks, + crafting_eu_per_tick); + + // --------------------------------------------------------------------- + + } + + private void itemPartsUXVAsslineRecipes() { + + // ---------------------------------------------------------------------- + // ------------------------- Set up information ------------------------- + // ---------------------------------------------------------------------- + + Fluid mutatedLivingSolder = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + + FluidStack moltenMHDCSM_576 = MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(576); + FluidStack moltenSpaceTime_576 = MaterialsUEVplus.SpaceTime.getMolten(576); + FluidStack moltenUniversium_576 = MaterialsUEVplus.Universium.getMolten(576); + FluidStack lubricantFluid_8000 = Materials.Lubricant.getFluid(8000); + FluidStack solderingAlloy_14_400 = new FluidStack(mutatedLivingSolder, 14_400); + + int totalComputation = 384_000; + int compPerSecond = 512; + int researchEuPerTick = 64_000_000; + int researchAmperage = 2; + + int craftingTimeInTicks = 1000; + int craftingEuPerTick = (int) TierEU.RECIPE_UMV; + + // ------------------------------------------------------------- + + // ------------------------- UXV Motor ------------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Motor_UMV.get(1L), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new ItemStack[] { ItemList.EnergisedTesseract.get(1), + GT_OreDictUnificator + .get(OrePrefixes.stickLong, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 16L), + GT_OreDictUnificator + .get(OrePrefixes.ring, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8L), + GT_OreDictUnificator + .get(OrePrefixes.round, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 32L), + + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.SuperconductorUMVBase, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.SuperconductorUMVBase, 64L), + + GT_OreDictUnificator + .get(OrePrefixes.wireFine, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64L), + GT_OreDictUnificator + .get(OrePrefixes.wireFine, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64L), + + GT_OreDictUnificator.get(OrePrefixes.wireFine, MaterialsUEVplus.Universium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, MaterialsUEVplus.Universium, 64L), + + GT_OreDictUnificator.get("wireFineShirabon", 64L), GT_OreDictUnificator.get("wireFineShirabon", 64L), + + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 2L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 2L), + Materials.Neutronium.getNanite(4) }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, lubricantFluid_8000 }, + ItemList.Electric_Motor_UXV.get(1L), + craftingTimeInTicks, + craftingEuPerTick); + + // ------------------------------------------------------------- + + // --------------------- UXV Electric Pump --------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Pump_UMV.get(1L), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { ItemList.Electric_Motor_UXV.get(1L), + GT_OreDictUnificator.get(OrePrefixes.pipeLarge, MaterialsUEVplus.SpaceTime, 2L), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 4L), + GT_OreDictUnificator + .get(OrePrefixes.screw, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 16L), + GT_OreDictUnificator.get(OrePrefixes.ring, MaterialsKevlar.Kevlar, 64L), + GT_OreDictUnificator.get("ringRadoxPoly", 64L), + GT_OreDictUnificator + .get(OrePrefixes.rotor, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 4L), + GT_OreDictUnificator.get("rotorShirabon", 4), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 2L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 2L), + Materials.Neutronium.getNanite(4) }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, lubricantFluid_8000 }, + ItemList.Electric_Pump_UXV.get(1), + craftingTimeInTicks, + craftingEuPerTick); + + // ------------------------------------------------------------- + + // ----------------------- UXV Conveyor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Conveyor_Module_UMV.get(1L), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { ItemList.Electric_Motor_UXV.get(2L), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 2L), + GT_OreDictUnificator + .get(OrePrefixes.ring, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8L), + GT_OreDictUnificator + .get(OrePrefixes.round, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 2L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 2L), + MaterialsKevlar.Kevlar.getPlates(64), MaterialsKevlar.Kevlar.getPlates(16), + GT_OreDictUnificator.get("plateRadoxPoly", 64L), GT_OreDictUnificator.get("plateRadoxPoly", 16L), + Materials.Neutronium.getNanite(4) }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, lubricantFluid_8000 }, + ItemList.Conveyor_Module_UXV.get(1), + craftingTimeInTicks, + craftingEuPerTick); + + // ------------------------------------------------------------- + + // -------------------- UXV Robot Arm -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Robot_Arm_UMV.get(1L), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { + GT_OreDictUnificator + .get(OrePrefixes.stickLong, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8L), + GT_OreDictUnificator + .get(OrePrefixes.gear, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 2L), + GT_OreDictUnificator.get("gearGtShirabon", 2L), + GT_OreDictUnificator + .get(OrePrefixes.gearGtSmall, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 6L), + GT_OreDictUnificator.get("gearGtSmallShirabon", 6L), ItemList.Electric_Motor_UXV.get(2L), + ItemList.Electric_Piston_UXV.get(1L), new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 2L }, + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 8L }, + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 6L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 6L), + Materials.Neutronium.getNanite(8) }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, lubricantFluid_8000 }, + ItemList.Robot_Arm_UXV.get(1L), + craftingTimeInTicks, + craftingEuPerTick); + + // ------------------------------------------------------------- + + // -------------------- UXV Electric Piston -------------------- + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Electric_Piston_UMV.get(1L), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new ItemStack[] { ItemList.Electric_Motor_UXV.get(1L), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 6L), + GT_OreDictUnificator + .get(OrePrefixes.ring, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8L), + GT_OreDictUnificator + .get(OrePrefixes.round, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64L), + GT_OreDictUnificator + .get(OrePrefixes.stick, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8L), + GT_OreDictUnificator + .get(OrePrefixes.gear, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 2L), + GT_OreDictUnificator.get("gearGtShirabon", 2L), + GT_OreDictUnificator + .get(OrePrefixes.gearGtSmall, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 4L), + GT_OreDictUnificator.get("gearGtSmallShirabon", 4L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 4L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 4L), + Materials.Neutronium.getNanite(4) }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, lubricantFluid_8000 }, + ItemList.Electric_Piston_UXV.get(1), + craftingTimeInTicks, + craftingEuPerTick); + + // ------------------------------------------------------------- + + // ------------------------ UXV Emitter ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Emitter_UMV.get(1L), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { + GT_OreDictUnificator + .get(OrePrefixes.frameGt, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 1L), + ItemList.Electric_Motor_UXV.get(1L), + GT_OreDictUnificator + .get(OrePrefixes.stick, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 16L), + ItemList.NuclearStar.get(16), new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 4L }, + GT_OreDictUnificator + .get(OrePrefixes.foil, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64), + GT_OreDictUnificator.get("foilShirabon", 64), + GT_OreDictUnificator.get(OrePrefixes.foil, MaterialsUEVplus.SpaceTime, 64), + GT_OreDictUnificator.get(OrePrefixes.foil, MaterialsUEVplus.Universium, 64), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 7L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 7L), + Materials.Neutronium.getNanite(8) + + }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, solderingAlloy_14_400 }, + ItemList.Emitter_UXV.get(1L), + craftingTimeInTicks, + craftingEuPerTick); + + // ------------------------------------------------------------- + + // ------------------------ UXV Sensor ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Sensor_UMV.get(1L), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { + GT_OreDictUnificator + .get(OrePrefixes.frameGt, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 1L), + ItemList.Electric_Motor_UXV.get(1L), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8L), + ItemList.NuclearStar.get(16), new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 4L }, + GT_OreDictUnificator + .get(OrePrefixes.foil, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64), + GT_OreDictUnificator.get("foilShirabon", 64), + GT_OreDictUnificator.get(OrePrefixes.foil, MaterialsUEVplus.SpaceTime, 64), + GT_OreDictUnificator.get(OrePrefixes.foil, MaterialsUEVplus.Universium, 64), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 7L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 7L), + Materials.Neutronium.getNanite(8) }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, solderingAlloy_14_400 }, + ItemList.Sensor_UXV.get(1L), + craftingTimeInTicks, + craftingEuPerTick); + + // --------------------------------------------------------------------- + + // ------------------------ UXV Field Generator ------------------------ + + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Field_Generator_UMV.get(1), + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { + GT_OreDictUnificator + .get(OrePrefixes.frameGt, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 1L), + GT_OreDictUnificator + .get(OrePrefixes.plate, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 6L), + ItemList.NuclearStar.get(64L), ItemList.Emitter_UXV.get(4L), + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 8 }, + + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.SuperconductorUMVBase, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.SuperconductorUMVBase, 64L), + GT_OreDictUnificator + .get(OrePrefixes.wireFine, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64L), + GT_OreDictUnificator + .get(OrePrefixes.wireFine, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, MaterialsUEVplus.Universium, 64L), + GT_OreDictUnificator.get(OrePrefixes.wireFine, MaterialsUEVplus.Universium, 64L), + GT_OreDictUnificator.get("wireFineShirabon", 64L), GT_OreDictUnificator.get("wireFineShirabon", 64L), + + GT_OreDictUnificator.get(OrePrefixes.wireGt04, MaterialsUEVplus.SpaceTime, 8L), + GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Infinity, 8L), + Materials.Neutronium.getNanite(12) }, + new FluidStack[] { moltenMHDCSM_576, moltenSpaceTime_576, moltenUniversium_576, solderingAlloy_14_400 }, + ItemList.Field_Generator_UXV.get(1L), + craftingTimeInTicks, + craftingEuPerTick); + + // --------------------------------------------------------------------- + + } + + private void addEOHRecipes() { + Fluid solderUEV = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + ItemStack largeShirabonPlate = TGregUtils.newItemStack(Materials.get("Shirabon"), PartTypes.LargePlate, 1); + ItemStack largeInfinityPlate = new ItemStack(TinkerTools.largePlate, 1, Tonkers.infinityMetalId); + ItemStack largeBedrockiumPlate = new ItemStack(TinkerTools.largePlate, 1, ExtraUtils.tcon_bedrock_material_id); + ItemStack largeCosmicNeutroniumPlate = new ItemStack(TinkerTools.largePlate, 1, Tonkers.neutroniumId); + + final FluidStack[] specialFluid = new FluidStack[] { MaterialsUEVplus.SpaceTime.getMolten(1_440), + MaterialsUEVplus.SpaceTime.getMolten(1_440), MaterialsUEVplus.SpaceTime.getMolten(1_440), + MaterialsUEVplus.SpaceTime.getMolten(1_440), MaterialsUEVplus.SpaceTime.getMolten(1_440), + MaterialsUEVplus.SpaceTime.getMolten(1_440), MaterialsUEVplus.SpaceTime.getMolten(1_440), + MaterialsUEVplus.SpaceTime.getMolten(1_440), MaterialsUEVplus.SpaceTime.getMolten(1_440) }; + + final ItemStack[] plateList = new ItemStack[] { + // Dense Shirabon plate. + GT_OreDictUnificator.get("boltShirabon", 2), + GT_OreDictUnificator.get(OrePrefixes.bolt, MaterialsUEVplus.WhiteDwarfMatter, 2), + GT_OreDictUnificator.get(OrePrefixes.bolt, MaterialsUEVplus.WhiteDwarfMatter, 8), + GT_OreDictUnificator.get(OrePrefixes.bolt, MaterialsUEVplus.WhiteDwarfMatter, 32), + GT_OreDictUnificator.get(OrePrefixes.bolt, MaterialsUEVplus.BlackDwarfMatter, 2), + GT_OreDictUnificator.get(OrePrefixes.bolt, MaterialsUEVplus.BlackDwarfMatter, 8), + GT_OreDictUnificator.get(OrePrefixes.bolt, MaterialsUEVplus.BlackDwarfMatter, 32), + GT_OreDictUnificator + .get(OrePrefixes.bolt, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 2), + GT_OreDictUnificator + .get(OrePrefixes.bolt, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 8) }; + + // EOH Controller Recipe. + { + TT_recipeAdder.addResearchableAssemblylineRecipe( + ItemList.Machine_Multi_PlasmaForge.get(1), + 512_000_000, // total comp + 2 * 16_384, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + 64, // amperage + new Object[] { + // Space elevator controller. + getModItem(GregTech.ID, "gt.blockmachines", 16, 14003), ItemList.Machine_Multi_PlasmaForge.get(4), + + CustomItemList.EOH_Infinite_Energy_Casing.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier0.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier0.get(1), + CustomItemList.StabilisationFieldGeneratorTier0.get(1), + + CustomItemList.Machine_Multi_Computer.get(64), + // Ultimate Time Anomaly. + getModItem(GregTech.ID, "gt.blockmachines", 64, 11107), ItemList.Quantum_Chest_IV.get(64), + // Void miner III. + getModItem(GregTech.ID, "gt.blockmachines", 64, 12739), + + ItemList.Field_Generator_UMV.get(16), ItemList.Robot_Arm_UMV.get(16), ItemList.ZPM4.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUMV, 64) }, + new FluidStack[] { MaterialsUEVplus.Time.getMolten(144_000), MaterialsUEVplus.Space.getMolten(144_000), + FluidUtils.getFluidStack("molten.metastable oganesson", 144 * 256 * 4), + FluidUtils.getFluidStack("molten.shirabon", 144 * 256 * 4), }, + CustomItemList.Machine_Multi_EyeOfHarmony.get(1), + 400 * MINUTES, + (int) TierEU.RECIPE_UMV); + } + + // EOH Spatial Individual Casing + { + TT_recipeAdder.addResearchableAssemblylineRecipe( + // Dyson Swarm Module Deployment Unit Base Casing + getModItem(GalaxySpace.ID, "dysonswarmparts", 1, 2), + 256_000_000, // total comp + 16_384, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + 32, // amperage + new Object[] { + // Space elevator blocks. + getModItem(GTNHIntergalactic.ID, "gt.blockcasingsSE", 64, 0), + // Cosmic neutronium block. + getModItem(Avaritia.ID, "Resource_Block", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Neutronium, 64), + GT_OreDictUnificator.get(OrePrefixes.nanite, Materials.Neutronium, 48), largeBedrockiumPlate, + largeCosmicNeutroniumPlate, largeShirabonPlate, largeInfinityPlate, + // UV Solar panel + getModItem(SuperSolarPanels.ID, "PhotonicSolarPanel", 1, 0), ItemList.Quantum_Chest_IV.get(1), + // Gravitation Engine + getModItem(GraviSuite.ID, "itemSimpleItem", 64, 3), ItemList.EnergisedTesseract.get(1) }, + + new FluidStack[] { Materials.Neutronium.getMolten(144 * 256 * 4), + Materials.CosmicNeutronium.getMolten(144 * 256 * 4), new FluidStack(solderUEV, 144 * 256 * 2), + MaterialsUEVplus.Space.getMolten(1_440) }, + CustomItemList.EOH_Reinforced_Spatial_Casing.get(4), + 10_000, + (int) TierEU.RECIPE_UMV); + } + + // EOH Spacetime Compression + { + // ME Digital singularity. + final ItemStack ME_Singularity = getModItem( + "appliedenergistics2", + "item.ItemExtremeStorageCell.Singularity", + 1); + final ItemStack baseCasing = CustomItemList.EOH_Reinforced_Spatial_Casing.get(1); + + int baseCompPerSec = 16_384; + + int set; + int tier; + int absoluteTier; + + // T0 - Shirabon + // T1 - White Dwarf Matter + // T2 - White Dwarf Matter + // T3 - White Dwarf Matter + // T4 - Black Dwarf Matter + // T5 - Black Dwarf Matter + // T6 - Black Dwarf Matter + // T7 - Black Dwarf Matter + // T8 - MHDCSM. + + { + tier = 1; + set = 1; + + absoluteTier = 0; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.EOH_Reinforced_Spatial_Casing.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T7 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Cosmic fabric manipulator + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 8), ME_Singularity, + plateList[absoluteTier], getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier] }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier0.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + + tier++; + absoluteTier = 1; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier0.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T7 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Cosmic fabric manipulator + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 8), ME_Singularity, ME_Singularity, + plateList[absoluteTier], getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier] }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier1.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + + tier++; + absoluteTier = 2; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier1.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T7 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Cosmic fabric manipulator + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 8), ME_Singularity, ME_Singularity, + ME_Singularity, plateList[absoluteTier], getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier], }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier2.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + } + + { + tier = 1; + set = 2; + absoluteTier = 3; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier2.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T8 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Infinity infused manipulator + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 9), ME_Singularity, ME_Singularity, + ME_Singularity, ME_Singularity, plateList[absoluteTier], + getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier], }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier3.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + + tier++; + absoluteTier = 4; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier3.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T8 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Infinity infused manipulator + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 9), ME_Singularity, ME_Singularity, + ME_Singularity, ME_Singularity, ME_Singularity, plateList[absoluteTier], + getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier], }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier4.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + + tier++; + absoluteTier = 5; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier4.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T8 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Infinity infused manipulator + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 9), ME_Singularity, ME_Singularity, + ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, plateList[absoluteTier], + getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier], }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier5.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + } + + { + tier = 1; + set = 3; + absoluteTier = 6; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier5.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T9 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Spacetime continuum ripper + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 10), ME_Singularity, + ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, + plateList[absoluteTier], getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier], }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier6.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + + tier++; + absoluteTier = 7; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier6.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T9 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Spacetime continuum ripper + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 10), ME_Singularity, + ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, + ME_Singularity, plateList[absoluteTier], getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier], }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier7.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + + tier++; + absoluteTier = 8; + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier7.get(1), + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, + // T9 Yotta cell. + getModItem(GoodGenerator.ID, "yottaFluidTankCells", tier, (5 + set)), + // quantum tank V (max tier) + ItemList.Quantum_Tank_IV.get(4 * (1 + absoluteTier)), + // Inf chest + getModItem(AvaritiaAddons.ID, "InfinityChest", absoluteTier + 1), + // Spacetime continuum ripper + getModItem(GTPlusPlus.ID, "gtplusplus.blockcasings.5", tier, 10), ME_Singularity, + ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, ME_Singularity, + ME_Singularity, ME_Singularity, plateList[absoluteTier], + getItemContainer("QuantumCircuit").get(set) }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier], }, + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(1), + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + } + } + + // EOH Time Dilation Field Generators. + { + final ItemStack baseCasing = CustomItemList.EOH_Reinforced_Temporal_Casing.get(1); + + int baseCompPerSec = 16_384; + + // T0 - Shirabon + // T1 - White Dwarf Matter + // T2 - White Dwarf Matter + // T3 - White Dwarf Matter + // T4 - Black Dwarf Matter + // T5 - Black Dwarf Matter + // T6 - Black Dwarf Matter + // T7 - Black Dwarf Matter + // T8 - MHDCSM. + + final ItemStack[] fusionReactors = new ItemStack[] { ItemList.FusionComputer_ZPMV.get(1), + ItemList.FusionComputer_ZPMV.get(2), ItemList.FusionComputer_ZPMV.get(3), + ItemList.FusionComputer_UV.get(1), ItemList.FusionComputer_UV.get(2), ItemList.FusionComputer_UV.get(3), + // MK4 Fusion Computer. + getModItem(GregTech.ID, "gt.blockmachines", 1, 965), + getModItem(GregTech.ID, "gt.blockmachines", 2, 965), + getModItem(GregTech.ID, "gt.blockmachines", 3, 965) }; + + final ItemStack[] fusionCoils = new ItemStack[] { getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 1), + getModItem(GoodGenerator.ID, "compactFusionCoil", 2, 1), + getModItem(GoodGenerator.ID, "compactFusionCoil", 3, 1), + getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 2), + getModItem(GoodGenerator.ID, "compactFusionCoil", 2, 2), + getModItem(GoodGenerator.ID, "compactFusionCoil", 3, 2), + getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 3), + getModItem(GoodGenerator.ID, "compactFusionCoil", 2, 3), + getModItem(GoodGenerator.ID, "compactFusionCoil", 3, 3) }; + + final ItemStack[] researchStuff = new ItemStack[] { baseCasing, + CustomItemList.TimeAccelerationFieldGeneratorTier0.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier1.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier2.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier3.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier4.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier5.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier6.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier7.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(1) }; + + // Spectral Components + // Cycling should fix issues with conflicting recipes for T1-T2, T4-T5 & T7-T8 + final ItemStack[] spectralComponents = new ItemStack[] { + // Red Spectral Component + getModItem(SuperSolarPanels.ID, "redcomponent", 64), + // Green Spectral Component + getModItem(SuperSolarPanels.ID, "greencomponent", 64), + // Blue Spectral Component + getModItem(SuperSolarPanels.ID, "bluecomponent", 64) }; + + for (int absoluteTier = 0; absoluteTier < 9; absoluteTier++) { + + TT_recipeAdder.addResearchableAssemblylineRecipe( + researchStuff[absoluteTier], + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { baseCasing, fusionReactors[absoluteTier], fusionCoils[absoluteTier], + // UV Solar panel + getModItem(SuperSolarPanels.ID, "PhotonicSolarPanel", absoluteTier + 1, 0), + + getItemContainer("QuantumCircuit").get(absoluteTier + 1), + // Red Spectral Component + spectralComponents[absoluteTier % spectralComponents.length], + // Green Spectral Component + spectralComponents[(absoluteTier + 1) % spectralComponents.length], + // Blue Spectral Component + spectralComponents[(absoluteTier + 2) % spectralComponents.length], + + plateList[absoluteTier], + // Dyson Swarm Module Deployment Unit Base Casing + getModItem(GalaxySpace.ID, "dysonswarmparts", (absoluteTier + 1) * 4, 2), + // Dyson Swarm Energy Receiver Dish Block + getModItem(GalaxySpace.ID, "dysonswarmparts", (absoluteTier + 1) * 4, 1), + // Ultimate Time Anomaly. + getModItem(GregTech.ID, "gt.blockmachines", (absoluteTier + 1) * 4, 11107), + + ItemList.Energy_Module.get(absoluteTier + 1), GT_OreDictUnificator + .get(OrePrefixes.wireGt01, Materials.SuperconductorUMV, (absoluteTier + 1) * 4), + + }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Time.getMolten(1_440 * (absoluteTier + 1)), specialFluid[absoluteTier] }, + researchStuff[absoluteTier + 1], + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + } + + } + + // EOH Stabilisation Field Generators. + { + final ItemStack baseCasing = CustomItemList.EOH_Infinite_Energy_Casing.get(1); + + int baseCompPerSec = 16_384; + + // T0 - Shirabon + // T1 - White Dwarf Matter + // T2 - White Dwarf Matter + // T3 - White Dwarf Matter + // T4 - Black Dwarf Matter + // T5 - Black Dwarf Matter + // T6 - Black Dwarf Matter + // T7 - Black Dwarf Matter + // T8 - MHDCSM. + + final ItemStack[] researchStuff = new ItemStack[] { baseCasing, + CustomItemList.StabilisationFieldGeneratorTier0.get(1), + CustomItemList.StabilisationFieldGeneratorTier1.get(1), + CustomItemList.StabilisationFieldGeneratorTier2.get(1), + CustomItemList.StabilisationFieldGeneratorTier3.get(1), + CustomItemList.StabilisationFieldGeneratorTier4.get(1), + CustomItemList.StabilisationFieldGeneratorTier5.get(1), + CustomItemList.StabilisationFieldGeneratorTier6.get(1), + CustomItemList.StabilisationFieldGeneratorTier7.get(1), + CustomItemList.StabilisationFieldGeneratorTier8.get(1) }; + + final ItemStack[] timeCasings = new ItemStack[] { CustomItemList.TimeAccelerationFieldGeneratorTier0.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier1.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier2.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier3.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier4.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier5.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier6.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier7.get(1), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(1) }; + + final ItemStack[] spatialCasings = new ItemStack[] { + CustomItemList.SpacetimeCompressionFieldGeneratorTier0.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier1.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier2.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier3.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier4.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier5.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier6.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier7.get(1), + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(1) }; + + for (int absoluteTier = 0; absoluteTier < 9; absoluteTier++) { + + // spotless:off + TT_recipeAdder.addResearchableAssemblylineRecipe( + researchStuff[absoluteTier], + (absoluteTier + 1) * 48_000_000, // total comp + (absoluteTier + 1) * baseCompPerSec, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + (absoluteTier + 1) * 8, // amperage + new Object[] { + timeCasings[absoluteTier], + spatialCasings[absoluteTier], + baseCasing, + // Dyson Swarm Module. + getModItem(GalaxySpace.ID, "item.DysonSwarmParts", 4 * (absoluteTier + 1), 0), + + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.SuperconductorUMVBase, 4 * (absoluteTier + 1)), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.SuperconductorUIVBase, 4 * (absoluteTier + 1)), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.SuperconductorUEVBase, 4 * (absoluteTier + 1)), + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Longasssuperconductornameforuhvwire, 4 * (absoluteTier + 1)), + + // Gravitation Engine + getModItem(GraviSuite.ID, "itemSimpleItem", 64, 3), + getModItem(GraviSuite.ID, "itemSimpleItem", 64, 3), + getModItem(GraviSuite.ID, "itemSimpleItem", 64, 3), + getModItem(GraviSuite.ID, "itemSimpleItem", 64, 3), + + plateList[absoluteTier], + getItemContainer("QuantumCircuit").get(2 * (absoluteTier + 1)), + GT_OreDictUnificator.get(OrePrefixes.gearGt, MaterialsUEVplus.SpaceTime, absoluteTier + 1), + GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, MaterialsUEVplus.SpaceTime, absoluteTier + 1) + + + }, + new FluidStack[] { new FluidStack(solderUEV, (int) (2_880 * pow(2L, absoluteTier))), + MaterialsUEVplus.Time.getMolten(1_440 * (absoluteTier + 1)), + MaterialsUEVplus.Space.getMolten(1_440 * (absoluteTier + 1)), + specialFluid[absoluteTier] }, + researchStuff[absoluteTier + 1], + (absoluteTier + 1) * 4_000 * 20, + (int) TierEU.RECIPE_UMV); + // spotless:on + } + + } + + // EOH Reinforced Temporal casings + { + TT_recipeAdder.addResearchableAssemblylineRecipe( + // Ultimate Time Anomaly. + getModItem(GregTech.ID, "gt.blockmachines", 1, 11107), + 256_000_000, // total comp + 16_384, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + 32, // amperage + new Object[] { + // Space elevator blocks. + getModItem(GTNHIntergalactic.ID, "gt.blockcasingsSE", 64, 0), + // Cosmic neutronium block. + getModItem(Avaritia.ID, "Resource_Block", 64, 0), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Neutronium, 64), + GT_OreDictUnificator.get(OrePrefixes.nanite, Materials.Neutronium, 48), + // Large Bedrockium Plate + largeBedrockiumPlate, largeCosmicNeutroniumPlate, largeShirabonPlate, largeInfinityPlate, + // UV Solar panel + getModItem(SuperSolarPanels.ID, "PhotonicSolarPanel", 1, 0), + // Ultimate Time Anomaly. + getModItem(GregTech.ID, "gt.blockmachines", 4, 11107), + // Gravitation Engine. + getModItem(GraviSuite.ID, "itemSimpleItem", 64, 3), ItemList.EnergisedTesseract.get(1) }, + + new FluidStack[] { Materials.Neutronium.getMolten(144 * 256 * 4), + Materials.CosmicNeutronium.getMolten(144 * 256 * 4), new FluidStack(solderUEV, 144 * 256 * 2), + MaterialsUEVplus.Time.getMolten(1_440) }, + CustomItemList.EOH_Reinforced_Temporal_Casing.get(4), + 10_000, + (int) TierEU.RECIPE_UMV); + } + + // EOH Infinite Spacetime Energy Boundary Casing + { + TT_recipeAdder.addResearchableAssemblylineRecipe( + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUMV, 1), + 256_000_000, // total comp + 16_384, // comp/s + (int) TierEU.RECIPE_MAX, // eu/t + 32, // amperage + new Object[] { getModItem(GregTech.ID, "gt.blockmachines", 1, 13106), + // UV Solar panel + getModItem(SuperSolarPanels.ID, "PhotonicSolarPanel", 1, 0), + // UHV Capacitor block + getModItem(KekzTech.ID, "kekztech_lapotronicenergyunit_block", 1, 5), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUMV, 4), + + CustomItemList.Machine_Multi_Transformer.get(16), ItemList.Wireless_Hatch_Energy_UMV.get(4), + CustomItemList.eM_energyTunnel5_UMV.get(1), + // High Energy Flow Circuit. + getModItem(NewHorizonsCoreMod.ID, "item.HighEnergyFlowCircuit", 64, 0), + + // Metastable Oganesson Plate. + GT_OreDictUnificator.get("plateMetastableOganesson", 6), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlueTopaz, 6), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CallistoIce, 6), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Ledox, 6), + + // Metastable Oganesson Screw. + GT_OreDictUnificator.get("screwMetastableOganesson", 6), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.BlueTopaz, 6), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.CallistoIce, 6), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Ledox, 6), }, + + new FluidStack[] { Materials.Neutronium.getMolten(144 * 256 * 16), + Materials.CosmicNeutronium.getMolten(144 * 256 * 16), new FluidStack(solderUEV, 144 * 256 * 8), + MaterialsUEVplus.SpaceTime.getMolten(16_000) }, + CustomItemList.EOH_Infinite_Energy_Casing.get(1), + 10_000, + (int) TierEU.RECIPE_UMV); + } + + // Astral Array Fabricator + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(1), + 480_000_000, + 32_768, + (int) TierEU.RECIPE_MAX, + 64, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.WhiteDwarfMatter, 8), + GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.BlackDwarfMatter, 8), + ItemList.EnergisedTesseract.get(32), + GT_OreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.Eternity, 16), + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(64), + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(64), + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(10), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(64), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(64), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(40), + CustomItemList.StabilisationFieldGeneratorTier8.get(48), + CustomItemList.EOH_Infinite_Energy_Casing.get(32), + CustomItemList.EOH_Reinforced_Temporal_Casing.get(64), + CustomItemList.EOH_Reinforced_Spatial_Casing.get(64), ItemList.Field_Generator_UMV.get(16) }, + new FluidStack[] { MaterialsUEVplus.Space.getMolten(32_768L * 64), + MaterialsUEVplus.Eternity.getMolten(16_384L * 64), MaterialsUEVplus.ExcitedDTSC.getFluid(8_192L * 64) }, + CustomItemList.astralArrayFabricator.get(1), + 300 * SECONDS, + (int) TierEU.RECIPE_UXV); + + } + + private void addWirelessEnergyRecipes() { + + Fluid solderUEV = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + + int recipeDurationTicks = 20 * 20; + int recipeEuPerTick = 128_000_000; + + int researchEuPerTick = 128_000_000; + int researchAmperage = 4; + int compPerSecond = 2000; + int totalComputation = 500_000; + + ItemStack[] energyHatches = { ItemList.Hatch_Energy_ULV.get(1), ItemList.Hatch_Energy_LV.get(1), + ItemList.Hatch_Energy_MV.get(1), ItemList.Hatch_Energy_HV.get(1), ItemList.Hatch_Energy_EV.get(1), + ItemList.Hatch_Energy_IV.get(1), ItemList.Hatch_Energy_LuV.get(1), ItemList.Hatch_Energy_ZPM.get(1), + ItemList.Hatch_Energy_UV.get(1), ItemList.Hatch_Energy_MAX.get(1), + getItemContainer("Hatch_Energy_UEV").get(1L), getItemContainer("Hatch_Energy_UIV").get(1L), + getItemContainer("Hatch_Energy_UMV").get(1L), getItemContainer("Hatch_Energy_UXV").get(1L) }; + + ItemStack[] energyHatches_4A = { CustomItemList.eM_energyMulti4_EV.get(1), + CustomItemList.eM_energyMulti4_IV.get(1), CustomItemList.eM_energyMulti4_LuV.get(1), + CustomItemList.eM_energyMulti4_ZPM.get(1), CustomItemList.eM_energyMulti4_UV.get(1), + CustomItemList.eM_energyMulti4_UHV.get(1), CustomItemList.eM_energyMulti4_UEV.get(1), + CustomItemList.eM_energyMulti4_UIV.get(1), CustomItemList.eM_energyMulti4_UMV.get(1), + CustomItemList.eM_energyMulti4_UXV.get(1) }; + + ItemStack[] energyHatches_16A = { CustomItemList.eM_energyMulti16_EV.get(1), + CustomItemList.eM_energyMulti16_IV.get(1), CustomItemList.eM_energyMulti16_LuV.get(1), + CustomItemList.eM_energyMulti16_ZPM.get(1), CustomItemList.eM_energyMulti16_UV.get(1), + CustomItemList.eM_energyMulti16_UHV.get(1), CustomItemList.eM_energyMulti16_UEV.get(1), + CustomItemList.eM_energyMulti16_UIV.get(1), CustomItemList.eM_energyMulti16_UMV.get(1), + CustomItemList.eM_energyMulti16_UXV.get(1) }; + + ItemStack[] energyHatches_64A = { CustomItemList.eM_energyMulti64_EV.get(1), + CustomItemList.eM_energyMulti64_IV.get(1), CustomItemList.eM_energyMulti64_LuV.get(1), + CustomItemList.eM_energyMulti64_ZPM.get(1), CustomItemList.eM_energyMulti64_UV.get(1), + CustomItemList.eM_energyMulti64_UHV.get(1), CustomItemList.eM_energyMulti64_UEV.get(1), + CustomItemList.eM_energyMulti64_UIV.get(1), CustomItemList.eM_energyMulti64_UMV.get(1), + CustomItemList.eM_energyMulti64_UXV.get(1) }; + + ItemStack[] laserTargets_UXV = { CustomItemList.eM_energyTunnel1_UXV.get(1), + CustomItemList.eM_energyTunnel2_UXV.get(1), CustomItemList.eM_energyTunnel3_UXV.get(1), + CustomItemList.eM_energyTunnel4_UXV.get(1), CustomItemList.eM_energyTunnel5_UXV.get(1), + CustomItemList.eM_energyTunnel6_UXV.get(1), CustomItemList.eM_energyTunnel7_UXV.get(1) }; + + ItemStack[] dynamoHatches = { ItemList.Hatch_Dynamo_ULV.get(1), ItemList.Hatch_Dynamo_LV.get(1), + ItemList.Hatch_Dynamo_MV.get(1), ItemList.Hatch_Dynamo_HV.get(1), ItemList.Hatch_Dynamo_EV.get(1), + ItemList.Hatch_Dynamo_IV.get(1), ItemList.Hatch_Dynamo_LuV.get(1), ItemList.Hatch_Dynamo_ZPM.get(1), + ItemList.Hatch_Dynamo_UV.get(1), ItemList.Hatch_Dynamo_MAX.get(1), + getItemContainer("Hatch_Dynamo_UEV").get(1L), getItemContainer("Hatch_Dynamo_UIV").get(1L), + getItemContainer("Hatch_Dynamo_UMV").get(1L), getItemContainer("Hatch_Dynamo_UXV").get(1L) }; + + Object[] circuitsTierPlusTwo = { new Object[] { OrePrefixes.circuit.get(Materials.Good), 1L }, // MV + new Object[] { OrePrefixes.circuit.get(Materials.Advanced), 1L }, // HV + new Object[] { OrePrefixes.circuit.get(Materials.Data), 1L }, // EV + new Object[] { OrePrefixes.circuit.get(Materials.Elite), 1L }, // IV + new Object[] { OrePrefixes.circuit.get(Materials.Master), 1L }, // LuV + new Object[] { OrePrefixes.circuit.get(Materials.Ultimate), 1L }, // ZPM + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 1L }, // UV + new Object[] { OrePrefixes.circuit.get(Materials.Infinite), 1L }, // UHV + new Object[] { OrePrefixes.circuit.get(Materials.Bio), 1L }, // UEV + new Object[] { OrePrefixes.circuit.get(Materials.Optical), 1L }, // UIV + new Object[] { OrePrefixes.circuit.get(Materials.Piko), 1L }, // UMV + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 1L }, // UXV + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 4L }, // MAX (Technically not MAX, can be + // changed once MAX circuits become + // craftable) + new Object[] { OrePrefixes.circuit.get(Materials.Quantum), 16L } // MAX (Technically not MAX, can be + // changed once MAX circuits become + // craftable) + }; + + ItemStack[] wirelessHatches = { ItemList.Wireless_Hatch_Energy_ULV.get(1), + ItemList.Wireless_Hatch_Energy_LV.get(1), ItemList.Wireless_Hatch_Energy_MV.get(1), + ItemList.Wireless_Hatch_Energy_HV.get(1), ItemList.Wireless_Hatch_Energy_EV.get(1), + ItemList.Wireless_Hatch_Energy_IV.get(1), ItemList.Wireless_Hatch_Energy_LuV.get(1), + ItemList.Wireless_Hatch_Energy_ZPM.get(1), ItemList.Wireless_Hatch_Energy_UV.get(1), + ItemList.Wireless_Hatch_Energy_UHV.get(1), ItemList.Wireless_Hatch_Energy_UEV.get(1), + ItemList.Wireless_Hatch_Energy_UIV.get(1), ItemList.Wireless_Hatch_Energy_UMV.get(1), + ItemList.Wireless_Hatch_Energy_UXV.get(1) }; + + ItemStack[] wirelessHatches_4A = { CustomItemList.eM_energyWirelessMulti4_EV.get(1), + CustomItemList.eM_energyWirelessMulti4_IV.get(1), CustomItemList.eM_energyWirelessMulti4_LuV.get(1), + CustomItemList.eM_energyWirelessMulti4_ZPM.get(1), CustomItemList.eM_energyWirelessMulti4_UV.get(1), + CustomItemList.eM_energyWirelessMulti4_UHV.get(1), CustomItemList.eM_energyWirelessMulti4_UEV.get(1), + CustomItemList.eM_energyWirelessMulti4_UIV.get(1), CustomItemList.eM_energyWirelessMulti4_UMV.get(1), + CustomItemList.eM_energyWirelessMulti4_UXV.get(1) }; + + ItemStack[] wirelessHatches_16A = { CustomItemList.eM_energyWirelessMulti16_EV.get(1), + CustomItemList.eM_energyWirelessMulti16_IV.get(1), CustomItemList.eM_energyWirelessMulti16_LuV.get(1), + CustomItemList.eM_energyWirelessMulti16_ZPM.get(1), CustomItemList.eM_energyWirelessMulti16_UV.get(1), + CustomItemList.eM_energyWirelessMulti16_UHV.get(1), CustomItemList.eM_energyWirelessMulti16_UEV.get(1), + CustomItemList.eM_energyWirelessMulti16_UIV.get(1), CustomItemList.eM_energyWirelessMulti16_UMV.get(1), + CustomItemList.eM_energyWirelessMulti16_UXV.get(1) }; + + ItemStack[] wirelessHatches_64A = { CustomItemList.eM_energyWirelessMulti64_EV.get(1), + CustomItemList.eM_energyWirelessMulti64_IV.get(1), CustomItemList.eM_energyWirelessMulti64_LuV.get(1), + CustomItemList.eM_energyWirelessMulti64_ZPM.get(1), CustomItemList.eM_energyWirelessMulti64_UV.get(1), + CustomItemList.eM_energyWirelessMulti64_UHV.get(1), CustomItemList.eM_energyWirelessMulti64_UEV.get(1), + CustomItemList.eM_energyWirelessMulti64_UIV.get(1), CustomItemList.eM_energyWirelessMulti64_UMV.get(1), + CustomItemList.eM_energyWirelessMulti64_UXV.get(1) }; + + ItemStack[] wirelessLasers = { CustomItemList.eM_energyWirelessTunnel1_UXV.get(1), + CustomItemList.eM_energyWirelessTunnel2_UXV.get(1), CustomItemList.eM_energyWirelessTunnel3_UXV.get(1), + CustomItemList.eM_energyWirelessTunnel4_UXV.get(1), CustomItemList.eM_energyWirelessTunnel5_UXV.get(1), + CustomItemList.eM_energyWirelessTunnel6_UXV.get(1), CustomItemList.eM_energyWirelessTunnel7_UXV.get(1) }; + + ItemStack[] wirelessDynamos = { ItemList.Wireless_Dynamo_Energy_ULV.get(1), + ItemList.Wireless_Dynamo_Energy_LV.get(1), ItemList.Wireless_Dynamo_Energy_MV.get(1), + ItemList.Wireless_Dynamo_Energy_HV.get(1), ItemList.Wireless_Dynamo_Energy_EV.get(1), + ItemList.Wireless_Dynamo_Energy_IV.get(1), ItemList.Wireless_Dynamo_Energy_LuV.get(1), + ItemList.Wireless_Dynamo_Energy_ZPM.get(1), ItemList.Wireless_Dynamo_Energy_UV.get(1), + ItemList.Wireless_Dynamo_Energy_UHV.get(1), ItemList.Wireless_Dynamo_Energy_UEV.get(1), + ItemList.Wireless_Dynamo_Energy_UIV.get(1), ItemList.Wireless_Dynamo_Energy_UMV.get(1), + ItemList.Wireless_Dynamo_Energy_UXV.get(1) }; + + // ------------------------ Wireless EU hatches ------------------------ + + for (int i = 0; i < wirelessHatches.length; i++) { + + TT_recipeAdder.addResearchableAssemblylineRecipe( + (i == 0) ? ItemList.Tesseract.get(1) : wirelessHatches[i - 1], + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { energyHatches[i], getModItem(GoodGenerator.ID, "compactFusionCoil", 1), + ItemList.Casing_Coil_Superconductor.get(1), CustomItemList.Machine_Multi_Transformer.get(1), + CustomItemList.eM_Power.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, MaterialsUEVplus.SpaceTime, 2), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Infinity, 1), circuitsTierPlusTwo[i], + ItemList.EnergisedTesseract.get(1) }, + new FluidStack[] { new FluidStack(solderUEV, 1296), MaterialsUEVplus.ExcitedDTEC.getFluid(500L) }, + wirelessHatches[i], + recipeDurationTicks, + recipeEuPerTick); + } + + // ------------------------ 4A Wireless EU hatches ------------------------ + + for (int i = 0; i < wirelessHatches_4A.length; i++) { + + TT_recipeAdder.addResearchableAssemblylineRecipe( + energyHatches_4A[i], + totalComputation * 4, + compPerSecond * 4, + researchEuPerTick, + researchAmperage * 2, + new Object[] { energyHatches_4A[i], getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 1), + ItemList.Casing_Coil_Superconductor.get(1), CustomItemList.Machine_Multi_Transformer.get(1), + CustomItemList.eM_Power.get(4), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, MaterialsUEVplus.SpaceTime, 4), + GT_OreDictUnificator.get("plateTripleShirabon", 4L), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Flerovium, 4), + circuitsTierPlusTwo[i + 4], ItemList.EnergisedTesseract.get(1) }, + new FluidStack[] { new FluidStack(solderUEV, 1_296 * 4), + MaterialsUEVplus.ExcitedDTEC.getFluid(500L * 4) }, + wirelessHatches_4A[i], + recipeDurationTicks, + recipeEuPerTick); + } + + // ------------------------ 16A Wireless EU hatches ------------------------ + + for (int i = 0; i < wirelessHatches_16A.length; i++) { + + TT_recipeAdder.addResearchableAssemblylineRecipe( + energyHatches_16A[i], + totalComputation * 16, + compPerSecond * 16, + researchEuPerTick, + researchAmperage * 4, + new Object[] { energyHatches_16A[i], getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 2), + ItemList.Casing_Coil_Superconductor.get(1), CustomItemList.Machine_Multi_Transformer.get(1), + CustomItemList.eM_Power.get(16), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, MaterialsUEVplus.SpaceTime, 16), + GT_OreDictUnificator.get("plateTripleShirabon", 16L), + GT_OreDictUnificator.get(OrePrefixes.plateDense, MaterialsUEVplus.TranscendentMetal, 4), + circuitsTierPlusTwo[i + 4], ItemList.EnergisedTesseract.get(1) }, + new FluidStack[] { new FluidStack(solderUEV, 1_296 * 16), + MaterialsUEVplus.ExcitedDTEC.getFluid(500L * 16) }, + wirelessHatches_16A[i], + recipeDurationTicks, + recipeEuPerTick); + } + + // ------------------------ 64A Wireless EU hatches ------------------------ + + for (int i = 0; i < wirelessHatches_64A.length; i++) { + + TT_recipeAdder.addResearchableAssemblylineRecipe( + energyHatches_64A[i], + totalComputation * 64, + compPerSecond * 64, + researchEuPerTick, + researchAmperage * 8, + new Object[] { energyHatches_64A[i], getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 3), + ItemList.Casing_Coil_Superconductor.get(1), CustomItemList.Machine_Multi_Transformer.get(1), + CustomItemList.eM_Power.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, MaterialsUEVplus.SpaceTime, 64), + GT_OreDictUnificator.get("plateTripleShirabon", 64L), + GT_OreDictUnificator.get("plateDenseMetastableOganesson", 4), circuitsTierPlusTwo[i + 4], + ItemList.EnergisedTesseract.get(1) }, + new FluidStack[] { new FluidStack(solderUEV, 1_296 * 64), + MaterialsUEVplus.ExcitedDTEC.getFluid(500L * 64) }, + wirelessHatches_64A[i], + recipeDurationTicks, + recipeEuPerTick); + } + + // ------------------------ Wireless UXV Lasers ------------------------ + + for (int i = 0; i < wirelessLasers.length; i++) { + + TT_recipeAdder.addResearchableAssemblylineRecipe( + laserTargets_UXV[i], + totalComputation * 64, + compPerSecond * 64, + researchEuPerTick * 4, + researchAmperage * 16, + new Object[] { laserTargets_UXV[i], getModItem(GoodGenerator.ID, "compactFusionCoil", 1, 4), + // Dyson Swarm Module Deployment Unit Superconducting Magnet + getModItem(GalaxySpace.ID, "dysonswarmparts", 1, 4), + CustomItemList.Machine_Multi_Transformer.get(1), CustomItemList.eM_Power.get(64), + GT_OreDictUnificator.get(OrePrefixes.wireGt16, MaterialsUEVplus.SpaceTime, 64), + GT_OreDictUnificator.get(OrePrefixes.plateDense, MaterialsUEVplus.Eternity, 32), + GT_OreDictUnificator + .get(OrePrefixes.plateDense, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, 16), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Quantum, 16L), + ItemList.EnergisedTesseract.get(1) }, + new FluidStack[] { new FluidStack(solderUEV, 1_296 * 64 * 4), + MaterialsUEVplus.ExcitedDTSC.getFluid(500L * 64) }, + wirelessLasers[i], + recipeDurationTicks, + recipeEuPerTick); + } + + // ------------------------ Wireless EU dynamos ------------------------ + + for (int i = 0; i < wirelessHatches.length; i++) { + + TT_recipeAdder.addResearchableAssemblylineRecipe( + (i == 0) ? ItemList.EnergisedTesseract.get(1) : wirelessDynamos[i - 1], + totalComputation, + compPerSecond, + researchEuPerTick, + researchAmperage, + new Object[] { dynamoHatches[i], getModItem(GoodGenerator.ID, "compactFusionCoil", 1), + ItemList.Casing_Coil_Superconductor.get(1), CustomItemList.Machine_Multi_Transformer.get(1), + CustomItemList.eM_Power.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, MaterialsUEVplus.SpaceTime, 2), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Infinity, 1), circuitsTierPlusTwo[i], + ItemList.EnergisedTesseract.get(1) }, + new FluidStack[] { new FluidStack(solderUEV, 1296), MaterialsUEVplus.ExcitedDTEC.getFluid(500L) }, + wirelessDynamos[i], + recipeDurationTicks, + recipeEuPerTick); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java new file mode 100644 index 0000000000..e410eec6b4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java @@ -0,0 +1,48 @@ +package com.github.technus.tectech.loader.thing; + +import net.minecraft.item.ItemStack; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.cover.GT_Cover_TM_EnderFluidLink; +import com.github.technus.tectech.thing.cover.GT_Cover_TM_PowerPassUpgrade; +import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil; +import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil_Ultimate; +import com.github.technus.tectech.thing.item.EnderFluidLinkCover; +import com.github.technus.tectech.thing.item.PowerPassUpgradeCover; +import com.github.technus.tectech.thing.item.TeslaCoilCover; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.objects.GT_RenderedTexture; + +public class CoverLoader implements Runnable { + + public void run() { + final IIconContainer TESLA_OVERLAY = new Textures.BlockIcons.CustomIcon("iconsets/TESLA_OVERLAY"); + final IIconContainer TESLA_OVERLAY_ULTIMATE = new Textures.BlockIcons.CustomIcon( + "iconsets/TESLA_OVERLAY_ULTIMATE"); + final IIconContainer ENDERFLUIDLINK_OVERLAY = new Textures.BlockIcons.CustomIcon( + "iconsets/ENDERFLUIDLINK_OVERLAY"); + final IIconContainer POWERPASSUPGRADE_OVERLAY = new Textures.BlockIcons.CustomIcon( + "iconsets/POWERPASSUPGRADE_OVERLAY"); + + GregTech_API.registerCover( + new ItemStack(TeslaCoilCover.INSTANCE, 1, 0), + new GT_RenderedTexture(TESLA_OVERLAY), + new GT_Cover_TM_TeslaCoil()); + GregTech_API.registerCover( + new ItemStack(TeslaCoilCover.INSTANCE, 1, 1), + new GT_RenderedTexture(TESLA_OVERLAY_ULTIMATE), + new GT_Cover_TM_TeslaCoil_Ultimate()); + GregTech_API.registerCover( + new ItemStack(EnderFluidLinkCover.INSTANCE, 1, 0), + new GT_RenderedTexture(ENDERFLUIDLINK_OVERLAY), + new GT_Cover_TM_EnderFluidLink()); + GregTech_API.registerCover( + new ItemStack(PowerPassUpgradeCover.INSTANCE, 1, 0), + new GT_RenderedTexture(POWERPASSUPGRADE_OVERLAY), + new GT_Cover_TM_PowerPassUpgrade()); + TecTech.LOGGER.info("Cover functionality registered"); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java new file mode 100644 index 0000000000..13681d2637 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java @@ -0,0 +1,2101 @@ +package com.github.technus.tectech.loader.thing; + +import static com.github.technus.tectech.thing.CustomItemList.DATApipe; +import static com.github.technus.tectech.thing.CustomItemList.DATApipeBlock; +import static com.github.technus.tectech.thing.CustomItemList.LASERpipe; +import static com.github.technus.tectech.thing.CustomItemList.LASERpipeBlock; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_IV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_LuV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_UEV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_UHV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_UIV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_UMV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_UV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_UXV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_BuckConverter_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.Machine_DebugGenny; +import static com.github.technus.tectech.thing.CustomItemList.Machine_DebugPollutor; +import static com.github.technus.tectech.thing.CustomItemList.Machine_DebugWriter; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_Computer; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_DataBank; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_EyeOfHarmony; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_ForgeOfGods; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_Infuser; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_Microwave; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_MoltenModule; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_PlasmaModule; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_QuarkGluonPlasmaModule; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_Research; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_SmeltingModule; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_Switch; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_TeslaCoil; +import static com.github.technus.tectech.thing.CustomItemList.Machine_Multi_Transformer; +import static com.github.technus.tectech.thing.CustomItemList.Machine_OwnerDetector; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_1by1_EV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_1by1_HV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_1by1_IV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_1by1_LV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_1by1_MV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_2by2_EV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_2by2_HV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_2by2_IV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_2by2_LV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_2by2_MV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_3by3_EV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_3by3_HV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_3by3_IV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_3by3_LV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_3by3_MV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_4by4_EV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_4by4_HV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_4by4_IV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_4by4_LV; +import static com.github.technus.tectech.thing.CustomItemList.Machine_TeslaCoil_4by4_MV; +import static com.github.technus.tectech.thing.CustomItemList.ParametrizerTXT_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.ParametrizerX_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.Parametrizer_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.UncertaintyX_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.Uncertainty_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.UnusedStuff; +import static com.github.technus.tectech.thing.CustomItemList.capacitor_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.dataInAss_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.dataIn_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.dataOutAss_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.dataOut_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti16_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti4_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoMulti64_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel1_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel2_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel3_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel4_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel5_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel6_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel7_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_dynamoTunnel9001; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti16_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti4_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyMulti64_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel1_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel2_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel3_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel4_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel5_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel6_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel7_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyTunnel9001; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_MAX; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti16_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_MAX; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti4_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_EV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_IV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_LuV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_MAX; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_UEV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_UHV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_UIV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_UMV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_UV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessMulti64_ZPM; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessTunnel1_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessTunnel2_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessTunnel3_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessTunnel4_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessTunnel5_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessTunnel6_UXV; +import static com.github.technus.tectech.thing.CustomItemList.eM_energyWirelessTunnel7_UXV; +import static com.github.technus.tectech.thing.CustomItemList.hatch_CreativeData; +import static com.github.technus.tectech.thing.CustomItemList.hatch_CreativeMaintenance; +import static com.github.technus.tectech.thing.CustomItemList.hatch_CreativeUncertainty; +import static com.github.technus.tectech.thing.CustomItemList.holder_Hatch; +import static com.github.technus.tectech.thing.CustomItemList.rack_Hatch; +import static com.github.technus.tectech.util.CommonValues.V; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Capacitor; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_CreativeData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_CreativeMaintenance; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_CreativeUncertainty; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoTunnel; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Holder; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputDataItems; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputDataItems; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_ParamText; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Rack; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Uncertainty; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_WirelessMulti; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_EyeOfHarmony; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_ForgeOfGods; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_computer; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_dataBank; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_infuser; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_research; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_switch; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_transformer; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_microwave; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_ExoticModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_MoltenModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_PlasmaModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_SmeltingModule; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_PipeBlock_Data; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_PipeBlock_Energy; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Energy; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_BuckConverter; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPollutor; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPowerGenerator; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugStructureWriter; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_OwnerDetector; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_TeslaCoil; + +/** + * Created by danie_000 on 16.11.2016. + */ +public class MachineLoader implements Runnable { + + @Override + public void run() { + + // =================================================================================================== + // Multi AMP Power INPUTS + // =================================================================================================== + eM_energyMulti4_EV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15109, "hatch.energymulti04.tier.04", "EV 4A Energy Hatch", 4, 4) + .getStackForm(1L)); + eM_energyMulti16_EV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15119, "hatch.energymulti16.tier.04", "EV 16A Energy Hatch", 4, 16) + .getStackForm(1L)); + eM_energyMulti64_EV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15129, "hatch.energymulti64.tier.04", "EV 64A Energy Hatch", 4, 64) + .getStackForm(1L)); + + eM_energyMulti4_IV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15100, "hatch.energymulti04.tier.05", "IV 4A Energy Hatch", 5, 4) + .getStackForm(1L)); + eM_energyMulti16_IV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15110, "hatch.energymulti16.tier.05", "IV 16A Energy Hatch", 5, 16) + .getStackForm(1L)); + eM_energyMulti64_IV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15120, "hatch.energymulti64.tier.05", "IV 64A Energy Hatch", 5, 64) + .getStackForm(1L)); + + eM_energyMulti4_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15101, "hatch.energymulti04.tier.06", "LuV 4A Energy Hatch", 6, 4) + .getStackForm(1L)); + eM_energyMulti16_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15111, "hatch.energymulti16.tier.06", "LuV 16A Energy Hatch", 6, 16) + .getStackForm(1L)); + eM_energyMulti64_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15121, "hatch.energymulti64.tier.06", "LuV 64A Energy Hatch", 6, 64) + .getStackForm(1L)); + + eM_energyMulti4_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15102, "hatch.energymulti04.tier.07", "ZPM 4A Energy Hatch", 7, 4) + .getStackForm(1L)); + eM_energyMulti16_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15112, "hatch.energymulti16.tier.07", "ZPM 16A Energy Hatch", 7, 16) + .getStackForm(1L)); + eM_energyMulti64_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15122, "hatch.energymulti64.tier.07", "ZPM 64A Energy Hatch", 7, 64) + .getStackForm(1L)); + + eM_energyMulti4_UV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15103, "hatch.energymulti04.tier.08", "UV 4A Energy Hatch", 8, 4) + .getStackForm(1L)); + eM_energyMulti16_UV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15113, "hatch.energymulti16.tier.08", "UV 16A Energy Hatch", 8, 16) + .getStackForm(1L)); + eM_energyMulti64_UV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15123, "hatch.energymulti64.tier.08", "UV 64A Energy Hatch", 8, 64) + .getStackForm(1L)); + + eM_energyMulti4_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15104, "hatch.energymulti04.tier.09", "UHV 4A Energy Hatch", 9, 4) + .getStackForm(1L)); + eM_energyMulti16_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15114, "hatch.energymulti16.tier.09", "UHV 16A Energy Hatch", 9, 16) + .getStackForm(1L)); + eM_energyMulti64_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15124, "hatch.energymulti64.tier.09", "UHV 64A Energy Hatch", 9, 64) + .getStackForm(1L)); + + eM_energyMulti4_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15105, "hatch.energymulti04.tier.10", "UEV 4A Energy Hatch", 10, 4) + .getStackForm(1L)); + eM_energyMulti16_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15115, + "hatch.energymulti16.tier.10", + "UEV 16A Energy Hatch", + 10, + 16).getStackForm(1L)); + eM_energyMulti64_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15125, + "hatch.energymulti64.tier.10", + "UEV 64A Energy Hatch", + 10, + 64).getStackForm(1L)); + + eM_energyMulti4_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15106, "hatch.energymulti04.tier.11", "UIV 4A Energy Hatch", 11, 4) + .getStackForm(1L)); + eM_energyMulti16_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15116, + "hatch.energymulti16.tier.11", + "UIV 16A Energy Hatch", + 11, + 16).getStackForm(1L)); + eM_energyMulti64_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15126, + "hatch.energymulti64.tier.11", + "UIV 64A Energy Hatch", + 11, + 64).getStackForm(1L)); + + eM_energyMulti4_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15107, "hatch.energymulti04.tier.12", "UMV 4A Energy Hatch", 12, 4) + .getStackForm(1L)); + eM_energyMulti16_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15117, + "hatch.energymulti16.tier.12", + "UMV 16A Energy Hatch", + 12, + 16).getStackForm(1L)); + eM_energyMulti64_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15127, + "hatch.energymulti64.tier.12", + "UMV 64A Energy Hatch", + 12, + 64).getStackForm(1L)); + + eM_energyMulti4_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti(15108, "hatch.energymulti04.tier.13", "UXV 4A Energy Hatch", 13, 4) + .getStackForm(1L)); + eM_energyMulti16_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15118, + "hatch.energymulti16.tier.13", + "UXV 16A Energy Hatch", + 13, + 16).getStackForm(1L)); + eM_energyMulti64_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyMulti( + 15128, + "hatch.energymulti64.tier.13", + "UXV 64A Energy Hatch", + 13, + 64).getStackForm(1L)); + // =================================================================================================== + // Multi AMP Wireless INPUTS + // =================================================================================================== + eM_energyWirelessMulti4_EV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15065, + "hatch.energywirelessmulti04.tier.04", + "EV 4A Wireless Energy Hatch", + 4, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_EV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15066, + "hatch.energywirelessmulti16.tier.04", + "EV 16A Wireless Energy Hatch", + 4, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_EV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15067, + "hatch.energywirelessmulti64.tier.04", + "EV 64A Wireless Energy Hatch", + 4, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_IV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15068, + "hatch.energywirelessmulti04.tier.05", + "IV 4A Wireless Energy Hatch", + 5, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_IV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15069, + "hatch.energywirelessmulti16.tier.05", + "IV 16A Wireless Energy Hatch", + 5, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_IV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15070, + "hatch.energywirelessmulti64.tier.05", + "IV 64A Wireless Energy Hatch", + 5, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_LuV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15071, + "hatch.energywirelessmulti04.tier.06", + "LuV 4A Wireless Energy Hatch", + 6, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_LuV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15072, + "hatch.energywirelessmulti16.tier.06", + "LuV 16A Wireless Energy Hatch", + 6, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_LuV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15073, + "hatch.energywirelessmulti64.tier.06", + "LuV 64A Wireless Energy Hatch", + 6, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_ZPM.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15074, + "hatch.energywirelessmulti04.tier.07", + "ZPM 4A Wireless Energy Hatch", + 7, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_ZPM.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15075, + "hatch.energywirelessmulti16.tier.07", + "ZPM 16A Wireless Energy Hatch", + 7, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_ZPM.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15076, + "hatch.energywirelessmulti64.tier.07", + "ZPM 64A Wireless Energy Hatch", + 7, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_UV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15077, + "hatch.energywirelessmulti04.tier.08", + "UV 4A Wireless Energy Hatch", + 8, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_UV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15078, + "hatch.energywirelessmulti16.tier.08", + "UV 16A Wireless Energy Hatch", + 8, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_UV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15079, + "hatch.energywirelessmulti64.tier.08", + "UV 64A Wireless Energy Hatch", + 8, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_UHV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15080, + "hatch.energywirelessmulti04.tier.09", + "UHV 4A Wireless Energy Hatch", + 9, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_UHV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15081, + "hatch.energywirelessmulti16.tier.09", + "UHV 16A Wireless Energy Hatch", + 9, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_UHV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15082, + "hatch.energywirelessmulti64.tier.09", + "UHV 64A Wireless Energy Hatch", + 9, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_UEV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15083, + "hatch.energywirelessmulti04.tier.10", + "UEV 4A Wireless Energy Hatch", + 10, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_UEV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15084, + "hatch.energywirelessmulti16.tier.10", + "UEV 16A Wireless Energy Hatch", + 10, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_UEV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15085, + "hatch.energywirelessmulti64.tier.10", + "UEV 64A Wireless Energy Hatch", + 10, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_UIV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15086, + "hatch.energywirelessmulti04.tier.11", + "UIV 4A Wireless Energy Hatch", + 11, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_UIV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15087, + "hatch.energywirelessmulti16.tier.11", + "UIV 16A Wireless Energy Hatch", + 11, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_UIV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15088, + "hatch.energywirelessmulti64.tier.11", + "UIV 64A Wireless Energy Hatch", + 11, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_UMV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15089, + "hatch.energywirelessmulti04.tier.12", + "UMV 4A Wireless Energy Hatch", + 12, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_UMV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15090, + "hatch.energywirelessmulti16.tier.12", + "UMV 16A Wireless Energy Hatch", + 12, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_UMV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15091, + "hatch.energywirelessmulti64.tier.12", + "UMV 64A Wireless Energy Hatch", + 12, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15092, + "hatch.energywirelessmulti04.tier.13", + "UXV 4A Wireless Energy Hatch", + 13, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15093, + "hatch.energywirelessmulti16.tier.13", + "UXV 16A Wireless Energy Hatch", + 13, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15094, + "hatch.energywirelessmulti64.tier.13", + "UXV 64A Wireless Energy Hatch", + 13, + 64).getStackForm(1L)); + eM_energyWirelessMulti4_MAX.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15095, + "hatch.energywirelessmulti04.tier.14", + "MAX 4A Wireless Energy Hatch", + 14, + 4).getStackForm(1L)); + eM_energyWirelessMulti16_MAX.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15096, + "hatch.energywirelessmulti16.tier.14", + "MAX 16A Wireless Energy Hatch", + 14, + 16).getStackForm(1L)); + eM_energyWirelessMulti64_MAX.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15097, + "hatch.energywirelessmulti64.tier.14", + "MAX 64A Wireless Energy Hatch", + 14, + 64).getStackForm(1L)); + + eM_energyWirelessTunnel1_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15500, + "hatch.energywirelesstunnel1.tier.13", + "UXV 256A Wireless Energy Hatch", + 13, + 256).getStackForm(1L)); + eM_energyWirelessTunnel2_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15501, + "hatch.energywirelesstunnel2.tier.13", + "UXV 1,024A Wireless Energy Hatch", + 13, + 1024).getStackForm(1L)); + eM_energyWirelessTunnel3_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15502, + "hatch.energywirelesstunnel3.tier.13", + "UXV 4,096A Wireless Energy Hatch", + 13, + 4096).getStackForm(1L)); + eM_energyWirelessTunnel4_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15503, + "hatch.energywirelesstunnel4.tier.13", + "UXV 16,384A Wireless Energy Hatch", + 13, + 16384).getStackForm(1L)); + eM_energyWirelessTunnel5_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15504, + "hatch.energywirelesstunnel5.tier.13", + "UXV 65,536A Wireless Energy Hatch", + 13, + 65536).getStackForm(1L)); + eM_energyWirelessTunnel6_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15505, + "hatch.energywirelesstunnel6.tier.13", + "UXV 262,144A Wireless Energy Hatch", + 13, + 262144).getStackForm(1L)); + eM_energyWirelessTunnel7_UXV.set( + new GT_MetaTileEntity_Hatch_WirelessMulti( + 15506, + "hatch.energywirelesstunnel7.tier.13", + "UXV 1,048,576A Wireless Energy Hatch", + 13, + 1048576).getStackForm(1L)); + // =================================================================================================== + // Multi AMP Laser INPUTS + // =================================================================================================== + + eM_energyTunnel1_IV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15130, + "hatch.energytunnel1.tier.05", + "IV 256A/t Laser Target Hatch", + 5, + 256).getStackForm(1L)); + eM_energyTunnel2_IV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15140, + "hatch.energytunnel2.tier.05", + "IV 1,024A/t Laser Target Hatch", + 5, + 1024).getStackForm(1L)); + eM_energyTunnel3_IV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15150, + "hatch.energytunnel3.tier.05", + "IV 4,096A/t Laser Target Hatch", + 5, + 4096).getStackForm(1L)); + eM_energyTunnel4_IV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15160, + "hatch.energytunnel4.tier.05", + "IV 16,384A/t Laser Target Hatch", + 5, + 16384).getStackForm(1L)); + eM_energyTunnel5_IV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15170, + "hatch.energytunnel5.tier.05", + "IV 65,536A/t Laser Target Hatch", + 5, + 65536).getStackForm(1L)); + eM_energyTunnel6_IV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15180, + "hatch.energytunnel6.tier.05", + "IV 262,144A/t Laser Target Hatch", + 5, + 262144).getStackForm(1L)); + eM_energyTunnel7_IV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15190, + "hatch.energytunnel7.tier.05", + "IV 1,048,576A/t Laser Target Hatch", + 5, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15131, + "hatch.energytunnel1.tier.06", + "LuV 256A/t Laser Target Hatch", + 6, + 256).getStackForm(1L)); + eM_energyTunnel2_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15141, + "hatch.energytunnel2.tier.06", + "LuV 1,024A/t Laser Target Hatch", + 6, + 1024).getStackForm(1L)); + eM_energyTunnel3_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15151, + "hatch.energytunnel3.tier.06", + "LuV 4,096A/t Laser Target Hatch", + 6, + 4096).getStackForm(1L)); + eM_energyTunnel4_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15161, + "hatch.energytunnel4.tier.06", + "LuV 16,384A/t Laser Target Hatch", + 6, + 16384).getStackForm(1L)); + eM_energyTunnel5_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15171, + "hatch.energytunnel5.tier.06", + "LuV 65,536A/t Laser Target Hatch", + 6, + 65536).getStackForm(1L)); + eM_energyTunnel6_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15181, + "hatch.energytunnel6.tier.06", + "LuV 262,144A/t Laser Target Hatch", + 6, + 262144).getStackForm(1L)); + eM_energyTunnel7_LuV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15191, + "hatch.energytunnel7.tier.06", + "LuV 1,048,576A/t Laser Target Hatch", + 6, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15132, + "hatch.energytunnel1.tier.07", + "ZPM 256A/t Laser Target Hatch", + 7, + 256).getStackForm(1L)); + eM_energyTunnel2_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15142, + "hatch.energytunnel2.tier.07", + "ZPM 1,024A/t Laser Target Hatch", + 7, + 1024).getStackForm(1L)); + eM_energyTunnel3_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15152, + "hatch.energytunnel3.tier.07", + "ZPM 4,096A/t Laser Target Hatch", + 7, + 4096).getStackForm(1L)); + eM_energyTunnel4_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15162, + "hatch.energytunnel4.tier.07", + "ZPM 16,384A/t Laser Target Hatch", + 7, + 16384).getStackForm(1L)); + eM_energyTunnel5_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15172, + "hatch.energytunnel5.tier.07", + "ZPM 65,536A/t Laser Target Hatch", + 7, + 65536).getStackForm(1L)); + eM_energyTunnel6_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15182, + "hatch.energytunnel6.tier.07", + "ZPM 262,144A/t Laser Target Hatch", + 7, + 262144).getStackForm(1L)); + eM_energyTunnel7_ZPM.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15192, + "hatch.energytunnel7.tier.07", + "ZPM 1,048,576A/t Laser Target Hatch", + 7, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_UV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15133, + "hatch.energytunnel1.tier.08", + "UV 256A/t Laser Target Hatch", + 8, + 256).getStackForm(1L)); + eM_energyTunnel2_UV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15143, + "hatch.energytunnel2.tier.08", + "UV 1,024A/t Laser Target Hatch", + 8, + 1024).getStackForm(1L)); + eM_energyTunnel3_UV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15153, + "hatch.energytunnel3.tier.08", + "UV 4,096A/t Laser Target Hatch", + 8, + 4096).getStackForm(1L)); + eM_energyTunnel4_UV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15163, + "hatch.energytunnel4.tier.08", + "UV 16,384A/t Laser Target Hatch", + 8, + 16384).getStackForm(1L)); + eM_energyTunnel5_UV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15173, + "hatch.energytunnel5.tier.08", + "UV 65,536A/t Laser Target Hatch", + 8, + 65536).getStackForm(1L)); + eM_energyTunnel6_UV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15183, + "hatch.energytunnel6.tier.08", + "UV 262,144A/t Laser Target Hatch", + 8, + 262144).getStackForm(1L)); + eM_energyTunnel7_UV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15193, + "hatch.energytunnel7.tier.08", + "UV 1,048,576A/t Laser Target Hatch", + 8, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15134, + "hatch.energytunnel1.tier.09", + "UHV 256A/t Laser Target Hatch", + 9, + 256).getStackForm(1L)); + eM_energyTunnel2_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15144, + "hatch.energytunnel2.tier.09", + "UHV 1,024A/t Laser Target Hatch", + 9, + 1024).getStackForm(1L)); + eM_energyTunnel3_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15154, + "hatch.energytunnel3.tier.09", + "UHV 4,096A/t Laser Target Hatch", + 9, + 4096).getStackForm(1L)); + eM_energyTunnel4_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15164, + "hatch.energytunnel4.tier.09", + "UHV 16,384A/t Laser Target Hatch", + 9, + 16384).getStackForm(1L)); + eM_energyTunnel5_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15174, + "hatch.energytunnel5.tier.09", + "UHV 65,536A/t Laser Target Hatch", + 9, + 65536).getStackForm(1L)); + eM_energyTunnel6_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15184, + "hatch.energytunnel6.tier.09", + "UHV 262,144A/t Laser Target Hatch", + 9, + 262144).getStackForm(1L)); + eM_energyTunnel7_UHV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15194, + "hatch.energytunnel7.tier.09", + "UHV 1,048,576A/t Laser Target Hatch", + 9, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15135, + "hatch.energytunnel1.tier.10", + "UEV 256A/t Laser Target Hatch", + 10, + 256).getStackForm(1L)); + eM_energyTunnel2_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15145, + "hatch.energytunnel2.tier.10", + "UEV 1,024A/t Laser Target Hatch", + 10, + 1024).getStackForm(1L)); + eM_energyTunnel3_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15155, + "hatch.energytunnel3.tier.10", + "UEV 4,096A/t Laser Target Hatch", + 10, + 4096).getStackForm(1L)); + eM_energyTunnel4_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15165, + "hatch.energytunnel4.tier.10", + "UEV 16,384A/t Laser Target Hatch", + 10, + 16384).getStackForm(1L)); + eM_energyTunnel5_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15175, + "hatch.energytunnel5.tier.10", + "UEV 65,536A/t Laser Target Hatch", + 10, + 65536).getStackForm(1L)); + eM_energyTunnel6_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15185, + "hatch.energytunnel6.tier.10", + "UEV 262,144A/t Laser Target Hatch", + 10, + 262144).getStackForm(1L)); + eM_energyTunnel7_UEV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15195, + "hatch.energytunnel7.tier.10", + "UEV 1,048,576A/t Laser Target Hatch", + 10, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15136, + "hatch.energytunnel1.tier.11", + "UIV 256A/t Laser Target Hatch", + 11, + 256).getStackForm(1L)); + eM_energyTunnel2_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15146, + "hatch.energytunnel2.tier.11", + "UIV 1,024A/t Laser Target Hatch", + 11, + 1024).getStackForm(1L)); + eM_energyTunnel3_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15156, + "hatch.energytunnel3.tier.11", + "UIV 4,096A/t Laser Target Hatch", + 11, + 4096).getStackForm(1L)); + eM_energyTunnel4_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15166, + "hatch.energytunnel4.tier.11", + "UIV 16,384A/t Laser Target Hatch", + 11, + 16384).getStackForm(1L)); + eM_energyTunnel5_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15176, + "hatch.energytunnel5.tier.11", + "UIV 65,536A/t Laser Target Hatch", + 11, + 65536).getStackForm(1L)); + eM_energyTunnel6_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15186, + "hatch.energytunnel6.tier.11", + "UIV 262,144A/t Laser Target Hatch", + 11, + 262144).getStackForm(1L)); + eM_energyTunnel7_UIV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15196, + "hatch.energytunnel7.tier.11", + "UIV 1,048,576A/t Laser Target Hatch", + 11, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15137, + "hatch.energytunnel1.tier.12", + "UMV 256A/t Laser Target Hatch", + 12, + 256).getStackForm(1L)); + eM_energyTunnel2_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15147, + "hatch.energytunnel2.tier.12", + "UMV 1,024A/t Laser Target Hatch", + 12, + 1024).getStackForm(1L)); + eM_energyTunnel3_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15157, + "hatch.energytunnel3.tier.12", + "UMV 4,096A/t Laser Target Hatch", + 12, + 4096).getStackForm(1L)); + eM_energyTunnel4_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15167, + "hatch.energytunnel4.tier.12", + "UMV 16,384A/t Laser Target Hatch", + 12, + 16384).getStackForm(1L)); + eM_energyTunnel5_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15177, + "hatch.energytunnel5.tier.12", + "UMV 65,536A/t Laser Target Hatch", + 12, + 65536).getStackForm(1L)); + eM_energyTunnel6_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15187, + "hatch.energytunnel6.tier.12", + "UMV 262,144A/t Laser Target Hatch", + 12, + 262144).getStackForm(1L)); + eM_energyTunnel7_UMV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15197, + "hatch.energytunnel7.tier.12", + "UMV 1,048,576A/t Laser Target Hatch", + 12, + 1048576).getStackForm(1L)); + + eM_energyTunnel1_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15138, + "hatch.energytunnel1.tier.13", + "UXV 256A/t Laser Target Hatch", + 13, + 256).getStackForm(1L)); + eM_energyTunnel2_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15148, + "hatch.energytunnel2.tier.13", + "UXV 1,024A/t Laser Target Hatch", + 13, + 1024).getStackForm(1L)); + eM_energyTunnel3_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15158, + "hatch.energytunnel3.tier.13", + "UXV 4,096A/t Laser Target Hatch", + 13, + 4096).getStackForm(1L)); + eM_energyTunnel4_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15168, + "hatch.energytunnel4.tier.13", + "UXV 16,384A/t Laser Target Hatch", + 13, + 16384).getStackForm(1L)); + eM_energyTunnel5_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15178, + "hatch.energytunnel5.tier.13", + "UXV 65,536A/t Laser Target Hatch", + 13, + 65536).getStackForm(1L)); + eM_energyTunnel6_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15188, + "hatch.energytunnel6.tier.13", + "UXV 262,144A/t Laser Target Hatch", + 13, + 262144).getStackForm(1L)); + eM_energyTunnel7_UXV.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15198, + "hatch.energytunnel7.tier.13", + "UXV 1,048,576A/t Laser Target Hatch", + 13, + 1048576).getStackForm(1L)); + eM_energyTunnel9001.set( + new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15199, + "hatch.energytunnel.tier.14", + "Legendary Laser Target Hatch", + 13, + (int) V[13]).getStackForm(1L)); + + // =================================================================================================== + // Multi AMP Power OUTPUTS + // =================================================================================================== + eM_dynamoMulti4_EV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15209, "hatch.dynamomulti04.tier.04", "EV 4A Dynamo Hatch", 4, 4) + .getStackForm(1L)); + eM_dynamoMulti16_EV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15219, "hatch.dynamomulti16.tier.04", "EV 16A Dynamo Hatch", 4, 16) + .getStackForm(1L)); + eM_dynamoMulti64_EV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15229, "hatch.dynamomulti64.tier.04", "EV 64A Dynamo Hatch", 4, 64) + .getStackForm(1L)); + + eM_dynamoMulti4_IV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15200, "hatch.dynamomulti04.tier.05", "IV 4A Dynamo Hatch", 5, 4) + .getStackForm(1L)); + eM_dynamoMulti16_IV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15210, "hatch.dynamomulti16.tier.05", "IV 16A Dynamo Hatch", 5, 16) + .getStackForm(1L)); + eM_dynamoMulti64_IV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15220, "hatch.dynamomulti64.tier.05", "IV 64A Dynamo Hatch", 5, 64) + .getStackForm(1L)); + + eM_dynamoMulti4_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15201, "hatch.dynamomulti04.tier.06", "LuV 4A Dynamo Hatch", 6, 4) + .getStackForm(1L)); + eM_dynamoMulti16_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15211, "hatch.dynamomulti16.tier.06", "LuV 16A Dynamo Hatch", 6, 16) + .getStackForm(1L)); + eM_dynamoMulti64_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15221, "hatch.dynamomulti64.tier.06", "LuV 64A Dynamo Hatch", 6, 64) + .getStackForm(1L)); + + eM_dynamoMulti4_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15202, "hatch.dynamomulti04.tier.07", "ZPM 4A Dynamo Hatch", 7, 4) + .getStackForm(1L)); + eM_dynamoMulti16_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15212, "hatch.dynamomulti16.tier.07", "ZPM 16A Dynamo Hatch", 7, 16) + .getStackForm(1L)); + eM_dynamoMulti64_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15222, "hatch.dynamomulti64.tier.07", "ZPM 64A Dynamo Hatch", 7, 64) + .getStackForm(1L)); + + eM_dynamoMulti4_UV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15203, "hatch.dynamomulti04.tier.08", "UV 4A Dynamo Hatch", 8, 4) + .getStackForm(1L)); + eM_dynamoMulti16_UV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15213, "hatch.dynamomulti16.tier.08", "UV 16A Dynamo Hatch", 8, 16) + .getStackForm(1L)); + eM_dynamoMulti64_UV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15223, "hatch.dynamomulti64.tier.08", "UV 64A Dynamo Hatch", 8, 64) + .getStackForm(1L)); + + eM_dynamoMulti4_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15204, "hatch.dynamomulti04.tier.09", "UHV 4A Dynamo Hatch", 9, 4) + .getStackForm(1L)); + eM_dynamoMulti16_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15214, "hatch.dynamomulti16.tier.09", "UHV 16A Dynamo Hatch", 9, 16) + .getStackForm(1L)); + eM_dynamoMulti64_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15224, "hatch.dynamomulti64.tier.09", "UHV 64A Dynamo Hatch", 9, 64) + .getStackForm(1L)); + + eM_dynamoMulti4_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15205, "hatch.dynamomulti04.tier.10", "UEV 4A Dynamo Hatch", 10, 4) + .getStackForm(1L)); + eM_dynamoMulti16_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15215, + "hatch.dynamomulti16.tier.10", + "UEV 16A Dynamo Hatch", + 10, + 16).getStackForm(1L)); + eM_dynamoMulti64_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15225, + "hatch.dynamomulti64.tier.10", + "UEV 64A Dynamo Hatch", + 10, + 64).getStackForm(1L)); + + eM_dynamoMulti4_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15206, "hatch.dynamomulti04.tier.11", "UIV 4A Dynamo Hatch", 11, 4) + .getStackForm(1L)); + eM_dynamoMulti16_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15216, + "hatch.dynamomulti16.tier.11", + "UIV 16A Dynamo Hatch", + 11, + 16).getStackForm(1L)); + eM_dynamoMulti64_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15226, + "hatch.dynamomulti64.tier.11", + "UIV 64A Dynamo Hatch", + 11, + 64).getStackForm(1L)); + + eM_dynamoMulti4_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15207, "hatch.dynamomulti04.tier.12", "UMV 4A Dynamo Hatch", 12, 4) + .getStackForm(1L)); + eM_dynamoMulti16_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15217, + "hatch.dynamomulti16.tier.12", + "UMV 16A Dynamo Hatch", + 12, + 16).getStackForm(1L)); + eM_dynamoMulti64_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15227, + "hatch.dynamomulti64.tier.12", + "UMV 64A Dynamo Hatch", + 12, + 64).getStackForm(1L)); + + eM_dynamoMulti4_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti(15208, "hatch.dynamomulti04.tier.13", "UXV 4A Dynamo Hatch", 13, 4) + .getStackForm(1L)); + eM_dynamoMulti16_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15218, + "hatch.dynamomulti16.tier.13", + "UXV 16A Dynamo Hatch", + 13, + 16).getStackForm(1L)); + eM_dynamoMulti64_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoMulti( + 15228, + "hatch.dynamomulti64.tier.13", + "UXV 64A Dynamo Hatch", + 13, + 64).getStackForm(1L)); + + // =================================================================================================== + // Multi AMP Laser OUTPUTS + // =================================================================================================== + + eM_dynamoTunnel1_IV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15230, + "hatch.dynamotunnel1.tier.05", + "IV 256A/t Laser Source Hatch", + 5, + 256).getStackForm(1L)); + eM_dynamoTunnel2_IV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15240, + "hatch.dynamotunnel2.tier.05", + "IV 1,024A/t Laser Source Hatch", + 5, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_IV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15250, + "hatch.dynamotunnel3.tier.05", + "IV 4,096A/t Laser Source Hatch", + 5, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_IV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15260, + "hatch.dynamotunnel4.tier.05", + "IV 16,384A/t Laser Source Hatch", + 5, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_IV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15270, + "hatch.dynamotunnel5.tier.05", + "IV 65,536A/t Laser Source Hatch", + 5, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_IV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15280, + "hatch.dynamotunnel6.tier.05", + "IV 262,144A/t Laser Source Hatch", + 5, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_IV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15290, + "hatch.dynamotunnel7.tier.05", + "IV 1,048,576A/t Laser Source Hatch", + 5, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15231, + "hatch.dynamotunnel1.tier.06", + "LuV 256A/t Laser Source Hatch", + 6, + 256).getStackForm(1L)); + eM_dynamoTunnel2_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15241, + "hatch.dynamotunnel2.tier.06", + "LuV 1,024A/t Laser Source Hatch", + 6, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15251, + "hatch.dynamotunnel3.tier.06", + "LuV 4,096A/t Laser Source Hatch", + 6, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15261, + "hatch.dynamotunnel4.tier.06", + "LuV 16,384A/t Laser Source Hatch", + 6, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15271, + "hatch.dynamotunnel5.tier.06", + "LuV 65,536A/t Laser Source Hatch", + 6, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15281, + "hatch.dynamotunnel6.tier.06", + "LuV 262,144A/t Laser Source Hatch", + 6, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15291, + "hatch.dynamotunnel7.tier.06", + "LuV 1,048,576A/t Laser Source Hatch", + 6, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15232, + "hatch.dynamotunnel1.tier.07", + "ZPM 256A/t Laser Source Hatch", + 7, + 256).getStackForm(1L)); + eM_dynamoTunnel2_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15242, + "hatch.dynamotunnel2.tier.07", + "ZPM 1,024A/t Laser Source Hatch", + 7, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15252, + "hatch.dynamotunnel3.tier.07", + "ZPM 4,096A/t Laser Source Hatch", + 7, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15262, + "hatch.dynamotunnel4.tier.07", + "ZPM 16,384A/t Laser Source Hatch", + 7, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15272, + "hatch.dynamotunnel5.tier.07", + "ZPM 65,536A/t Laser Source Hatch", + 7, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15282, + "hatch.dynamotunnel6.tier.07", + "ZPM 262,144A/t Laser Source Hatch", + 7, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15292, + "hatch.dynamotunnel7.tier.07", + "ZPM 1,048,576A/t Laser Source Hatch", + 7, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_UV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15233, + "hatch.dynamotunnel1.tier.08", + "UV 256A/t Laser Source Hatch", + 8, + 256).getStackForm(1L)); + eM_dynamoTunnel2_UV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15243, + "hatch.dynamotunnel2.tier.08", + "UV 1,024A/t Laser Source Hatch", + 8, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_UV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15253, + "hatch.dynamotunnel3.tier.08", + "UV 4,096A/t Laser Source Hatch", + 8, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_UV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15263, + "hatch.dynamotunnel4.tier.08", + "UV 16,384A/t Laser Source Hatch", + 8, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_UV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15273, + "hatch.dynamotunnel5.tier.08", + "UV 65,536A/t Laser Source Hatch", + 8, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_UV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15283, + "hatch.dynamotunnel6.tier.08", + "UV 262,144A/t Laser Source Hatch", + 8, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_UV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15293, + "hatch.dynamotunnel7.tier.08", + "UV 1,048,576A/t Laser Source Hatch", + 8, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15234, + "hatch.dynamotunnel1.tier.09", + "UHV 256A/t Laser Source Hatch", + 9, + 256).getStackForm(1L)); + eM_dynamoTunnel2_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15244, + "hatch.dynamotunnel2.tier.09", + "UHV 1,024A/t Laser Source Hatch", + 9, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15254, + "hatch.dynamotunnel3.tier.09", + "UHV 4,096A/t Laser Source Hatch", + 9, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15264, + "hatch.dynamotunnel4.tier.09", + "UHV 16,384A/t Laser Source Hatch", + 9, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15274, + "hatch.dynamotunnel5.tier.09", + "UHV 65,536A/t Laser Source Hatch", + 9, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15284, + "hatch.dynamotunnel6.tier.09", + "UHV 262,144A/t Laser Source Hatch", + 9, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_UHV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15294, + "hatch.dynamotunnel7.tier.09", + "UHV 1,048,576A/t Laser Source Hatch", + 9, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15235, + "hatch.dynamotunnel1.tier.10", + "UEV 256A/t Laser Source Hatch", + 10, + 256).getStackForm(1L)); + eM_dynamoTunnel2_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15245, + "hatch.dynamotunnel2.tier.10", + "UEV 1,024A/t Laser Source Hatch", + 10, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15255, + "hatch.dynamotunnel3.tier.10", + "UEV 4,096A/t Laser Source Hatch", + 10, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15265, + "hatch.dynamotunnel4.tier.10", + "UEV 16,384A/t Laser Source Hatch", + 10, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15275, + "hatch.dynamotunnel5.tier.10", + "UEV 65,536A/t Laser Source Hatch", + 10, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15285, + "hatch.dynamotunnel6.tier.10", + "UEV 262,144A/t Laser Source Hatch", + 10, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_UEV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15295, + "hatch.dynamotunnel7.tier.10", + "UEV 1,048,576A/t Laser Source Hatch", + 10, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15236, + "hatch.dynamotunnel1.tier.11", + "UIV 256A/t Laser Source Hatch", + 11, + 256).getStackForm(1L)); + eM_dynamoTunnel2_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15246, + "hatch.dynamotunnel2.tier.11", + "UIV 1,024A/t Laser Source Hatch", + 11, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15256, + "hatch.dynamotunnel3.tier.11", + "UIV 4,096A/t Laser Source Hatch", + 11, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15266, + "hatch.dynamotunnel4.tier.11", + "UIV 16,384A/t Laser Source Hatch", + 11, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15276, + "hatch.dynamotunnel5.tier.11", + "UIV 65,536A/t Laser Source Hatch", + 11, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15286, + "hatch.dynamotunnel6.tier.11", + "UIV 262,144A/t Laser Source Hatch", + 11, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_UIV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15296, + "hatch.dynamotunnel7.tier.11", + "UIV 1,048,576A/t Laser Source Hatch", + 11, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15237, + "hatch.dynamotunnel1.tier.12", + "UMV 256A/t Laser Source Hatch", + 12, + 256).getStackForm(1L)); + eM_dynamoTunnel2_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15247, + "hatch.dynamotunnel2.tier.12", + "UMV 1,024A/t Laser Source Hatch", + 12, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15257, + "hatch.dynamotunnel3.tier.12", + "UMV 4,096A/t Laser Source Hatch", + 12, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15267, + "hatch.dynamotunnel4.tier.12", + "UMV 16,384A/t Laser Source Hatch", + 12, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15277, + "hatch.dynamotunnel5.tier.12", + "UMV 65,536A/t Laser Source Hatch", + 12, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15287, + "hatch.dynamotunnel6.tier.12", + "UMV 262,144A/t Laser Source Hatch", + 12, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_UMV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15297, + "hatch.dynamotunnel7.tier.12", + "UMV 1,048,576A/t Laser Source Hatch", + 12, + 1048576).getStackForm(1L)); + + eM_dynamoTunnel1_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15238, + "hatch.dynamotunnel1.tier.13", + "UXV 256A/t Laser Source Hatch", + 13, + 256).getStackForm(1L)); + eM_dynamoTunnel2_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15248, + "hatch.dynamotunnel2.tier.13", + "UXV 1,024A/t Laser Source Hatch", + 13, + 1024).getStackForm(1L)); + eM_dynamoTunnel3_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15258, + "hatch.dynamotunnel3.tier.13", + "UXV 4,096A/t Laser Source Hatch", + 13, + 4096).getStackForm(1L)); + eM_dynamoTunnel4_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15268, + "hatch.dynamotunnel4.tier.13", + "UXV 16,384A/t Laser Source Hatch", + 13, + 16384).getStackForm(1L)); + eM_dynamoTunnel5_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15278, + "hatch.dynamotunnel5.tier.13", + "UXV 65,536A/t Laser Source Hatch", + 13, + 65536).getStackForm(1L)); + eM_dynamoTunnel6_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15288, + "hatch.dynamotunnel6.tier.13", + "UXV 262,144A/t Laser Source Hatch", + 13, + 262144).getStackForm(1L)); + eM_dynamoTunnel7_UXV.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15298, + "hatch.dynamotunnel7.tier.13", + "UXV 1,048,576A/t Laser Source Hatch", + 13, + 1048576).getStackForm(1L)); + eM_dynamoTunnel9001.set( + new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15299, + "hatch.dynamotunnel.tier.14", + "Legendary Laser Source Hatch", + 13, + (int) V[13]).getStackForm(1L)); + + // =================================================================================================== + // MULTIBLOCKS + // =================================================================================================== + + Machine_Multi_Transformer.set( + new GT_MetaTileEntity_EM_transformer(15300, "multimachine.em.transformer", "Active Transformer") + .getStackForm(1L)); + Machine_Multi_Microwave.set( + new GT_MetaTileEntity_TM_microwave(15312, "multimachine.tm.microwave", "Microwave Grinder") + .getStackForm(1L)); + Machine_Multi_TeslaCoil.set( + new GT_MetaTileEntity_TM_teslaCoil(15314, "multimachine.tm.teslaCoil", "Tesla Tower").getStackForm(1L)); + + Machine_Multi_Switch.set( + new GT_MetaTileEntity_EM_switch(15310, "multimachine.em.switch", "Network Switch With QoS") + .getStackForm(1L)); + Machine_Multi_Computer.set( + new GT_MetaTileEntity_EM_computer(15311, "multimachine.em.computer", "Quantum Computer").getStackForm(1L)); + + Machine_Multi_DataBank + .set(new GT_MetaTileEntity_EM_dataBank(15313, "multimachine.em.databank", "Data Bank").getStackForm(1L)); + + Machine_Multi_Research.set( + new GT_MetaTileEntity_EM_research(15331, "multimachine.em.research", "Research station").getStackForm(1L)); + + Machine_Multi_Infuser + .set(new GT_MetaTileEntity_EM_infuser(15350, "multimachine.em.infuser", "Energy Infuser").getStackForm(1)); + + Machine_Multi_EyeOfHarmony.set( + new GT_MetaTileEntity_EM_EyeOfHarmony(15410, "multimachine.em.eye_of_harmony", "Eye of Harmony") + .getStackForm(1L)); + if (!NewHorizonsCoreMod.isModLoaded()) { + Machine_Multi_ForgeOfGods.set( + new GT_MetaTileEntity_EM_ForgeOfGods(15411, "multimachine.em.forge_of_gods", "Forge of the Gods") + .getStackForm(1L)); + Machine_Multi_SmeltingModule.set( + new GT_MetaTileEntity_EM_SmeltingModule( + 15412, + "multimachine.em.smelting_module", + "Helioflare Power Forge").getStackForm(1L)); + Machine_Multi_MoltenModule.set( + new GT_MetaTileEntity_EM_MoltenModule(15413, "multimachine.em.molten_module", "Helioflux Melting Core") + .getStackForm(1L)); + Machine_Multi_PlasmaModule.set( + new GT_MetaTileEntity_EM_PlasmaModule( + 15414, + "multimachine.em.plasma_module", + "Heliothermal Plasma Fabricator").getStackForm(1L)); + Machine_Multi_QuarkGluonPlasmaModule.set( + new GT_MetaTileEntity_EM_ExoticModule(15415, "multimachine.em.exotic_module", "Heliofusion Exoticizer") + .getStackForm(1L)); + } + + // =================================================================================================== + // Hatches + // =================================================================================================== + + Parametrizer_Hatch + .set(new GT_MetaTileEntity_Hatch_Param(15420, "hatch.param.tier.05", "Parametrizer", 5).getStackForm(1L)); // TODO + // refactor + // aName + // to + // hatch.param.tier.04 + // and + // aTier + // to + // 4, + // check + // recipe + // for + // NH + ParametrizerX_Hatch + .set(new GT_MetaTileEntity_Hatch_Param(15421, "hatch.param.tier.07", "Parametrizer X", 7).getStackForm(1L)); + ParametrizerTXT_Hatch.set( + new GT_MetaTileEntity_Hatch_ParamText(15422, "hatch.param.tier.10", "Parametrizer tXt", 10) + .getStackForm(1L)); // TODO check recipe for NH + + Uncertainty_Hatch.set( + new GT_MetaTileEntity_Hatch_Uncertainty(15430, "hatch.certain.tier.07", "Uncertainty Resolver", 7) + .getStackForm(1L)); + UncertaintyX_Hatch.set( + new GT_MetaTileEntity_Hatch_Uncertainty(15431, "hatch.certain.tier.10", "Uncertainty Resolver X", 10) + .getStackForm(1L)); + + dataIn_Hatch.set( + new GT_MetaTileEntity_Hatch_InputData(15440, "hatch.datain.tier.07", "Optical Slave Connector", 7) + .getStackForm(1L)); + dataOut_Hatch.set( + new GT_MetaTileEntity_Hatch_OutputData(15441, "hatch.dataout.tier.07", "Optical Master Connector", 7) + .getStackForm(1L)); + dataInAss_Hatch.set( + new GT_MetaTileEntity_Hatch_InputDataItems( + 15442, + "hatch.datainass.tier.07", + "Assembly line Slave Connector", + 7).getStackForm(1L)); + dataOutAss_Hatch.set( + new GT_MetaTileEntity_Hatch_OutputDataItems( + 15443, + "hatch.dataoutass.tier.07", + "Data Bank Master Connector", + 7).getStackForm(1L)); + + rack_Hatch + .set(new GT_MetaTileEntity_Hatch_Rack(15450, "hatch.rack.tier.08", "Computer Rack", 8).getStackForm(1L)); + holder_Hatch.set( + new GT_MetaTileEntity_Hatch_Holder(15451, "hatch.holder.tier.09", "Object Holder", 8).getStackForm(1L)); + + capacitor_Hatch.set( + new GT_MetaTileEntity_Hatch_Capacitor(15452, "hatch.capacitor.tier.03", "Capacitor Hatch", 3) + .getStackForm(1L)); + + // =================================================================================================== + // Pipes + // =================================================================================================== + + LASERpipe + .set(new GT_MetaTileEntity_Pipe_Energy(15465, "pipe.energystream", "Laser Vacuum Pipe").getStackForm(1L)); + DATApipe.set(new GT_MetaTileEntity_Pipe_Data(15470, "pipe.datastream", "Optical Fiber Cable").getStackForm(1L)); + + LASERpipeBlock.set( + new GT_MetaTileEntity_PipeBlock_Energy(15472, "pipe.energystream.block", "Laser Vacuum Pipe Casing") + .getStackForm(1L)); + DATApipeBlock.set( + new GT_MetaTileEntity_PipeBlock_Data(15473, "pipe.datastream.block", "Optical Fiber Cable Casing") + .getStackForm(1L)); + + // =================================================================================================== + // Single Blocks + // =================================================================================================== + + Machine_OwnerDetector.set( + new GT_MetaTileEntity_OwnerDetector(15480, "machine.tt.ownerdetector", "Owner detector", 3) + .getStackForm(1L)); + + // =================================================================================================== + // Buck Converters + // =================================================================================================== + + Machine_BuckConverter_IV.set( + new GT_MetaTileEntity_BuckConverter(15485, "machine.tt.buck.05", "Insane Buck Converter", 5) + .getStackForm(1L)); + Machine_BuckConverter_LuV.set( + new GT_MetaTileEntity_BuckConverter(15486, "machine.tt.buck.06", "Ludicrous Buck Converter", 6) + .getStackForm(1L)); + Machine_BuckConverter_ZPM.set( + new GT_MetaTileEntity_BuckConverter(15487, "machine.tt.buck.07", "ZPM Voltage Buck Converter", 7) + .getStackForm(1L)); + Machine_BuckConverter_UV.set( + new GT_MetaTileEntity_BuckConverter(15488, "machine.tt.buck.08", "Ultimate Power Buck Converter", 8) + .getStackForm(1L)); + Machine_BuckConverter_UHV.set( + new GT_MetaTileEntity_BuckConverter(15489, "machine.tt.buck.09", "Highly Ultimate Buck Converter", 9) + .getStackForm(1L)); + Machine_BuckConverter_UEV.set( + new GT_MetaTileEntity_BuckConverter(15490, "machine.tt.buck.10", "Extremely Ultimate Buck Converter", 10) + .getStackForm(1L)); + Machine_BuckConverter_UIV.set( + new GT_MetaTileEntity_BuckConverter(15491, "machine.tt.buck.11", "Insanely Ultimate Buck Converter", 11) + .getStackForm(1L)); + Machine_BuckConverter_UMV.set( + new GT_MetaTileEntity_BuckConverter(15492, "machine.tt.buck.12", "Mega Ultimate Buck Converter", 12) + .getStackForm(1L)); + Machine_BuckConverter_UXV.set( + new GT_MetaTileEntity_BuckConverter( + 15493, + "machine.tt.buck.13", + "Extended Mega Ultimate Buck Converter", + 13).getStackForm(1L)); + + // =================================================================================================== + // Tesla Transceiver + // =================================================================================================== + + Machine_TeslaCoil_1by1_LV.set( + new GT_MetaTileEntity_TeslaCoil(16000, "machine.tt.tesla.01", "Basic Tesla Transceiver", 1, 1) + .getStackForm(1L)); + Machine_TeslaCoil_1by1_MV.set( + new GT_MetaTileEntity_TeslaCoil(16001, "machine.tt.tesla.02", "Advanced Tesla Transceiver", 2, 1) + .getStackForm(1L)); + Machine_TeslaCoil_1by1_HV.set( + new GT_MetaTileEntity_TeslaCoil(16002, "machine.tt.tesla.03", "Epyc Tesla Transceiver", 3, 1) + .getStackForm(1L)); + Machine_TeslaCoil_1by1_EV.set( + new GT_MetaTileEntity_TeslaCoil(16003, "machine.tt.tesla.04", "Ultimate Power Tesla Transceiver", 4, 1) + .getStackForm(1L)); + Machine_TeslaCoil_1by1_IV.set( + new GT_MetaTileEntity_TeslaCoil(16004, "machine.tt.tesla.05", "Insane Tesla Transceiver", 5, 1) + .getStackForm(1L)); + + Machine_TeslaCoil_2by2_LV.set( + new GT_MetaTileEntity_TeslaCoil(16005, "machine.tt.tesla.01", "Basic Tesla Transceiver", 1, 4) + .getStackForm(1L)); + Machine_TeslaCoil_2by2_MV.set( + new GT_MetaTileEntity_TeslaCoil(16006, "machine.tt.tesla.02", "Advanced Tesla Transceiver", 2, 4) + .getStackForm(1L)); + Machine_TeslaCoil_2by2_HV.set( + new GT_MetaTileEntity_TeslaCoil(16007, "machine.tt.tesla.03", "Epyc Tesla Transceiver", 3, 4) + .getStackForm(1L)); + Machine_TeslaCoil_2by2_EV.set( + new GT_MetaTileEntity_TeslaCoil(16008, "machine.tt.tesla.04", "Ultimate Power Tesla Transceiver", 4, 4) + .getStackForm(1L)); + Machine_TeslaCoil_2by2_IV.set( + new GT_MetaTileEntity_TeslaCoil(16009, "machine.tt.tesla.05", "Insane Tesla Transceiver", 5, 4) + .getStackForm(1L)); + + Machine_TeslaCoil_3by3_LV.set( + new GT_MetaTileEntity_TeslaCoil(16010, "machine.tt.tesla.01", "Basic Tesla Transceiver", 1, 9) + .getStackForm(1L)); + Machine_TeslaCoil_3by3_MV.set( + new GT_MetaTileEntity_TeslaCoil(16011, "machine.tt.tesla.02", "Advanced Tesla Transceiver", 2, 9) + .getStackForm(1L)); + Machine_TeslaCoil_3by3_HV.set( + new GT_MetaTileEntity_TeslaCoil(16012, "machine.tt.tesla.03", "Epyc Tesla Transceiver", 3, 9) + .getStackForm(1L)); + Machine_TeslaCoil_3by3_EV.set( + new GT_MetaTileEntity_TeslaCoil(16013, "machine.tt.tesla.04", "Ultimate Power Tesla Transceiver", 4, 9) + .getStackForm(1L)); + Machine_TeslaCoil_3by3_IV.set( + new GT_MetaTileEntity_TeslaCoil(16014, "machine.tt.tesla.05", "Insane Tesla Transceiver", 5, 9) + .getStackForm(1L)); + + Machine_TeslaCoil_4by4_LV.set( + new GT_MetaTileEntity_TeslaCoil(16015, "machine.tt.tesla.01", "Basic Tesla Transceiver", 1, 16) + .getStackForm(1L)); + Machine_TeslaCoil_4by4_MV.set( + new GT_MetaTileEntity_TeslaCoil(16016, "machine.tt.tesla.02", "Advanced Tesla Transceiver", 2, 16) + .getStackForm(1L)); + Machine_TeslaCoil_4by4_HV.set( + new GT_MetaTileEntity_TeslaCoil(16017, "machine.tt.tesla.03", "Epyc Tesla Transceiver", 3, 16) + .getStackForm(1L)); + Machine_TeslaCoil_4by4_EV.set( + new GT_MetaTileEntity_TeslaCoil(16018, "machine.tt.tesla.04", "Ultimate Power Tesla Transceiver", 4, 16) + .getStackForm(1L)); + Machine_TeslaCoil_4by4_IV.set( + new GT_MetaTileEntity_TeslaCoil(16019, "machine.tt.tesla.05", "Insane Tesla Transceiver", 5, 16) + .getStackForm(1L)); + + // =================================================================================================== + // Debug Stuff + // =================================================================================================== + Machine_DebugPollutor.set( + new GT_MetaTileEntity_DebugPollutor(15495, "debug.tt.pollutor", "Debug Pollution Generator", 14) + .getStackForm(1)); + hatch_CreativeData.set( + new GT_MetaTileEntity_Hatch_CreativeData(15496, "debug.tt.data", "Debug Data Hatch", 14).getStackForm(1)); + hatch_CreativeMaintenance.set( + new GT_MetaTileEntity_Hatch_CreativeMaintenance( + 15497, + "debug.tt.maintenance", + "Auto-Taping Maintenance Hatch", + 14).getStackForm(1L)); + Machine_DebugGenny.set( + new GT_MetaTileEntity_DebugPowerGenerator(15498, "debug.tt.genny", "Debug Power Generator", 14) + .getStackForm(1L)); + Machine_DebugWriter.set( + new GT_MetaTileEntity_DebugStructureWriter(15499, "debug.tt.writer", "Debug Structure Writer", 14) + .getStackForm(1L)); + UnusedStuff.set(new ItemStack(Blocks.air)); + hatch_CreativeUncertainty.set( + new GT_MetaTileEntity_Hatch_CreativeUncertainty(15510, "debug.tt.certain", "Uncertainty Resolution", 14) + .getStackForm(1)); + + // =================================================================================================== + // MetaTE init + // =================================================================================================== + + GT_MetaTileEntity_Hatch_Rack.run(); + + GT_MetaTileEntity_Hatch_Capacitor.run(); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/thing/MuTeLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/MuTeLoader.java new file mode 100644 index 0000000000..15ab723e42 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/thing/MuTeLoader.java @@ -0,0 +1,21 @@ +package com.github.technus.tectech.loader.thing; + +import com.github.technus.tectech.TecTech; + +public class MuTeLoader implements Runnable { + + @Override + public void run() { + TecTech.LOGGER.info("TecTech: Registering MultiTileEntities"); + registerMachines(); + registerCasings(); + } + + private static void registerMachines() { + + } + + private static void registerCasings() { + + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java new file mode 100644 index 0000000000..11e4415080 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java @@ -0,0 +1,99 @@ +package com.github.technus.tectech.loader.thing; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.tectechTexturePage1; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.block.GodforgeGlassBlock; +import com.github.technus.tectech.thing.block.QuantumGlassBlock; +import com.github.technus.tectech.thing.block.ReactorSimBlock; +import com.github.technus.tectech.thing.block.TileEyeOfHarmony; +import com.github.technus.tectech.thing.block.TileForgeOfGods; +import com.github.technus.tectech.thing.casing.GT_Block_CasingsBA0; +import com.github.technus.tectech.thing.casing.GT_Block_CasingsTT; +import com.github.technus.tectech.thing.casing.GodforgeCasings; +import com.github.technus.tectech.thing.casing.SpacetimeCompressionFieldCasing; +import com.github.technus.tectech.thing.casing.StabilisationFieldCasing; +import com.github.technus.tectech.thing.casing.TT_Container_Casings; +import com.github.technus.tectech.thing.casing.TimeAccelerationFieldCasing; +import com.github.technus.tectech.thing.item.AstralArrayFabricator; +import com.github.technus.tectech.thing.item.EnderFluidLinkCover; +import com.github.technus.tectech.thing.item.EuMeterGT; +import com.github.technus.tectech.thing.item.ParametrizerMemoryCard; +import com.github.technus.tectech.thing.item.PowerPassUpgradeCover; +import com.github.technus.tectech.thing.item.TeslaCoilCapacitor; +import com.github.technus.tectech.thing.item.TeslaCoilComponent; +import com.github.technus.tectech.thing.item.TeslaCoilCover; +import com.github.technus.tectech.thing.item.TeslaStaff; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; + +/** + * Created by danie_000 on 16.11.2016. + */ +public class ThingsLoader implements Runnable { + + @Override + public void run() { + + GameRegistry.registerTileEntity(TileEyeOfHarmony.class, MODID + ":EyeOfHarmonyRenderBlock"); + GameRegistry.registerTileEntity(TileForgeOfGods.class, MODID + ":ForgeOfGodsRenderBlock"); + + if (Textures.BlockIcons.casingTexturePages[tectechTexturePage1] == null) { + Textures.BlockIcons.casingTexturePages[tectechTexturePage1] = new ITexture[128]; + } + + if (Textures.BlockIcons.casingTexturePages[7] == null) { + Textures.BlockIcons.casingTexturePages[7] = new ITexture[128]; + } + + TecTech.LOGGER.info("Added texture page if was null"); + + TT_Container_Casings.sBlockCasingsTT = new GT_Block_CasingsTT(); + TecTech.LOGGER.info("Elemental Casing registered"); + TT_Container_Casings.sBlockCasingsBA0 = new GT_Block_CasingsBA0(); + TecTech.LOGGER.info("Nikolai's Casing registered"); + + TT_Container_Casings.SpacetimeCompressionFieldGenerators = new SpacetimeCompressionFieldCasing(); + TecTech.LOGGER.info("Spacetime Compression Field Casings registered."); + + TT_Container_Casings.TimeAccelerationFieldGenerator = new TimeAccelerationFieldCasing(); + TecTech.LOGGER.info("Time Acceleration Field Casings registered."); + + TT_Container_Casings.StabilisationFieldGenerators = new StabilisationFieldCasing(); + + if (!NewHorizonsCoreMod.isModLoaded()) { + + TT_Container_Casings.GodforgeCasings = new GodforgeCasings(); + TecTech.LOGGER.info("Godforge blocks registered."); + + GodforgeGlassBlock.run(); + TecTech.LOGGER.info("Godforge Glass registered"); + + } + + QuantumGlassBlock.run(); + TecTech.LOGGER.info("Quantum Glass registered"); + + ReactorSimBlock.run(); + TecTech.LOGGER.info("Reactor Simulator registered"); + + ParametrizerMemoryCard.run(); + EuMeterGT.run(); + TeslaStaff.run(); + TeslaCoilCover.run(); + TeslaCoilCapacitor.run(); + EnderFluidLinkCover.run(); + PowerPassUpgradeCover.run(); + TecTech.LOGGER.info("Useful Items registered"); + + TeslaCoilComponent.run(); + AstralArrayFabricator.run(); + TecTech.LOGGER.info("Crafting Components registered"); + + TecTech.LOGGER.info("Debug Items registered"); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/dataTransport/DataPacket.java b/src/main/java/com/github/technus/tectech/mechanics/dataTransport/DataPacket.java new file mode 100644 index 0000000000..01ef4560ee --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/dataTransport/DataPacket.java @@ -0,0 +1,104 @@ +package com.github.technus.tectech.mechanics.dataTransport; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import net.minecraft.nbt.NBTTagCompound; + +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +/** + * Created by Tec on 05.04.2017. + */ +public abstract class DataPacket { + + private static final byte MAX_HISTORY = 64; + private final Set trace = new LinkedHashSet<>(); + + protected T content; + + protected DataPacket(T content) { + this.content = content; + } + + protected DataPacket(NBTTagCompound nbt) { + content = contentFromNBT(nbt.getCompoundTag("qContent")); + for (int i = 0; i < nbt.getByte("qHistory"); i++) { + trace.add(new Vec3Impl(nbt.getInteger("qX" + i), nbt.getInteger("qY" + i), nbt.getInteger("qZ" + i))); + } + } + + public final NBTTagCompound toNbt() { + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagCompound contentTag = contentToNBT(); + if (contentTag != null) { + nbt.setTag("qContent", contentTag); + } + nbt.setByte("qHistory", (byte) trace.size()); + int i = 0; + for (Vec3Impl v : trace) { + nbt.setInteger("qX" + i, v.get0()); + nbt.setInteger("qY" + i, v.get1()); + nbt.setInteger("qZ" + i, v.get2()); + i++; + } + return nbt; + } + + protected abstract NBTTagCompound contentToNBT(); + + protected abstract T contentFromNBT(NBTTagCompound nbt); + + protected abstract T unifyContentWith(T content); + + public final boolean contains(Vec3Impl v) { + return trace.contains(v); + } + + public final boolean check() { + return trace.size() <= MAX_HISTORY; + } + + public abstract boolean extraCheck(); + + protected final DataPacket unifyTrace(Vec3Impl... positions) { + Collections.addAll(trace, positions); + return (check() && extraCheck()) ? this : null; + } + + protected final DataPacket unifyTrace(DataPacket p) { + if (p == null) return this; + trace.addAll(p.trace); + return (check() && extraCheck()) ? this : null; + } + + protected final DataPacket unifyWith(DataPacket p) { + if (p == null) return this; + trace.addAll(p.trace); + if (check() && extraCheck()) { + content = unifyContentWith(p.content); + return this; + } + return null; + } + + public final T contentIfNotInTrace(Vec3Impl pos) { + if (trace.contains(pos)) { + return null; + } + return getContent(); + } + + public T getContent() { + return content; + } + + public String getContentString() { + return content.toString(); + } + + public final int getTraceSize() { + return trace.size(); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/dataTransport/InventoryDataPacket.java b/src/main/java/com/github/technus/tectech/mechanics/dataTransport/InventoryDataPacket.java new file mode 100644 index 0000000000..e6e24b9ac7 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/dataTransport/InventoryDataPacket.java @@ -0,0 +1,62 @@ +package com.github.technus.tectech.mechanics.dataTransport; + +import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class InventoryDataPacket extends DataPacket { + + public InventoryDataPacket(ItemStack[] content) { + super(content); + } + + public InventoryDataPacket(NBTTagCompound compound) { + super(compound); + } + + @Override + protected ItemStack[] contentFromNBT(NBTTagCompound nbt) { + int count = nbt.getInteger("count"); + if (count > 0) { + ArrayList stacks = new ArrayList<>(); + for (int i = 0; i < count; i++) { + ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag(Integer.toString(i))); + if (stack != null) { + stacks.add(stack); + } + } + return stacks.size() > 0 ? stacks.toArray(nullItem) : null; + } + return null; + } + + @Override + protected NBTTagCompound contentToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + if (content != null && content.length > 0) { + compound.setInteger("count", content.length); + for (int i = 0; i < content.length; i++) { + compound.setTag(Integer.toString(i), content[i].writeToNBT(new NBTTagCompound())); + } + } + return compound; + } + + @Override + public boolean extraCheck() { + return true; + } + + @Override + protected ItemStack[] unifyContentWith(ItemStack[] content) { + throw new NoSuchMethodError("Unavailable to unify item stack data packet"); + } + + @Override + public String getContentString() { + return "Stack Count: " + (content == null ? 0 : content.length); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/dataTransport/QuantumDataPacket.java b/src/main/java/com/github/technus/tectech/mechanics/dataTransport/QuantumDataPacket.java new file mode 100644 index 0000000000..8dff99a42d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/dataTransport/QuantumDataPacket.java @@ -0,0 +1,50 @@ +package com.github.technus.tectech.mechanics.dataTransport; + +import net.minecraft.nbt.NBTTagCompound; + +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +public class QuantumDataPacket extends DataPacket { + + public QuantumDataPacket(Long content) { + super(content); + } + + public QuantumDataPacket(NBTTagCompound compound) { + super(compound); + } + + @Override + protected Long contentFromNBT(NBTTagCompound nbt) { + return nbt.getLong("computation"); + } + + @Override + protected NBTTagCompound contentToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setLong("computation", content); + return compound; + } + + @Override + public boolean extraCheck() { + return true; + } + + @Override + protected Long unifyContentWith(Long content) { + return this.content + content; + } + + public QuantumDataPacket unifyTraceWith(Vec3Impl... positions) { + return (QuantumDataPacket) super.unifyTrace(positions); + } + + public QuantumDataPacket unifyTraceWith(QuantumDataPacket p) { + return (QuantumDataPacket) super.unifyTrace(p); + } + + public QuantumDataPacket unifyPacketWith(QuantumDataPacket p) { + return (QuantumDataPacket) super.unifyWith(p); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderFluidContainer.java b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderFluidContainer.java new file mode 100644 index 0000000000..2499ecf596 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderFluidContainer.java @@ -0,0 +1,134 @@ +package com.github.technus.tectech.mechanics.enderStorage; + +import java.io.DataInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +import com.github.technus.tectech.TecTech; + +public class EnderFluidContainer implements IFluidHandler, Serializable { + + private static final long serialVersionUID = 2L; + private static final int SERIALIZE_TYPE_WITH_NBT = 0; + private static final int SERIALIZE_TYPE_WITHOUT_NBT = 1; + private static final int SERIALIZE_TYPE_NULL = 2; + + private static final int CAPACITY = 64000; + private transient FluidStack fluidStack; + + public EnderFluidContainer() {} + + private FluidStack getFluidStack() { + return fluidStack; + } + + private void setFluidStack(FluidStack fluidStack) { + this.fluidStack = fluidStack; + } + + @Override + public int fill(ForgeDirection side, FluidStack fluidStackIn, boolean doFill) { + int filledFluid = 0; + FluidStack fluidStackStored = getFluidStack(); + if (fluidStackIn != null) { + if (fluidStackStored == null) { + fluidStackStored = fluidStackIn.copy(); + fluidStackStored.amount = 0; + } + if (fluidStackStored.amount < CAPACITY && fluidStackIn.isFluidEqual(fluidStackStored)) { + filledFluid = Math.min(CAPACITY - fluidStackStored.amount, fluidStackIn.amount); + if (doFill) { + fluidStackStored.amount += filledFluid; + setFluidStack(fluidStackStored); + } + } + } + return filledFluid; + } + + @Override + public FluidStack drain(ForgeDirection side, FluidStack fluidStack, boolean doDrain) { + FluidStack fluidStackOutput = null; + if (fluidStack != null && fluidStack.isFluidEqual(getFluidStack())) { + fluidStackOutput = drain(side, fluidStack.amount, doDrain); + } + return fluidStackOutput; + } + + @Override + public FluidStack drain(ForgeDirection side, int amount, boolean doDrain) { + FluidStack fluidStackOutput = null; + FluidStack fluidStackStored = getFluidStack(); + if (fluidStackStored != null && fluidStackStored.amount > 0) { + int drainedFluid = Math.min(fluidStackStored.amount, amount); + fluidStackOutput = fluidStackStored.copy(); + fluidStackOutput.amount = drainedFluid; + if (doDrain) { + fluidStackStored.amount -= drainedFluid; + if (fluidStackStored.amount == 0) { + fluidStackStored = null; + } + setFluidStack(fluidStackStored); + } + } + return fluidStackOutput; + } + + @Override + public boolean canFill(ForgeDirection forgeDirection, Fluid fluid) { + return true; + } + + @Override + public boolean canDrain(ForgeDirection forgeDirection, Fluid fluid) { + return true; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection forgeDirection) { + return new FluidTankInfo[] { new FluidTankInfo(getFluidStack(), CAPACITY) }; + } + + private void writeObject(ObjectOutputStream out) throws IOException { + if (fluidStack != null) { + out.writeByte(fluidStack.tag != null ? SERIALIZE_TYPE_WITH_NBT : SERIALIZE_TYPE_WITHOUT_NBT); + if (fluidStack.tag != null) CompressedStreamTools.write(fluidStack.tag, out); + out.writeUTF( + fluidStack.getFluid() + .getName()); + out.writeInt(fluidStack.amount); + } else { + out.writeByte(SERIALIZE_TYPE_NULL); + } + } + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + byte type = in.readByte(); + NBTTagCompound tag = null; + switch (type) { + case SERIALIZE_TYPE_WITH_NBT: + tag = CompressedStreamTools.read(new DataInputStream(in)); + case SERIALIZE_TYPE_WITHOUT_NBT: + fluidStack = FluidRegistry.getFluidStack(in.readUTF(), in.readInt()); + break; + case SERIALIZE_TYPE_NULL: + fluidStack = null; + break; + default: + TecTech.LOGGER.error("Something very wrong... got a fluid container with state " + type); + fluidStack = null; + } + if (fluidStack != null) fluidStack.tag = tag; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTag.java b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTag.java new file mode 100644 index 0000000000..e700c54b17 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTag.java @@ -0,0 +1,39 @@ +package com.github.technus.tectech.mechanics.enderStorage; + +import java.io.Serializable; +import java.util.UUID; + +import com.google.common.base.Objects; + +public class EnderLinkTag implements Serializable { + + private static final long serialVersionUID = 6884008436570077863L; + private final String frequency; + private final UUID player; + + public EnderLinkTag(String frequency, UUID player) { + this.frequency = frequency; + this.player = player; + } + + public String getFrequency() { + return frequency; + } + + public UUID getUUID() { + return player; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EnderLinkTag that = (EnderLinkTag) o; + return Objects.equal(frequency, that.frequency) && Objects.equal(player, that.player); + } + + @Override + public int hashCode() { + return Objects.hashCode(frequency, player); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTank.java b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTank.java new file mode 100644 index 0000000000..574f9c2b36 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderLinkTank.java @@ -0,0 +1,47 @@ +package com.github.technus.tectech.mechanics.enderStorage; + +import java.io.Serializable; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.fluids.IFluidHandler; + +import com.google.common.base.Objects; + +public class EnderLinkTank implements Serializable { + + private static final long serialVersionUID = 1030297456736434221L; + private final int X; + private final int Y; + private final int Z; + private final int D; + + public EnderLinkTank(IFluidHandler fluidHandler) { + TileEntity tile = (TileEntity) fluidHandler; + X = tile.xCoord; + Y = tile.yCoord; + Z = tile.zCoord; + D = tile.getWorldObj().provider.dimensionId; + } + + public IFluidHandler getFluidHandler() { + IFluidHandler fluidHandler = null; + TileEntity tile = DimensionManager.getWorld(D) + .getTileEntity(X, Y, Z); + if (tile instanceof IFluidHandler) fluidHandler = (IFluidHandler) tile; + return fluidHandler; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EnderLinkTank that = (EnderLinkTank) o; + return X == that.X && Y == that.Y && Z == that.Z && D == that.D; + } + + @Override + public int hashCode() { + return Objects.hashCode(X, Y, Z, D); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderWorldSavedData.java b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderWorldSavedData.java new file mode 100644 index 0000000000..125ce33304 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/enderStorage/EnderWorldSavedData.java @@ -0,0 +1,145 @@ +package com.github.technus.tectech.mechanics.enderStorage; + +import static com.github.technus.tectech.Reference.MODID; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.WorldSavedData; +import net.minecraft.world.storage.MapStorage; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fluids.IFluidHandler; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class EnderWorldSavedData extends WorldSavedData { + + private static EnderWorldSavedData INSTANCE; + + private static final String DATA_NAME = MODID + "_EnderWorldSavedData"; + private static final String ENDER_LIQUID_TAG_LINK = DATA_NAME + "_EnderLiquidTagLink"; + private static final String ENDER_LIQUID_TANK_LINK = DATA_NAME + "_EnderLiquidTankLink"; + private static final EnderLinkTag DEFAULT_LINK_TAG = new EnderLinkTag("", null); + + private Map EnderLiquidTagLink = new HashMap<>(); + private Map EnderLiquidTankLink = new HashMap<>(); + + public EnderWorldSavedData() { + super(DATA_NAME); + } + + public EnderWorldSavedData(String s) { + super(s); + } + + @SuppressWarnings("unchecked") + @Override + public void readFromNBT(NBTTagCompound nbtTagCompound) { + try { + byte[] ba = nbtTagCompound.getByteArray(ENDER_LIQUID_TAG_LINK); + InputStream is = new ByteArrayInputStream(ba); + ObjectInputStream ois = new ObjectInputStream(is); + Object data = ois.readObject(); + EnderLiquidTagLink = (Map) data; + } catch (IOException | ClassNotFoundException ignored) { + System.out.println("ENDER_LIQUID_TAG_LINK LOAD FAILED"); + System.out.println(ignored); + } + + try { + byte[] ba = nbtTagCompound.getByteArray(ENDER_LIQUID_TANK_LINK); + InputStream is = new ByteArrayInputStream(ba); + ObjectInputStream ois = new ObjectInputStream(is); + Object data = ois.readObject(); + EnderLiquidTankLink = (Map) data; + } catch (IOException | ClassNotFoundException ignored) { + System.out.println("ENDER_LIQUID_TANK_LINK LOAD FAILED"); + System.out.println(ignored); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTagCompound) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(EnderLiquidTagLink); + oos.flush(); + byte[] data = bos.toByteArray(); + nbtTagCompound.setByteArray(ENDER_LIQUID_TAG_LINK, data); + } catch (IOException ignored) { + System.out.println("ENDER_LIQUID_TAG_LINK SAVE FAILED"); + System.out.println(ignored); + } + + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(EnderLiquidTankLink); + oos.flush(); + byte[] data = bos.toByteArray(); + nbtTagCompound.setByteArray(ENDER_LIQUID_TANK_LINK, data); + } catch (IOException ignored) { + System.out.println("ENDER_LIQUID_TANK_LINK SAVE FAILED"); + System.out.println(ignored); + } + } + + private static void loadInstance() { + if (INSTANCE == null) { + MapStorage storage = DimensionManager.getWorld(0).mapStorage; + INSTANCE = (EnderWorldSavedData) storage.loadData(EnderWorldSavedData.class, DATA_NAME); + if (INSTANCE == null) { + INSTANCE = new EnderWorldSavedData(); + storage.setData(DATA_NAME, INSTANCE); + } + } + INSTANCE.markDirty(); + } + + private static Map getEnderLiquidLink() { + loadInstance(); + return INSTANCE.EnderLiquidTagLink; + } + + private static Map getEnderLiquidTankLink() { + loadInstance(); + return INSTANCE.EnderLiquidTankLink; + } + + public static EnderFluidContainer getEnderFluidContainer(EnderLinkTag tag) { + if (!getEnderLiquidLink().containsKey(tag)) { + getEnderLiquidLink().put(tag, new EnderFluidContainer()); + } + return getEnderLiquidLink().get(tag); + } + + public static EnderLinkTag getEnderLinkTag(IFluidHandler handler) { + EnderLinkTank tank = new EnderLinkTank(handler); + if (!getEnderLiquidTankLink().containsKey(tank)) { + getEnderLiquidTankLink().put(tank, DEFAULT_LINK_TAG); + } + return getEnderLiquidTankLink().get(tank); + } + + public static void bindEnderLinkTag(IFluidHandler handler, EnderLinkTag tag) { + EnderLinkTank tank = new EnderLinkTank(handler); + getEnderLiquidTankLink().remove(tank); + getEnderLiquidTankLink().put(tank, tag); + } + + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + if (event.world.provider.dimensionId == 0) { + INSTANCE = null; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/pipe/IActivePipe.java b/src/main/java/com/github/technus/tectech/mechanics/pipe/IActivePipe.java new file mode 100644 index 0000000000..c1ec11ffc4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/pipe/IActivePipe.java @@ -0,0 +1,12 @@ +package com.github.technus.tectech.mechanics.pipe; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; + +public interface IActivePipe extends IMetaTileEntity { + + void setActive(boolean active); + + boolean getActive(); + + void markUsed(); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToDataPipe.java b/src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToDataPipe.java new file mode 100644 index 0000000000..cc5f72d12e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToDataPipe.java @@ -0,0 +1,17 @@ +package com.github.technus.tectech.mechanics.pipe; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Created by Tec on 26.02.2017. + */ +public interface IConnectsToDataPipe { + + boolean canConnectData(ForgeDirection side); + + IConnectsToDataPipe getNext(IConnectsToDataPipe source); + + boolean isDataInputFacing(ForgeDirection side); + + byte getColorization(); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToEnergyTunnel.java b/src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToEnergyTunnel.java new file mode 100644 index 0000000000..e9047d22f0 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToEnergyTunnel.java @@ -0,0 +1,11 @@ +package com.github.technus.tectech.mechanics.pipe; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Created by Tec on 26.02.2017. + */ +public interface IConnectsToEnergyTunnel { + + boolean canConnect(ForgeDirection side); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/pipe/PipeActivityMessage.java b/src/main/java/com/github/technus/tectech/mechanics/pipe/PipeActivityMessage.java new file mode 100644 index 0000000000..549397afa0 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/pipe/PipeActivityMessage.java @@ -0,0 +1,136 @@ +package com.github.technus.tectech.mechanics.pipe; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; +import eu.usrv.yamcore.network.server.AbstractServerMessageHandler; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import io.netty.buffer.ByteBuf; + +public class PipeActivityMessage implements IMessage { + + int mPosX; + int mPosY; + int mPosZ; + int mPosD; + int mActive; + + public PipeActivityMessage() {} + + private PipeActivityMessage(IActivePipe metaTile) { + IGregTechTileEntity base = metaTile.getBaseMetaTileEntity(); + mPosX = base.getXCoord(); + mPosY = base.getYCoord(); + mPosZ = base.getZCoord(); + mPosD = base.getWorld().provider.dimensionId; + mActive = metaTile.getActive() ? 1 : 0; + } + + private PipeActivityMessage(World world, int x, int y, int z, boolean active) { + mPosX = x; + mPosY = y; + mPosZ = z; + mPosD = world.provider.dimensionId; + mActive = active ? 1 : 0; + } + + @Override + public void fromBytes(ByteBuf pBuffer) { + NBTTagCompound tTag = ByteBufUtils.readTag(pBuffer); + mPosX = tTag.getInteger("posx"); + mPosY = tTag.getInteger("posy"); + mPosZ = tTag.getInteger("posz"); + mPosD = tTag.getInteger("posd"); + mActive = tTag.getInteger("active"); + } + + @Override + public void toBytes(ByteBuf pBuffer) { + NBTTagCompound tFXTag = new NBTTagCompound(); + tFXTag.setInteger("posx", mPosX); + tFXTag.setInteger("posy", mPosY); + tFXTag.setInteger("posz", mPosZ); + tFXTag.setInteger("posd", mPosD); + tFXTag.setInteger("active", mActive); + + ByteBufUtils.writeTag(pBuffer, tFXTag); + } + + public static class PipeActivityQuery extends PipeActivityMessage { + + public PipeActivityQuery() {} + + public PipeActivityQuery(IActivePipe metaTile) { + super(metaTile); + } + + public PipeActivityQuery(World world, int x, int y, int z, boolean active) { + super(world, x, y, z, active); + } + } + + public static class PipeActivityData extends PipeActivityMessage { + + public PipeActivityData() {} + + private PipeActivityData(PipeActivityQuery query) { + mPosX = query.mPosX; + mPosY = query.mPosY; + mPosZ = query.mPosZ; + mPosD = query.mPosD; + mActive = query.mActive; + } + + public PipeActivityData(IActivePipe metaTile) { + super(metaTile); + } + + public PipeActivityData(World world, int x, int y, int z, boolean active) { + super(world, x, y, z, active); + } + } + + public static class ClientHandler extends AbstractClientMessageHandler { + + @Override + public IMessage handleClientMessage(EntityPlayer pPlayer, PipeActivityData pMessage, MessageContext pCtx) { + if (pPlayer.worldObj.provider.dimensionId == pMessage.mPosD) { + TileEntity te = pPlayer.worldObj.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ); + if (te instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); + if (meta instanceof IActivePipe) { + ((IActivePipe) meta).setActive(pMessage.mActive == 1); + } + } + } + return null; + } + } + + public static class ServerHandler extends AbstractServerMessageHandler { + + @Override + public IMessage handleServerMessage(EntityPlayer pPlayer, PipeActivityQuery pMessage, MessageContext pCtx) { + World world = DimensionManager.getWorld(pMessage.mPosD); + if (world != null) { + TileEntity te = world.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ); + if (te instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); + if (meta instanceof IActivePipe) { + pMessage.mActive = ((IActivePipe) meta).getActive() ? 1 : 0; + return new PipeActivityData(pMessage); + } + } + } + return null; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java new file mode 100644 index 0000000000..d13e8bfb7f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java @@ -0,0 +1,149 @@ +package com.github.technus.tectech.mechanics.spark; + +import static gregtech.api.enums.Mods.Thaumcraft; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamClass; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Random; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; +import io.netty.buffer.ByteBuf; +import thaumcraft.client.fx.bolt.FXLightningBolt; + +// TODO Re-work how sparks are distributed +public class RendererMessage implements IMessage { + + HashSet sparkList; + + public RendererMessage() {} + + @SuppressWarnings("unchecked") + @Override + public void fromBytes(ByteBuf pBuffer) { + if (FMLCommonHandler.instance() + .getSide() + .isServer()) return; + try { + // I'd love to know why I need to offset by one byte for this to work + byte[] boop = pBuffer.array(); + boop = Arrays.copyOfRange(boop, 1, boop.length); + InputStream is = new ByteArrayInputStream(boop); + ObjectInputStream ois = new ValidatingObjectInputStream(is); + Object data = ois.readObject(); + sparkList = (HashSet) data; + } catch (IOException | ClassNotFoundException ignored) {} + } + + @Override + public void toBytes(ByteBuf pBuffer) { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(sparkList); + oos.flush(); + InputStream is = new ByteArrayInputStream(baos.toByteArray()); + pBuffer.writeBytes(is, baos.toByteArray().length); + } catch (IOException ignore) {} + } + + public static class RendererData extends RendererMessage { + + public RendererData() {} + + public RendererData(HashSet eSparkList) { + sparkList = eSparkList; + } + } + + public static class ClientHandler extends AbstractClientMessageHandler { + + @Override + public IMessage handleClientMessage(EntityPlayer pPlayer, RendererData pMessage, MessageContext pCtx) { + // disgusting + Random localRand = Minecraft.getMinecraft().theWorld.rand; + int[] zapsToUse = new int[4]; + for (int i = 0; i < 3; i++) { + zapsToUse[i] = localRand.nextInt(pMessage.sparkList.size()); + } + int i = 0; + for (ThaumSpark sp : pMessage.sparkList) { + for (int j : zapsToUse) { + if (i == j) { + thaumLightning(sp.x, sp.y, sp.z, sp.xR, sp.yR, sp.zR, sp.wID); + } + } + i++; + } + pMessage.sparkList.clear(); + return null; + } + } + + @SideOnly(Side.CLIENT) + private static void thaumLightning(int tX, int tY, int tZ, int tXN, int tYN, int tZN, int wID) { + // This is enough to check for thaum, since it only ever matters for client side effects (Tested not to crash) + if (Thaumcraft.isModLoaded()) { + World world = Minecraft.getMinecraft().theWorld; + if (world.provider.dimensionId == wID) { + FXLightningBolt bolt = new FXLightningBolt( + world, + tX + 0.5F, + tY + 0.5F, + tZ + 0.5F, + tX + tXN + 0.5F, + tY + tYN + 0.5F, + tZ + tZN + 0.5F, + world.rand.nextLong(), + 6, + 0.5F, + 8); + bolt.defaultFractal(); + bolt.setType(2); + bolt.setWidth(0.125F); + bolt.finalizeBolt(); + } + } + } + + private static class ValidatingObjectInputStream extends ObjectInputStream { + + private static final Logger logger = LogManager.getLogger(); + private static final Marker securityMarker = MarkerManager.getMarker("SuspiciousPackets"); + + private ValidatingObjectInputStream(InputStream in) throws IOException { + super(in); + } + + @Override + protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { + String name = desc.getName(); + if (!name.equals("java.util.HashSet") + && !name.equals("com.github.technus.tectech.mechanics.spark.ThaumSpark")) { + logger.warn(securityMarker, "Received packet containing disallowed class: " + name); + throw new RuntimeException(); + } + return super.resolveClass(desc); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java b/src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java new file mode 100644 index 0000000000..8265c2a81b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java @@ -0,0 +1,57 @@ +package com.github.technus.tectech.mechanics.spark; + +import java.io.Serializable; +import java.util.Objects; + +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +public class ThaumSpark implements Serializable { + + // This works regardless of if TC is loaded + private static final long serialVersionUID = -7037856938316679566L; + public int x, y, z, wID; + public byte xR, yR, zR; + + public ThaumSpark(int x, int y, int z, byte xR, byte yR, byte zR, int wID) { + this.x = x; + this.y = y; + this.z = z; + + this.xR = xR; + this.yR = yR; + this.zR = zR; + + this.wID = wID; + } + + public ThaumSpark(Vec3Impl origin, Vec3Impl target, int wID) { + this.x = origin.get0(); + this.y = origin.get1(); + this.z = origin.get2(); + + Vec3Impl offset = target.sub(origin); + this.xR = (byte) offset.get0(); + this.yR = (byte) offset.get1(); + this.zR = (byte) offset.get2(); + + this.wID = wID; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ThaumSpark that = (ThaumSpark) o; + return x == that.x && y == that.y + && z == that.z + && wID == that.wID + && xR == that.xR + && yR == that.yR + && zR == that.zR; + } + + @Override + public int hashCode() { + return Objects.hash(x, y, z, wID, xR, yR, zR); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java new file mode 100644 index 0000000000..cabacc075b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java @@ -0,0 +1,169 @@ +package com.github.technus.tectech.mechanics.tesla; + +import static java.lang.Math.sqrt; + +import java.util.HashSet; +import java.util.Map; + +import com.github.technus.tectech.mechanics.spark.ThaumSpark; +import com.google.common.collect.Multimap; + +public interface ITeslaConnectable extends ITeslaConnectableSimple { + + // Map with all Teslas in the same dimension and the distance to them //TODO Range + Multimap getTeslaNodeMap(); + + // ThaumCraft lighting coordinate pairs, so we can send them in bursts and save on lag + HashSet getSparkList(); + + // -128 to -1 disables capability + // 0 means any source or target + // 1 to 127 must match on source and target or source/target must be 0 + byte getTeslaTransmissionCapability(); + + // Transmission Range is typically 16+ in blocks + int getTeslaTransmissionRange(); + + boolean isOverdriveEnabled(); + + int getTeslaEnergyLossPerBlock(); + + float getTeslaOverdriveLossCoefficient(); + + long getTeslaOutputVoltage(); + + long getTeslaOutputCurrent(); + + boolean teslaDrainEnergy(long teslaVoltageDrained); + + class TeslaUtil { + + private static final HashSet teslaSimpleNodeSet = new HashSet<>(); // Targets for power + // transmission + private static final HashSet teslaNodeSet = new HashSet<>(); // Sources of power transmission + + public static void teslaSimpleNodeSetAdd(ITeslaConnectableSimple target) { + if (!teslaSimpleNodeSet.contains(target)) { + teslaSimpleNodeSet.add(target); + teslaNodeSet.forEach(origin -> addTargetToTeslaOrigin(target, origin)); + } + } + + public static void teslaSimpleNodeSetRemove(ITeslaConnectableSimple target) { + teslaSimpleNodeSet.remove(target); + if (target instanceof ITeslaConnectable) teslaNodeSet.remove(target); + teslaNodeSet.forEach(origin -> removeTargetFromTeslaOrigin(target, origin)); + } + + private static void addTargetToTeslaOrigin(ITeslaConnectableSimple target, ITeslaConnectable origin) { + if (origin.equals(target) || !origin.getTeslaDimension() + .equals(target.getTeslaDimension())) { + // Skip if looking at myself and skip if not in the same dimension + // TODO, INTERDIM? + return; + } else if (origin.getTeslaTransmissionCapability() != 0 && origin.getTeslaReceptionCapability() != 0 + && origin.getTeslaTransmissionCapability() != origin.getTeslaReceptionCapability()) { + // Skip if incompatible + return; + } + // Range calc + int distance = (int) sqrt( + origin.getTeslaPosition() + .distanceSq(target.getTeslaPosition())); + if (distance > origin.getTeslaTransmissionRange() * target.getTeslaReceptionCoefficient()) { + // Skip if the range is too vast + return; + } + origin.getTeslaNodeMap() + .put(distance, target); + } + + private static void removeTargetFromTeslaOrigin(ITeslaConnectableSimple target, ITeslaConnectable origin) { + // Range calc TODO Remove duplicate? + int distance = (int) sqrt( + origin.getTeslaPosition() + .distanceSq(target.getTeslaPosition())); + origin.getTeslaNodeMap() + .remove(distance, target); + } + + public static void generateTeslaNodeMap(ITeslaConnectable origin) { + origin.getTeslaNodeMap() + .clear(); + for (ITeslaConnectableSimple target : teslaSimpleNodeSet) { + // Sanity checks + if (target == null) { + // The Tesla Covers do not remove themselves from the list and this is the code that does + teslaSimpleNodeSet.remove(null); + continue; + } + addTargetToTeslaOrigin(target, origin); + } + teslaNodeSet.add(origin); + } + + public static long powerTeslaNodeMap(ITeslaConnectable origin) { + long remainingAmperes = origin.getTeslaOutputCurrent(); + boolean canSendPower = !origin.isTeslaReadyToReceive() && remainingAmperes > 0; + + if (canSendPower) { + for (Map.Entry Rx : origin.getTeslaNodeMap() + .entries()) { + // Do we still have power left to send kind of check + if (origin.getTeslaStoredEnergy() + < (origin.isOverdriveEnabled() ? origin.getTeslaOutputVoltage() * 2 + : origin.getTeslaOutputVoltage())) + break; + // Explicit words for the important fields + ITeslaConnectableSimple target = Rx.getValue(); + int distance = Rx.getKey(); + // Can our target receive energy? + if (!target.isTeslaReadyToReceive()) continue; + + // Calculate the voltage output + long outputVoltageInjectable; + long outputVoltageConsumption; + if (origin.isOverdriveEnabled()) { + outputVoltageInjectable = origin.getTeslaOutputVoltage(); + outputVoltageConsumption = origin.getTeslaOutputVoltage() + + ((long) distance * origin.getTeslaEnergyLossPerBlock()) + + (long) Math + .round(origin.getTeslaOutputVoltage() * origin.getTeslaOverdriveLossCoefficient()); + } else { + outputVoltageInjectable = origin.getTeslaOutputVoltage() + - ((long) distance * origin.getTeslaEnergyLossPerBlock()); + outputVoltageConsumption = origin.getTeslaOutputVoltage(); + } + + // Break out of the loop if the cost is too high + // Since the next target will have an even higher cost, just quit now. + if (origin.getTeslaStoredEnergy() < outputVoltageConsumption) break; + + // Now shove in as many packets as will fit~ + while (canSendPower) { + if (target.teslaInjectEnergy(outputVoltageInjectable)) { + origin.teslaDrainEnergy(outputVoltageConsumption); + origin.getSparkList() + .add( + new ThaumSpark( + origin.getTeslaPosition(), + target.getTeslaPosition(), + origin.getTeslaDimension())); + remainingAmperes--; + // Update the can send power flag each time we send power + canSendPower = (origin.getTeslaStoredEnergy() < outputVoltageConsumption + || remainingAmperes > 0); + } else { + // Breaks out when I can't send anymore power + break; + } + } + + // Break out if we can't send power anymore + if (!canSendPower) break; + } + } + return origin.getTeslaOutputCurrent() - remainingAmperes; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java new file mode 100644 index 0000000000..a43b313d28 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java @@ -0,0 +1,24 @@ +package com.github.technus.tectech.mechanics.tesla; + +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +public interface ITeslaConnectableSimple { + + // -128 to -1 disables capability + // 0 means any source or target + // 1 to 127 must match on source and target or source/target must be 0 + byte getTeslaReceptionCapability(); + + // Reception Coefficient is a range extension, typical is 1 + float getTeslaReceptionCoefficient(); + + boolean isTeslaReadyToReceive(); + + long getTeslaStoredEnergy(); + + boolean teslaInjectEnergy(long teslaVoltageInjected); + + Vec3Impl getTeslaPosition(); + + Integer getTeslaDimension(); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java new file mode 100644 index 0000000000..95a0fdb3f6 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java @@ -0,0 +1,81 @@ +package com.github.technus.tectech.mechanics.tesla; + +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove; + +import net.minecraftforge.common.util.ForgeDirection; + +import com.google.common.base.Objects; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class TeslaCoverConnection implements ITeslaConnectableSimple { + + private final IGregTechTileEntity IGT; + private final Vec3Impl pos; + private final byte teslaReceptionCapability; + + public TeslaCoverConnection(IGregTechTileEntity IGT, byte teslaReceptionCapability) { + this.IGT = IGT; + this.pos = new Vec3Impl(IGT.getXCoord(), IGT.getYCoord(), IGT.getZCoord()); + + this.teslaReceptionCapability = teslaReceptionCapability; + } + + @Override + public byte getTeslaReceptionCapability() { + return teslaReceptionCapability; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 1; + } + + @Override + public boolean isTeslaReadyToReceive() { + return true; + } + + @Override + public long getTeslaStoredEnergy() { + return IGT.getStoredEU(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return pos; + } + + @Override + public Integer getTeslaDimension() { + return IGT.getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + // Same as in the microwave transmitters, this does not account for amp limits + boolean output = false; + + if (!IGT.isDead()) { + output = IGT.injectEnergyUnits(ForgeDirection.UP, teslaVoltageInjected, 1L) > 0L; + } else { + teslaSimpleNodeSetRemove(this); + } + + return output; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TeslaCoverConnection that = (TeslaCoverConnection) o; + return Objects.equal(IGT, that.IGT); + } + + @Override + public int hashCode() { + return Objects.hashCode(IGT); + } +} diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java new file mode 100644 index 0000000000..da5f46e002 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -0,0 +1,182 @@ +package com.github.technus.tectech.proxy; + +import static com.github.technus.tectech.TecTech.RANDOM; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.eyeOfHarmonyRenderBlock; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.forgeOfGodsRenderBlock; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiNewChat; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.rendering.EOH.EOH_ItemRenderer; +import com.github.technus.tectech.rendering.EOH.EOH_TESR; +import com.github.technus.tectech.thing.block.GodforgeGlassBlock; +import com.github.technus.tectech.thing.block.GodforgeGlassRender; +import com.github.technus.tectech.thing.block.QuantumGlassBlock; +import com.github.technus.tectech.thing.block.QuantumGlassRender; +import com.github.technus.tectech.thing.block.RenderForgeOfGods; +import com.github.technus.tectech.thing.block.TileEyeOfHarmony; +import com.github.technus.tectech.thing.block.TileForgeOfGods; +import com.github.technus.tectech.thing.item.RenderForgeOfGodsItem; +import com.gtnewhorizon.structurelib.entity.fx.WeightlessParticleFX; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class ClientProxy extends CommonProxy { + + @Override + public void registerRenderInfo() { + QuantumGlassBlock.renderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(QuantumGlassBlock.renderID, new QuantumGlassRender()); + GodforgeGlassBlock.renderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(GodforgeGlassBlock.renderID, new GodforgeGlassRender()); + + MinecraftForgeClient + .registerItemRenderer(Item.getItemFromBlock(eyeOfHarmonyRenderBlock), new EOH_ItemRenderer()); + MinecraftForgeClient + .registerItemRenderer(Item.getItemFromBlock(forgeOfGodsRenderBlock), new RenderForgeOfGodsItem()); + + ClientRegistry.bindTileEntitySpecialRenderer(TileEyeOfHarmony.class, new EOH_TESR()); + ClientRegistry.bindTileEntitySpecialRenderer(TileForgeOfGods.class, new RenderForgeOfGods()); + } + + @Override + public void em_particle(IGregTechTileEntity aMuffler, ForgeDirection facing) { // CUTE! + float xPos = facing.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F; + float yPos = facing.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F; + float zPos = facing.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F; + + EntityFX particle = new WeightlessParticleFX( + aMuffler.getWorld(), + xPos + RANDOM.nextFloat() * 0.5F, + yPos + RANDOM.nextFloat() * 0.5F, + zPos + RANDOM.nextFloat() * 0.5F, + 0, + 0, + 0); + particle.setRBGColorF(0, 0.6F * RANDOM.nextFloat(), 0.8f); + Minecraft.getMinecraft().effectRenderer.addEffect(particle); + } + + @Override + public void pollutor_particle(IGregTechTileEntity aMuffler, ForgeDirection facing) { + float xPos = facing.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F; + float yPos = facing.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F; + float zPos = facing.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F; + + float ySpd = facing.offsetY * 0.1F + 0.2F + 0.1F * (float) RANDOM.nextGaussian(); + float xSpd; + float zSpd; + + if (facing.offsetY == -1) { + float temp = RANDOM.nextFloat() * 2 * (float) Math.PI; + xSpd = (float) Math.sin(temp) * 0.1F * (float) RANDOM.nextGaussian(); + zSpd = (float) Math.cos(temp) * 0.1F * (float) RANDOM.nextGaussian(); + } else { + xSpd = facing.offsetX * (0.1F + 0.2F * (float) RANDOM.nextGaussian()); + zSpd = facing.offsetZ * (0.1F + 0.2F * (float) RANDOM.nextGaussian()); + } + aMuffler.getWorld() + .spawnParticle( + "largesmoke", + xPos + RANDOM.nextFloat() * 0.5F, + yPos + RANDOM.nextFloat() * 0.5F, + zPos + RANDOM.nextFloat() * 0.5F, + xSpd, + ySpd, + zSpd); + aMuffler.getWorld() + .spawnParticle( + "largesmoke", + xPos + RANDOM.nextFloat() * 0.5F, + yPos + RANDOM.nextFloat() * 0.5F, + zPos + RANDOM.nextFloat() * 0.5F, + xSpd, + ySpd, + zSpd); + aMuffler.getWorld() + .spawnParticle( + "largesmoke", + xPos + RANDOM.nextFloat() * 0.5F, + yPos + RANDOM.nextFloat() * 0.5F, + zPos + RANDOM.nextFloat() * 0.5F, + xSpd, + ySpd, + zSpd); + } + + @Override + public void em_particle(World w, double x, double y, double z) { // CUTE! + EntityFX particle = new WeightlessParticleFX( + w, + x + RANDOM.nextFloat() * 0.5F, + y + RANDOM.nextFloat() * 0.5F, + z + RANDOM.nextFloat() * 0.5F, + 0, + 0, + 0); + particle.setRBGColorF(0, 0.6F * RANDOM.nextFloat(), 0.8f); + Minecraft.getMinecraft().effectRenderer.addEffect(particle); + } + + @Override + public void pollutor_particle(World w, double x, double y, double z) { + w.spawnParticle( + "largesmoke", + x + RANDOM.nextFloat() * 0.5F, + y + RANDOM.nextFloat() * 0.5F, + z + RANDOM.nextFloat() * 0.5F, + 0, + 0, + 0); + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @Override + public World getClientWorld() { + return FMLClientHandler.instance() + .getClient().theWorld; + } + + @Override + public void printInchat(String... strings) { + GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); + for (String s : strings) { + chat.printChatMessage(new ChatComponentText(s)); + } + } + + @Override + public void playSound(IGregTechTileEntity base, String name) { + base.getWorld() + .playSoundEffect(base.getXCoord(), base.getYCoord(), base.getZCoord(), Reference.MODID + ':' + name, 1, 1); + } + + @Override + public void renderAABB(World w, AxisAlignedBB box) { + em_particle(w, box.minX, box.minY, box.minZ); + em_particle(w, box.minX, box.minY, box.maxZ); + em_particle(w, box.minX, box.maxY, box.maxZ); + em_particle(w, box.minX, box.maxY, box.minZ); + em_particle(w, box.maxX, box.maxY, box.minZ); + em_particle(w, box.maxX, box.maxY, box.maxZ); + em_particle(w, box.maxX, box.minY, box.maxZ); + em_particle(w, box.maxX, box.minY, box.minZ); + } + +} diff --git a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java new file mode 100644 index 0000000000..0c160ffb54 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java @@ -0,0 +1,94 @@ +package com.github.technus.tectech.proxy; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.network.IGuiHandler; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class CommonProxy implements IGuiHandler { + + public void registerRenderInfo() {} + + public void em_particle(IGregTechTileEntity aMuffler, ForgeDirection facing) {} // CUTE! + + public void pollutor_particle(IGregTechTileEntity aPollutor, ForgeDirection facing) {} // CUTE! + + public void em_particle(World w, double x, double y, double z) {} + + public void pollutor_particle(World w, double x, double y, double z) {} + + public void renderAABB(World w, AxisAlignedBB box) {} + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + public World getClientWorld() { + return null; + } + + public void broadcast(String str) { + MinecraftServer.getServer() + .getConfigurationManager() + .sendChatMsg(new ChatComponentText(str)); + } + + public void printInchat(String... strings) {} + + public void playSound(IGregTechTileEntity base, String name) {} + + public String getUUID(String name) { + for (WorldServer worldServer : MinecraftServer.getServer().worldServers) { + for (Object o : worldServer.playerEntities) { + if (o instanceof EntityPlayer && ((EntityPlayer) o).getGameProfile() + .getName() + .equals(name)) { + return ((EntityPlayer) o).getGameProfile() + .getId() + .toString(); + } + } + } + return null; + } + + public boolean isOnlineName(String name) { + for (WorldServer worldServer : MinecraftServer.getServer().worldServers) { + for (Object o : worldServer.playerEntities) { + if (o instanceof EntityPlayer && ((EntityPlayer) o).getGameProfile() + .getName() + .equals(name)) { + return true; + } + } + } + return false; + } + + public boolean isOnlineUUID(String uuid) { + for (WorldServer worldServer : MinecraftServer.getServer().worldServers) { + for (Object o : worldServer.playerEntities) { + if (o instanceof EntityPlayer && ((EntityPlayer) o).getGameProfile() + .getId() + .toString() + .equals(uuid)) { + return true; + } + } + } + return false; + } + +} diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java new file mode 100644 index 0000000000..48b48f37e9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java @@ -0,0 +1,206 @@ +package com.github.technus.tectech.recipe; + +import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES; +import static com.google.common.math.LongMath.pow; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static java.lang.Math.min; +import static net.minecraft.util.EnumChatFormatting.BOLD; +import static net.minecraft.util.EnumChatFormatting.DARK_RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; + +import appeng.util.ReadableNumberConverter; +import codechicken.nei.PositionedStack; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.nei.GT_NEI_DefaultHandler; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class EyeOfHarmonyFrontend extends RecipeMapFrontend { + + private static final int xDirMaxCount = 9; + private static final int itemRows = 9, fluidRows = 2; + public static final int maxItemInputs = 1, maxItemOutputs = xDirMaxCount * itemRows, maxFluidInputs = 0, + maxFluidOutputs = xDirMaxCount * fluidRows; + private static final int yOrigin = 8; + private static final long TRILLION = pow(10, 12); + + public EyeOfHarmonyFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder.logoPos(new Pos2d(8, yOrigin)), + neiPropertiesBuilder.recipeBackgroundSize(new Size(170, 117 + (itemRows + fluidRows - 4) * 18)) + .neiSpecialInfoFormatter(new EyeOfHarmonySpecialValueFormatter())); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return UIHelper.getGridPositions(itemInputCount, 79, yOrigin, 1, 1); + } + + public static final int maxItemsToRender = 80; + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return UIHelper.getGridPositions(min(itemOutputCount, maxItemsToRender + 1), 7, yOrigin + 36, xDirMaxCount, 12); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + return UIHelper.getGridPositions(fluidInputCount, 0, 0, 0, 0); + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + return UIHelper.getGridPositions(fluidOutputCount, 7, yOrigin + 13 * 17 - 7 - 16, xDirMaxCount, 3); + } + + @Override + public List handleNEIItemTooltip(ItemStack stack, List currentTip, + GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + super.handleNEIItemTooltip(stack, currentTip, neiCachedRecipe); + EyeOfHarmonyRecipe currentRecipe = (EyeOfHarmonyRecipe) neiCachedRecipe.mRecipe.mSpecialItems; + + // Draw tooltip on planet item. + if (stack.isItemEqual(currentRecipe.getRecipeTriggerItem())) { + currentTip.add( + EnumChatFormatting.GRAY + translateToLocalFormatted( + "tt.nei.eoh.total_items", + formatNumbers(currentRecipe.getSumOfItems()))); + return currentTip; + } + + // Draw tooltip on other items. + double percentage = currentRecipe.getItemStackToProbabilityMap() + .getOrDefault(stack, -1.0); + + if (percentage != -1.0) { + currentTip.add(EnumChatFormatting.GRAY + translateToLocalFormatted("tt.nei.eoh.solid_mass", percentage)); + currentTip.add( + EnumChatFormatting.GRAY + translateToLocalFormatted( + "tt.nei.eoh.item_count", + formatNumbers( + currentRecipe.getItemStackToTrueStackSizeMap() + .get(stack)))); + } + + return currentTip; + } + + @Override + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + EyeOfHarmonyRecipe EOHRecipe = (EyeOfHarmonyRecipe) neiCachedRecipe.mRecipe.mSpecialItems; + for (PositionedStack stack : neiCachedRecipe.mInputs) { + if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + if (stack.item.isItemEqual(EOHRecipe.getRecipeTriggerItem())) { + drawNEIOverlayText(translateToLocal("NC"), stack); + } + } + } + for (PositionedStack stack : neiCachedRecipe.mOutputs) { + if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + if (EOHRecipe.getItemStackToTrueStackSizeMap() + .containsKey(stack.item)) { + long stackSize = EOHRecipe.getItemStackToTrueStackSizeMap() + .get(stack.item); + String displayString; + if (stackSize > 9999) { + displayString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize); + } else { + displayString = String.valueOf(stackSize); + } + + drawNEIOverlayText(displayString, stack, 0xffffff, 0.5f, true, Alignment.BottomRight); + } + } + } + } + + private static class EyeOfHarmonySpecialValueFormatter implements INEISpecialInfoFormatter { + + @Override + public List format(RecipeDisplayInfo recipeInfo) { + EyeOfHarmonyRecipe recipe = (EyeOfHarmonyRecipe) recipeInfo.recipe.mSpecialItems; + List result = new ArrayList<>(); + + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.Hydrogen.In", "Hydrogen") + ": " + + formatNumbers(recipe.getHydrogenRequirement()) + + " L"); + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.Helium.In", "Helium") + ": " + + formatNumbers(recipe.getHydrogenRequirement()) + + " L"); + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.SpacetimeTier", "Spacetime Tier") + ": " + + EOH_TIER_FANCY_NAMES[(int) recipe.getSpacetimeCasingTierRequired()]); + + if (recipe.getEUOutput() < TRILLION) { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.Out", "EU Output") + ": " + + formatNumbers(recipe.getEUOutput()) + + " EU"); + } else { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.Out", "EU Output") + ": " + + ReadableNumberConverter.INSTANCE.toWideReadableForm(recipe.getEUOutput()) + + " EU"); + } + + if (recipe.getEUOutput() < TRILLION) { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.In", "EU Input") + ": " + + formatNumbers(recipe.getEUStartCost()) + + " EU"); + } else { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.In", "EU Input") + ": " + + ReadableNumberConverter.INSTANCE.toWideReadableForm(recipe.getEUStartCost()) + + " EU"); + } + + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.BaseRecipeChance", "Base Recipe Chance") + ": " + + formatNumbers(100 * recipe.getBaseRecipeSuccessChance()) + + "%"); + result.add( + GT_LanguageManager + .addStringLocalization("EOH.Recipe.RecipeEnergyEfficiency", "Recipe Energy Efficiency") + ": " + + formatNumbers(100 * recipe.getRecipeEnergyEfficiency()) + + "%"); + + if (recipe.getOutputItems() + .size() > maxItemsToRender) { + result.add( + "" + DARK_RED + + BOLD + + GT_LanguageManager.addStringLocalization("EOH.Recipe.Warning.0", "Warning") + + RESET + + ": " + + GT_LanguageManager.addStringLocalization("EOH.Recipe.Warning.1", "Not all items displayed.")); + } + + return result; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java new file mode 100644 index 0000000000..cc7de26fb6 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java @@ -0,0 +1,499 @@ +package com.github.technus.tectech.recipe; + +import static com.github.technus.tectech.recipe.EyeOfHarmonyRecipeStorage.BILLION; +import static com.google.common.math.IntMath.pow; +import static gregtech.api.GregTech_API.getUnificatedOreDictStack; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.util.GT_ModHandler.getModItem; +import static gregtech.api.util.GT_Utility.getPlasmaFuelValueInEUPerLiterFromMaterial; +import static java.lang.Math.min; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; + +import com.github.technus.tectech.util.FluidStackLong; +import com.github.technus.tectech.util.ItemStackLong; + +import gnu.trove.map.TMap; +import gnu.trove.map.hash.TCustomHashMap; +import gnu.trove.strategy.HashingStrategy; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import pers.gwyog.gtneioreplugin.plugin.block.BlockDimensionDisplay; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; + +@SuppressWarnings("SpellCheckingInspection") +public class EyeOfHarmonyRecipe { + + static final FluidStackLong[] SPECIAL_FLUIDS = new FluidStackLong[] { + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(4_608), 4_608), + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(18_432), 18_432), + new FluidStackLong(MaterialsUEVplus.BlackDwarfMatter.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.BlackDwarfMatter.getMolten(4_608), 4_608), + new FluidStackLong(MaterialsUEVplus.BlackDwarfMatter.getMolten(18_432), 18_432), + new FluidStackLong(MaterialsUEVplus.Universium.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.Universium.getMolten(4_608), 4_608), + new FluidStackLong(MaterialsUEVplus.Universium.getMolten(18_432), 18_432) }; + + HashingStrategy itemStackHashingStrategy = new HashingStrategy<>() { + + private static final long serialVersionUID = -3966004160368229212L; + + @Override + public int computeHashCode(ItemStack stack) { + // Not really sure how this works or if it is "unique enough". + int result = stack.getItem() + .hashCode(); + result = 31 * result + stack.getItemDamage(); + return result; + } + + @Override + public boolean equals(ItemStack item1, ItemStack item2) { + return item1.getUnlocalizedName() + .equals(item2.getUnlocalizedName()); + } + }; + + private final TMap itemStackToProbabilityMap = new TCustomHashMap<>(itemStackHashingStrategy); + private final TMap itemStackToTrueStackSizeMap = new TCustomHashMap<>(itemStackHashingStrategy); + + private final ArrayList outputItems; + private final ArrayList outputFluids; + + private final long hydrogenRequirement; + private final long heliumRequirement; + + private final long euOutput; + private final long euStartCost; + + private final double baseSuccessChance; + + private final long spacetimeCasingTierRequired; + + private final long miningTimeSeconds; + + private final double recipeEnergyEfficiency; + + private final ItemStack recipeTriggerItem; + + private final long sumOfItems; + private final long rocketTier; + + public TMap getItemStackToProbabilityMap() { + return itemStackToProbabilityMap; + } + + public TMap getItemStackToTrueStackSizeMap() { + return itemStackToTrueStackSizeMap; + } + + public double getRecipeEnergyEfficiency() { + return recipeEnergyEfficiency; + } + + @SuppressWarnings("FieldCanBeLocal") + private final long standardRecipeEUOutPerTick = 100 * BILLION; + + public long getSumOfItems() { + return sumOfItems; + } + + public long getRocketTier() { + return rocketTier; + } + + public EyeOfHarmonyRecipe(final ArrayList> materialList, final BlockDimensionDisplay block, + final double recipeEnergyEfficiency, final long hydrogenRequirement, final long heliumRequirement, + final long miningTimeSeconds, final long rocketTierOfRecipe, final double baseSuccessChance) { + + this.rocketTier = rocketTierOfRecipe; + this.spacetimeCasingTierRequired = min(8, rocketTierOfRecipe); + + this.recipeTriggerItem = new ItemStack(block); + + this.outputItems = validDustGenerator(materialList); + + this.sumOfItems = this.outputItems.stream() + .map(ItemStackLong::getStackSize) + .reduce(0L, Long::sum); + + this.outputItems.add(new ItemStackLong(getStoneDustType(block.getDimension()), this.sumOfItems * 3L)); + this.outputItems.sort(Comparator.comparingLong(ItemStackLong::getStackSize)); + Collections.reverse(this.outputItems); + + for (ItemStackLong itemStackLong : outputItems) { + double stackSize = (double) itemStackLong.getStackSize(); + double probability = Math.round(100_000 * stackSize / sumOfItems) / 1000.0; + + itemStackToProbabilityMap.put(itemStackLong.itemStack, probability); + itemStackToTrueStackSizeMap.put(itemStackLong.itemStack, itemStackLong.stackSize); + } + // End item processing. + + // --- Fluid handling --- + ArrayList fluidStackLongArrayList = new ArrayList<>(); + + int plasmaAmount = (int) ((this.spacetimeCasingTierRequired + 1) * 8_000_000L); + + // If DeepDark then it should output all plasmas involved in making exotic catalyst. + if (rocketTier == 9) { + for (Materials material : VALID_PLASMAS) { + fluidStackLongArrayList.add(new FluidStackLong(material.getPlasma(plasmaAmount), plasmaAmount)); + } + } else { + // --- Output and process fluids of the recipe. + ArrayList fluidStackArrayList = new ArrayList<>(validPlasmaGenerator(materialList)); + for (FluidStack fluidStack : fluidStackArrayList) { + fluidStack = new FluidStack(fluidStack, plasmaAmount); + fluidStackLongArrayList.add(new FluidStackLong(fluidStack, plasmaAmount)); + } + } + + // Add a bonus fluid of compressed star matter. + fluidStackLongArrayList.add( + new FluidStackLong( + MaterialsUEVplus.RawStarMatter.getFluid((this.spacetimeCasingTierRequired + 1) * 100_000), + (this.spacetimeCasingTierRequired + 1) * 100_000)); + + // Tier 0 & 1 - 576 White + // Tier 2 - 2304 White + // Tier 3 - 9216 White + + // Tier 4 - 576 Black + // Tier 5 - 2304 Black + // Tier 6 - 9216 Black + + // Tier 7 - 576 Universium + // Tier 8 - 2304 Universium + // Tier 9 - 9216 Universium + int spacetimeTier = (int) rocketTierOfRecipe; + if (spacetimeTier == 0 || spacetimeTier == 9) { + spacetimeTier -= 1; + } + fluidStackLongArrayList.add(SPECIAL_FLUIDS[spacetimeTier + 1]); + + outputFluids = fluidStackLongArrayList; + // --- End fluid handling ---. + + this.hydrogenRequirement = hydrogenRequirement; + this.heliumRequirement = heliumRequirement; + + this.baseSuccessChance = baseSuccessChance; + + this.miningTimeSeconds = miningTimeSeconds; + this.recipeEnergyEfficiency = recipeEnergyEfficiency; + + long plasmaEU = plasmaCostCalculator(outputFluids); + long VM3EU = miningTimeSeconds * pow(2, 19) * 20; + this.euStartCost = (plasmaEU + VM3EU + standardRecipeEUOutPerTick * 20 * miningTimeSeconds); + this.euOutput = (long) (euStartCost * recipeEnergyEfficiency); + } + + private ItemStack getStoneDustType(String key) { + + switch (key) { + case "Ne": + return GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Netherrack, 1); + case "ED": + case "VA": + case "EA": + return GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Endstone, 1); + case "Mo": + return getModItem(NewHorizonsCoreMod.ID, "item.MoonStoneDust", 1); + case "De": + return getModItem(NewHorizonsCoreMod.ID, "item.DeimosStoneDust", 1); + case "Ma": + return getModItem(NewHorizonsCoreMod.ID, "item.MarsStoneDust", 1); + case "Ph": + return getModItem(NewHorizonsCoreMod.ID, "item.PhobosStoneDust", 1); + case "As": + case "KB": + return getModItem(NewHorizonsCoreMod.ID, "item.AsteroidsStoneDust", 1); + case "Ca": + return getModItem(NewHorizonsCoreMod.ID, "item.CallistoStoneDust", 1); + case "Ce": + return getModItem(NewHorizonsCoreMod.ID, "item.CeresStoneDust", 1); + case "Eu": + return getModItem(NewHorizonsCoreMod.ID, "item.EuropaStoneDust", 1); + case "Ga": + return getModItem(NewHorizonsCoreMod.ID, "item.GanymedeStoneDust", 1); + case "Io": + return getModItem(NewHorizonsCoreMod.ID, "item.IoStoneDust", 1); + case "Me": + return getModItem(NewHorizonsCoreMod.ID, "item.MercuryStoneDust", 1); + case "Ve": + return getModItem(NewHorizonsCoreMod.ID, "item.VenusStoneDust", 1); + case "En": + return getModItem(NewHorizonsCoreMod.ID, "item.EnceladusStoneDust", 1); + case "Mi": + return getModItem(NewHorizonsCoreMod.ID, "item.MirandaStoneDust", 1); + case "Ob": + return getModItem(NewHorizonsCoreMod.ID, "item.OberonStoneDust", 1); + case "Ti": + return getModItem(NewHorizonsCoreMod.ID, "item.TitanStoneDust", 1); + case "Pr": + return getModItem(NewHorizonsCoreMod.ID, "item.ProteusStoneDust", 1); + case "Tr": + return getModItem(NewHorizonsCoreMod.ID, "item.TritonStoneDust", 1); + case "Ha": + return getModItem(NewHorizonsCoreMod.ID, "item.HaumeaStoneDust", 1); + case "MM": + return getModItem(NewHorizonsCoreMod.ID, "item.MakeMakeStoneDust", 1); + case "Pl": + return getModItem(NewHorizonsCoreMod.ID, "item.PlutoStoneDust", 1); + case "BE": + return getModItem(NewHorizonsCoreMod.ID, "item.BarnardaEStoneDust", 1); + case "BF": + return getModItem(NewHorizonsCoreMod.ID, "item.BarnardaFStoneDust", 1); + case "CB": + return getModItem(NewHorizonsCoreMod.ID, "item.CentauriAStoneDust", 1); + case "TE": + return getModItem(NewHorizonsCoreMod.ID, "item.TCetiEStoneDust", 1); + case "VB": + return getModItem(NewHorizonsCoreMod.ID, "item.VegaBStoneDust", 1); + default: + return GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1); + } + } + + public EyeOfHarmonyRecipe(final GT5OreLayerHelper.NormalOreDimensionWrapper normalOreDimensionWrapper, + final GT5OreSmallHelper.SmallOreDimensionWrapper smallOreDimensionWrapper, final BlockDimensionDisplay block, + final double recipeEnergyEfficiency, final long hydrogenRequirement, final long heliumRequirement, + final long miningTimeSeconds, final long spacetimeCasingTierRequired, final double baseSuccessChance) { + + // Process recipes output items. + // 6 * 64 = 6 stacks/second for VM tier 3 + Og gas. + this( + processDimension(normalOreDimensionWrapper, smallOreDimensionWrapper, miningTimeSeconds), + block, + recipeEnergyEfficiency, + hydrogenRequirement, + heliumRequirement, + miningTimeSeconds, + spacetimeCasingTierRequired, + baseSuccessChance); + } + + // Return clone of list. Deep copy. Maybe a better way to do this? + public ArrayList getOutputItems() { + ArrayList copyOutputList = new ArrayList<>(); + for (ItemStackLong itemStackLong : outputItems) { + copyOutputList.add(new ItemStackLong(itemStackLong)); + } + + return copyOutputList; + } + + // Deep copy. + public ArrayList getOutputFluids() { + ArrayList copyOutputList = new ArrayList<>(); + + for (FluidStackLong fluidStackLong : outputFluids) { + copyOutputList.add(new FluidStackLong(fluidStackLong)); + } + + return copyOutputList; + } + + public long getHydrogenRequirement() { + return hydrogenRequirement; + } + + public long getHeliumRequirement() { + return heliumRequirement; + } + + public long getEUOutput() { + return euOutput; + } + + public long getEUStartCost() { + return euStartCost; + } + + public long getRecipeTimeInTicks() { + return miningTimeSeconds * 20; + } + + public double getBaseRecipeSuccessChance() { + return baseSuccessChance; + } + + public long getSpacetimeCasingTierRequired() { + return spacetimeCasingTierRequired; + } + + public ItemStack getRecipeTriggerItem() { + return recipeTriggerItem; + } + + private static final double PRIMARY_MULTIPLIER = (0.1 + 1.0 / 9.0); // Byproduct from macerating/washing chance. + private static final double SECONDARY_MULTIPLIER = (1.0 / 9.0); // Thermal centrifuge byproduct chance. + private static final double TERTIARY_MULTIPLIER = (0.1); // Macerating thermal centrifuged byproduct chance. + private static final double QUATERNARY_MULTIPLIER = (0.7); // Mercury/chem bath processing chance. + + private static final double[] ORE_MULTIPLIER = { PRIMARY_MULTIPLIER, SECONDARY_MULTIPLIER, TERTIARY_MULTIPLIER, + QUATERNARY_MULTIPLIER }; + + public static class HashMapHelper extends HashMap { + + private static final long serialVersionUID = 2297018142561480614L; + + void add(Materials material, double value) { + + // If key already exists. + if (this.containsKey(material)) { + this.put(material, value + this.get(material)); + return; + } + + // Otherwise, add value to hashmap entry. + this.put(material, value); + } + } + + public static void processHelper(HashMapHelper outputMap, Materials material, double mainMultiplier, + double probability) { + if (material == null) return; + outputMap.add(material.mDirectSmelting, (material.mOreMultiplier * 2) * mainMultiplier * probability); + + int index = 0; + for (Materials byProductMaterial : material.mOreByProducts) { + outputMap + .add(byProductMaterial.mDirectSmelting, mainMultiplier * (ORE_MULTIPLIER[index++] * 2) * probability); + } + } + + private static ArrayList> processDimension( + GT5OreLayerHelper.NormalOreDimensionWrapper normalOreDimWrapper, + GT5OreSmallHelper.SmallOreDimensionWrapper smallOreDimWrapper, long timeInSeconds) { + HashMapHelper outputMap = new HashMapHelper(); + + double mainMultiplier = timeInSeconds * 384.0; + + if (normalOreDimWrapper != null) { + normalOreDimWrapper.oreVeinToProbabilityInDimension.forEach((veinInfo, probability) -> { + processHelper(outputMap, veinInfo.mPrimaryVeinMaterial, mainMultiplier, probability); + processHelper(outputMap, veinInfo.mSecondaryMaterial, mainMultiplier, probability); + // 8.0 to replicate void miner getDropsVanillaVeins method yields. + processHelper(outputMap, veinInfo.mBetweenMaterial, mainMultiplier / 8.0, probability); + processHelper(outputMap, veinInfo.mSporadicMaterial, mainMultiplier / 8.0, probability); + }); + } + + // Iterate over small ores in dimension and add them, kinda hacky but works and is close enough. + if (smallOreDimWrapper != null) { + smallOreDimWrapper.oreVeinToProbabilityInDimension.forEach( + (veinInfo, + probability) -> processHelper(outputMap, veinInfo.getOreMaterial(), mainMultiplier, probability)); + } + + ArrayList> outputList = new ArrayList<>(); + + outputMap.forEach((material, quantity) -> outputList.add(Pair.of(material, (long) Math.floor(quantity)))); + + return outputList; + } + + private static ArrayList validPlasmaGenerator(final List> planetList) { + + ArrayList plasmaList = new ArrayList<>(); + + for (Pair pair : planetList) { + if (VALID_PLASMAS.contains(pair.getLeft())) { + plasmaList.add( + pair.getLeft() + .getPlasma(1)); + } + } + + return plasmaList; + } + + private static ArrayList validDustGenerator(final ArrayList> planetList) { + + ArrayList dustList = new ArrayList<>(); + + for (Pair pair : planetList) { + ItemStack dust = getUnificatedOreDictStack( + pair.getLeft() + .getDust(1)); + if (dust != null) { + dustList.add(new ItemStackLong(dust, pair.getRight())); + } + } + return dustList; + } + + private static long plasmaCostCalculator(ArrayList plasmas) { + long total = 0; + + for (FluidStackLong plasma : plasmas) { + FluidStack plasmaFluid = plasma.getRegularFluidStack(plasma, 1); + try { + String plasmaName = plasmaFluid.getFluid() + .getUnlocalizedName(); + total += plasmaEnergyMap.getOrDefault(plasmaName, 0L) * plasma.amount; + } catch (Exception e) { + e.printStackTrace(); + } + } + + return (long) (total * getMaxPlasmaTurbineEfficiency()); + } + + private static double getMaxPlasmaTurbineEfficiency() { + // I hate Shirabon. + return 3.85; + } + + private static final List VALID_PLASMAS = Stream + .of( + Materials.Helium, + Materials.Iron, + Materials.Calcium, + Materials.Niobium, + Materials.Nitrogen, + Materials.Zinc, + Materials.Silver, + Materials.Titanium, + Materials.Radon, + Materials.Nickel, + Materials.Boron, + Materials.Sulfur, + Materials.Americium, + Materials.Bismuth, + Materials.Oxygen, + Materials.Tin) + .collect(Collectors.toList()); + + private static final HashMap plasmaEnergyMap = new HashMap<>() { + + private static final long serialVersionUID = 7933945171103801933L; + + { + VALID_PLASMAS.forEach( + (material -> put( + material.getPlasma(1) + .getFluid() + .getUnlocalizedName(), + (long) (getPlasmaFuelValueInEUPerLiterFromMaterial(material) * getMaxPlasmaTurbineEfficiency())))); + } + }; +} diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java new file mode 100644 index 0000000000..fb2030d52d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java @@ -0,0 +1,184 @@ +package com.github.technus.tectech.recipe; + +import static com.github.technus.tectech.recipe.EyeOfHarmonyRecipe.processHelper; +import static com.github.technus.tectech.recipe.TecTechRecipeMaps.eyeOfHarmonyRecipes; +import static java.lang.Math.pow; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; + +import com.github.technus.tectech.util.FluidStackLong; +import com.github.technus.tectech.util.ItemStackLong; +import com.google.common.math.LongMath; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import pers.gwyog.gtneioreplugin.plugin.block.BlockDimensionDisplay; +import pers.gwyog.gtneioreplugin.plugin.block.ModBlocks; +import pers.gwyog.gtneioreplugin.util.DimensionHelper; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; + +public class EyeOfHarmonyRecipeStorage { + + public static final long BILLION = LongMath.pow(10, 9); + private static final double CHANCE_DECREASE_PER_DIMENSION = 0.05; + + // Map is unique so this is fine. + HashMap blocksMapInverted = new HashMap<>() { + + private static final long serialVersionUID = -1634011860327553337L; + + { + ModBlocks.blocks.forEach((dimString, dimBlock) -> { put(dimBlock, dimString); }); + } + }; + + private final HashMap recipeHashMap = new HashMap() { + + private static final long serialVersionUID = -3501819612517400500L; + + { + for (String dimAbbreviation : DimensionHelper.DimNameDisplayed) { + BlockDimensionDisplay blockDimensionDisplay = (BlockDimensionDisplay) ModBlocks.blocks + .get(dimAbbreviation); + + if (dimAbbreviation.equals("DD")) { + specialDeepDarkRecipe(this, blockDimensionDisplay); + } else { + + GT5OreLayerHelper.NormalOreDimensionWrapper normalOre = GT5OreLayerHelper.dimToOreWrapper + .getOrDefault(dimAbbreviation, null); + GT5OreSmallHelper.SmallOreDimensionWrapper smallOre = GT5OreSmallHelper.dimToSmallOreWrapper + .getOrDefault(dimAbbreviation, null); + if (normalOre == null && smallOre == null) { + // No ores are generated in this dimension. Fail silently. + continue; + } + + long spacetimeTier = blockDimensionDisplay.getDimensionRocketTier(); + if (spacetimeTier == 0) { + spacetimeTier += 1; + } + + put( + dimAbbreviation, + new EyeOfHarmonyRecipe( + normalOre, + smallOre, + blockDimensionDisplay, + 0.6 + blockDimensionDisplay.getDimensionRocketTier() / 10.0, + BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), + BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), + timeCalculator(blockDimensionDisplay.getDimensionRocketTier()), + spacetimeTier - 1, + 1.0 - CHANCE_DECREASE_PER_DIMENSION * blockDimensionDisplay.getDimensionRocketTier())); + } + } + } + }; + + public EyeOfHarmonyRecipe recipeLookUp(final ItemStack aStack) { + String dimAbbreviation = blocksMapInverted.get(Block.getBlockFromItem(aStack.getItem())); + return recipeHashMap.get(dimAbbreviation); + } + + public EyeOfHarmonyRecipeStorage() { + + for (EyeOfHarmonyRecipe recipe : recipeHashMap.values()) { + + ArrayList outputItems = new ArrayList<>(); + for (ItemStackLong itemStackLong : recipe.getOutputItems()) { + outputItems.add(itemStackLong.itemStack); + } + + ArrayList outputFluids = new ArrayList<>(); + for (FluidStackLong fluidStackLong : recipe.getOutputFluids()) { + outputFluids.add(fluidStackLong.fluidStack); + } + + ItemStack planetItem = recipe.getRecipeTriggerItem() + .copy(); + planetItem.stackSize = 0; + + eyeOfHarmonyRecipes.addRecipe( + false, + new ItemStack[] { planetItem }, + outputItems.toArray(new ItemStack[0]), + recipe, + null, + new FluidStack[] { Materials.Hydrogen.getGas(0), Materials.Helium.getGas(0), + MaterialsUEVplus.RawStarMatter.getFluid(0) }, + outputFluids.toArray(new FluidStack[0]), + (int) recipe.getRecipeTimeInTicks(), + 0, + 0); + } + } + + private void specialDeepDarkRecipe(final HashMap hashMap, + final BlockDimensionDisplay planetItem) { + + HashSet validMaterialSet = new HashSet<>(); + + for (Materials material : Materials.values()) { + + ItemStack normalOre = GT_OreDictUnificator.get(OrePrefixes.ore, material, 1); + + if ((normalOre != null)) { + validMaterialSet.add(material); + } + + ItemStack smallOre = GT_OreDictUnificator.get(OrePrefixes.oreSmall, material, 1); + + if ((smallOre != null)) { + validMaterialSet.add(material); + } + } + + ArrayList validMaterialList = new ArrayList<>(validMaterialSet); + + long rocketTier = 9; + + hashMap.put( + "DD", + new EyeOfHarmonyRecipe( + processDD(validMaterialList), + planetItem, + 0.6 + rocketTier / 10.0, + BILLION * (rocketTier + 1), + BILLION * (rocketTier + 1), + timeCalculator(rocketTier), + rocketTier, // -1 so that we avoid out of bounds exception on NEI render. + 1.0 - rocketTier * CHANCE_DECREASE_PER_DIMENSION)); + } + + private static long timeCalculator(final long rocketTier) { + return (long) (18_000L * pow(1.4, rocketTier)); + } + + private ArrayList> processDD(final ArrayList validMaterialList) { + EyeOfHarmonyRecipe.HashMapHelper outputMap = new EyeOfHarmonyRecipe.HashMapHelper(); + + // 10 from rocketTier + 1, 6 * 64 = VM3 + Og, 1.4 = time increase per tier. + double mainMultiplier = (timeCalculator(10) * (6 * 64)); + double probability = 1.0 / validMaterialList.size(); + + validMaterialList.forEach((material) -> { processHelper(outputMap, material, mainMultiplier, probability); }); + + ArrayList> outputList = new ArrayList<>(); + + outputMap.forEach((material, quantity) -> outputList.add(Pair.of(material, (long) Math.floor(quantity)))); + + return outputList; + } +} diff --git a/src/main/java/com/github/technus/tectech/recipe/GodforgeExoticFrontend.java b/src/main/java/com/github/technus/tectech/recipe/GodforgeExoticFrontend.java new file mode 100644 index 0000000000..38c505b89b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/GodforgeExoticFrontend.java @@ -0,0 +1,82 @@ +package com.github.technus.tectech.recipe; + +import static com.github.technus.tectech.loader.recipe.Godforge.magmatterItemsForNEI; +import static com.github.technus.tectech.loader.recipe.Godforge.magmatterSpaceFluidItemsForNEI; +import static com.github.technus.tectech.loader.recipe.Godforge.magmatterTimeFluidItemsForNEI; +import static com.github.technus.tectech.loader.recipe.Godforge.quarkGluonFluidItemsForNEI; +import static com.github.technus.tectech.loader.recipe.Godforge.quarkGluonItemsForNEI; +import static gregtech.api.util.GT_Utility.trans; + +import java.util.Collections; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; + +import codechicken.nei.PositionedStack; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.GT_NEI_DefaultHandler; +import gregtech.nei.RecipeDisplayInfo; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class GodforgeExoticFrontend extends RecipeMapFrontend { + + public GodforgeExoticFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super(uiPropertiesBuilder, neiPropertiesBuilder); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder, Pos2d windowOffset) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_LOGO) + .setSize(18, 18) + .setPos(new Pos2d(151, 63).add(windowOffset))); + } + + @Override + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + if (neiCachedRecipe.mRecipe.mFluidOutputs[0].equals(MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000))) { + neiCachedRecipe.mInputs.set(0, new PositionedStack(quarkGluonItemsForNEI, 48, 23, true)); + neiCachedRecipe.mInputs.set(1, new PositionedStack(quarkGluonFluidItemsForNEI, 48, 52, true)); + } else { + neiCachedRecipe.mInputs.set(0, new PositionedStack(magmatterItemsForNEI, 48, 23, true)); + neiCachedRecipe.mInputs.set(1, new PositionedStack(magmatterSpaceFluidItemsForNEI, 30, 52, true)); + neiCachedRecipe.mInputs.set(2, new PositionedStack(magmatterTimeFluidItemsForNEI, 48, 52, true)); + } + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return Collections.singletonList(new Pos2d(52, 33)); + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(106, 33)); + } + + @Override + protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) { + long eut = recipeInfo.recipe.mEUt; + long duration = recipeInfo.recipe.mDuration; + recipeInfo.drawText(trans("152", "Total: ") + GT_Utility.formatNumbers(eut * duration) + " EU"); + recipeInfo.drawText(trans("153", "Usage: ") + GT_Utility.formatNumbers(eut) + " EU/t"); + recipeInfo.drawText(trans("158", "Time: ") + GT_Utility.formatNumbers(duration / 20) + " secs"); + + } + + @Override + protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} + +} diff --git a/src/main/java/com/github/technus/tectech/recipe/GodforgePlasmaFrontend.java b/src/main/java/com/github/technus/tectech/recipe/GodforgePlasmaFrontend.java new file mode 100644 index 0000000000..8264c6a169 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/GodforgePlasmaFrontend.java @@ -0,0 +1,76 @@ +package com.github.technus.tectech.recipe; + +import static gregtech.api.util.GT_Utility.trans; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.Collections; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; + +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.RecipeDisplayInfo; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class GodforgePlasmaFrontend extends RecipeMapFrontend { + + public GodforgePlasmaFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super(uiPropertiesBuilder, neiPropertiesBuilder); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder, Pos2d windowOffset) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_LOGO) + .setSize(18, 18) + .setPos(new Pos2d(151, 63).add(windowOffset))); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return Collections.singletonList(new Pos2d(52, 33)); + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(106, 33)); + } + + @Override + protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) { + long eut = recipeInfo.recipe.mEUt; + long duration = recipeInfo.recipe.mDuration; + String multistep = "No"; + if (recipeInfo.recipe.mSpecialItems.toString() + .equals("true")) { + multistep = "Yes"; + } + String requiredUpgrade = switch (recipeInfo.recipe.mSpecialValue) { + case 1 -> "T4-T5"; + case 2 -> "Exotic"; + default -> "T1-T3"; + }; + + recipeInfo.drawText(trans("152", "Total: ") + GT_Utility.formatNumbers(eut * duration) + " EU"); + recipeInfo.drawText(trans("153", "Usage: ") + GT_Utility.formatNumbers(eut) + " EU/t"); + recipeInfo.drawText(trans("158", "Time: ") + GT_Utility.formatNumbers(duration / 20) + " secs"); + recipeInfo.drawText(translateToLocal("gt.blockmachines.multimachine.FOG.plasmamultistep") + ": " + multistep); + recipeInfo + .drawText(translateToLocal("gt.blockmachines.multimachine.FOG.plasmarecipetier") + ": " + requiredUpgrade); + } + + @Override + protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} + +} diff --git a/src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java b/src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java new file mode 100644 index 0000000000..2f95652a77 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java @@ -0,0 +1,101 @@ +package com.github.technus.tectech.recipe; + +import static gregtech.api.util.GT_Utility.trans; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.Collections; +import java.util.List; +import java.util.function.Supplier; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.RecipeDisplayInfo; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class ResearchStationFrontend extends RecipeMapFrontend { + + public ResearchStationFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super(uiPropertiesBuilder, neiPropertiesBuilder); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return Collections.singletonList(new Pos2d(52, 33)); + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(106, 33)); + } + + @Override + public Pos2d getSpecialItemPosition() { + return new Pos2d(124, 62); + } + + @Override + protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) { + long eut = recipeInfo.recipe.mEUt; + int computation = recipeInfo.recipe.mDuration; + short ampere = (short) (recipeInfo.recipe.mSpecialValue & 0xFFFF); + short minComputationPerSec = (short) (recipeInfo.recipe.mSpecialValue >>> 16); + recipeInfo.drawText( + translateToLocalFormatted( + "tt.nei.research.max_eu", + GT_Utility.formatNumbers( + (1 + (computation - minComputationPerSec) / minComputationPerSec) * eut * ampere * 20))); + recipeInfo.drawText(trans("153", "Usage: ") + GT_Utility.formatNumbers(eut * ampere) + " EU/t"); + recipeInfo.drawText(trans("154", "Voltage: ") + GT_Utility.formatNumbers(eut) + " EU/t"); + recipeInfo.drawText(trans("155", "Amperage: ") + GT_Utility.formatNumbers(ampere)); + recipeInfo + .drawText(translateToLocalFormatted("tt.nei.research.computation", GT_Utility.formatNumbers(computation))); + recipeInfo.drawText( + translateToLocalFormatted( + "tt.nei.research.min_computation", + GT_Utility.formatNumbers(minComputationPerSec))); + } + + @Override + protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} + + @Override + public void addProgressBar(ModularWindow.Builder builder, Supplier progressSupplier, Pos2d windowOffset) { + int bar1Width = 25; + int bar2Width = 11; + int bar3Height = 18; + List> splitProgress = splitProgress(progressSupplier, bar1Width, bar2Width, bar3Height); + builder.widget( + new ProgressBar().setTexture(TecTechUITextures.PROGRESSBAR_RESEARCH_STATION_1, bar1Width) + .setDirection(ProgressBar.Direction.RIGHT) + .setProgress(splitProgress.get(0)) + .setSynced(false, false) + .setPos(new Pos2d(81, 40).add(windowOffset)) + .setSize(bar1Width, 5)); + builder.widget( + new ProgressBar().setTexture(TecTechUITextures.PROGRESSBAR_RESEARCH_STATION_2, bar2Width) + .setDirection(ProgressBar.Direction.RIGHT) + .setProgress(splitProgress.get(1)) + .setSynced(false, false) + .setPos(new Pos2d(124, 40).add(windowOffset)) + .setSize(bar2Width, 5)); + builder.widget( + new ProgressBar().setTexture(TecTechUITextures.PROGRESSBAR_RESEARCH_STATION_3, bar3Height) + .setDirection(ProgressBar.Direction.DOWN) + .setProgress(splitProgress.get(2)) + .setSynced(false, false) + .setPos(new Pos2d(128, 44).add(windowOffset)) + .setSize(10, bar3Height)); + } +} diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java new file mode 100644 index 0000000000..1730e81713 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -0,0 +1,278 @@ +package com.github.technus.tectech.recipe; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.CustomItemList; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.ItemList; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_RecipeAdder; + +public class TT_recipeAdder extends GT_RecipeAdder { + + public static final ItemStack[] nullItem = new ItemStack[0]; + public static final FluidStack[] nullFluid = new FluidStack[0]; + + public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, int totalComputationRequired, + int computationRequiredPerSec, int researchEUt, int researchAmperage, ItemStack[] aInputs, + FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { + if (aInputs == null) { + aInputs = nullItem; + } + if (aFluidInputs == null) { + aFluidInputs = nullFluid; + } + if (aResearchItem == null || totalComputationRequired <= 0 || aOutput == null || aInputs.length > 16) { + return false; + } + for (ItemStack tItem : aInputs) { + if (tItem == null) { + TecTech.LOGGER.error( + "addResearchableAssemblingLineRecipe " + aResearchItem.getDisplayName() + + " --> " + + aOutput.getUnlocalizedName() + + " there is some null item in that recipe"); + } + } + researchAmperage = GT_Utility.clamp(researchAmperage, 1, Short.MAX_VALUE); + computationRequiredPerSec = GT_Utility.clamp(computationRequiredPerSec, 1, Short.MAX_VALUE); + TecTechRecipeMaps.researchStationFakeRecipes.addFakeRecipe( + false, + new ItemStack[] { aResearchItem }, + new ItemStack[] { aOutput }, + new ItemStack[] { ItemList.Tool_DataStick.getWithName(1L, "Writes Research result") }, + null, + null, + totalComputationRequired, + researchEUt, + researchAmperage | computationRequiredPerSec << 16); + RecipeMaps.assemblylineVisualRecipes.addFakeRecipe( + false, + aInputs, + new ItemStack[] { aOutput }, + new ItemStack[] { ItemList.Tool_DataStick.getWithName(1L, "Reads Research result") }, + aFluidInputs, + null, + assDuration, + assEUt, + 0, + false); + GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add( + new GT_Recipe.GT_Recipe_AssemblyLine( + CustomItemList.UnusedStuff.get(1), + totalComputationRequired / computationRequiredPerSec, + aInputs, + aFluidInputs, + aOutput, + assDuration, + assEUt)); + TecTechRecipeMaps.researchableALRecipeList.add( + new GT_Recipe.GT_Recipe_AssemblyLine( + aResearchItem, + totalComputationRequired / computationRequiredPerSec, + aInputs, + aFluidInputs, + aOutput, + assDuration, + assEUt)); + return true; + } + + public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, int totalComputationRequired, + int computationRequiredPerSec, int researchEUt, int researchAmperage, Object[] aInputs, + FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { + if (aInputs == null) { + aInputs = nullItem; + } + if (aFluidInputs == null) { + aFluidInputs = nullFluid; + } + if (aResearchItem == null || totalComputationRequired <= 0 + || aOutput == null + || aInputs.length > 16 + || aFluidInputs.length > 4 + || assDuration <= 0 + || assEUt <= 0) { + return false; + } + + ItemStack[] tInputs = new ItemStack[aInputs.length]; + ItemStack[][] tAlts = new ItemStack[aInputs.length][]; + int tPersistentHash = 1; + for (int i = 0; i < aInputs.length; i++) { + Object obj = aInputs[i]; + if (obj instanceof ItemStack) { + tInputs[i] = (ItemStack) obj; + tAlts[i] = null; + tPersistentHash = tPersistentHash * 31 + GT_Utility.persistentHash(tInputs[i], true, false); + continue; + } else if (obj instanceof ItemStack[]aStacks) { + if (aStacks.length > 0) { + tInputs[i] = aStacks[0]; + tAlts[i] = Arrays.copyOf(aStacks, aStacks.length); + for (ItemStack tAlt : tAlts[i]) { + tPersistentHash = tPersistentHash * 31 + GT_Utility.persistentHash(tAlt, true, false); + } + tPersistentHash *= 31; + continue; + } + } else if (obj instanceof Object[]objs) { + List tList; + if (objs.length >= 2 && !(tList = GT_OreDictUnificator.getOres(objs[0])).isEmpty()) { + try { + // sort the output, so the hash code is stable across launches + tList.sort( + Comparator + .comparing( + s -> GameRegistry.findUniqueIdentifierFor(s.getItem()).modId) + .thenComparing(s -> GameRegistry.findUniqueIdentifierFor(s.getItem()).modId) + .thenComparingInt(Items.feather::getDamage) + .thenComparingInt(s -> s.stackSize)); + int tAmount = ((Number) objs[1]).intValue(); + List uList = new ArrayList<>(); + for (ItemStack tStack : tList) { + ItemStack uStack = GT_Utility.copyAmount(tAmount, tStack); + if (GT_Utility.isStackValid(uStack)) { + uList.add(uStack); + if (tInputs[i] == null) tInputs[i] = uStack; + } + } + tAlts[i] = uList.toArray(new ItemStack[0]); + tPersistentHash = tPersistentHash * 31 + (objs[0] == null ? "" : objs[0].toString()).hashCode(); + tPersistentHash = tPersistentHash * 31 + tAmount; + continue; + } catch (Exception t) { + TecTech.LOGGER.error( + "addAssemblingLineRecipe " + aResearchItem.getDisplayName() + + " --> there is some ... in that recipe"); + } + } + } + TecTech.LOGGER.error( + "addAssemblingLineRecipe " + aResearchItem.getDisplayName() + + " --> " + + aOutput.getUnlocalizedName() + + " there is some null item in that recipe"); + } + tPersistentHash = tPersistentHash * 31 + GT_Utility.persistentHash(aResearchItem, true, false); + tPersistentHash = tPersistentHash * 31 + GT_Utility.persistentHash(aOutput, true, false); + for (FluidStack tFluidInput : aFluidInputs) { + if (tFluidInput == null) continue; + tPersistentHash = tPersistentHash * 31 + GT_Utility.persistentHash(tFluidInput, true, false); + } + researchAmperage = GT_Utility.clamp(researchAmperage, 1, Short.MAX_VALUE); + computationRequiredPerSec = GT_Utility.clamp(computationRequiredPerSec, 1, Short.MAX_VALUE); + tPersistentHash = tPersistentHash * 31 + totalComputationRequired; + tPersistentHash = tPersistentHash * 31 + computationRequiredPerSec; + tPersistentHash = tPersistentHash * 31 + researchAmperage; + tPersistentHash = tPersistentHash * 31 + researchEUt; + tPersistentHash = tPersistentHash * 31 + assDuration; + tPersistentHash = tPersistentHash * 31 + assEUt; + TecTechRecipeMaps.researchStationFakeRecipes.addFakeRecipe( + false, + new ItemStack[] { aResearchItem }, + new ItemStack[] { aOutput }, + new ItemStack[] { ItemList.Tool_DataStick.getWithName(1L, "Writes Research result") }, + null, + null, + totalComputationRequired, + researchEUt, + researchAmperage | computationRequiredPerSec << 16); + RecipeMaps.assemblylineVisualRecipes.addFakeRecipe( + false, + tInputs, + new ItemStack[] { aOutput }, + new ItemStack[] { ItemList.Tool_DataStick.getWithName(1L, "Reads Research result") }, + aFluidInputs, + null, + assDuration, + assEUt, + 0, + tAlts, + false); + GT_Recipe_AssemblyLine recipeGT = new GT_Recipe_AssemblyLine( + CustomItemList.UnusedStuff.get(1), + totalComputationRequired / computationRequiredPerSec, + tInputs, + aFluidInputs, + aOutput, + assDuration, + assEUt, + tAlts); + recipeGT.setPersistentHash(tPersistentHash); + GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(recipeGT); + GT_Recipe_AssemblyLine recipeTT = new GT_Recipe_AssemblyLine( + aResearchItem, + totalComputationRequired / computationRequiredPerSec, + tInputs, + aFluidInputs, + aOutput, + assDuration, + assEUt, + tAlts); + recipeTT.setPersistentHash(tPersistentHash); + TecTechRecipeMaps.researchableALRecipeList.add(recipeTT); + return true; + } + + public static boolean addFOGPlasmaRecipe(ItemStack[] itemInputs, FluidStack[] fluidOutputs, int machineDuration, + int machineEUt, boolean multiStep, int recipeTier) { + if (itemInputs == null) { + itemInputs = nullItem; + } + + TecTechRecipeMaps.godforgePlasmaRecipes + .addRecipe(false, itemInputs, null, multiStep, null, fluidOutputs, machineDuration, machineEUt, recipeTier); + return true; + } + + public static boolean addFOGPlasmaRecipe(FluidStack[] fluidInputs, FluidStack[] fluidOutputs, int machineDuration, + int machineEUt, boolean multiStep, int recipeTier) { + + if (fluidInputs == null) { + fluidInputs = nullFluid; + } + + TecTechRecipeMaps.godforgePlasmaRecipes.addRecipe( + false, + null, + null, + multiStep, + fluidInputs, + fluidOutputs, + machineDuration, + machineEUt, + recipeTier); + return true; + } + + public static boolean addFOGExoticFakeRecipe(ItemStack[] itemInputs, FluidStack[] fluidInputs, + FluidStack[] fluidOutputs, int machineDuration, int machineEUt, int recipeTier) { + + TecTechRecipeMaps.godforgeExoticMatterRecipes.addFakeRecipe( + false, + itemInputs, + null, + null, + fluidInputs, + fluidOutputs, + machineDuration, + machineEUt, + recipeTier, + false); + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java b/src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java new file mode 100644 index 0000000000..1626ac3252 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java @@ -0,0 +1,77 @@ +package com.github.technus.tectech.recipe; + +import java.util.ArrayList; +import java.util.List; + +import com.github.technus.tectech.thing.CustomItemList; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.util.GT_Recipe; + +public class TecTechRecipeMaps { + + public static void init() {} + + public static final List researchableALRecipeList = new ArrayList<>(); + + public static final RecipeMap eyeOfHarmonyRecipes = RecipeMapBuilder.of("gt.recipe.eyeofharmony") + .maxIO( + EyeOfHarmonyFrontend.maxItemInputs, + EyeOfHarmonyFrontend.maxItemOutputs, + EyeOfHarmonyFrontend.maxFluidInputs, + EyeOfHarmonyFrontend.maxFluidOutputs) + .minInputs(1, 0) + .progressBar(GT_UITextures.PROGRESSBAR_HAMMER, ProgressBar.Direction.DOWN) + .progressBarPos(78, 24 + 2) + .logoPos(10, 10) + .neiHandlerInfo( + builder -> builder.setDisplayStack(CustomItemList.Machine_Multi_EyeOfHarmony.get(1)) + .setMaxRecipesPerPage(1)) + .frontend(EyeOfHarmonyFrontend::new) + .build(); + public static final RecipeMap researchStationFakeRecipes = RecipeMapBuilder + .of("gt.recipe.researchStation") + .maxIO(1, 1, 0, 0) + .useSpecialSlot() + .slotOverlays((index, isFluid, isOutput, isSpecial) -> { + if (isSpecial) { + return GT_UITextures.OVERLAY_SLOT_DATA_ORB; + } + if (isOutput) { + return TecTechUITextures.OVERLAY_SLOT_MESH; + } + return GT_UITextures.OVERLAY_SLOT_MICROSCOPE; + }) + .addSpecialTexture(19, 12, 84, 60, TecTechUITextures.PICTURE_HEAT_SINK) + .addSpecialTexture(41, 22, 40, 40, TecTechUITextures.PICTURE_RACK_LARGE) + .logo(TecTechUITextures.PICTURE_TECTECH_LOGO) + .logoSize(18, 18) + .logoPos(151, 63) + .neiTransferRect(81, 33, 25, 18) + .neiTransferRect(124, 33, 18, 29) + .frontend(ResearchStationFrontend::new) + .neiHandlerInfo(builder -> builder.setDisplayStack(CustomItemList.Machine_Multi_Research.get(1))) + .build(); + + public static final RecipeMap godforgePlasmaRecipes = RecipeMapBuilder.of("gt.recipe.fog_plasma") + .maxIO(1, 1, 1, 1) + .progressBar(TecTechUITextures.PROGRESSBAR_GODFORGE_PLASMA, ProgressBar.Direction.RIGHT) + .progressBarPos(78, 33) + .neiTransferRect(78, 33, 20, 20) + .frontend(GodforgePlasmaFrontend::new) + .build(); + public static final RecipeMap godforgeExoticMatterRecipes = RecipeMapBuilder + .of("gt.recipe.fog_exotic") + .maxIO(1, 1, 2, 1) + .progressBar(TecTechUITextures.PROGRESSBAR_GODFORGE_PLASMA, ProgressBar.Direction.RIGHT) + .progressBarPos(78, 33) + .neiTransferRect(78, 33, 20, 20) + .frontend(GodforgeExoticFrontend::new) + .build(); + +} diff --git a/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_ItemRenderer.java b/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_ItemRenderer.java new file mode 100644 index 0000000000..b5d75fdc71 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_ItemRenderer.java @@ -0,0 +1,98 @@ +package com.github.technus.tectech.rendering.EOH; + +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.STAR_LAYER_0; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.STAR_LAYER_1; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.STAR_LAYER_2; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.starModel; +import static java.lang.Math.pow; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +public class EOH_ItemRenderer implements IItemRenderer { + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + + if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); + else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0.5, 0.5, 0.5); + if (type == ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0); + } + + // Render star stuff. + renderStarLayer(0, STAR_LAYER_0, 1.0f); + renderStarLayer(1, STAR_LAYER_1, 0.4f); + renderStarLayer(2, STAR_LAYER_2, 0.2f); + + GL11.glPopMatrix(); + } + + private void renderStarLayer(int layer, ResourceLocation texture, float alpha) { + + // Begin animation. + GL11.glPushMatrix(); + + // OpenGL settings, not sure exactly what these do. + + // Disables lighting, so star is always lit (I think). + GL11.glDisable(GL11.GL_LIGHTING); + // Culls things out of line of sight? + GL11.glEnable(GL11.GL_CULL_FACE); + // Merges colours of the various layers of the star? + GL11.glEnable(GL11.GL_BLEND); + // ??? + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + // Bind animation to layer of star. + FMLClientHandler.instance() + .getClient() + .getTextureManager() + .bindTexture(texture); + + // 0.01f magic number to shrink sphere obj down. + // Size obtained from the multis current recipe. + float scale = 0.01f; + + // Put each subsequent layer further out. + scale *= pow(1.04f, layer); + + // Scale the star up in the x, y and z directions. + GL11.glScalef(scale, scale, scale); + + switch (layer) { + case 0 -> GL11.glRotatef(130 + (System.currentTimeMillis() / 64) % 360, 0F, 1F, 1F); + case 1 -> GL11.glRotatef(-49 + (System.currentTimeMillis() / 64) % 360, 1F, 1F, 0F); + case 2 -> GL11.glRotatef(67 + (System.currentTimeMillis() / 64) % 360, 1F, 0F, 1F); + } + + // Set colour and alpha (transparency) of the star layer. + GL11.glColor4f(1, 1, 1, alpha); + + starModel.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LIGHTING); + + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + // Finish animation. + GL11.glPopMatrix(); + } + +} diff --git a/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_RenderingUtils.java b/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_RenderingUtils.java new file mode 100644 index 0000000000..3f72cacd77 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_RenderingUtils.java @@ -0,0 +1,270 @@ +package com.github.technus.tectech.rendering.EOH; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.STAR_LAYER_0; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.STAR_LAYER_1; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.STAR_LAYER_2; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.spaceModel; +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.starModel; +import static java.lang.Math.pow; + +import java.awt.Color; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +public abstract class EOH_RenderingUtils { + + public static void renderStar(IItemRenderer.ItemRenderType type, Color color) { + GL11.glPushMatrix(); + + if (type == IItemRenderer.ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); + else if (type == IItemRenderer.ItemRenderType.EQUIPPED + || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0.5, 0.5, 0.5); + if (type == IItemRenderer.ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0); + } + + // Render star stuff. + renderStarLayer(0, STAR_LAYER_0, color, 1.0f); + renderStarLayer(1, STAR_LAYER_1, color, 0.4f); + renderStarLayer(2, STAR_LAYER_2, color, 0.2f); + + GL11.glPopMatrix(); + } + + public static void renderStar(IItemRenderer.ItemRenderType type) { + renderStar(type, new Color(1.0f, 0.4f, 0.05f, 1.0f)); + } + + private static void renderStarLayer(int layer, ResourceLocation texture, Color color, float alpha) { + + // Begin animation. + GL11.glPushMatrix(); + + // OpenGL settings, not sure exactly what these do. + + // Disables lighting, so star is always lit (I think). + GL11.glDisable(GL11.GL_LIGHTING); + // Culls triangles/quads facing away from the camera + GL11.glEnable(GL11.GL_CULL_FACE); + // Allows alpha blending to occur (transparency-based color mixing) + GL11.glEnable(GL11.GL_BLEND); + // ??? + if (alpha < 1.0f) { + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + } else { + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + + // Bind image to layer of star. + FMLClientHandler.instance() + .getClient() + .getTextureManager() + .bindTexture(texture); + + // 0.01f magic number to shrink sphere obj down. + // Size obtained from the multis current recipe. + float scale = 0.01f; + + // Put each subsequent layer further out. + scale *= pow(1.04f, layer); + + // Scale the star up in the x, y and z directions. + GL11.glScalef(scale, scale, scale); + + switch (layer) { + case 0 -> GL11.glRotatef(130 + (System.currentTimeMillis() / 64) % 360, 0F, 1F, 1F); + case 1 -> GL11.glRotatef(-49 + (System.currentTimeMillis() / 64) % 360, 1F, 1F, 0F); + case 2 -> GL11.glRotatef(67 + (System.currentTimeMillis() / 64) % 360, 1F, 0F, 1F); + } + + // Set colour and alpha (transparency) of the star layer. + final float red = color.getRed() / 255.0f; + final float green = color.getGreen() / 255.0f; + final float blue = color.getBlue() / 255.0f; + + GL11.glColor4f(red, green, blue, alpha); + + starModel.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LIGHTING); + + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + // Finish animation. + GL11.glPopMatrix(); + } + + public static void beginRenderingBlocksInWorld(final float blockSize) { + final Tessellator tes = Tessellator.instance; + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + + GL11.glDisable(GL11.GL_LIGHTING); + + tes.setColorOpaque_F(1f, 1f, 1f); + tes.startDrawingQuads(); + + GL11.glScalef(blockSize, blockSize, blockSize); + } + + public static void endRenderingBlocksInWorld() { + Tessellator.instance.draw(); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + static final double[] BLOCK_X = { -0.5, -0.5, +0.5, +0.5, +0.5, +0.5, -0.5, -0.5 }; + static final double[] BLOCK_Y = { +0.5, -0.5, -0.5, +0.5, +0.5, -0.5, -0.5, +0.5 }; + static final double[] BLOCK_Z = { +0.5, +0.5, +0.5, +0.5, -0.5, -0.5, -0.5, -0.5 }; + + public static void addRenderedBlockInWorld(final Block block, final int meta, final double x, final double y, + final double z) { + final Tessellator tes = Tessellator.instance; + + IIcon texture; + + double minU; + double maxU; + double minV; + double maxV; + + { + texture = block.getIcon(4, meta); + + minU = texture.getMinU(); + maxU = texture.getMaxU(); + minV = texture.getMinV(); + maxV = texture.getMaxV(); + + tes.addVertexWithUV(x + BLOCK_X[1], y + BLOCK_Y[1], z + BLOCK_Z[1], maxU, maxV); + tes.addVertexWithUV(x + BLOCK_X[0], y + BLOCK_Y[0], z + BLOCK_Z[0], maxU, minV); + tes.addVertexWithUV(x + BLOCK_X[7], y + BLOCK_Y[7], z + BLOCK_Z[7], minU, minV); + tes.addVertexWithUV(x + BLOCK_X[6], y + BLOCK_Y[6], z + BLOCK_Z[6], minU, maxV); + } + + { + // Bottom face. + texture = block.getIcon(0, meta); + + minU = texture.getMinU(); + maxU = texture.getMaxU(); + minV = texture.getMinV(); + maxV = texture.getMaxV(); + + tes.addVertexWithUV(x + BLOCK_X[5], y + BLOCK_Y[5], z + BLOCK_Z[5], maxU, minV); + tes.addVertexWithUV(x + BLOCK_X[2], y + BLOCK_Y[2], z + BLOCK_Z[2], maxU, maxV); + tes.addVertexWithUV(x + BLOCK_X[1], y + BLOCK_Y[1], z + BLOCK_Z[1], minU, maxV); + tes.addVertexWithUV(x + BLOCK_X[6], y + BLOCK_Y[6], z + BLOCK_Z[6], minU, minV); + } + + { + texture = block.getIcon(2, meta); + + minU = texture.getMinU(); + maxU = texture.getMaxU(); + minV = texture.getMinV(); + maxV = texture.getMaxV(); + + tes.addVertexWithUV(x + BLOCK_X[6], y + BLOCK_Y[6], z + BLOCK_Z[6], maxU, maxV); + tes.addVertexWithUV(x + BLOCK_X[7], y + BLOCK_Y[7], z + BLOCK_Z[7], maxU, minV); + tes.addVertexWithUV(x + BLOCK_X[4], y + BLOCK_Y[4], z + BLOCK_Z[4], minU, minV); + tes.addVertexWithUV(x + BLOCK_X[5], y + BLOCK_Y[5], z + BLOCK_Z[5], minU, maxV); + } + + { + texture = block.getIcon(5, meta); + + minU = texture.getMinU(); + maxU = texture.getMaxU(); + minV = texture.getMinV(); + maxV = texture.getMaxV(); + + tes.addVertexWithUV(x + BLOCK_X[5], y + BLOCK_Y[5], z + BLOCK_Z[5], maxU, maxV); + tes.addVertexWithUV(x + BLOCK_X[4], y + BLOCK_Y[4], z + BLOCK_Z[4], maxU, minV); + tes.addVertexWithUV(x + BLOCK_X[3], y + BLOCK_Y[3], z + BLOCK_Z[3], minU, minV); + tes.addVertexWithUV(x + BLOCK_X[2], y + BLOCK_Y[2], z + BLOCK_Z[2], minU, maxV); + } + + { + texture = block.getIcon(1, meta); + + minU = texture.getMinU(); + maxU = texture.getMaxU(); + minV = texture.getMinV(); + maxV = texture.getMaxV(); + + tes.addVertexWithUV(x + BLOCK_X[3], y + BLOCK_Y[3], z + BLOCK_Z[3], maxU, maxV); + tes.addVertexWithUV(x + BLOCK_X[4], y + BLOCK_Y[4], z + BLOCK_Z[4], maxU, minV); + tes.addVertexWithUV(x + BLOCK_X[7], y + BLOCK_Y[7], z + BLOCK_Z[7], minU, minV); + tes.addVertexWithUV(x + BLOCK_X[0], y + BLOCK_Y[0], z + BLOCK_Z[0], minU, maxV); + } + + { + texture = block.getIcon(3, meta); + + minU = texture.getMinU(); + maxU = texture.getMaxU(); + minV = texture.getMinV(); + maxV = texture.getMaxV(); + + tes.addVertexWithUV(x + BLOCK_X[2], y + BLOCK_Y[2], z + BLOCK_Z[2], maxU, maxV); + tes.addVertexWithUV(x + BLOCK_X[3], y + BLOCK_Y[3], z + BLOCK_Z[3], maxU, minV); + tes.addVertexWithUV(x + BLOCK_X[0], y + BLOCK_Y[0], z + BLOCK_Z[0], minU, minV); + tes.addVertexWithUV(x + BLOCK_X[1], y + BLOCK_Y[1], z + BLOCK_Z[1], minU, maxV); + } + } + + public static void renderBlockInWorld(final Block block, final int meta, final float blockSize) { + beginRenderingBlocksInWorld(blockSize); + + addRenderedBlockInWorld(block, meta, 0, 0, 0); + + endRenderingBlocksInWorld(); + } + + public static void renderOuterSpaceShell() { + + // Save current OpenGL state. + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + + // Begin animation. + GL11.glPushMatrix(); + + // Disables lighting, so star is always lit. + GL11.glDisable(GL11.GL_LIGHTING); + // Merges colors of the various layers of the star. + // GL11.glEnable(GL11.GL_BLEND); + + // Bind animation to layer of star. + FMLClientHandler.instance() + .getClient() + .getTextureManager() + .bindTexture(new ResourceLocation(MODID, "models/spaceLayer.png")); + + final float scale = 0.01f * 17.5f; + // Scale the star up in the x, y and z directions. + GL11.glScalef(scale, scale, scale); + + GL11.glColor4f(1, 1, 1, 1); + + spaceModel.renderAll(); + + // Finish animation. + GL11.glPopMatrix(); + + // Restore previous OpenGL state. + GL11.glPopAttrib(); + } + +} diff --git a/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_TESR.java b/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_TESR.java new file mode 100644 index 0000000000..da704a37ff --- /dev/null +++ b/src/main/java/com/github/technus/tectech/rendering/EOH/EOH_TESR.java @@ -0,0 +1,91 @@ +package com.github.technus.tectech.rendering.EOH; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.rendering.EOH.EOH_RenderingUtils.renderBlockInWorld; +import static com.github.technus.tectech.rendering.EOH.EOH_RenderingUtils.renderOuterSpaceShell; +import static com.github.technus.tectech.rendering.EOH.EOH_RenderingUtils.renderStar; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +import org.lwjgl.opengl.GL11; + +import com.github.technus.tectech.thing.block.TileEyeOfHarmony; + +public class EOH_TESR extends TileEntitySpecialRenderer { + + public static final ResourceLocation STAR_LAYER_0 = new ResourceLocation(MODID, "models/StarLayer0.png"); + public static final ResourceLocation STAR_LAYER_1 = new ResourceLocation(MODID, "models/StarLayer1.png"); + public static final ResourceLocation STAR_LAYER_2 = new ResourceLocation(MODID, "models/StarLayer2.png"); + public static IModelCustom starModel; + public static IModelCustom spaceModel; + + public EOH_TESR() { + starModel = AdvancedModelLoader.loadModel(new ResourceLocation(MODID, "models/Star.obj")); + spaceModel = AdvancedModelLoader.loadModel(new ResourceLocation(MODID, "models/Space.obj")); + } + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + if (!(tile instanceof TileEyeOfHarmony EOHRenderTile)) return; + + GL11.glPushMatrix(); + // Required to centre the render to the middle of the block. + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + + // Space shell. + renderOuterSpaceShell(); + + // Render the planets. + renderOrbitObjects(EOHRenderTile); + + // Render the star itself. + renderStar(IItemRenderer.ItemRenderType.INVENTORY); + GL11.glPopAttrib(); + + GL11.glPopMatrix(); + } + + private void renderOrbitObjects(final TileEyeOfHarmony EOHRenderTile) { + + if (EOHRenderTile.getOrbitingObjects() != null) { + + if (EOHRenderTile.getOrbitingObjects() + .size() == 0) { + EOHRenderTile.generateImportantInfo(); + } + + for (TileEyeOfHarmony.OrbitingObject t : EOHRenderTile.getOrbitingObjects()) { + renderOrbit(EOHRenderTile, t); + } + } + } + + void renderOrbit(final TileEyeOfHarmony EOHRenderTile, final TileEyeOfHarmony.OrbitingObject orbitingObject) { + // Render orbiting body. + GL11.glPushMatrix(); + + GL11.glRotatef(orbitingObject.zAngle, 0, 0, 1); + GL11.glRotatef(orbitingObject.xAngle, 1, 0, 0); + GL11.glRotatef((orbitingObject.rotationSpeed * 0.1f * EOHRenderTile.angle) % 360.0f, 0F, 1F, 0F); + GL11.glTranslated(-0.2 - orbitingObject.distance - STAR_RESCALE * EOHRenderTile.getSize(), 0, 0); + GL11.glRotatef((orbitingObject.orbitSpeed * 0.1f * EOHRenderTile.angle) % 360.0f, 0F, 1F, 0F); + + this.bindTexture(TextureMap.locationBlocksTexture); + renderBlockInWorld(orbitingObject.block, 0, orbitingObject.scale); + + GL11.glPopMatrix(); + } + + private static final float STAR_RESCALE = 0.2f; + +} diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java new file mode 100644 index 0000000000..a45e342050 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -0,0 +1,609 @@ +package com.github.technus.tectech.thing; + +import static gregtech.api.enums.GT_Values.W; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +public enum CustomItemList implements IItemContainer { + + Casing_UEV, + Casing_UIV, + Casing_UMV, + Casing_UXV, + Casing_MAXV, + Hull_UEV, + Hull_UIV, + Hull_UMV, + Hull_UXV, + Hull_MAXV, + Transformer_UEV_UHV, + Transformer_UIV_UEV, + Transformer_UMV_UIV, + Transformer_UXV_UMV, + Transformer_MAXV_UXV, + WetTransformer_LV_ULV, + WetTransformer_MV_LV, + WetTransformer_HV_MV, + WetTransformer_EV_HV, + WetTransformer_IV_EV, + WetTransformer_LuV_IV, + WetTransformer_ZPM_LuV, + WetTransformer_UV_ZPM, + WetTransformer_UHV_UV, + WetTransformer_UEV_UHV, + WetTransformer_UIV_UEV, + WetTransformer_UMV_UIV, + WetTransformer_UXV_UMV, + WetTransformer_MAXV_UXV, + + Transformer_HA_UEV_UHV, + Transformer_HA_UIV_UEV, + Transformer_HA_UMV_UIV, + Transformer_HA_UXV_UMV, + Transformer_HA_MAXV_UXV, + + hatch_CreativeMaintenance, + hatch_CreativeData, + hatch_CreativeUncertainty, + Machine_OwnerDetector, + Machine_BuckConverter_IV, + Machine_BuckConverter_LuV, + Machine_BuckConverter_ZPM, + Machine_BuckConverter_UV, + Machine_BuckConverter_UHV, + Machine_BuckConverter_UEV, + Machine_BuckConverter_UIV, + Machine_BuckConverter_UMV, + Machine_BuckConverter_UXV, + Machine_DebugWriter, + Machine_DebugGenny, + UnusedStuff, + Machine_DebugPollutor, + DATApipe, + LASERpipe, + rack_Hatch, + holder_Hatch, + capacitor_Hatch, + + eM_dynamoMulti4_EV, + eM_dynamoMulti16_EV, + eM_dynamoMulti64_EV, + eM_dynamoMulti4_IV, + eM_dynamoMulti16_IV, + eM_dynamoMulti64_IV, + eM_dynamoMulti4_LuV, + eM_dynamoMulti16_LuV, + eM_dynamoMulti64_LuV, + eM_dynamoMulti4_ZPM, + eM_dynamoMulti16_ZPM, + eM_dynamoMulti64_ZPM, + eM_dynamoMulti4_UV, + eM_dynamoMulti16_UV, + eM_dynamoMulti64_UV, + eM_dynamoMulti4_UHV, + eM_dynamoMulti16_UHV, + eM_dynamoMulti64_UHV, + eM_dynamoMulti4_UEV, + eM_dynamoMulti16_UEV, + eM_dynamoMulti64_UEV, + eM_dynamoMulti4_UIV, + eM_dynamoMulti16_UIV, + eM_dynamoMulti64_UIV, + eM_dynamoMulti4_UMV, + eM_dynamoMulti16_UMV, + eM_dynamoMulti64_UMV, + eM_dynamoMulti4_UXV, + eM_dynamoMulti16_UXV, + eM_dynamoMulti64_UXV, + eM_dynamoTunnel1_IV, + eM_dynamoTunnel2_IV, + eM_dynamoTunnel3_IV, + eM_dynamoTunnel4_IV, + eM_dynamoTunnel5_IV, + eM_dynamoTunnel6_IV, + eM_dynamoTunnel7_IV, + eM_dynamoTunnel1_LuV, + eM_dynamoTunnel2_LuV, + eM_dynamoTunnel3_LuV, + eM_dynamoTunnel4_LuV, + eM_dynamoTunnel5_LuV, + eM_dynamoTunnel6_LuV, + eM_dynamoTunnel7_LuV, + eM_dynamoTunnel1_ZPM, + eM_dynamoTunnel2_ZPM, + eM_dynamoTunnel3_ZPM, + eM_dynamoTunnel4_ZPM, + eM_dynamoTunnel5_ZPM, + eM_dynamoTunnel6_ZPM, + eM_dynamoTunnel7_ZPM, + eM_dynamoTunnel1_UV, + eM_dynamoTunnel2_UV, + eM_dynamoTunnel3_UV, + eM_dynamoTunnel4_UV, + eM_dynamoTunnel5_UV, + eM_dynamoTunnel6_UV, + eM_dynamoTunnel7_UV, + eM_dynamoTunnel1_UHV, + eM_dynamoTunnel2_UHV, + eM_dynamoTunnel3_UHV, + eM_dynamoTunnel4_UHV, + eM_dynamoTunnel5_UHV, + eM_dynamoTunnel6_UHV, + eM_dynamoTunnel7_UHV, + eM_dynamoTunnel1_UEV, + eM_dynamoTunnel2_UEV, + eM_dynamoTunnel3_UEV, + eM_dynamoTunnel4_UEV, + eM_dynamoTunnel5_UEV, + eM_dynamoTunnel6_UEV, + eM_dynamoTunnel7_UEV, + eM_dynamoTunnel1_UIV, + eM_dynamoTunnel2_UIV, + eM_dynamoTunnel3_UIV, + eM_dynamoTunnel4_UIV, + eM_dynamoTunnel5_UIV, + eM_dynamoTunnel6_UIV, + eM_dynamoTunnel7_UIV, + eM_dynamoTunnel1_UMV, + eM_dynamoTunnel2_UMV, + eM_dynamoTunnel3_UMV, + eM_dynamoTunnel4_UMV, + eM_dynamoTunnel5_UMV, + eM_dynamoTunnel6_UMV, + eM_dynamoTunnel7_UMV, + eM_dynamoTunnel1_UXV, + eM_dynamoTunnel2_UXV, + eM_dynamoTunnel3_UXV, + eM_dynamoTunnel4_UXV, + eM_dynamoTunnel5_UXV, + eM_dynamoTunnel6_UXV, + eM_dynamoTunnel7_UXV, + eM_dynamoTunnel9001, + + eM_energyMulti4_EV, + eM_energyMulti16_EV, + eM_energyMulti64_EV, + eM_energyMulti4_IV, + eM_energyMulti16_IV, + eM_energyMulti64_IV, + eM_energyMulti4_LuV, + eM_energyMulti16_LuV, + eM_energyMulti64_LuV, + eM_energyMulti4_ZPM, + eM_energyMulti16_ZPM, + eM_energyMulti64_ZPM, + eM_energyMulti4_UV, + eM_energyMulti16_UV, + eM_energyMulti64_UV, + eM_energyMulti4_UHV, + eM_energyMulti16_UHV, + eM_energyMulti64_UHV, + eM_energyMulti4_UEV, + eM_energyMulti16_UEV, + eM_energyMulti64_UEV, + eM_energyMulti4_UIV, + eM_energyMulti16_UIV, + eM_energyMulti64_UIV, + eM_energyMulti4_UMV, + eM_energyMulti16_UMV, + eM_energyMulti64_UMV, + eM_energyMulti4_UXV, + eM_energyMulti16_UXV, + eM_energyMulti64_UXV, + eM_energyWirelessMulti4_EV, + eM_energyWirelessMulti16_EV, + eM_energyWirelessMulti64_EV, + eM_energyWirelessMulti4_IV, + eM_energyWirelessMulti16_IV, + eM_energyWirelessMulti64_IV, + eM_energyWirelessMulti4_LuV, + eM_energyWirelessMulti16_LuV, + eM_energyWirelessMulti64_LuV, + eM_energyWirelessMulti4_ZPM, + eM_energyWirelessMulti16_ZPM, + eM_energyWirelessMulti64_ZPM, + eM_energyWirelessMulti4_UV, + eM_energyWirelessMulti16_UV, + eM_energyWirelessMulti64_UV, + eM_energyWirelessMulti4_UHV, + eM_energyWirelessMulti16_UHV, + eM_energyWirelessMulti64_UHV, + eM_energyWirelessMulti4_UEV, + eM_energyWirelessMulti16_UEV, + eM_energyWirelessMulti64_UEV, + eM_energyWirelessMulti4_UIV, + eM_energyWirelessMulti16_UIV, + eM_energyWirelessMulti64_UIV, + eM_energyWirelessMulti4_UMV, + eM_energyWirelessMulti16_UMV, + eM_energyWirelessMulti64_UMV, + eM_energyWirelessMulti4_UXV, + eM_energyWirelessMulti16_UXV, + eM_energyWirelessMulti64_UXV, + eM_energyWirelessMulti4_MAX, + eM_energyWirelessMulti16_MAX, + eM_energyWirelessMulti64_MAX, + eM_energyTunnel1_IV, + eM_energyTunnel2_IV, + eM_energyTunnel3_IV, + eM_energyTunnel4_IV, + eM_energyTunnel5_IV, + eM_energyTunnel6_IV, + eM_energyTunnel7_IV, + eM_energyTunnel1_LuV, + eM_energyTunnel2_LuV, + eM_energyTunnel3_LuV, + eM_energyTunnel4_LuV, + eM_energyTunnel5_LuV, + eM_energyTunnel6_LuV, + eM_energyTunnel7_LuV, + eM_energyTunnel1_ZPM, + eM_energyTunnel2_ZPM, + eM_energyTunnel3_ZPM, + eM_energyTunnel4_ZPM, + eM_energyTunnel5_ZPM, + eM_energyTunnel6_ZPM, + eM_energyTunnel7_ZPM, + eM_energyTunnel1_UV, + eM_energyTunnel2_UV, + eM_energyTunnel3_UV, + eM_energyTunnel4_UV, + eM_energyTunnel5_UV, + eM_energyTunnel6_UV, + eM_energyTunnel7_UV, + eM_energyTunnel1_UHV, + eM_energyTunnel2_UHV, + eM_energyTunnel3_UHV, + eM_energyTunnel4_UHV, + eM_energyTunnel5_UHV, + eM_energyTunnel6_UHV, + eM_energyTunnel7_UHV, + eM_energyTunnel1_UEV, + eM_energyTunnel2_UEV, + eM_energyTunnel3_UEV, + eM_energyTunnel4_UEV, + eM_energyTunnel5_UEV, + eM_energyTunnel6_UEV, + eM_energyTunnel7_UEV, + eM_energyTunnel1_UIV, + eM_energyTunnel2_UIV, + eM_energyTunnel3_UIV, + eM_energyTunnel4_UIV, + eM_energyTunnel5_UIV, + eM_energyTunnel6_UIV, + eM_energyTunnel7_UIV, + eM_energyTunnel1_UMV, + eM_energyTunnel2_UMV, + eM_energyTunnel3_UMV, + eM_energyTunnel4_UMV, + eM_energyTunnel5_UMV, + eM_energyTunnel6_UMV, + eM_energyTunnel7_UMV, + eM_energyTunnel1_UXV, + eM_energyTunnel2_UXV, + eM_energyTunnel3_UXV, + eM_energyTunnel4_UXV, + eM_energyTunnel5_UXV, + eM_energyTunnel6_UXV, + eM_energyTunnel7_UXV, + eM_energyTunnel9001, + eM_energyWirelessTunnel1_UXV, + eM_energyWirelessTunnel2_UXV, + eM_energyWirelessTunnel3_UXV, + eM_energyWirelessTunnel4_UXV, + eM_energyWirelessTunnel5_UXV, + eM_energyWirelessTunnel6_UXV, + eM_energyWirelessTunnel7_UXV, + + Parametrizer_Hatch, + ParametrizerX_Hatch, + ParametrizerTXT_Hatch, + Uncertainty_Hatch, + UncertaintyX_Hatch, + dataIn_Hatch, + dataOut_Hatch, + dataInAss_Hatch, + dataOutAss_Hatch, + eM_Containment, + eM_Containment_Field, + eM_Containment_Advanced, + eM_Coil, + eM_Teleportation, + eM_Dimensional, + eM_Ultimate_Containment, + eM_Ultimate_Containment_Advanced, + eM_Ultimate_Containment_Field, + eM_Spacetime, + eM_Computer_Casing, + eM_Computer_Bus, + eM_Computer_Vent, + eM_Hollow, + eM_Power, + debugBlock, + + tM_TeslaBase, + tM_TeslaToroid, + EOH_Reinforced_Temporal_Casing, + EOH_Reinforced_Spatial_Casing, + EOH_Infinite_Energy_Casing, + tM_TeslaSecondary, + tM_TeslaPrimary_0, + tM_TeslaPrimary_1, + tM_TeslaPrimary_2, + tM_TeslaPrimary_3, + tM_TeslaPrimary_4, + tM_TeslaPrimary_5, + tM_TeslaPrimary_6, + + Machine_Multi_Microwave, + Machine_Multi_TeslaCoil, + Machine_Multi_Transformer, + Machine_Multi_Computer, + Machine_Multi_Switch, + Machine_Multi_Research, + Machine_Multi_DataBank, + Machine_Multi_Infuser, + Machine_Multi_Decay, + Machine_Multi_Annihilation, + Machine_Multi_EyeOfHarmony, + Machine_Multi_ForgeOfGods, + Machine_Multi_SmeltingModule, + Machine_Multi_MoltenModule, + Machine_Multi_PlasmaModule, + Machine_Multi_QuarkGluonPlasmaModule, + + hint_0, + hint_1, + hint_2, + hint_3, + hint_4, + hint_5, + hint_6, + hint_7, + hint_8, + hint_9, + hint_10, + hint_11, + hint_general, + hint_air, + hint_noAir, + hint_error, + + scanContainer, + parametrizerMemory, + teslaCapacitor, + teslaCover, + teslaComponent, + teslaStaff, + enderLinkFluidCover, + powerPassUpgradeCover, + + Machine_TeslaCoil_1by1_LV, + Machine_TeslaCoil_1by1_MV, + Machine_TeslaCoil_1by1_HV, + Machine_TeslaCoil_1by1_EV, + Machine_TeslaCoil_1by1_IV, + Machine_TeslaCoil_2by2_LV, + Machine_TeslaCoil_2by2_MV, + Machine_TeslaCoil_2by2_HV, + Machine_TeslaCoil_2by2_EV, + Machine_TeslaCoil_2by2_IV, + Machine_TeslaCoil_3by3_LV, + Machine_TeslaCoil_3by3_MV, + Machine_TeslaCoil_3by3_HV, + Machine_TeslaCoil_3by3_EV, + Machine_TeslaCoil_3by3_IV, + Machine_TeslaCoil_4by4_LV, + Machine_TeslaCoil_4by4_MV, + Machine_TeslaCoil_4by4_HV, + Machine_TeslaCoil_4by4_EV, + Machine_TeslaCoil_4by4_IV, + DATApipeBlock, + LASERpipeBlock, + + SpacetimeCompressionFieldGeneratorTier0, + SpacetimeCompressionFieldGeneratorTier1, + SpacetimeCompressionFieldGeneratorTier2, + SpacetimeCompressionFieldGeneratorTier3, + SpacetimeCompressionFieldGeneratorTier4, + SpacetimeCompressionFieldGeneratorTier5, + SpacetimeCompressionFieldGeneratorTier6, + SpacetimeCompressionFieldGeneratorTier7, + SpacetimeCompressionFieldGeneratorTier8, + + TimeAccelerationFieldGeneratorTier0, + TimeAccelerationFieldGeneratorTier1, + TimeAccelerationFieldGeneratorTier2, + TimeAccelerationFieldGeneratorTier3, + TimeAccelerationFieldGeneratorTier4, + TimeAccelerationFieldGeneratorTier5, + TimeAccelerationFieldGeneratorTier6, + TimeAccelerationFieldGeneratorTier7, + TimeAccelerationFieldGeneratorTier8, + + StabilisationFieldGeneratorTier0, + StabilisationFieldGeneratorTier1, + StabilisationFieldGeneratorTier2, + StabilisationFieldGeneratorTier3, + StabilisationFieldGeneratorTier4, + StabilisationFieldGeneratorTier5, + StabilisationFieldGeneratorTier6, + StabilisationFieldGeneratorTier7, + StabilisationFieldGeneratorTier8, + + Godforge_Gravitational_Lens, + Godforge_Singularity_Shielding_Casing, + Godforge_Guidance_Casing, + Godforge_Boundless_Structure_Casing, + Godforge_Magnetic_Confinement_Casing, + Godforge_Stellar_Energy_Siphon_Casing, + Godforge_GravitonFlowModulatorTier1, + Godforge_GravitonFlowModulatorTier2, + Godforge_GravitonFlowModulatorTier3, + + astralArrayFabricator; + + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + // public static Fluid sOilExtraHeavy, sOilHeavy, sOilMedium, sOilLight, sNaturalGas; + + @Override + public IItemContainer set(Item aItem) { + mHasNotBeenSet = false; + if (aItem == null) { + return this; + } + ItemStack aStack = new ItemStack(aItem, 1, 0); + mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public IItemContainer set(ItemStack aStack) { + mHasNotBeenSet = false; + mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public Item getItem() { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(mStack)) { + return null; + } + return mStack.getItem(); + } + + @Override + public Block getBlock() { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + return GT_Utility.getBlockFromStack(new ItemStack(getItem())); + } + + @Override + public final boolean hasBeenSet() { + return !mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(Object aStack) { + return isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } + return GT_Utility.areUnificationsEqual((ItemStack) aStack, aWildcard ? getWildcard(1) : get(1), aIgnoreNBT); + } + + @Override + public ItemStack get(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getWildcard(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getUndamaged(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) { + ItemStack rStack = get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } + rStack.setStackDisplayName(aDisplayName); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) { + ItemStack rStack = get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } + GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(mStack)); + } + + @Override + public IItemContainer registerOre(Object... aOreNames) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + for (Object tOreName : aOreNames) { + GT_OreDictUnificator.registerOre(tOreName, get(1)); + } + return this; + } + + @Override + public IItemContainer registerWildcardAsOre(Object... aOreNames) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + for (Object tOreName : aOreNames) { + GT_OreDictUnificator.registerOre(tOreName, getWildcard(1)); + } + return this; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/EOH_RenderBlock.java b/src/main/java/com/github/technus/tectech/thing/block/EOH_RenderBlock.java new file mode 100644 index 0000000000..110dc83015 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/EOH_RenderBlock.java @@ -0,0 +1,79 @@ +package com.github.technus.tectech.thing.block; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import com.github.technus.tectech.TecTech; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class EOH_RenderBlock extends Block { + + public EOH_RenderBlock() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + this.setCreativeTab(TecTech.creativeTabTecTech); + this.setBlockName("Eye of Harmony Renderer"); + this.setLightLevel(100.0f); + registerOther(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canRenderInPass(int a) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEyeOfHarmony(); + } + + public static void registerOther(Block block) { + String name = block.getUnlocalizedName() + .substring( + block.getUnlocalizedName() + .indexOf(".") + 1); + GameRegistry.registerBlock(block, name.substring(name.indexOf(":") + 1)); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(); + } + + @Override + public boolean isCollidable() { + return false; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/ForgeOfGodsBlock.java b/src/main/java/com/github/technus/tectech/thing/block/ForgeOfGodsBlock.java new file mode 100644 index 0000000000..02be399bb0 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/ForgeOfGodsBlock.java @@ -0,0 +1,70 @@ +package com.github.technus.tectech.thing.block; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import com.github.technus.tectech.TecTech; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ForgeOfGodsBlock extends Block { + + public ForgeOfGodsBlock() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + this.setCreativeTab(TecTech.creativeTabTecTech); + this.setBlockName("Forge of the Gods Renderer"); + this.setLightLevel(100.0f); + registerOther(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canRenderInPass(int a) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileForgeOfGods(); + } + + public static void registerOther(Block block) { + GameRegistry.registerBlock(block, "ForgeOfGodsRenderBlock"); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(); + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassBlock.java b/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassBlock.java new file mode 100644 index 0000000000..67c77f5ac4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassBlock.java @@ -0,0 +1,107 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import eu.usrv.yamcore.blocks.BlockBase; +import gregtech.api.GregTech_API; + +public class GodforgeGlassBlock extends BlockBase { + + public static IIcon Icon; + public static int renderID; + public static GodforgeGlassBlock INSTANCE; + + public GodforgeGlassBlock() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("spatiallyTranscendentGravitationalLens"); + setHarvestLevel("wrench", 3); + setHardness(50); + setResistance(30); + setLightOpacity(0); + setStepSound(Block.soundTypeGlass); + setBlockTextureName(MODID + ":blockSpatiallyTranscendentGravitationalLens"); + setCreativeTab(creativeTabTecTech); + } + + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getCanBlockGrass() { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + Block block = worldIn.getBlock(x, y, z); + return block != this; + } + + @Override + public int getRenderType() { + return renderID; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + Icon = blockIcon; + } + + public static void run() { + INSTANCE = new GodforgeGlassBlock(); + GameRegistry.registerBlock(INSTANCE, GodforgeGlassItem.class, INSTANCE.getUnlocalizedName()); + GregTech_API.registerMachineBlock(INSTANCE, -1); + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassItem.java b/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassItem.java new file mode 100644 index 0000000000..bd7d58a4da --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassItem.java @@ -0,0 +1,30 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.util.CommonValues.GODFORGE_MARK; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class GodforgeGlassItem extends ItemBlock { + + public static GodforgeGlassItem INSTANCE; + + public GodforgeGlassItem(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(GODFORGE_MARK); + aList.add(translateToLocal("tile.godforgeGlass.desc.0")); + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("tile.godforgeGlass.desc.1")); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassRender.java b/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassRender.java new file mode 100644 index 0000000000..51c909c83d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/GodforgeGlassRender.java @@ -0,0 +1,122 @@ +package com.github.technus.tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +public class GodforgeGlassRender implements ISimpleBlockRenderingHandler { + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + // Get icons from custom register (useful for renderers and fluids) + IIcon side = GodforgeGlassBlock.Icon; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + + renderer.renderStandardBlock(block, x, y, z); + Tessellator tes = Tessellator.instance; + tes.setNormal(0F, 1F, 0F); + tes.setBrightness(15728880); + tes.setColorOpaque_F(0F, 1F, 1F); + IIcon side = GodforgeGlassBlock.Icon; + + // South + if (world.getBlock(x, y, z + 1) + .getClass() != GodforgeGlassBlock.class) { + tes.addVertexWithUV(x, y, z + 0.999, side.getMinU(), side.getMaxV()); // 0.999 instead of 1 for fighting + // (textures overlapping) + tes.addVertexWithUV(x, y + 1, z + 0.999, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.999, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y, z + 0.999, side.getMaxU(), side.getMaxV()); + } + // East + if (world.getBlock(x + 1, y, z) + .getClass() != GodforgeGlassBlock.class) { + tes.addVertexWithUV(x + 0.999, y, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.999, y + 1, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y + 1, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y, z, side.getMaxU(), side.getMaxV()); + } + // North + if (world.getBlock(x, y, z - 1) + .getClass() != GodforgeGlassBlock.class) { + tes.addVertexWithUV(x + 1, y, z + 0.001, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.001, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x, y + 1, z + 0.001, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x, y, z + 0.001, side.getMaxU(), side.getMaxV()); + } + // West + if (world.getBlock(x - 1, y, z) + .getClass() != GodforgeGlassBlock.class) { + tes.addVertexWithUV(x + 0.001, y, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.001, y + 1, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y + 1, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y, z + 1, side.getMaxU(), side.getMaxV()); + } + // Top + if (world.getBlock(x, y + 1, z) + .getClass() != GodforgeGlassBlock.class) { + tes.addVertexWithUV(x, y + 0.999, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.999, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z + 1, side.getMaxU(), side.getMaxV()); + } + // Bottom + if (world.getBlock(x, y - 1, z) + .getClass() != GodforgeGlassBlock.class) { + tes.addVertexWithUV(x, y + 0.001, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.001, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z, side.getMaxU(), side.getMaxV()); + } + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return GodforgeGlassBlock.renderID; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java new file mode 100644 index 0000000000..790b4f390b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java @@ -0,0 +1,111 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import eu.usrv.yamcore.blocks.BlockBase; +import gregtech.api.GregTech_API; + +/** + * Created by danie_000 on 17.12.2016. + */ +public final class QuantumGlassBlock extends BlockBase { + + public static IIcon stuff; + public static int renderID; + public static QuantumGlassBlock INSTANCE; + + public QuantumGlassBlock() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("quantumGlass"); + setHarvestLevel("wrench", 3); + setHardness(50); + setResistance(30); + setLightOpacity(0); + setStepSound(Block.soundTypeMetal); + setBlockTextureName(MODID + ":blockQuantumGlass"); + setCreativeTab(creativeTabTecTech); + } + + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getCanBlockGrass() { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + Block block = worldIn.getBlock(x, y, z); + return block != this; // && super.shouldSideBeRendered(worldIn, x, y, z, + // side); + } + + @Override + public int getRenderType() { + return renderID; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + stuff = blockIcon; + } + + public static void run() { + INSTANCE = new QuantumGlassBlock(); + GameRegistry.registerBlock(INSTANCE, QuantumGlassItem.class, INSTANCE.getUnlocalizedName()); + GregTech_API.registerMachineBlock(INSTANCE, -1); + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java new file mode 100644 index 0000000000..43c41735b8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java @@ -0,0 +1,33 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.util.CommonValues.TEC_MARK_EM; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +/** + * Created by Tec on 11.04.2017. + */ +public class QuantumGlassItem extends ItemBlock { + + public static QuantumGlassItem INSTANCE; + + public QuantumGlassItem(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(TEC_MARK_EM); + aList.add(translateToLocal("tile.quantumGlass.desc.0")); // Dense yet transparent + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("tile.quantumGlass.desc.1")); // Glassy & Classy + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java new file mode 100644 index 0000000000..f45e54f4ec --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java @@ -0,0 +1,129 @@ +package com.github.technus.tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +/** + * Created by danie_000 on 19.12.2016. + */ +public final class QuantumGlassRender implements ISimpleBlockRenderingHandler { + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + // Get icons from custom register (useful for renderers and fluids) + IIcon side = QuantumGlassBlock.stuff; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + + renderer.renderStandardBlock(block, x, y, z); + Tessellator tes = Tessellator.instance; + GL11.glPushMatrix(); + tes.setNormal(0F, 1F, 0F); + tes.setBrightness(15728880); + tes.setColorOpaque_F(0F, 1F, 1F); + IIcon side = QuantumGlassBlock.stuff; + GL11.glDisable(GL11.GL_CULL_FACE); + + // South + if (world.getBlock(x, y, z + 1) + .getClass() != QuantumGlassBlock.class) { + tes.addVertexWithUV(x, y, z + 0.999, side.getMinU(), side.getMaxV()); // 0.999 instead of 1 for fighting + // (textures overlapping) + tes.addVertexWithUV(x, y + 1, z + 0.999, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.999, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y, z + 0.999, side.getMaxU(), side.getMaxV()); + } + // East + if (world.getBlock(x + 1, y, z) + .getClass() != QuantumGlassBlock.class) { + tes.addVertexWithUV(x + 0.999, y, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.999, y + 1, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y + 1, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y, z, side.getMaxU(), side.getMaxV()); + } + // North + if (world.getBlock(x, y, z - 1) + .getClass() != QuantumGlassBlock.class) { + tes.addVertexWithUV(x + 1, y, z + 0.001, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.001, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x, y + 1, z + 0.001, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x, y, z + 0.001, side.getMaxU(), side.getMaxV()); + } + // West + if (world.getBlock(x - 1, y, z) + .getClass() != QuantumGlassBlock.class) { + tes.addVertexWithUV(x + 0.001, y, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.001, y + 1, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y + 1, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y, z + 1, side.getMaxU(), side.getMaxV()); + } + // Top + if (world.getBlock(x, y + 1, z) + .getClass() != QuantumGlassBlock.class) { + tes.addVertexWithUV(x, y + 0.999, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.999, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z + 1, side.getMaxU(), side.getMaxV()); + } + // Bottom + if (world.getBlock(x, y - 1, z) + .getClass() != QuantumGlassBlock.class) { + tes.addVertexWithUV(x, y + 0.001, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.001, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z, side.getMaxU(), side.getMaxV()); + } + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_CULL_FACE); + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return QuantumGlassBlock.renderID; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java new file mode 100644 index 0000000000..db8d064f6f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java @@ -0,0 +1,104 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.Reference.MODID; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import eu.usrv.yamcore.blocks.BlockBase; + +/** + * Created by danie_000 on 17.12.2016. + */ +public final class QuantumStuffBlock extends BlockBase { + + public static IIcon stuff; + public static int renderID; + public static QuantumStuffBlock INSTANCE; + + public QuantumStuffBlock() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("quantumStuff"); + setHarvestLevel("wrench", 0); + setHardness(500); + setResistance(1); + setLightOpacity(0); + setBlockTextureName(MODID + ":blockQuantumStuff"); + } + + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + stuff = blockIcon; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getCanBlockGrass() { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + return false; + } + + @Override + public int getRenderType() { + return renderID; + } + + public static void run() { + INSTANCE = new QuantumStuffBlock(); + GameRegistry.registerBlock(INSTANCE, INSTANCE.getUnlocalizedName()); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList<>(); + } + + @Override + public Item getItemDropped(int meta, Random random, int fortune) { + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java new file mode 100644 index 0000000000..4230dff43f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java @@ -0,0 +1,104 @@ +package com.github.technus.tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import com.github.technus.tectech.TecTech; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +/** + * Created by danie_000 on 19.12.2016. + */ +public final class QuantumStuffRender implements ISimpleBlockRenderingHandler { + + private static final Tessellator tes = Tessellator.instance; + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glPushMatrix(); + // Get icons from custom register (useful for renderers and fluids) + IIcon side = QuantumStuffBlock.stuff; + tes.startDrawingQuads(); + tes.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + // renderer.renderStandardBlock(block, x, y, z); + GL11.glPushMatrix(); + tes.setNormal(0F, 1F, 0F); + tes.setBrightness(15728880); + IIcon side = QuantumStuffBlock.stuff; + for (int i = 0; i < 6; i++) { + float f = 1 - TecTech.RANDOM.nextFloat() / 4f, g = f - TecTech.RANDOM.nextFloat() / 4f, + r = g - TecTech.RANDOM.nextFloat() / 4f - 0.25f; + tes.setColorOpaque_F(r, g, f); + float rotX = TecTech.RANDOM.nextFloat() * 2 * (float) Math.PI, + rotY = TecTech.RANDOM.nextFloat() * 2 * (float) Math.PI, + rotZ = TecTech.RANDOM.nextFloat() * 2 * (float) Math.PI; + tesAbuse(x, y, z, -1.425f, -1.425f, .1f, rotX, rotY, rotZ, side.getMinU(), side.getMaxV()); + tesAbuse(x, y, z, -1.425f, 1.425f, .1f, rotX, rotY, rotZ, side.getMinU(), side.getMinV()); + tesAbuse(x, y, z, 1.425f, 1.425f, .1f, rotX, rotY, rotZ, side.getMaxU(), side.getMinV()); + tesAbuse(x, y, z, 1.425f, -1.425f, .1f, rotX, rotY, rotZ, side.getMaxU(), side.getMaxV()); + + tesAbuse(x, y, z, 1.425f, -1.425f, -.1f, rotX, rotY, rotZ, side.getMaxU(), side.getMaxV()); + tesAbuse(x, y, z, 1.425f, 1.425f, -.1f, rotX, rotY, rotZ, side.getMaxU(), side.getMinV()); + tesAbuse(x, y, z, -1.425f, 1.425f, -.1f, rotX, rotY, rotZ, side.getMinU(), side.getMinV()); + tesAbuse(x, y, z, -1.425f, -1.425f, -.1f, rotX, rotY, rotZ, side.getMinU(), side.getMaxV()); + } + GL11.glPopMatrix(); + return true; + } + + private void tesAbuse(int x, int y, int z, float sx, float sy, float sz, float rotX, float rotY, float rotZ, + float sideU, float sideV) { + Vec3 pos = Vec3.createVectorHelper(sx, sy, sz); + pos.rotateAroundX(rotX); + pos.rotateAroundY(rotY); + pos.rotateAroundZ(rotZ); + tes.addVertexWithUV(pos.xCoord + x + .5f, pos.yCoord + y + .5f, pos.zCoord + z + .5f, sideU, sideV); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return QuantumStuffBlock.renderID; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java new file mode 100644 index 0000000000..80eca10cad --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java @@ -0,0 +1,96 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.Reference.MODID; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import com.github.technus.tectech.thing.tileEntity.ReactorSimTileEntity; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityBlock; + +/** + * Created by danie_000 on 30.09.2017. + */ +public class ReactorSimBlock extends Block implements ITileEntityProvider { + + public static ReactorSimBlock INSTANCE; + public static IIcon stuff; + + public ReactorSimBlock() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("reactorSim"); + setHarvestLevel("wrench", 3); + setHardness(50); + setResistance(30); + setLightOpacity(0); + setStepSound(Block.soundTypeMetal); + setBlockTextureName(MODID + ":blockReactorSimulator"); + } + + @Override + public boolean isOpaqueCube() { + return true; + } + + @Override + public boolean getCanBlockGrass() { + return true; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + stuff = blockIcon; + } + + public static void run() { + INSTANCE = new ReactorSimBlock(); + GameRegistry.registerBlock(INSTANCE, ReactorSimItem.class, INSTANCE.getUnlocalizedName()); + GameRegistry.registerTileEntity(ReactorSimTileEntity.class, MODID + "_reactorSim"); + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + return new ReactorSimTileEntity(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float a, + float b, float c) { + if (entityPlayer.isSneaking()) { + return false; + } else { + TileEntity te = world.getTileEntity(x, y, z); + return te instanceof IHasGui + && (!IC2.platform.isSimulating() || IC2.platform.launchGui(entityPlayer, (IHasGui) te)); + } + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block srcBlock) { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof TileEntityBlock) { + ((TileEntityBlock) te).onNeighborUpdate(srcBlock); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java new file mode 100644 index 0000000000..01ed6b54ad --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java @@ -0,0 +1,36 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.util.CommonValues.TEC_MARK_GENERAL; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +/** + * Created by danie_000 on 30.09.2017. + */ +public class ReactorSimItem extends ItemBlock { + + public static QuantumGlassItem INSTANCE; + + public ReactorSimItem(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(TEC_MARK_GENERAL); + aList.add(translateToLocal("tile.reactorSim.desc.0")); // Fission Reaction Uncertainty Resolver 9001 + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("tile.reactorSim.desc.1")); // Explodes, + // but + // not + // as + // much... + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/RenderForgeOfGods.java b/src/main/java/com/github/technus/tectech/thing/block/RenderForgeOfGods.java new file mode 100644 index 0000000000..70314927f4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/RenderForgeOfGods.java @@ -0,0 +1,130 @@ +package com.github.technus.tectech.thing.block; + +import static com.github.technus.tectech.Reference.MODID; +import static java.lang.Math.pow; + +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +public class RenderForgeOfGods extends TileEntitySpecialRenderer { + + public static final ResourceLocation STAR_LAYER_0 = new ResourceLocation(MODID, "models/StarLayer0.png"); + public static final ResourceLocation STAR_LAYER_1 = new ResourceLocation(MODID, "models/StarLayer1.png"); + public static final ResourceLocation STAR_LAYER_2 = new ResourceLocation(MODID, "models/StarLayer2.png"); + public static IModelCustom starModel; + private static IModelCustom spaceModel; + private static final float RED = 180 / 255f; + private static final float GREEN = 180 / 255f; + private static final float BLUE = 255 / 255f; + + public RenderForgeOfGods() { + starModel = AdvancedModelLoader.loadModel(new ResourceLocation(MODID, "models/Star.obj")); + spaceModel = AdvancedModelLoader.loadModel(new ResourceLocation(MODID, "models/Space.obj")); + } + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + if (!(tile instanceof TileForgeOfGods)) return; + + TileForgeOfGods FOGRenderTile = (TileForgeOfGods) tile; + + // Render outer space layer. + + { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + renderOuterSpaceShell(); + + // Render star stuff. + renderStarLayer(FOGRenderTile, 0, STAR_LAYER_0, 1.0f); + renderStarLayer(FOGRenderTile, 1, STAR_LAYER_1, 0.4f); + renderStarLayer(FOGRenderTile, 2, STAR_LAYER_2, 0.2f); + + GL11.glPopMatrix(); + } + } + + public static void renderOuterSpaceShell() { + + GL11.glPushMatrix(); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + + FMLClientHandler.instance() + .getClient() + .getTextureManager() + .bindTexture(new ResourceLocation(MODID, "models/spaceLayer.png")); + + final float scale = 0.01f * 17.5f; + GL11.glScalef(scale, scale, scale); + + GL11.glColor4f(222 / 255f, 243 / 255f, 250 / 255f, 255 / 255f); + + spaceModel.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LIGHTING); + + GL11.glPopMatrix(); + } + + private static final float STAR_RESCALE = 0.2f; + + private void renderStarLayer(TileForgeOfGods FOGRenderTile, int layer, ResourceLocation texture, float alpha) { + + GL11.glPushMatrix(); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + FMLClientHandler.instance() + .getClient() + .getTextureManager() + .bindTexture(texture); + + // 0.01f magic number to shrink sphere obj down + float scale = 0.01f * STAR_RESCALE * FOGRenderTile.getRenderSize(); + + // Put each layer further out + scale *= pow(1.04f, layer); + + // Scale the star up in the x, y and z directions + GL11.glScalef(scale, scale, scale); + + switch (layer) { + case 0: + GL11.glRotatef(130, 0F, 1F, 1F); + break; + case 1: + GL11.glRotatef(-49, 1F, 1F, 0F); + break; + case 2: + GL11.glRotatef(67, 1F, 0F, 1F); + break; + } + + // Set color and alpha of the star layer + GL11.glColor4f(RED, GREEN, BLUE, alpha); + + // Spin the star + GL11.glRotatef((0.03f * FOGRenderTile.angle * FOGRenderTile.getRenderRotationSpeed()) % 360.0f, 0F, 0F, 1F); + + starModel.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LIGHTING); + + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java new file mode 100644 index 0000000000..4c9d51a175 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java @@ -0,0 +1,200 @@ +package com.github.technus.tectech.thing.block; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.stream.IntStream; + +import net.minecraft.block.Block; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; + +import pers.gwyog.gtneioreplugin.plugin.block.ModBlocks; + +public class TileEyeOfHarmony extends TileEntity { + + private static final double EOH_STAR_FIELD_RADIUS = 13; + + // Prevent culling when block is out of frame so model can remain active. + @Override + public AxisAlignedBB getRenderBoundingBox() { + + // Assuming your block is at (x, y, z) + double x = this.xCoord; + double y = this.yCoord; + double z = this.zCoord; + + // Create a bounding box that extends 'size' blocks in all directions from the block. + return AxisAlignedBB.getBoundingBox( + x - EOH_STAR_FIELD_RADIUS, + y - EOH_STAR_FIELD_RADIUS, + z - EOH_STAR_FIELD_RADIUS, + x + EOH_STAR_FIELD_RADIUS + 1, + y + EOH_STAR_FIELD_RADIUS + 1, + z + EOH_STAR_FIELD_RADIUS + 1); + } + + public void setSize(float size) { + this.size = size; + } + + public void setRotationSpeed(float rotationSpeed) { + this.rotationSpeed = rotationSpeed; + } + + private float size = 10; + private float rotationSpeed = 10; + + // Fun fact, these methods were entirely written by ChatGPT3... Take that as you will. + public static ArrayList selectNRandomElements(Collection inputList, long n) { + ArrayList randomElements = new ArrayList<>((int) n); + ArrayList inputArray = new ArrayList<>(inputList); + Random rand = new Random(); + IntStream.range(0, (int) n) + .forEach(i -> { + int randomIndex = rand.nextInt(inputArray.size()); + randomElements.add(inputArray.get(randomIndex)); + inputArray.remove(randomIndex); + }); + return randomElements; + } + + public static float generateRandomFloat(float a, float b) { + Random rand = new Random(); + return rand.nextFloat() * (b - a) + a; + } + + public long getTier() { + return tier; + } + + public void setTier(long tier) { + this.tier = tier; + } + + private long tier = 9; + + public float getSize() { + return size; + } + + public float getRotationSpeed() { + return rotationSpeed; + } + + @Override + public void updateEntity() { + angle += 10.0f; + } + + public static class OrbitingObject { + + public OrbitingObject(Block block, float distance, float rotationSpeed, float orbitSpeed, float xAngle, + float zAngle, float scale) { + this.block = block; + this.distance = distance; + this.rotationSpeed = rotationSpeed; + this.orbitSpeed = orbitSpeed; + this.xAngle = xAngle; + this.zAngle = zAngle; + this.scale = scale; + } + + public final Block block; + public final float distance; + public final float rotationSpeed; + public final float orbitSpeed; + public final float xAngle; + public final float zAngle; + public final float scale; + } + + public ArrayList getOrbitingObjects() { + return orbitingObjects; + } + + private final ArrayList orbitingObjects = new ArrayList<>(); + private static final Set BLACKLISTED_BLOCKS = Collections + .unmodifiableSet(new HashSet<>(Arrays.asList("Tf", "Ow", "ED", "EA", "VA"))); + // Map of strings to blocks + private static final Map BLOCKS = new HashMap<>(); + + static { + // Initialize the map of blocks + ModBlocks.blocks.forEach((dimString, dimBlock) -> { + if (!BLACKLISTED_BLOCKS.contains(dimString)) { + BLOCKS.put(dimString, dimBlock); + } + }); + } + + private static final float MAX_ANGLE = 30; + + // This must be set last. + public void generateImportantInfo() { + + int index = 0; + for (Block block : selectNRandomElements(BLOCKS.values(), tier + 1)) { + + float xAngle = generateRandomFloat(-MAX_ANGLE, MAX_ANGLE); + float zAngle = generateRandomFloat(-MAX_ANGLE, MAX_ANGLE); + index += 1.0; + float distance = index + generateRandomFloat(-0.2f, 0.2f); + float scale = generateRandomFloat(0.2f, 0.9f); + float rotationSpeed = generateRandomFloat(0.5f, 1.5f); + float orbitSpeed = generateRandomFloat(0.5f, 1.5f); + orbitingObjects.add(new OrbitingObject(block, distance, rotationSpeed, orbitSpeed, xAngle, zAngle, scale)); + } + } + + // Used to track the rotation of the star/planets. + public float angle; + + private static final String EOH_NBT_TAG = "EOH:"; + private static final String ROTATION_SPEED_NBT_TAG = EOH_NBT_TAG + "rotationSpeed"; + private static final String SIZE_NBT_TAG = EOH_NBT_TAG + "size"; + private static final String TIER_NBT_TAG = EOH_NBT_TAG + "tier"; + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + + // Save other stats. + compound.setFloat(ROTATION_SPEED_NBT_TAG, rotationSpeed); + compound.setFloat(SIZE_NBT_TAG, size); + compound.setLong(TIER_NBT_TAG, tier); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + + // Load other stats. + rotationSpeed = compound.getFloat(ROTATION_SPEED_NBT_TAG); + size = compound.getFloat(SIZE_NBT_TAG); + tier = compound.getLong(TIER_NBT_TAG); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/block/TileForgeOfGods.java b/src/main/java/com/github/technus/tectech/thing/block/TileForgeOfGods.java new file mode 100644 index 0000000000..0e0b536046 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/block/TileForgeOfGods.java @@ -0,0 +1,77 @@ +package com.github.technus.tectech.thing.block; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; + +public class TileForgeOfGods extends TileEntity { + + private float size = 10; + private float rotationSpeed = 10; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + public void setRenderSize(float size) { + this.size = size; + } + + public void setRenderRotationSpeed(float rotationSpeed) { + this.rotationSpeed = rotationSpeed; + } + + public float getRenderSize() { + return size; + } + + public float getRenderRotationSpeed() { + return rotationSpeed; + } + + @Override + public void updateEntity() { + angle += 10.0f; + } + + // Used to track the rotation of the star + public float angle; + + private static final String FOG_NBT_TAG = "FOG:"; + private static final String ROTATION_SPEED_NBT_TAG = FOG_NBT_TAG + "renderRotationSpeed"; + private static final String SIZE_NBT_TAG = FOG_NBT_TAG + "renderSize"; + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + + // Save stats + compound.setFloat(ROTATION_SPEED_NBT_TAG, rotationSpeed); + compound.setFloat(SIZE_NBT_TAG, size); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + + // Load stats + rotationSpeed = compound.getFloat(ROTATION_SPEED_NBT_TAG); + size = compound.getFloat(SIZE_NBT_TAG); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java new file mode 100644 index 0000000000..1c6524934c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java @@ -0,0 +1,227 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import com.github.technus.tectech.thing.CustomItemList; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.common.blocks.GT_Material_Casings; + +/** + * Created by danie_000 on 03.10.2016. + */ +// Mostly tesla coils, also 2 eye of harmony casings. +public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { + + private static final IIcon[] tM0 = new IIcon[2]; + private static final IIcon[] tM1 = new IIcon[2]; + private static final IIcon[] tM2 = new IIcon[2]; + private static final IIcon[] tM3 = new IIcon[2]; + private static final IIcon[] tM4 = new IIcon[2]; + private static final IIcon[] tM5 = new IIcon[2]; + private static final IIcon[] tM6 = new IIcon[2]; + private static IIcon tM7; + private static final IIcon[] tM8 = new IIcon[2]; + private static final IIcon[] tM9 = new IIcon[2]; + + private static IIcon EOH_INNER; + private static IIcon EOH_OUTER; + private static IIcon EOH_INFINITE; + + private static final byte START_INDEX = 16; + + public GT_Block_CasingsBA0() { + super(GT_Item_CasingsBA0.class, "gt.blockcasingsBA0", GT_Material_Casings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[texturePage][b + + START_INDEX] = new GT_CopiedBlockTexture(this, 6, b); + /* IMPORTANT for block recoloring **/ + } + + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".0.name", "Redstone Alloy Primary Tesla Windings"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".1.name", "MV Superconductor Primary Tesla Windings"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".2.name", "HV Superconductor Primary Tesla Windings"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".3.name", "EV Superconductor Primary Tesla Windings"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".4.name", "IV Superconductor Primary Tesla Windings"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".5.name", "LuV Superconductor Primary Tesla Windings"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".9.name", "ZPM Superconductor Primary Tesla Windings"); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Tesla Base Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Tesla Toroid Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Tesla Secondary Windings"); + + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".10.name", "Reinforced Temporal Structure Casing"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".11.name", "Reinforced Spatial Structure Casing"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".12.name", "Infinite Spacetime Energy Boundary Casing"); + + CustomItemList.tM_TeslaPrimary_0.set(new ItemStack(this, 1, 0)); + CustomItemList.tM_TeslaPrimary_1.set(new ItemStack(this, 1, 1)); + CustomItemList.tM_TeslaPrimary_2.set(new ItemStack(this, 1, 2)); + CustomItemList.tM_TeslaPrimary_3.set(new ItemStack(this, 1, 3)); + CustomItemList.tM_TeslaPrimary_4.set(new ItemStack(this, 1, 4)); + CustomItemList.tM_TeslaPrimary_5.set(new ItemStack(this, 1, 5)); + CustomItemList.tM_TeslaPrimary_6.set(new ItemStack(this, 1, 9)); + + CustomItemList.tM_TeslaBase.set(new ItemStack(this, 1, 6)); + CustomItemList.tM_TeslaToroid.set(new ItemStack(this, 1, 7)); + CustomItemList.tM_TeslaSecondary.set(new ItemStack(this, 1, 8)); + + CustomItemList.EOH_Reinforced_Temporal_Casing.set(new ItemStack(this, 1, 10)); + CustomItemList.EOH_Reinforced_Spatial_Casing.set(new ItemStack(this, 1, 11)); + CustomItemList.EOH_Infinite_Energy_Casing.set(new ItemStack(this, 1, 12)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + tM0[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_0"); + tM0[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_0"); + tM1[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_1"); + tM1[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_1"); + tM2[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_2"); + tM2[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_2"); + tM3[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_3"); + tM3[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_3"); + tM4[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_4"); + tM4[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_4"); + tM5[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_5"); + tM5[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_5"); + tM9[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6"); + tM9[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6"); + + tM6[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_BASE_TOP_BOTTOM"); + tM6[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_BASE_SIDES"); + tM7 = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_TOROID"); + tM8[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_SECONDARY_TOP_BOTTOM"); + tM8[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_SECONDARY_SIDES"); + + EOH_INNER = aIconRegister.registerIcon("gregtech:iconsets/EM_INNER_SPACETIME_REINFORCED_EOH_CASING"); + EOH_OUTER = aIconRegister.registerIcon("gregtech:iconsets/EM_OUTER_SPACETIME_REINFORCED_EOH_CASING"); + EOH_INFINITE = aIconRegister.registerIcon("gregtech:iconsets/EM_POWER_INFINITE"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + switch (ordinalSide) { + case 0: + case 1: + return tM0[0]; + default: + return tM0[1]; + } + case 1: + switch (ordinalSide) { + case 0: + case 1: + return tM1[0]; + default: + return tM1[1]; + } + case 2: + switch (ordinalSide) { + case 0: + case 1: + return tM2[0]; + default: + return tM2[1]; + } + case 3: + switch (ordinalSide) { + case 0: + case 1: + return tM3[0]; + default: + return tM3[1]; + } + case 4: + switch (ordinalSide) { + case 0: + case 1: + return tM4[0]; + default: + return tM4[1]; + } + case 5: + switch (ordinalSide) { + case 0: + case 1: + return tM5[0]; + default: + return tM5[1]; + } + case 6: + switch (ordinalSide) { + case 0: + case 1: + return tM6[0]; + default: + return tM6[1]; + } + case 7: + return tM7; + case 8: + switch (ordinalSide) { + case 0: + case 1: + return tM8[0]; + default: + return tM8[1]; + } + case 9: + switch (ordinalSide) { + case 0: + case 1: + return tM9[0]; + default: + return tM9[1]; + } + case 10: + return EOH_INNER; + case 11: + return EOH_OUTER; + case 12: + return EOH_INFINITE; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i <= 12; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java new file mode 100644 index 0000000000..00021154f4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java @@ -0,0 +1,64 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINECASINGS_BOTTOM_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINECASINGS_SIDE_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINECASINGS_TOP_TT; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import com.github.technus.tectech.thing.CustomItemList; + +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.common.blocks.GT_Material_Casings; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class GT_Block_CasingsNH extends GT_Block_Casings_Abstract { + + public static boolean mConnectedMachineTextures = true; + + public GT_Block_CasingsNH() { + super(GT_Item_CasingsNH.class, "gt.blockcasingsNH", GT_Material_Casings.INSTANCE); + setCreativeTab(creativeTabTecTech); + + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[8][b + 64] = new GT_CopiedBlockTexture(this, 6, b); + /* IMPORTANT for block recoloring */ + } + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "UEV Machine Casing"); // adding + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "UIV Machine Casing"); // adding + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "UMV Machine Casing"); // adding + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "UXV Machine Casing"); // adding + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "MAX Machine Casing"); // adding + + CustomItemList.Casing_UEV.set(new ItemStack(this, 1, 10)); + CustomItemList.Casing_UIV.set(new ItemStack(this, 1, 11)); + CustomItemList.Casing_UMV.set(new ItemStack(this, 1, 12)); + CustomItemList.Casing_UXV.set(new ItemStack(this, 1, 13)); + CustomItemList.Casing_MAXV.set(new ItemStack(this, 1, 14)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + // super.registerBlockIcons(aIconRegister); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + if (ordinalSide == 0) { + return MACHINECASINGS_BOTTOM_TT[aMeta].getIcon(); + } + if (ordinalSide == 1) { + return MACHINECASINGS_TOP_TT[aMeta].getIcon(); + } + return MACHINECASINGS_SIDE_TT[aMeta].getIcon(); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java new file mode 100644 index 0000000000..dc15b87f95 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java @@ -0,0 +1,196 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.tectechTexturePage1; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import com.github.technus.tectech.thing.CustomItemList; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.common.blocks.GT_Material_Casings; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class GT_Block_CasingsTT extends GT_Block_Casings_Abstract { + + public static final byte texturePage = tectechTexturePage1; + public static final short textureOffset = texturePage << 7; // Start of PAGE 8 (which is the 9th page) (8*128) + private static IIcon eM0, eM1, eM1s, eM2, eM2s, eM3, eM3s, eM4, eM5, eM6, eM7, eM7s, eM8, eM9, eM10, eM11, eM12, + eM13, eM14; + private static final IIcon[] debug = new IIcon[6]; + + public GT_Block_CasingsTT() { + super(GT_Item_CasingsTT.class, "gt.blockcasingsTT", GT_Material_Casings.INSTANCE); + setCreativeTab(creativeTabTecTech); + + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[texturePage][b] = new GT_CopiedBlockTexture(this, 6, b); + /* IMPORTANT for block recoloring **/ + } + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "High Power Casing"); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Computer Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Computer Heat Vent"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Advanced Computer Casing"); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Molecular Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Advanced Molecular Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Containment Field Generator"); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Molecular Coil"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Hollow Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Spacetime Altering Casing"); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Teleportation Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Dimensional Bridge Generator"); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Ultimate Molecular Casing"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".13.name", "Ultimate Advanced Molecular Casing"); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".14.name", "Ultimate Containment Field Generator"); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Debug Sides"); // NOT REGISTER AS + // TEXTURE FOR + // HATCHES! + + CustomItemList.eM_Power.set(new ItemStack(this, 1, 0)); + + CustomItemList.eM_Computer_Casing.set(new ItemStack(this, 1, 1)); + CustomItemList.eM_Computer_Vent.set(new ItemStack(this, 1, 2)); + CustomItemList.eM_Computer_Bus.set(new ItemStack(this, 1, 3)); + + CustomItemList.eM_Containment.set(new ItemStack(this, 1, 4)); + CustomItemList.eM_Containment_Advanced.set(new ItemStack(this, 1, 5)); + CustomItemList.eM_Containment_Field.set(new ItemStack(this, 1, 6)); + + CustomItemList.eM_Coil.set(new ItemStack(this, 1, 7)); + CustomItemList.eM_Hollow.set(new ItemStack(this, 1, 8)); + CustomItemList.eM_Spacetime.set(new ItemStack(this, 1, 9)); + + CustomItemList.eM_Teleportation.set(new ItemStack(this, 1, 10)); + CustomItemList.eM_Dimensional.set(new ItemStack(this, 1, 11)); + + CustomItemList.eM_Ultimate_Containment.set(new ItemStack(this, 1, 12)); + CustomItemList.eM_Ultimate_Containment_Advanced.set(new ItemStack(this, 1, 13)); + CustomItemList.eM_Ultimate_Containment_Field.set(new ItemStack(this, 1, 14)); + + CustomItemList.debugBlock.set(new ItemStack(this, 1, 15)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + // super.registerBlockIcons(aIconRegister); + eM0 = aIconRegister.registerIcon("gregtech:iconsets/EM_POWER"); + + eM1 = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_NONSIDE"); + eM1s = aIconRegister.registerIcon("gregtech:iconsets/EM_PC"); + eM2 = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_VENT_NONSIDE"); + eM2s = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_VENT"); + eM3 = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_ADV_NONSIDE"); + eM3s = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_ADV"); + + eM4 = aIconRegister.registerIcon("gregtech:iconsets/EM_CASING"); + eM5 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_CASING"); + eM6 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD"); + + eM7 = aIconRegister.registerIcon("gregtech:iconsets/EM_COIL_NONSIDE"); + eM7s = aIconRegister.registerIcon("gregtech:iconsets/EM_COIL"); + eM8 = aIconRegister.registerIcon("gregtech:iconsets/EM_HOLLOW"); + eM9 = aIconRegister.registerIcon("gregtech:iconsets/EM_TIMESPACE"); + + eM10 = aIconRegister.registerIcon("gregtech:iconsets/EM_TELE"); + eM11 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM"); + + eM12 = aIconRegister.registerIcon("gregtech:iconsets/EM_ULTIMATE_CASING"); + eM13 = aIconRegister.registerIcon("gregtech:iconsets/EM_ULTIMATE_FIELD_CASING"); + eM14 = aIconRegister.registerIcon("gregtech:iconsets/EM_ULTIMATE_FIELD"); + + debug[0] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_0"); + debug[1] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_1"); + debug[2] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_2"); + debug[3] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_3"); + debug[4] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_4"); + debug[5] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_5"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return eM0; + case 1: + if (ordinalSide < 2) { + return eM1; + } + return eM1s; + case 2: + if (ordinalSide < 2) { + return eM2; + } + return eM2s; + case 3: + if (ordinalSide < 2) { + return eM3; + } + return eM3s; + case 4: + return eM4; + case 5: + return eM5; + case 6: + return eM6; + case 7: + if (ordinalSide < 2) { + return eM7; + } + return eM7s; + case 8: + return eM8; + case 9: + return eM9; + case 10: + return eM10; + case 11: + return eM11; + case 12: + return eM12; + case 13: + return eM13; + case 14: + return eM14; + case 15: + return debug[ordinalSide]; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i <= 15; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java new file mode 100644 index 0000000000..de6336ed60 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java @@ -0,0 +1,111 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.util.CommonValues.COSMIC_MARK; +import static com.github.technus.tectech.util.CommonValues.THETA_MOVEMENT; +import static com.github.technus.tectech.util.CommonValues.V; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static net.minecraft.util.EnumChatFormatting.AQUA; +import static net.minecraft.util.EnumChatFormatting.GRAY; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.enums.TierEU; +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +public class GT_Item_CasingsBA0 extends GT_Item_Casings_Abstract { + + public GT_Item_CasingsBA0(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + if (aStack.getItemDamage() < 15) { + aList.add(THETA_MOVEMENT); + } else { + aList.add(COSMIC_MARK); + } + switch (aStack.getItemDamage()) { + case 0: // "Redstone Alloy Primary Tesla Windings" + case 1: // "MV Superconductor Primary Tesla Windings" + case 2: // "HV Superconductor Primary Tesla Windings" + case 3: // "EV Superconductor Primary Tesla Windings" + case 4: // "IV Superconductor Primary Tesla Windings" + case 5: // "LuV Superconductor Primary Tesla Windings" + aList.add( + translateToLocal("gt.blockcasingsBA0.0.desc.0") + " " + + formatNumbers(V[aStack.getItemDamage() + 1]) + + " EU/t"); // Handles up to + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.0.desc.1")); // What + // one + // man + // calls + // God, + // another + // calls + // the + // laws of physics. + break; + case 6: // "Tesla Base Casing" + aList.add(translateToLocal("gt.blockcasingsBA0.6.desc.0")); // The base of a wondrous contraption + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.6.desc.1")); // it's + // alive, + // IT'S + // ALIVE! + break; + case 7: // "Tesla Toroid Casing" + aList.add(translateToLocal("gt.blockcasingsBA0.7.desc.0")); // Made out of the finest tin foil! + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.7.desc.1")); // Faraday + // suits + // might + // come + // later + break; + case 8: // "Tesla Secondary Windings" + aList.add(translateToLocal("gt.blockcasingsBA0.8.desc.0")); // Picks up power from a primary coil + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.8.desc.1")); // Who + // wouldn't + // want + // a + // 32k + // epoxy + // multi? + break; + case 9: // "ZPM Superconductor Primary Tesla Windings" + aList.add(translateToLocal("gt.blockcasingsBA0.0.desc.0") + " " + formatNumbers(TierEU.ZPM) + " EU/t"); // Handles + // up + // to + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.0.desc.1")); // What + // one + // man + // calls + // God, + // another + case 10: // Reinforced Temporal Structure Casing + aList.add(AQUA + translateToLocal("gt.blockcasingsBA0.10.desc.0")); + aList.add(GRAY + translateToLocal("gt.blockcasingsBA0.10.desc.1")); + // Designed to resist spatial shearing from internal volume expansion. + // Can survive at least one big bang, maybe two... + break; + case 11: // Reinforced Temporal Structure Casing + aList.add(AQUA + translateToLocal("gt.blockcasingsBA0.11.desc.0")); + aList.add(GRAY + translateToLocal("gt.blockcasingsBA0.11.desc.1")); + // Resistant to temporal shearing from time dilation differences. + // This block can last an eternity without any decay. + break; + case 12: // Infinite Spacetime Energy Boundary Casing + aList.add(AQUA + translateToLocal("gt.blockcasingsBA0.12.desc.0")); + // Provides a stable bridge between spacetime regions. + break; + default: + aList.add("Damn son where did you get that!?"); + aList.add(EnumChatFormatting.BLUE + "From outer space... I guess..."); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsNH.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsNH.java new file mode 100644 index 0000000000..b69abca128 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsNH.java @@ -0,0 +1,15 @@ +package com.github.technus.tectech.thing.casing; + +import net.minecraft.block.Block; + +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class GT_Item_CasingsNH extends GT_Item_Casings_Abstract { + + public GT_Item_CasingsNH(Block par1) { + super(par1); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java new file mode 100644 index 0000000000..3c2f349b03 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java @@ -0,0 +1,133 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.util.CommonValues.COSMIC_MARK; +import static com.github.technus.tectech.util.CommonValues.TEC_MARK_EM; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class GT_Item_CasingsTT extends GT_Item_Casings_Abstract { + + public GT_Item_CasingsTT(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + if (aStack.getItemDamage() < 15) { + aList.add(TEC_MARK_EM); + } else { + aList.add(COSMIC_MARK); + } + switch (aStack.getItemDamage()) { + case 0: // "High Power Casing" + aList.add(translateToLocal("gt.blockcasingsTT.0.desc.0")); // Well suited for high power applications. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.0.desc.1")); // The power levels are rising! + break; + case 1: // "Computer Casing" + aList.add(translateToLocal("gt.blockcasingsTT.1.desc.0")); // Nice and clean casing. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.1.desc.1")); // Dust can break it!? + break; + case 2: // "Computer Heat Vent" + aList.add(translateToLocal("gt.blockcasingsTT.2.desc.0")); // Air vent with a filter. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.2.desc.1")); // Perfectly muffled sound! + break; + case 3: // "Advanced Computer Casing" + aList.add(translateToLocal("gt.blockcasingsTT.3.desc.0")); // Contains high bandwidth bus + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.3.desc.1")); // couple thousand qubits wide. + break; + case 4: // "Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.4.desc.0")); // Stops elemental things. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.4.desc.1")); // Radiation and emotions too... + break; + case 5: // "Advanced Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.5.desc.0")); // Cooling and stabilization. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.5.desc.1")); // A comfortable machine bed. + break; + case 6: // "Containment Field Generator" + aList.add(translateToLocal("gt.blockcasingsTT.6.desc.0")); // Creates a field that... + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.6.desc.1")); // can stop even force carriers. + break; + case 7: // "Molecular Coil" + aList.add(translateToLocal("gt.blockcasingsTT.7.desc.0")); // Well it does things too... + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.7.desc.1")); // [Use this coil!] + break; + case 8: // "Collider Hollow Casing" + aList.add(translateToLocal("gt.blockcasingsTT.8.desc.0")); // Reinforced accelerator tunnel. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.8.desc.1")); // Most advanced pipe ever. + break; + case 9: // "Spacetime Altering Casing" + aList.add(translateToLocal("gt.blockcasingsTT.9.desc.0")); // c is no longer the limit. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.9.desc.1")); // Wibbly wobbly timey wimey stuff. + break; + case 10: // "Teleportation Casing" + aList.add(translateToLocal("gt.blockcasingsTT.10.desc.0")); // Remote connection. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.10.desc.1")); // Better touch with a stick. + break; + case 11: // "Dimensional Bridge Generator" + aList.add(translateToLocal("gt.blockcasingsTT.11.desc.0")); // Interdimensional Operations. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.11.desc.1")); // Around the universe and other + // places too. + break; + case 12: // "Ultimate Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.12.desc.0")); // Ultimate in every way. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.12.desc.1")); // I don't know what it can't do. + break; + case 13: // "Ultimate Advanced Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.13.desc.0")); // More Ultimate in every way. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.13.desc.1")); // I don't know what I am doing! + break; + case 14: // "Ultimate Containment Field Generator" + aList.add(translateToLocal("gt.blockcasingsTT.14.desc.0")); // Black Hole... + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.14.desc.1")); // Meh... + break; + case 15: // "Debug Sides" + aList.add(translateToLocal("gt.blockcasingsTT.15.desc.0")); // Lazy man way of determining sides. + aList.add(EnumChatFormatting.BLUE + translateToLocal("gt.blockcasingsTT.15.desc.1")); + break; + default: // WTF? + aList.add("Damn son where did you get that!?"); + aList.add(EnumChatFormatting.BLUE + "From outer space... I guess..."); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Godforge.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Godforge.java new file mode 100644 index 0000000000..e527fc552d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Godforge.java @@ -0,0 +1,114 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.util.CommonValues.GODFORGE_MARK; +import static net.minecraft.util.EnumChatFormatting.AQUA; +import static net.minecraft.util.EnumChatFormatting.BOLD; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +public class GT_Item_Casings_Godforge extends GT_Item_Casings_Abstract { + + public GT_Item_Casings_Godforge(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(GODFORGE_MARK); + switch (aStack.getItemDamage()) { + case 0: + aList.add( + GT_LanguageManager.addStringLocalization( + "godforge.casings.0.Tooltip.0", + "Shielded by the event horizon of a singularity")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager + .addStringLocalization("godforge.casings.0.Tooltip.1", "Don't get too close...")); + break; + case 1: + aList.add( + GT_LanguageManager.addStringLocalization( + "godforge.casings.1.Tooltip.0", + "Designed to route stellar matter using spacetime distortion")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager + .addStringLocalization("godforge.casings.1.Tooltip.1", "Reality Distortion")); + break; + case 2: + aList.add( + GT_LanguageManager + .addStringLocalization("godforge.casings.2.Tooltip.0", "Unaffected by gravitational forces")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager.addStringLocalization( + "godforge.casings.2.Tooltip.1", + "Not even a black hole could tear it apart.")); + break; + case 3: + aList.add( + GT_LanguageManager.addStringLocalization( + "godforge.casings.3.Tooltip.0", + "Creates enormous magnetic fields capable of constraining entire stars")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager + .addStringLocalization("godforge.casings.3.Tooltip.1", "It's super effective!")); + break; + case 4: + aList.add( + GT_LanguageManager.addStringLocalization( + "godforge.casings.4.Tooltip.0", + "Taps into streams of stellar matter to harness their heat energy")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager + .addStringLocalization("godforge.casings.4.Tooltip.1", "Turn up the heat!")); + break; + case 5: + aList.add( + GT_LanguageManager.addStringLocalization( + "godforge.casings.5.Tooltip.0", + "Controls the flow of gravitons to manipulate gravity")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager.addStringLocalization( + "godforge.casings.5.Tooltip.1", + "Exponential scaling past 800 Galaxies")); + break; + case 6: + aList.add( + GT_LanguageManager.addStringLocalization( + "godforge.casings.6.Tooltip.0", + "Controls the flow of gravitons to manipulate gravity")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager + .addStringLocalization("godforge.casings.6.Tooltip.1", "Getting closer...")); + break; + case 7: + aList.add( + GT_LanguageManager.addStringLocalization( + "godforge.casings.7.Tooltip.0", + "Controls the flow of gravitons to manipulate gravity")); + aList.add( + AQUA.toString() + BOLD + + GT_LanguageManager.addStringLocalization("godforge.casings.7.Tooltip.1", "Gravity Central")); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + BOLD + + GT_LanguageManager + .addStringLocalization("godforge.casings.Error.Tooltip", "Error, report to GTNH team")); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Spacetime.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Spacetime.java new file mode 100644 index 0000000000..f966d85695 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Spacetime.java @@ -0,0 +1,56 @@ +package com.github.technus.tectech.thing.casing; + +import static com.google.common.math.LongMath.pow; +import static gregtech.api.enums.GT_Values.AuthorColen; +import static gregtech.api.util.GT_Utility.formatNumbers; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +public class GT_Item_Casings_Spacetime extends GT_Item_Casings_Abstract { + + public GT_Item_Casings_Spacetime(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + switch (aStack.getItemDamage()) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + aList.add( + GT_LanguageManager.addStringLocalization( + "EOH.Spacetime.Standard.Tooltip.0", + "Supports an internal spacetime volume of up to ") + + formatNumbers(pow(10, 5 + aStack.getItemDamage())) + + "km³."); + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + GT_LanguageManager.addStringLocalization( + "EOH.Spacetime.Standard.Tooltip.1", + "Capable of running recipes up to tier ") + + (aStack.getItemDamage() + 1)); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + + GT_LanguageManager + .addStringLocalization("EOH.TimeDilation.Error.Tooltip", "Error, report to GTNH team")); + } + aList.add(AuthorColen); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Stabilisation.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Stabilisation.java new file mode 100644 index 0000000000..6bd86524a1 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_Stabilisation.java @@ -0,0 +1,47 @@ +package com.github.technus.tectech.thing.casing; + +import static gregtech.api.enums.GT_Values.AuthorColen; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +public class GT_Item_Casings_Stabilisation extends GT_Item_Casings_Abstract { + + public GT_Item_Casings_Stabilisation(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + switch (aStack.getItemDamage()) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + GT_LanguageManager.addStringLocalization( + "EOH.Stability.Tooltip.0", + "Increases stability of spacetime field.")); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + + GT_LanguageManager + .addStringLocalization("EOH.TimeDilation.Error.Tooltip", "Error, report to GTNH team")); + } + aList.add(AuthorColen); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_TimeAcceleration.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_TimeAcceleration.java new file mode 100644 index 0000000000..994f40b9e7 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_Casings_TimeAcceleration.java @@ -0,0 +1,46 @@ +package com.github.technus.tectech.thing.casing; + +import static gregtech.api.enums.GT_Values.AuthorColen; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +public class GT_Item_Casings_TimeAcceleration extends GT_Item_Casings_Abstract { + + public GT_Item_Casings_TimeAcceleration(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + switch (aStack.getItemDamage()) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + GT_LanguageManager + .addStringLocalization("EOH.TimeDilation.Standard.Tooltip", "Time dilation in a box.")); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + + GT_LanguageManager + .addStringLocalization("EOH.TimeDilation.Error.Tooltip", "Error, report to GTNH team")); + } + aList.add(AuthorColen); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GodforgeCasings.java b/src/main/java/com/github/technus/tectech/thing/casing/GodforgeCasings.java new file mode 100644 index 0000000000..809e6bbff1 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/GodforgeCasings.java @@ -0,0 +1,124 @@ +package com.github.technus.tectech.thing.casing; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import com.github.technus.tectech.thing.CustomItemList; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.common.blocks.GT_Material_Casings; + +public class GodforgeCasings extends GT_Block_Casings_Abstract { + + private static IIcon GodforgeTrim; + private static IIcon GodforgeInner; + private static IIcon GodforgeSupport; + private static IIcon GodforgeOuter; + private static IIcon GodforgeEnergy; + private static IIcon GravitonModulatorT1; + private static IIcon GravitonModulatorT2; + private static IIcon GravitonModulatorT3; + + private static final byte START_INDEX = 64; + + public GodforgeCasings() { + super(GT_Item_Casings_Godforge.class, "gt.godforgecasing", GT_Material_Casings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GT_CopiedBlockTexture(this, 6, b); + } + + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + ".0.name", "Singularity Reinforced Stellar Shielding Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Celestial Matter Guidance Casing"); + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + ".2.name", + "Boundless Gravitationally Severed Structure Casing"); + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + ".3.name", + "Transcendentally Amplified Magnetic Confinement Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Stellar Energy Siphon Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Remote Graviton Flow Modulator"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Medial Graviton Flow Modulator"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Central Graviton Flow Modulator"); + + CustomItemList.Godforge_Singularity_Shielding_Casing.set(new ItemStack(this, 1, 0)); + CustomItemList.Godforge_Guidance_Casing.set(new ItemStack(this, 1, 1)); + CustomItemList.Godforge_Boundless_Structure_Casing.set(new ItemStack(this, 1, 2)); + CustomItemList.Godforge_Magnetic_Confinement_Casing.set(new ItemStack(this, 1, 3)); + CustomItemList.Godforge_Stellar_Energy_Siphon_Casing.set(new ItemStack(this, 1, 4)); + CustomItemList.Godforge_GravitonFlowModulatorTier1.set(new ItemStack(this, 1, 5)); + CustomItemList.Godforge_GravitonFlowModulatorTier2.set(new ItemStack(this, 1, 6)); + CustomItemList.Godforge_GravitonFlowModulatorTier3.set(new ItemStack(this, 1, 7)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + GodforgeTrim = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_TRIM"); + GodforgeInner = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_INNER"); + GodforgeSupport = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_SUPPORT"); + GodforgeOuter = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_TOP_BOTTOM"); + GodforgeEnergy = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_ENERGY"); + GravitonModulatorT1 = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_CASING_2"); + GravitonModulatorT2 = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_CASING_1"); + GravitonModulatorT3 = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_CASING_0"); + } + + @Override + public IIcon getIcon(int aSide, int aMeta) { + switch (aMeta) { + case 0: + return GodforgeTrim; + case 1: + return GodforgeInner; + case 2: + return GodforgeSupport; + case 3: + return GodforgeOuter; + case 4: + return GodforgeEnergy; + case 5: + if (aSide < 2) { + return GodforgeOuter; + } + return GravitonModulatorT1; + case 6: + if (aSide < 2) { + return GodforgeOuter; + } + return GravitonModulatorT2; + case 7: + if (aSide < 2) { + return GodforgeOuter; + } + return GravitonModulatorT3; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(aSide, tMeta); + } + + @SuppressWarnings("unchecked") + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i <= 7; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java b/src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java new file mode 100644 index 0000000000..6d00822c19 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java @@ -0,0 +1,120 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.WHITE; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import com.github.technus.tectech.thing.CustomItemList; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.common.blocks.GT_Material_Casings; + +@SuppressWarnings("SpellCheckingInspection") +public class SpacetimeCompressionFieldCasing extends GT_Block_Casings_Abstract { + + private static IIcon textureTier0; + private static IIcon textureTier1; + private static IIcon textureTier2; + private static IIcon textureTier3; + private static IIcon textureTier4; + private static IIcon textureTier5; + private static IIcon textureTier6; + private static IIcon textureTier7; + private static IIcon textureTier8; + private static final int MAX_BLOCK_TIER = 9; + + private static final byte START_INDEX = 16; + + public SpacetimeCompressionFieldCasing() { + super( + GT_Item_Casings_Spacetime.class, + "gt.spacetime_compression_field_generator", + GT_Material_Casings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GT_CopiedBlockTexture(this, 6, b); + } + + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + "." + i + ".name", + WHITE + EOH_TIER_FANCY_NAMES[i] + RESET + " Spacetime Compression Field Generator"); + } + + CustomItemList.SpacetimeCompressionFieldGeneratorTier0.set(new ItemStack(this, 1, 0)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier1.set(new ItemStack(this, 1, 1)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier2.set(new ItemStack(this, 1, 2)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier3.set(new ItemStack(this, 1, 3)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier4.set(new ItemStack(this, 1, 4)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier5.set(new ItemStack(this, 1, 5)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier6.set(new ItemStack(this, 1, 6)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier7.set(new ItemStack(this, 1, 7)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.set(new ItemStack(this, 1, 8)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + textureTier0 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_0"); + textureTier1 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_1"); + textureTier2 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_2"); + textureTier3 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_3"); + textureTier4 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_4"); + textureTier5 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_5"); + textureTier6 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_6"); + textureTier7 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_7"); + textureTier8 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_8"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return textureTier0; + case 1: + return textureTier1; + case 2: + return textureTier2; + case 3: + return textureTier3; + case 4: + return textureTier4; + case 5: + return textureTier5; + case 6: + return textureTier6; + case 7: + return textureTier7; + case 8: + return textureTier8; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/StabilisationFieldCasing.java b/src/main/java/com/github/technus/tectech/thing/casing/StabilisationFieldCasing.java new file mode 100644 index 0000000000..ed35e82b83 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/StabilisationFieldCasing.java @@ -0,0 +1,117 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.WHITE; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import com.github.technus.tectech.thing.CustomItemList; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.common.blocks.GT_Material_Casings; + +@SuppressWarnings("SpellCheckingInspection") +public class StabilisationFieldCasing extends GT_Block_Casings_Abstract { + + private static IIcon textureTier0; + private static IIcon textureTier1; + private static IIcon textureTier2; + private static IIcon textureTier3; + private static IIcon textureTier4; + private static IIcon textureTier5; + private static IIcon textureTier6; + private static IIcon textureTier7; + private static IIcon textureTier8; + private static final int MAX_BLOCK_TIER = 9; + + private static final byte START_INDEX = 32; + + public StabilisationFieldCasing() { + super(GT_Item_Casings_Stabilisation.class, "gt.stabilisation_field_generator", GT_Material_Casings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GT_CopiedBlockTexture(this, 6, b); + } + + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + "." + i + ".name", + WHITE + EOH_TIER_FANCY_NAMES[i] + RESET + " Stabilisation Field Generator"); + } + + CustomItemList.StabilisationFieldGeneratorTier0.set(new ItemStack(this, 1, 0)); + CustomItemList.StabilisationFieldGeneratorTier1.set(new ItemStack(this, 1, 1)); + CustomItemList.StabilisationFieldGeneratorTier2.set(new ItemStack(this, 1, 2)); + CustomItemList.StabilisationFieldGeneratorTier3.set(new ItemStack(this, 1, 3)); + CustomItemList.StabilisationFieldGeneratorTier4.set(new ItemStack(this, 1, 4)); + CustomItemList.StabilisationFieldGeneratorTier5.set(new ItemStack(this, 1, 5)); + CustomItemList.StabilisationFieldGeneratorTier6.set(new ItemStack(this, 1, 6)); + CustomItemList.StabilisationFieldGeneratorTier7.set(new ItemStack(this, 1, 7)); + CustomItemList.StabilisationFieldGeneratorTier8.set(new ItemStack(this, 1, 8)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + textureTier0 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_0"); + textureTier1 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_1"); + textureTier2 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_2"); + textureTier3 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_3"); + textureTier4 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_4"); + textureTier5 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_5"); + textureTier6 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_6"); + textureTier7 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_7"); + textureTier8 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_8"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return textureTier0; + case 1: + return textureTier1; + case 2: + return textureTier2; + case 3: + return textureTier3; + case 4: + return textureTier4; + case 5: + return textureTier5; + case 6: + return textureTier6; + case 7: + return textureTier7; + case 8: + return textureTier8; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java new file mode 100644 index 0000000000..009a9f4255 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java @@ -0,0 +1,28 @@ +package com.github.technus.tectech.thing.casing; + +import net.minecraft.block.Block; + +import com.github.technus.tectech.thing.block.EOH_RenderBlock; +import com.github.technus.tectech.thing.block.ForgeOfGodsBlock; + +/** + * Created by danie_000 on 03.10.2016. + */ +public final class TT_Container_Casings { + + public static Block sBlockCasingsTT; + + public static Block sBlockCasingsBA0; + + public static Block sBlockCasingsNH; + public static Block TimeAccelerationFieldGenerator; + public static Block SpacetimeCompressionFieldGenerators; + public static Block StabilisationFieldGenerators; + + public static Block eyeOfHarmonyRenderBlock = new EOH_RenderBlock(); + public static Block forgeOfGodsRenderBlock = new ForgeOfGodsBlock(); + + public static Block GodforgeCasings; + + private TT_Container_Casings() {} +} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/TimeAccelerationFieldCasing.java b/src/main/java/com/github/technus/tectech/thing/casing/TimeAccelerationFieldCasing.java new file mode 100644 index 0000000000..739fe300a9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/casing/TimeAccelerationFieldCasing.java @@ -0,0 +1,120 @@ +package com.github.technus.tectech.thing.casing; + +import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.WHITE; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import com.github.technus.tectech.thing.CustomItemList; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.common.blocks.GT_Material_Casings; + +@SuppressWarnings("SpellCheckingInspection") +public class TimeAccelerationFieldCasing extends GT_Block_Casings_Abstract { + + private static IIcon textureTier0; + private static IIcon textureTier1; + private static IIcon textureTier2; + private static IIcon textureTier3; + private static IIcon textureTier4; + private static IIcon textureTier5; + private static IIcon textureTier6; + private static IIcon textureTier7; + private static IIcon textureTier8; + private static final int MAX_BLOCK_TIER = 9; + + private static final byte START_INDEX = 48; + + public TimeAccelerationFieldCasing() { + super( + GT_Item_Casings_TimeAcceleration.class, + "gt.time_acceleration_field_generator", + GT_Material_Casings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GT_CopiedBlockTexture(this, 6, b); + } + + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + "." + i + ".name", + WHITE + EOH_TIER_FANCY_NAMES[i] + RESET + " Time Dilation Field Generator"); + } + + CustomItemList.TimeAccelerationFieldGeneratorTier0.set(new ItemStack(this, 1, 0)); + CustomItemList.TimeAccelerationFieldGeneratorTier1.set(new ItemStack(this, 1, 1)); + CustomItemList.TimeAccelerationFieldGeneratorTier2.set(new ItemStack(this, 1, 2)); + CustomItemList.TimeAccelerationFieldGeneratorTier3.set(new ItemStack(this, 1, 3)); + CustomItemList.TimeAccelerationFieldGeneratorTier4.set(new ItemStack(this, 1, 4)); + CustomItemList.TimeAccelerationFieldGeneratorTier5.set(new ItemStack(this, 1, 5)); + CustomItemList.TimeAccelerationFieldGeneratorTier6.set(new ItemStack(this, 1, 6)); + CustomItemList.TimeAccelerationFieldGeneratorTier7.set(new ItemStack(this, 1, 7)); + CustomItemList.TimeAccelerationFieldGeneratorTier8.set(new ItemStack(this, 1, 8)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + textureTier0 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_0"); + textureTier1 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_1"); + textureTier2 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_2"); + textureTier3 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_3"); + textureTier4 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_4"); + textureTier5 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_5"); + textureTier6 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_6"); + textureTier7 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_7"); + textureTier8 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_8"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return textureTier0; + case 1: + return textureTier1; + case 2: + return textureTier2; + case 3: + return textureTier3; + case 4: + return textureTier4; + case 5: + return textureTier5; + case 6: + return textureTier6; + case 7: + return textureTier7; + case 8: + return textureTier8; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java new file mode 100644 index 0000000000..b3fe110201 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java @@ -0,0 +1,252 @@ +package com.github.technus.tectech.thing.cover; + +import static com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData.getEnderFluidContainer; +import static com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData.getEnderLinkTag; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +import com.github.technus.tectech.mechanics.enderStorage.EnderLinkTag; +import com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import eu.usrv.yamcore.auxiliary.PlayerChatHelper; +import gregtech.api.gui.modularui.GT_CoverUIBuildContext; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.ISerializableObject; +import gregtech.common.gui.modularui.widget.CoverDataControllerWidget; +import gregtech.common.gui.modularui.widget.CoverDataFollower_ToggleButtonWidget; + +public class GT_Cover_TM_EnderFluidLink extends GT_CoverBehavior { + + private static final int L_PER_TICK = 8000; + private static final int IMPORT_EXPORT_MASK = 0b0001; + private static final int PUBLIC_PRIVATE_MASK = 0b0010; + + public GT_Cover_TM_EnderFluidLink() {} + + private void transferFluid(IFluidHandler source, ForgeDirection side, IFluidHandler target, ForgeDirection tSide, + int amount) { + FluidStack fluidStack = source.drain(side, amount, false); + + if (fluidStack != null) { + int fluidTransferred = target.fill(tSide, fluidStack, true); + source.drain(side, fluidTransferred, true); + } + } + + private boolean testBit(int aCoverVariable, int bitMask) { + return (aCoverVariable & bitMask) != 0; + } + + private int toggleBit(int aCoverVariable, int bitMask) { + return (aCoverVariable ^ bitMask); + } + + @Override + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + if ((aTileEntity instanceof IFluidHandler fluidHandlerSelf)) { + IFluidHandler fluidHandlerEnder = getEnderFluidContainer(getEnderLinkTag((IFluidHandler) aTileEntity)); + + if (testBit(aCoverVariable, IMPORT_EXPORT_MASK)) { + transferFluid(fluidHandlerEnder, ForgeDirection.UNKNOWN, fluidHandlerSelf, side, L_PER_TICK); + } else { + transferFluid(fluidHandlerSelf, side, fluidHandlerEnder, ForgeDirection.UNKNOWN, L_PER_TICK); + } + } + return aCoverVariable; + } + + @Override + public String getDescription(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return ""; + } + + @Override + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + int newCoverVariable = toggleBit(aCoverVariable, IMPORT_EXPORT_MASK); + + if (testBit(aCoverVariable, IMPORT_EXPORT_MASK)) { + PlayerChatHelper.SendInfo(aPlayer, "Ender Suction Engaged!"); // TODO Translation support + } else { + PlayerChatHelper.SendInfo(aPlayer, "Ender Filling Engaged!"); + } + return newCoverVariable; + } + + @Override + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + // Runs each tick + return 1; + } + + // region GUI + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public ModularWindow createWindow(GT_CoverUIBuildContext buildContext) { + // Only open gui if we're placed on a fluid tank + if (buildContext.getTile() instanceof IFluidHandler) { + return new EnderFluidLinkUIFactory(buildContext).createWindow(); + } + return null; + } + + private class EnderFluidLinkUIFactory extends UIFactory { + + private static final int START_X = 10; + private static final int START_Y = 25; + private static final int SPACE_X = 18; + private static final int SPACE_Y = 18; + private static final int PUBLIC_BUTTON_ID = 0; + private static final int PRIVATE_BUTTON_ID = 1; + private static final int IMPORT_BUTTON_ID = 2; + private static final int EXPORT_BUTTON_ID = 3; + + public EnderFluidLinkUIFactory(GT_CoverUIBuildContext buildContext) { + super(buildContext); + } + + @SuppressWarnings("PointlessArithmeticExpression") + @Override + protected void addUIWidgets(ModularWindow.Builder builder) { + TextFieldWidget frequencyField = new TextFieldWidget(); + builder.widget(frequencyField.setGetter(() -> { + ICoverable te = getUIBuildContext().getTile(); + if (!frequencyField.isClient() && te instanceof IFluidHandler) { + return EnderWorldSavedData.getEnderLinkTag((IFluidHandler) te) + .getFrequency(); + } + return ""; + }) + .setSetter(val -> { + ICoverable te = getUIBuildContext().getTile(); + if (!frequencyField.isClient() && te instanceof IFluidHandler) { + UUID uuid; + if (testBit(convert(getCoverData()), PUBLIC_PRIVATE_MASK)) { + uuid = getUUID(); + if (!(te instanceof IGregTechTileEntity)) return; + if (!uuid.equals(((IGregTechTileEntity) te).getOwnerUuid())) return; + } else { + uuid = null; + } + EnderWorldSavedData.bindEnderLinkTag((IFluidHandler) te, new EnderLinkTag(val, uuid)); + } + }) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setFocusOnGuiOpen(true) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(START_X + SPACE_X * 0, START_Y + SPACE_Y * 0) + .setSize(SPACE_X * 5 - 8, 12)) + .widget( + new CoverDataControllerWidget.CoverDataIndexedControllerWidget_ToggleButtons<>( + this::getCoverData, + this::setCoverData, + GT_Cover_TM_EnderFluidLink.this, + (id, coverData) -> !getClickable(id, convert(coverData)), + (id, coverData) -> new ISerializableObject.LegacyCoverData( + getNewCoverVariable(id, convert(coverData)))) + .addToggleButton( + PUBLIC_BUTTON_ID, + CoverDataFollower_ToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GT_UITextures.OVERLAY_BUTTON_WHITELIST) + .addTooltip(GT_Utility.trans("326", "Public")) + .setPos(START_X + SPACE_X * 0, START_Y + SPACE_Y * 2)) + .addToggleButton( + PRIVATE_BUTTON_ID, + CoverDataFollower_ToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GT_UITextures.OVERLAY_BUTTON_BLACKLIST) + .addTooltip(GT_Utility.trans("327", "Private")) + .setPos(START_X + SPACE_X * 1, START_Y + SPACE_Y * 2)) + .addToggleButton( + IMPORT_BUTTON_ID, + CoverDataFollower_ToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GT_UITextures.OVERLAY_BUTTON_IMPORT) + .addTooltip(GT_Utility.trans("007", "Import")) + .setPos(START_X + SPACE_X * 0, START_Y + SPACE_Y * 3)) + .addToggleButton( + EXPORT_BUTTON_ID, + CoverDataFollower_ToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GT_UITextures.OVERLAY_BUTTON_EXPORT) + .addTooltip(GT_Utility.trans("006", "Export")) + .setPos(START_X + SPACE_X * 1, START_Y + SPACE_Y * 3))) + .widget( + new TextWidget(GT_Utility.trans("328", "Channel")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(START_X + SPACE_X * 5, 4 + START_Y + SPACE_Y * 0)) + .widget( + new TextWidget(GT_Utility.trans("329", "Public/Private")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(START_X + SPACE_X * 2, 4 + START_Y + SPACE_Y * 2)) + .widget( + new TextWidget(GT_Utility.trans("229", "Import/Export")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(START_X + SPACE_X * 2, 4 + START_Y + SPACE_Y * 3)); + } + + private int getNewCoverVariable(int id, int coverVariable) { + switch (id) { + case PUBLIC_BUTTON_ID: + case PRIVATE_BUTTON_ID: + return toggleBit(coverVariable, PUBLIC_PRIVATE_MASK); + case IMPORT_BUTTON_ID: + case EXPORT_BUTTON_ID: + return toggleBit(coverVariable, IMPORT_EXPORT_MASK); + } + return coverVariable; + } + + private boolean getClickable(int id, int coverVariable) { + switch (id) { + case PUBLIC_BUTTON_ID: + return testBit(coverVariable, PUBLIC_PRIVATE_MASK); + case PRIVATE_BUTTON_ID: + return !testBit(coverVariable, PUBLIC_PRIVATE_MASK); + case IMPORT_BUTTON_ID: + return testBit(coverVariable, IMPORT_EXPORT_MASK); + case EXPORT_BUTTON_ID: + return !testBit(coverVariable, IMPORT_EXPORT_MASK); + } + return false; + } + + private UUID getUUID() { + return getUIBuildContext().getPlayer() + .getUniqueID(); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_PowerPassUpgrade.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_PowerPassUpgrade.java new file mode 100644 index 0000000000..ef867e9a35 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_PowerPassUpgrade.java @@ -0,0 +1,53 @@ +package com.github.technus.tectech.thing.cover; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.util.GT_CoverBehavior; + +public class GT_Cover_TM_PowerPassUpgrade extends GT_CoverBehavior { + + public GT_Cover_TM_PowerPassUpgrade() {} + + @Override + public boolean isCoverPlaceable(ForgeDirection side, ItemStack aStack, ICoverable aTileEntity) { + IMetaTileEntity iGregTechTileEntityOffset = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0) + .getMetaTileEntity(); + if (iGregTechTileEntityOffset instanceof GT_MetaTileEntity_MultiblockBase_EM multi) { + return !multi.ePowerPassCover; + } + return false; + } + + @Override + public void placeCover(ForgeDirection side, ItemStack aCover, ICoverable aTileEntity) { + IMetaTileEntity iGregTechTileEntityOffset = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0) + .getMetaTileEntity(); + if (iGregTechTileEntityOffset instanceof GT_MetaTileEntity_MultiblockBase_EM multi) { + multi.ePowerPassCover = true; + multi.ePowerPass = true; + } + super.placeCover(side, aCover, aTileEntity); + } + + @Override + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { + IMetaTileEntity iGregTechTileEntityOffset = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0) + .getMetaTileEntity(); + if (iGregTechTileEntityOffset instanceof GT_MetaTileEntity_MultiblockBase_EM multi) { + multi.ePowerPassCover = false; + multi.ePowerPass = false; + } + return true; + } + + @Deprecated + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 0; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java new file mode 100644 index 0000000000..e5d2b7acde --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java @@ -0,0 +1,71 @@ +package com.github.technus.tectech.thing.cover; + +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove; +import static ic2.api.info.Info.DMG_ELECTRIC; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.tesla.TeslaCoverConnection; + +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_Utility; + +public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior { + + public GT_Cover_TM_TeslaCoil() {} + + @Override + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + // Only do stuff if we're on top and have power + if (side == ForgeDirection.UP || aTileEntity.getEUCapacity() > 0) { + // Makes sure we're on the list + teslaSimpleNodeSetAdd( + new TeslaCoverConnection( + aTileEntity.getIGregTechTileEntityOffset(0, 0, 0), + getTeslaReceptionCapability())); + } + return super.doCoverThings(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity, aTimer); + } + + @Override + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { + teslaSimpleNodeSetRemove( + new TeslaCoverConnection(aTileEntity.getIGregTechTileEntityOffset(0, 0, 0), getTeslaReceptionCapability())); + return super.onCoverRemoval(side, aCoverID, aCoverVariable, aTileEntity, aForced); + } + + @Override + public String getDescription(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return "Do not attempt to use screwdriver!"; // TODO Translation support + } + + @Override + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + @Override + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + // Shock a non-hazmat player if they dare stuff a screwdriver into one of these + if (aTileEntity.getStoredEU() > 0 && !GT_Utility.isWearingFullElectroHazmat(aPlayer)) { + aPlayer.attackEntityFrom(DMG_ELECTRIC, 20); + } + return aCoverVariable; + } + + @Override + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + // It updates once every 10 ticks, so once every 0.5 second + return 10; + } + + public byte getTeslaReceptionCapability() { + return 2; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java new file mode 100644 index 0000000000..7169cb61fb --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java @@ -0,0 +1,44 @@ +package com.github.technus.tectech.thing.cover; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +import gregtech.api.interfaces.tileentity.ICoverable; + +public class GT_Cover_TM_TeslaCoil_Ultimate extends GT_Cover_TM_TeslaCoil { + + public GT_Cover_TM_TeslaCoil_Ultimate() {} + + @Override + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + public byte getTeslaReceptionCapability() { + return 1; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java b/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java new file mode 100644 index 0000000000..8c0c801363 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java @@ -0,0 +1,184 @@ +package com.github.technus.tectech.thing.gui; + +import static com.github.technus.tectech.Reference.MODID; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +@SuppressWarnings("SimplifyStreamApiCallChains") +public class TecTechUITextures { + + public static final AdaptableUITexture BACKGROUND_SCREEN_BLUE = AdaptableUITexture + .of(MODID, "gui/background/screen_blue", 90, 72, 2); + public static final UITexture BACKGROUND_SCREEN_BLUE_PARAMETRIZER_TXT = UITexture + .fullImage(MODID, "gui/background/screen_blue_parametrizer_txt"); + public static final UITexture BACKGROUND_SCREEN_BLUE_NO_INVENTORY = UITexture + .fullImage(MODID, "gui/background/screen_blue_no_inventory"); + public static final UITexture BACKGROUND_STAR = UITexture.fullImage(MODID, "gui/background/star"); + public static final UITexture BACKGROUND_GLOW_ORANGE = UITexture.fullImage(MODID, "gui/background/orange_glow"); + public static final UITexture BACKGROUND_GLOW_PURPLE = UITexture.fullImage(MODID, "gui/background/purple_glow"); + public static final UITexture BACKGROUND_GLOW_BLUE = UITexture.fullImage(MODID, "gui/background/blue_glow"); + public static final UITexture BACKGROUND_GLOW_GREEN = UITexture.fullImage(MODID, "gui/background/green_glow"); + public static final UITexture BACKGROUND_GLOW_WHITE = UITexture.fullImage(MODID, "gui/background/white_glow"); + public static final UITexture BACKGROUND_SPACE = UITexture.fullImage(MODID, "gui/background/space"); + + public static final UITexture BUTTON_STANDARD_16x16 = UITexture.fullImage(MODID, "gui/button/standard_16x16"); + public static final UITexture BUTTON_STANDARD_LIGHT_16x16 = UITexture + .fullImage(MODID, "gui/button/standard_light_16x16"); + public static final UITexture BUTTON_CELESTIAL_32x32 = UITexture.fullImage(MODID, "gui/button/celestial"); + + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_disabled"); + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_off"); + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_ON = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_on"); + public static final UITexture OVERLAY_BUTTON_HEAT_OFF = UITexture.fullImage(MODID, "gui/overlay_button/heat_off"); + public static final UITexture OVERLAY_BUTTON_HEAT_ON = UITexture.fullImage(MODID, "gui/overlay_button/heat_on"); + public static final UITexture[] OVERLAY_BUTTON_UNCERTAINTY = IntStream.range(0, 16) + .mapToObj(i -> UITexture.fullImage(MODID, "gui/overlay_button/uncertainty/" + i)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture OVERLAY_BUTTON_SAFE_VOID_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/safe_void_disabled"); + public static final UITexture OVERLAY_BUTTON_SAFE_VOID_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/safe_void_off"); + public static final UITexture OVERLAY_BUTTON_SAFE_VOID_ON = UITexture + .fullImage(MODID, "gui/overlay_button/safe_void_on"); + public static final UITexture OVERLAY_BUTTON_POWER_PASS_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/power_pass_disabled"); + public static final UITexture OVERLAY_BUTTON_POWER_PASS_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/power_pass_off"); + public static final UITexture OVERLAY_BUTTON_POWER_PASS_ON = UITexture + .fullImage(MODID, "gui/overlay_button/power_pass_on"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_ID = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_id"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_0 = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_0"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_1 = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_1"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_X = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_x"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_S = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_s"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_T = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_t"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_C = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_c"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_IF = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_if"); + public static final UITexture OVERLAY_BUTTON_ARROW_BLUE_UP = UITexture + .fullImage(MODID, "gui/overlay_button/arrow_blue_up"); + public static final UITexture OVERLAY_BUTTON_BATTERY_ON = UITexture + .fullImage(MODID, "gui/overlay_button/battery_on"); + public static final UITexture OVERLAY_BUTTON_BATTERY_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/battery_off"); + public static final UITexture OVERLAY_BUTTON_FLAG = UITexture.fullImage(MODID, "gui/overlay_button/flag"); + public static final UITexture OVERLAY_CYCLIC_BLUE = UITexture.fullImage(MODID, "gui/overlay_button/cyclic_blue"); + + public static final UITexture OVERLAY_SLOT_RACK = UITexture.fullImage(MODID, "gui/overlay_slot/rack"); + public static final UITexture OVERLAY_SLOT_MESH = UITexture.fullImage(MODID, "gui/overlay_slot/mesh"); + + public static final UITexture PROGRESSBAR_RESEARCH_STATION_1 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_1"); + public static final UITexture PROGRESSBAR_RESEARCH_STATION_2 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_2"); + public static final UITexture PROGRESSBAR_RESEARCH_STATION_3 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_3"); + public static final UITexture PROGRESSBAR_GODFORGE_PLASMA = UITexture + .fullImage(MODID, "gui/progressbar/godforge_plasma"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_background"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_BLUE = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_blue"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_red"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_PURPLE = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_purple"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_rainbow"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_BLUE_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_blue_inverted"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RED_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_red_inverted"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_PURPLE_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_purple_inverted"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_rainbow_inverted"); + + public static final UITexture PICTURE_TECTECH_LOGO = UITexture.fullImage(MODID, "gui/picture/tectech_logo"); + public static final UITexture PICTURE_TECTECH_LOGO_DARK = UITexture + .fullImage(MODID, "gui/picture/tectech_logo_dark"); + public static final UITexture PICTURE_GODFORGE_LOGO = UITexture.fullImage(MODID, "gui/picture/gorge_logo"); + public static final UITexture PICTURE_RACK_LARGE = UITexture.fullImage(MODID, "gui/picture/rack_large"); + public static final UITexture PICTURE_HEAT_SINK = UITexture.fullImage(MODID, "gui/picture/heat_sink"); + public static final UITexture PICTURE_UNCERTAINTY_MONITOR = UITexture + .fullImage(MODID, "gui/picture/uncertainty/monitor"); + public static final UITexture PICTURE_UNCERTAINTY_INDICATOR = UITexture + .fullImage(MODID, "gui/picture/uncertainty/indicator"); + public static final UITexture PICTURE_UNCERTAINTY_SELECTED = UITexture + .fullImage(MODID, "gui/picture/uncertainty/selected"); + public static final UITexture[] PICTURE_UNCERTAINTY_VALID = IntStream.range(0, 9) + .mapToObj(i -> UITexture.fullImage(MODID, "gui/picture/uncertainty/valid_" + i)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_UNCERTAINTY_INVALID = IntStream.range(0, 9) + .mapToObj(i -> UITexture.fullImage(MODID, "gui/picture/uncertainty/invalid_" + i)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture PICTURE_HEAT_SINK_SMALL = UITexture.fullImage(MODID, "gui/picture/heat_sink_small"); + public static final UITexture PICTURE_PARAMETER_BLANK = UITexture.fullImage(MODID, "gui/picture/parameter_blank"); + public static final UITexture[] PICTURE_PARAMETER_BLUE = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_blue", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_CYAN = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_cyan", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_GREEN = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_green", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_ORANGE = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_orange", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_RED = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_red", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture PICTURE_PARAMETER_GRAY = UITexture.fullImage(MODID, "gui/picture/parameter_gray"); + public static final UITexture PICTURE_UNCERTAINTY_MONITOR_MULTIMACHINE = UITexture + .fullImage(MODID, "gui/picture/uncertainty/monitor_multimachine"); + public static final UITexture PICTURE_UPGRADE_CONNECTOR_FULL = UITexture.fullImage(MODID, "gui/picture/connector"); + public static final UITexture PICTURE_UPGRADE_CONNECTOR_EMPTY = UITexture + .fullImage(MODID, "gui/picture/connector_empty"); + public static final UITexture PICTURE_UPGRADE_CONNECTOR_SWITCH = UITexture + .fullImage(MODID, "gui/picture/connector_switch"); + public static final UITexture SLOT_OUTLINE_GREEN = UITexture.fullImage(MODID, "gui/picture/green_selector"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CHARGE = UITexture + .fullImage(MODID, "gui/picture/milestone_charge"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CONVERSION = UITexture + .fullImage(MODID, "gui/picture/milestone_conversion"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CATALYST = UITexture + .fullImage(MODID, "gui/picture/milestone_catalyst"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_COMPOSITION = UITexture + .fullImage(MODID, "gui/picture/milestone_composition"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CHARGE_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_charge_glow"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CONVERSION_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_conversion_glow"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CATALYST_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_catalyst_glow"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_COMPOSITION_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_composition_glow"); + public static final UITexture PICTURE_OVERLAY_BLUE = UITexture.fullImage(MODID, "gui/picture/overlay_blue"); + public static final UITexture PICTURE_OVERLAY_ORANGE = UITexture.fullImage(MODID, "gui/picture/overlay_orange"); + public static final UITexture PICTURE_OVERLAY_GREEN = UITexture.fullImage(MODID, "gui/picture/overlay_green"); + public static final UITexture PICTURE_OVERLAY_PURPLE = UITexture.fullImage(MODID, "gui/picture/overlay_purple"); + +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/AstralArrayFabricator.java b/src/main/java/com/github/technus/tectech/thing/item/AstralArrayFabricator.java new file mode 100644 index 0000000000..f0d0df6206 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/AstralArrayFabricator.java @@ -0,0 +1,53 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +import static com.github.technus.tectech.thing.CustomItemList.astralArrayFabricator; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class AstralArrayFabricator extends Item { + + public static AstralArrayFabricator INSTANCE; + + private AstralArrayFabricator() { + setHasSubtypes(false); + setUnlocalizedName("tm.itemAstralArrayFabricator"); + setTextureName(MODID + ":itemAstralArray"); + setCreativeTab(creativeTabTecTech); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc1")); + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc2")); + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc3")); + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("item.tm.itemAstralArrayFabricator.desc0")); + } + + public static void run() { + INSTANCE = new AstralArrayFabricator(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + astralArrayFabricator.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/EnderFluidLinkCover.java b/src/main/java/com/github/technus/tectech/thing/item/EnderFluidLinkCover.java new file mode 100644 index 0000000000..00a1c29599 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/EnderFluidLinkCover.java @@ -0,0 +1,56 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.enderLinkFluidCover; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public final class EnderFluidLinkCover extends Item { + + public static EnderFluidLinkCover INSTANCE; + + private EnderFluidLinkCover() { + setHasSubtypes(true); + setUnlocalizedName("tm.enderfluidlinkcover"); + setTextureName(MODID + ":itemEnderFluidLinkCover"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.tm.enderfluidlinkcover.desc.0")); // Ender-Fluid-Enables Machines! + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.enderfluidlinkcover.desc.1")); // Use on any side + // of a fluid tank + // to link it to + // the Ender + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.enderfluidlinkcover.desc.2")); // Ender Tanks so + // are laggy -Bot + // from the Chads + // of NH + } + + public static void run() { + INSTANCE = new EnderFluidLinkCover(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + enderLinkFluidCover.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java new file mode 100644 index 0000000000..f293f4178b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java @@ -0,0 +1,169 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +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; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; +import gregtech.api.util.GT_Utility; + +public class EuMeterGT extends Item { + + public static EuMeterGT INSTANCE; + + private EuMeterGT() { + setMaxStackSize(1); + setUnlocalizedName("em.EuMeterGT"); + setTextureName(MODID + ":itemEuMeterGT"); + setCreativeTab(creativeTabTecTech); + } + + @Override + public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity == null || aPlayer instanceof FakePlayer) { + return aPlayer instanceof EntityPlayerMP; + } + if (aPlayer instanceof EntityPlayerMP && !aPlayer.isSneaking() && tTileEntity instanceof IGregTechTileEntity) { + String clientLocale; + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + + if (tTileEntity instanceof BaseMetaTileEntity) { + GT_Utility.sendChatToPlayer( + aPlayer, + EnumChatFormatting.AQUA + "----- X:" + + aX + + " Y:" + + aY + + " Z:" + + aZ + + " D:" + + aWorld.provider.dimensionId + + " S:" + + ordinalSide + + " -----"); + GT_Utility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Stored_energy", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getUniversalEnergyStored()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GREEN + + (((BaseMetaTileEntity) tTileEntity).getUniversalEnergyCapacity())); + GT_Utility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Stored_EU", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getStoredEU()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GREEN + + (((BaseMetaTileEntity) tTileEntity).getEUCapacity())); + GT_Utility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Average_IO", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getAverageElectricInput()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getAverageElectricOutput())); + GT_Utility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Average_IO_(max)", clientLocale) + ": " + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getInputVoltage()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getOutputVoltage())); + GT_Utility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Average_IO_max", clientLocale) + ": " + + EnumChatFormatting.RED + + (((BaseMetaTileEntity) tTileEntity).getMaxSafeInput()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.RED + + (((BaseMetaTileEntity) tTileEntity).getMaxEnergyOutput())); + GT_Utility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Amperage_IO_(max)", clientLocale) + ": " + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getInputAmperage()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getOutputAmperage())); + GT_Utility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Side_capabilities", clientLocale) + ": " + + (((BaseMetaTileEntity) tTileEntity).inputEnergyFrom(side) + ? translateToLocalFormatted("tt.keyword.input", clientLocale) + " " + : "") + + (((BaseMetaTileEntity) tTileEntity).outputsEnergyTo(side) + ? translateToLocalFormatted("tt.keyword.output", clientLocale) + : "")); + return true; + } else if (tTileEntity instanceof BaseMetaPipeEntity) { + if (((BaseMetaPipeEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable) { + ArrayList tList = new ArrayList<>(); + GT_Utility.getCoordinateScan(tList, aPlayer, aWorld, 1, aX, aY, aZ, side, hitX, hitY, hitZ); + for (String str : tList) { + GT_Utility.sendChatToPlayer(aPlayer, str); + } + } + return true; + } + } + if (!(aPlayer instanceof EntityPlayerMP)) { + GT_Utility.doSoundAtClient(new ResourceLocation(Reference.MODID, "fx_scan"), 1, 1.0F, aX, aY, aZ); + } + return false; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.TEC_MARK_GENERAL); + aList.add(translateToLocal("item.em.EuMeterGT.desc.0")); // Measures basic EU related stuff + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.EuMeterGT.desc.1")); // Just right click on + // blocks. + } + + public static void run() { + INSTANCE = new EuMeterGT(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java new file mode 100644 index 0000000000..753bb691b9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java @@ -0,0 +1,234 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +import static com.github.technus.tectech.thing.CustomItemList.parametrizerMemory; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.Constants; + +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_ParamText; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +/** + * Created by Tec on 15.03.2017. + */ +public final class ParametrizerMemoryCard extends Item { + + public static ParametrizerMemoryCard INSTANCE; + private static IIcon locked, unlocked; + + private ParametrizerMemoryCard() { + setMaxStackSize(1); + setHasSubtypes(true); + setUnlocalizedName("em.parametrizerMemoryCard"); + setTextureName(MODID + ":itemParametrizerMemoryCardUnlocked"); + setCreativeTab(creativeTabTecTech); + } + + @Override + public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(aPlayer instanceof EntityPlayerMP)) return false; + if (!(tTileEntity instanceof IGregTechTileEntity)) return false; + aStack.stackSize = 1; + IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + + if (metaTE instanceof GT_MetaTileEntity_Hatch_ParamText parametrizer) { + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (aStack.getItemDamage() == 1) { + // write to parametrizer + parametrizer.param = tNBT.getInteger("param"); + parametrizer.value0D = tNBT.getDouble("value0D"); + parametrizer.value1D = tNBT.getDouble("value1D"); + parametrizer.value0s = tNBT.getString("value0s"); + parametrizer.value1s = tNBT.getString("value1s"); + } else { + // read from parametrizer + NBTTagCompound newTag = new NBTTagCompound(); + newTag.setInteger("param", parametrizer.param); + newTag.setDouble("value0D", parametrizer.value0D); + newTag.setDouble("value1D", parametrizer.value1D); + newTag.setString("value0s", parametrizer.value0s); + newTag.setString("value1s", parametrizer.value1s); + aStack.setTagCompound(newTag); + } + return true; + } else if (metaTE instanceof GT_MetaTileEntity_Hatch_Param parametrizer) { + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (aStack.getItemDamage() == 1) { + // write to parametrizer + parametrizer.param = tNBT.getInteger("param"); + parametrizer.value0D = tNBT.getDouble("value0D"); + parametrizer.value1D = tNBT.getDouble("value1D"); + } else { + // read from parametrizer + NBTTagCompound newTag = new NBTTagCompound(); + tNBT.setInteger("param", parametrizer.param); + tNBT.setDouble("value0D", parametrizer.value0D); + tNBT.setDouble("value1D", parametrizer.value1D); + aStack.setTagCompound(newTag); + } + return true; + } else if (metaTE instanceof GT_MetaTileEntity_MultiblockBase_EM controller) { + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (aStack.getItemDamage() == 1) { + // write to controller + if (tNBT.hasKey("paramList", Constants.NBT.TAG_LIST)) { + // from controller + NBTTagList tagList = tNBT.getTagList("paramList", Constants.NBT.TAG_COMPOUND); + for (int hatch = 0; hatch < 10; hatch++) { + NBTTagCompound tag = tagList.getCompoundTagAt(hatch); + controller.parametrization + .trySetParameters(hatch, tag.getDouble("value0D"), tag.getDouble("value1D")); + } + } else { + // from parametrizer + controller.parametrization.trySetParameters( + tNBT.getInteger("param"), + tNBT.getDouble("value0D"), + tNBT.getDouble("value1D")); + } + } else { + // read from controller + NBTTagCompound newTag = new NBTTagCompound(); + NBTTagList tagList = new NBTTagList(); + for (int hatch = 0; hatch < 10; hatch++) { + NBTTagCompound tagChild = new NBTTagCompound(); + Parameters.Group.ParameterIn[] parameters = controller.parametrization.getGroup(hatch).parameterIn; + if (parameters[0] != null) { + tagChild.setDouble("value0D", parameters[0].get()); + } + if (parameters[1] != null) { + tagChild.setDouble("value1D", parameters[1].get()); + } + tagList.appendTag(tagChild); + } + newTag.setTag("paramList", tagList); + aStack.setTagCompound(newTag); + } + return true; + } + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (aPlayer instanceof EntityPlayerMP && aPlayer.isSneaking()) { + aStack.stackSize = 1; + if (aStack.getItemDamage() == 1) { + aStack.setItemDamage(0); + } else { + aStack.setItemDamage(1); + } + return aStack; + } + return aStack; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + if (stack.getItemDamage() == 1) { + return StatCollector.translateToLocal("item.em.parametrizerMemoryCard.name.paste"); + } else { + return StatCollector.translateToLocal("item.em.parametrizerMemoryCard.name.copy"); + } + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + NBTTagCompound tNBT = aStack.getTagCompound(); + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.em.parametrizerMemoryCard.desc.0")); // Stores Parameters + + if (aStack.getItemDamage() == 1) { + // Use on Multiblock Controller to configure it + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.parametrizerMemoryCard.desc.1")); + } else { + // Use on Multiblock Controller to store parameters + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.parametrizerMemoryCard.desc.2")); + } + // Sneak right click to lock/unlock + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.parametrizerMemoryCard.desc.3")); + + double temp; + if (tNBT != null && tNBT.hasKey("param")) { + aList.add("Hatch ID: " + EnumChatFormatting.AQUA + tNBT.getInteger("param")); + temp = tNBT.getInteger("value0D"); + aList.add("Value 0D: " + EnumChatFormatting.AQUA + temp); + aList.add( + "Value 0B: " + EnumChatFormatting.AQUA + + TT_Utility.longBitsToShortString(Double.doubleToLongBits(temp))); + aList.add("Value 0s: " + EnumChatFormatting.AQUA + tNBT.getString("value0s")); + temp = tNBT.getInteger("value1D"); + aList.add("Value 1D: " + EnumChatFormatting.AQUA + temp); + aList.add( + "Value 1B: " + EnumChatFormatting.AQUA + + TT_Utility.longBitsToShortString(Double.doubleToLongBits(temp))); + aList.add("Value 1s: " + EnumChatFormatting.AQUA + tNBT.getString("value1s")); + } + } + + public static void run() { + INSTANCE = new ParametrizerMemoryCard(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + parametrizerMemory.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + locked = iconRegister.registerIcon(MODID + ":itemParametrizerMemoryCardLocked"); + unlocked = itemIcon = iconRegister.registerIcon(getIconString()); + } + + @Override + public IIcon getIconFromDamage(int damage) { + if (damage == 1) { + return locked; + } + return unlocked; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + ItemStack that = new ItemStack(this, 1); + that.setTagCompound(new NBTTagCompound()); + list.add(that); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/PowerPassUpgradeCover.java b/src/main/java/com/github/technus/tectech/thing/item/PowerPassUpgradeCover.java new file mode 100644 index 0000000000..015d284c4e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/PowerPassUpgradeCover.java @@ -0,0 +1,55 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.powerPassUpgradeCover; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public final class PowerPassUpgradeCover extends Item { + + public static PowerPassUpgradeCover INSTANCE; + + private PowerPassUpgradeCover() { + setHasSubtypes(true); + setUnlocalizedName("tm.powerpassupgradecover"); + setTextureName(MODID + ":itemPowerPassUpgradeCover"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.tm.powerpassupgradecover.desc.0")); // Add power pass functionality to TecTech + // Multiblocks + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.powerpassupgradecover.desc.1")); // Active + // transformer in + // a can?? + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.powerpassupgradecover.desc.2")); // Chain them up + // like Christmas + // lights! + } + + public static void run() { + INSTANCE = new PowerPassUpgradeCover(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + powerPassUpgradeCover.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/RenderForgeOfGodsItem.java b/src/main/java/com/github/technus/tectech/thing/item/RenderForgeOfGodsItem.java new file mode 100644 index 0000000000..35f2199663 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/RenderForgeOfGodsItem.java @@ -0,0 +1,91 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.rendering.EOH.EOH_TESR.*; +import static java.lang.Math.pow; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +public class RenderForgeOfGodsItem implements IItemRenderer { + + @Override + public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) { + return true; + } + + @Override + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, + IItemRenderer.ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + + if (type == IItemRenderer.ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); + else if (type == IItemRenderer.ItemRenderType.EQUIPPED + || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0.5, 0.5, 0.5); + if (type == IItemRenderer.ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0); + } + + // Render star stuff + renderStarLayer(0, STAR_LAYER_0, 1.0f); + renderStarLayer(1, STAR_LAYER_1, 0.4f); + renderStarLayer(2, STAR_LAYER_2, 0.2f); + + GL11.glPopMatrix(); + } + + private void renderStarLayer(int layer, ResourceLocation texture, float alpha) { + + GL11.glPushMatrix(); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + FMLClientHandler.instance() + .getClient() + .getTextureManager() + .bindTexture(texture); + + // 0.01f magic number to shrink sphere obj down + float scale = 0.01f; + + // Put each layer further out + scale *= pow(1.04f, layer); + + // Scale the star up in the x, y and z directions + GL11.glScalef(scale, scale, scale); + + switch (layer) { + case 0: + GL11.glRotatef(130 + (System.currentTimeMillis() / 64) % 360, 0F, 1F, 1F); + break; + case 1: + GL11.glRotatef(-49 + (System.currentTimeMillis() / 64) % 360, 1F, 1F, 0F); + break; + case 2: + GL11.glRotatef(67 + (System.currentTimeMillis() / 64) % 360, 1F, 0F, 1F); + break; + } + + // Set colour and alpha of the star layer + GL11.glColor4f(222, 243, 250, alpha); + + starModel.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LIGHTING); + + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java new file mode 100644 index 0000000000..6e292bc9c7 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java @@ -0,0 +1,108 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.teslaCapacitor; +import static com.github.technus.tectech.util.CommonValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public final class TeslaCoilCapacitor extends Item { + + public static TeslaCoilCapacitor INSTANCE; + private static IIcon LVicon, MVicon, HVicon, EVicon, IVicon, LuVicon, ZPMicon; + + private TeslaCoilCapacitor() { + setHasSubtypes(true); + setUnlocalizedName("tm.teslaCoilCapacitor"); + setTextureName(MODID + ":itemCapacitorLV"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + if (aStack.getItemDamage() >= 0 && aStack.getItemDamage() <= 6) { + aList.add( + translateToLocal("item.tm.teslaCoilCapacitor.desc.0") + " " + + V[aStack.getItemDamage() + 1] * 512 + + " " + + translateToLocal("item.tm.teslaCoilCapacitor.desc.1") + + " " + + V[aStack.getItemDamage() + 1] + + " EU/t"); // Stores 16384 EU in a tesla tower at 32 EU/t + } else { + aList.add(translateToLocal("item.tm.teslaCoilCapacitor.desc.2")); // Yeet this broken item into some spicy + // water! + } + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCoilCapacitor.desc.3")); // Insert into a + // Capacitor hatch + // of a Tesla Tower + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCoilCapacitor.desc.4")); // Capacitors are + // the same thing as + // batteries, right? + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return getUnlocalizedName() + "." + getDamage(aStack); + } + + public static void run() { + INSTANCE = new TeslaCoilCapacitor(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + teslaCapacitor.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + LVicon = itemIcon = iconRegister.registerIcon(getIconString()); + MVicon = iconRegister.registerIcon(MODID + ":itemCapacitorMV"); + HVicon = iconRegister.registerIcon(MODID + ":itemCapacitorHV"); + EVicon = iconRegister.registerIcon(MODID + ":itemCapacitorEV"); + IVicon = iconRegister.registerIcon(MODID + ":itemCapacitorIV"); + LuVicon = iconRegister.registerIcon(MODID + ":itemCapacitorLuV"); + ZPMicon = iconRegister.registerIcon(MODID + ":itemCapacitorZPM"); + } + + @Override + public IIcon getIconFromDamage(int damage) { + switch (damage) { + case 1: + return MVicon; + case 2: + return HVicon; + case 3: + return EVicon; + case 4: + return IVicon; + case 5: + return LuVicon; + case 6: + return ZPMicon; + default: + return LVicon; + } + } + + @Override + public void getSubItems(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i <= 6; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilComponent.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilComponent.java new file mode 100644 index 0000000000..b4f1d33382 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilComponent.java @@ -0,0 +1,72 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.teslaComponent; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public final class TeslaCoilComponent extends Item { + + public static TeslaCoilComponent INSTANCE; + private static IIcon ultItemIcon; + + private TeslaCoilComponent() { + setHasSubtypes(true); + setUnlocalizedName("tm.itemTeslaComponent"); + setTextureName(MODID + ":itemTeslaComponent"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.itemTeslaComponent.desc")); // Tesla bois need + // these! + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return getUnlocalizedName() + "." + getDamage(aStack); + } + + public static void run() { + INSTANCE = new TeslaCoilComponent(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + teslaComponent.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + ultItemIcon = iconRegister.registerIcon(MODID + ":itemTeslaComponentUltimate"); + } + + @Override + public IIcon getIconFromDamage(int damage) { + if (damage == 1) { + return ultItemIcon; + } + return itemIcon; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 1)); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCover.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCover.java new file mode 100644 index 0000000000..3ee7fd3e93 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCover.java @@ -0,0 +1,87 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.teslaCover; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public final class TeslaCoilCover extends Item { + + public static TeslaCoilCover INSTANCE; + private static IIcon ultItemIcon; + + private TeslaCoilCover() { + setHasSubtypes(true); + setUnlocalizedName("tm.teslaCover"); + setTextureName(MODID + ":itemTeslaCover"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + switch (aStack.getItemDamage()) { + case 0: + aList.add(translateToLocal("item.tm.teslaCover.desc.0")); // Tesla-Enables Machines! + break; + case 1: + aList.add(translateToLocal("item.tm.teslaCover.desc.1")); // Tesla-Enables Machines! (BUT LOUDER!!) + break; + default: + aList.add(translateToLocal("item.tm.teslaCover.desc.2")); // Yeet this broken item into some spicy + // water! + break; + } + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCover.desc.3")); // Use on top of a machine + // to enable Tesla + // capabilities + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCover.desc.4")); // Who the hell uses cables + // anyway? + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return getUnlocalizedName() + "." + getDamage(aStack); + } + + public static void run() { + INSTANCE = new TeslaCoilCover(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + teslaCover.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + ultItemIcon = iconRegister.registerIcon(MODID + ":itemTeslaCoverUltimate"); + } + + @Override + public IIcon getIconFromDamage(int damage) { + if (damage == 1) { + return ultItemIcon; + } + return itemIcon; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 1)); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java new file mode 100644 index 0000000000..88028f910c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java @@ -0,0 +1,54 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.teslaStaff; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_Utility; + +public final class TeslaStaff extends Item { + + public static TeslaStaff INSTANCE; + + private TeslaStaff() { + setUnlocalizedName("tm.teslaStaff"); + setTextureName(MODID + ":itemTeslaStaff"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.tm.teslaStaff.desc")); + } + + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer aPlayer, Entity entity) { + GT_Utility.sendChatToPlayer(aPlayer, "Zapperoni!"); + if (!(aPlayer instanceof EntityPlayerMP)) { + double aX = aPlayer.posX; + double aY = aPlayer.posY; + double aZ = aPlayer.posZ; + GT_Utility.doSoundAtClient(new ResourceLocation(Reference.MODID, "fx_scan"), 1, 1.0F, aX, aY, aZ); + } + return false; + } + + public static void run() { + INSTANCE = new TeslaStaff(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + teslaStaff.set(INSTANCE); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java new file mode 100644 index 0000000000..cd4d743587 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java @@ -0,0 +1,318 @@ +package com.github.technus.tectech.thing.metaTileEntity; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static gregtech.api.enums.Textures.BlockIcons.CustomIcon; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_8V_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_8V_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_8V_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_EV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_EV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_EV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_HV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_HV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_HV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_IV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_IV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_IV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LuV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LuV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LuV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MAX_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MAX_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MAX_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_UV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_UV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_UV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_ZPM_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_ZPM_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_ZPM_TOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_IN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_IN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_IN_MULTI; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_ON_WIRELESS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_OUT; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_OUT_MULTI; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.GT_SidedTexture; +import gregtech.api.render.TextureFactory; + +public class Textures { + + private static final IIconContainer OVERLAY_ENERGY_IN_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_IN_POWER"); + private static final IIconContainer OVERLAY_ENERGY_OUT_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_POWER"); + private static final IIconContainer OVERLAY_ENERGY_IN_LASER = new CustomIcon("iconsets/OVERLAY_ENERGY_IN_LASER"); + private static final IIconContainer OVERLAY_ENERGY_OUT_LASER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_LASER"); + private static final IIconContainer OVERLAY_ENERGY_ON_WIRELESS_4A = new CustomIcon( + "iconsets/OVERLAY_ENERGY_ON_WIRELESS_4A"); + private static final IIconContainer OVERLAY_ENERGY_ON_WIRELESS_16A = new CustomIcon( + "iconsets/OVERLAY_ENERGY_ON_WIRELESS_16A"); + private static final IIconContainer OVERLAY_ENERGY_ON_WIRELESS_LASER = new CustomIcon( + "iconsets/OVERLAY_ENERGY_ON_WIRELESS_LASER"); + private static final IIconContainer MACHINE_UEV_SIDE = new CustomIcon("iconsets/MACHINE_UEV_SIDE"); + private static final IIconContainer MACHINE_UIV_SIDE = new CustomIcon("iconsets/MACHINE_UIV_SIDE"); + private static final IIconContainer MACHINE_UMV_SIDE = new CustomIcon("iconsets/MACHINE_UMV_SIDE"); + private static final IIconContainer MACHINE_UXV_SIDE = new CustomIcon("iconsets/MACHINE_UXV_SIDE"); + private static final IIconContainer MACHINE_MAXV_SIDE = new CustomIcon("iconsets/MACHINE_MAXV_SIDE"); + private static final IIconContainer MACHINE_UEV_TOP = new CustomIcon("iconsets/MACHINE_UEV_TOP"); + private static final IIconContainer MACHINE_UIV_TOP = new CustomIcon("iconsets/MACHINE_UIV_TOP"); + private static final IIconContainer MACHINE_UMV_TOP = new CustomIcon("iconsets/MACHINE_UMV_TOP"); + private static final IIconContainer MACHINE_UXV_TOP = new CustomIcon("iconsets/MACHINE_UXV_TOP"); + private static final IIconContainer MACHINE_MAXV_TOP = new CustomIcon("iconsets/MACHINE_MAXV_TOP"); + private static final IIconContainer MACHINE_UEV_BOTTOM = new CustomIcon("iconsets/MACHINE_UEV_BOTTOM"); + private static final IIconContainer MACHINE_UIV_BOTTOM = new CustomIcon("iconsets/MACHINE_UIV_BOTTOM"); + private static final IIconContainer MACHINE_UMV_BOTTOM = new CustomIcon("iconsets/MACHINE_UMV_BOTTOM"); + private static final IIconContainer MACHINE_UXV_BOTTOM = new CustomIcon("iconsets/MACHINE_UXV_BOTTOM"); + private static final IIconContainer MACHINE_MAXV_BOTTOM = new CustomIcon("iconsets/MACHINE_MAXV_BOTTOM"); + + private static final IIconContainer TESLA_TRANSCEIVER_TOP = new CustomIcon("iconsets/TESLA_TRANSCEIVER_TOP"); + + public static IIconContainer[] MACHINECASINGS_SIDE_TT = new IIconContainer[] { MACHINE_8V_SIDE, MACHINE_LV_SIDE, + MACHINE_MV_SIDE, MACHINE_HV_SIDE, MACHINE_EV_SIDE, MACHINE_IV_SIDE, MACHINE_LuV_SIDE, MACHINE_ZPM_SIDE, + MACHINE_UV_SIDE, MACHINE_MAX_SIDE, MACHINE_UEV_SIDE, MACHINE_UIV_SIDE, MACHINE_UMV_SIDE, MACHINE_UXV_SIDE, + MACHINE_MAXV_SIDE, }, + MACHINECASINGS_TOP_TT = new IIconContainer[] { MACHINE_8V_TOP, MACHINE_LV_TOP, MACHINE_MV_TOP, MACHINE_HV_TOP, + MACHINE_EV_TOP, MACHINE_IV_TOP, MACHINE_LuV_TOP, MACHINE_ZPM_TOP, MACHINE_UV_TOP, MACHINE_MAX_TOP, + MACHINE_UEV_TOP, MACHINE_UIV_TOP, MACHINE_UMV_TOP, MACHINE_UXV_TOP, MACHINE_MAXV_TOP, }, + MACHINECASINGS_BOTTOM_TT = new IIconContainer[] { MACHINE_8V_BOTTOM, MACHINE_LV_BOTTOM, MACHINE_MV_BOTTOM, + MACHINE_HV_BOTTOM, MACHINE_EV_BOTTOM, MACHINE_IV_BOTTOM, MACHINE_LuV_BOTTOM, MACHINE_ZPM_BOTTOM, + MACHINE_UV_BOTTOM, MACHINE_MAX_BOTTOM, MACHINE_UEV_BOTTOM, MACHINE_UIV_BOTTOM, MACHINE_UMV_BOTTOM, + MACHINE_UXV_BOTTOM, MACHINE_MAXV_BOTTOM, }; + public static ITexture[] OVERLAYS_ENERGY_IN_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_IN_MULTI_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_MULTI_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_IN_POWER_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_POWER_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_IN_LASER_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_LASER_TT = new ITexture[] { + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 180, 180, 180, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 220, 220, 220, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 255, 100, 0, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 255, 255, 30, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 128, 128, 128, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 240, 240, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 220, 220, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 200, 200, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 180, 180, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 160, 160, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 140, 140, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 120, 120, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 100, 100, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 80, 80, 245, 0 }), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 60, 60, 245, 0 }), }; + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_MULTI_4A = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }) }; + + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_MULTI_16A = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }) }; + + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_MULTI_64A = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }) }; + + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_LASER = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }) }; + + public static ITexture[][] MACHINE_CASINGS_TT = new ITexture[15][17]; + + public static ITexture TESLA_TRANSCEIVER_TOP_BA = new GT_RenderedTexture(TESLA_TRANSCEIVER_TOP); + + public static void run() { + for (byte i = 0; i < MACHINE_CASINGS_TT.length; i++) { + for (byte j = 0; j < MACHINE_CASINGS_TT[i].length; j++) { + MACHINE_CASINGS_TT[i][j] = new GT_SidedTexture( + MACHINECASINGS_BOTTOM_TT[i], + MACHINECASINGS_TOP_TT[i], + MACHINECASINGS_SIDE_TT[i], + Dyes.getModulation(j - 1, MACHINE_METAL.mRGBa)); + } + } + MACHINE_CASINGS = MACHINE_CASINGS_TT; + + // These will throw IndexOutOfBoundsException if one of the arrays are the wrong length + System.arraycopy(OVERLAYS_ENERGY_IN_TT, 0, OVERLAYS_ENERGY_IN, 0, OVERLAYS_ENERGY_IN_TT.length); + System.arraycopy(OVERLAYS_ENERGY_OUT_TT, 0, OVERLAYS_ENERGY_OUT, 0, OVERLAYS_ENERGY_OUT_TT.length); + System + .arraycopy(OVERLAYS_ENERGY_IN_MULTI_TT, 0, OVERLAYS_ENERGY_IN_MULTI, 0, OVERLAYS_ENERGY_IN_MULTI_TT.length); + System.arraycopy( + OVERLAYS_ENERGY_OUT_MULTI_TT, + 0, + OVERLAYS_ENERGY_OUT_MULTI, + 0, + OVERLAYS_ENERGY_OUT_MULTI_TT.length); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java new file mode 100644 index 0000000000..3cb7a93f77 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java @@ -0,0 +1,268 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.github.technus.tectech.util.TT_Utility.getUniqueIdentifier; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; + +/** + * Created by Tec on 03.04.2017. + */ +public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch implements IAddUIWidgets { + + private static Textures.BlockIcons.CustomIcon TM_H; + private static Textures.BlockIcons.CustomIcon TM_H_ACTIVE; + private static final Map componentBinds = new HashMap<>(); + + public GT_MetaTileEntity_Hatch_Capacitor(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 16, + new String[] { CommonValues.THETA_MOVEMENT, translateToLocal("gt.blockmachines.hatch.capacitor.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.capacitor.desc.1") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_Capacitor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + TM_H_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_CAPS_ACTIVE"); + TM_H = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_CAPS"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(TM_H_ACTIVE) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(TM_H) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Capacitor(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public int getSizeInventory() { + return getBaseMetaTileEntity().isActive() ? 0 : mInventory.length; + } + + public long[] getCapacitors() { + long tier = -1; + long tCurrent = 0; + long tEnergyMax = 0; + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + CapacitorComponent cap = componentBinds.get(getUniqueIdentifier(mInventory[i])); + if (cap != null && cap.tier > tier) { + tier = cap.tier; + } + } + if (tier >= 0) { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + CapacitorComponent cap = componentBinds.get(getUniqueIdentifier(mInventory[i])); + if (cap == null) { + continue; + } + if (cap.tier < tier) { + if (getBaseMetaTileEntity().isActive()) { + mInventory[i] = null; + getBaseMetaTileEntity().setOnFire(); + } + } else { + tCurrent += cap.current; + tEnergyMax += cap.energyMax; + } + } + } + return new long[] { tier, tCurrent, tEnergyMax }; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 4) + .startFromSlot(0) + .endAtSlot(15) + .slotCreator(index -> new BaseSlot(inventoryHandler, index) { + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean isEnabled() { + return !getBaseMetaTileEntity().isActive(); + } + }) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(52, 7)); + } + + public static void run() { + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent( + Reference.MODID + ":item.tm.teslaCoilCapacitor.0", + 0, + 1, + V[1] * 512); // LV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent( + Reference.MODID + ":item.tm.teslaCoilCapacitor.1", + 1, + 1, + V[2] * 512); // MV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent( + Reference.MODID + ":item.tm.teslaCoilCapacitor.2", + 2, + 1, + V[3] * 512); // HV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent( + Reference.MODID + ":item.tm.teslaCoilCapacitor.3", + 3, + 1, + V[4] * 512); // EV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent( + Reference.MODID + ":item.tm.teslaCoilCapacitor.4", + 4, + 1, + V[5] * 512); // IV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent( + Reference.MODID + ":item.tm.teslaCoilCapacitor.5", + 5, + 1, + V[6] * 512); // LuV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent( + Reference.MODID + ":item.tm.teslaCoilCapacitor.6", + 6, + 1, + V[7] * 512); // ZPM Capacitor + } + + public static class CapacitorComponent implements Comparable { + + private final String unlocalizedName; + private final long tier, current, energyMax; + + CapacitorComponent(ItemStack is, long tier, long current, long energyMax) { + this(getUniqueIdentifier(is), tier, current, energyMax); + } + + CapacitorComponent(String is, long tier, long current, long energyMax) { + unlocalizedName = is; + this.tier = tier; + this.current = current; + this.energyMax = energyMax; + componentBinds.put(unlocalizedName, this); + if (DEBUG_MODE) { + TecTech.LOGGER.info("Tesla Capacitor registered: " + unlocalizedName); + } + } + + @Override + public int compareTo(CapacitorComponent o) { + return unlocalizedName.compareTo(o.unlocalizedName); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof CapacitorComponent) { + return compareTo((CapacitorComponent) obj) == 0; + } + return false; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java new file mode 100644 index 0000000000..e4b279e46d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java @@ -0,0 +1,133 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.util.CommonValues.MOVE_AT; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; +import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class GT_MetaTileEntity_Hatch_CreativeData extends GT_MetaTileEntity_Hatch_DataConnector { + + public GT_MetaTileEntity_Hatch_CreativeData(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.debug.tt.data.desc.0"), + translateToLocal("gt.blockmachines.debug.tt.data.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.debug.tt.data.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_CreativeData(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_CreativeData(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new QuantumDataPacket(nbt); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isOutputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + IConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof GT_MetaTileEntity_Hatch_InputData) { + ((GT_MetaTileEntity_Hatch_InputData) next).setContents(q); + break; + } + source = current; + current = next; + } + q = null; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source /* ==this */) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); + if (color < 0) { + return null; + } + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + if (next == null) { + return null; + } + IMetaTileEntity meta = next.getMetaTileEntity(); + if (meta instanceof GT_MetaTileEntity_Pipe_Data) { + ((GT_MetaTileEntity_Pipe_Data) meta).markUsed(); + return (IConnectsToDataPipe) meta; + } else if (meta instanceof GT_MetaTileEntity_Hatch_InputData + && ((GT_MetaTileEntity_Hatch_InputData) meta).getColorization() == color + && ((GT_MetaTileEntity_Hatch_InputData) meta).canConnectData( + base.getFrontFacing() + .getOpposite())) { + return (IConnectsToDataPipe) meta; + } + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (MOVE_AT == aTick % 20) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + getBaseMetaTileEntity().setActive(true); + if (q == null) q = new QuantumDataPacket(0xFFFFFFFFL); + moveAround(aBaseMetaTileEntity); + } else { + q = null; + getBaseMetaTileEntity().setActive(false); + } + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java new file mode 100644 index 0000000000..b62375076b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java @@ -0,0 +1,96 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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_Maintenance; +import gregtech.api.objects.GT_RenderedTexture; + +public class GT_MetaTileEntity_Hatch_CreativeMaintenance extends GT_MetaTileEntity_Hatch_Maintenance { + + private static Textures.BlockIcons.CustomIcon face; + + public GT_MetaTileEntity_Hatch_CreativeMaintenance(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_CreativeMaintenance(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures, false); + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.THETA_MOVEMENT, + translateToLocal("gt.blockmachines.debug.tt.maintenance.desc.0"), // For automatically maintaining + // Multiblocks + translateToLocal("gt.blockmachines.debug.tt.maintenance.desc.1"), // Does fix everything but itself. + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.debug.tt.maintenance.desc.2") // Fixing is + // for plebs! + }; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + face = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_FULLAUTOMAINTENANCE"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(face) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(face) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_CreativeMaintenance( + this.mName, + this.mTier, + this.mDescriptionArray, + this.mTextures); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.mWrench = this.mScrewdriver = this.mSoftHammer = this.mHardHammer = this.mCrowbar = this.mSolderingTool = true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeUncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeUncertainty.java new file mode 100644 index 0000000000..fa295721e5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeUncertainty.java @@ -0,0 +1,58 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.util.EnumChatFormatting; + +import com.github.technus.tectech.util.CommonValues; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GT_MetaTileEntity_Hatch_CreativeUncertainty extends GT_MetaTileEntity_Hatch_Uncertainty { + + public GT_MetaTileEntity_Hatch_CreativeUncertainty(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_CreativeUncertainty(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Hatch_CreativeUncertainty(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.debug.tt.certain.desc.0"), // Feeling + // certain, + // for + // sure + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.debug.tt.certain.desc.1") // Schrödinger's cat escaped the + // box + }; + } + + @Override + public void regenerate() { + // no-op + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && (aTick % 100) == 0) { + if (mode == 0) { + aBaseMetaTileEntity.setActive(false); + status = -128; + } else { + aBaseMetaTileEntity.setActive(true); + compute(); + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java new file mode 100644 index 0000000000..e0ea91f090 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java @@ -0,0 +1,202 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.util.CommonValues.MOVE_AT; +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.mechanics.dataTransport.DataPacket; +import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.util.TT_Utility; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; + +/** + * Created by danie_000 on 11.12.2016. + */ +public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileEntity_Hatch + implements IConnectsToDataPipe { + + public static Textures.BlockIcons.CustomIcon EM_D_SIDES; + public static Textures.BlockIcons.CustomIcon EM_D_ACTIVE; + public static Textures.BlockIcons.CustomIcon EM_D_CONN; + + private String clientLocale = "en_US"; + + public T q; + + public short id = -1; + + protected GT_MetaTileEntity_Hatch_DataConnector(int aID, String aName, String aNameRegional, int aTier, + String[] descr) { + super(aID, aName, aNameRegional, aTier, 0, descr); + TT_Utility.setTier(aTier, this); + } + + protected GT_MetaTileEntity_Hatch_DataConnector(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_D_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_D_ACTIVE"); + EM_D_SIDES = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_D_SIDES"); + EM_D_CONN = new Textures.BlockIcons.CustomIcon("iconsets/EM_DATA_CONN"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GT_RenderedTexture( + EM_D_ACTIVE, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GT_RenderedTexture(EM_D_CONN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GT_RenderedTexture( + EM_D_SIDES, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GT_RenderedTexture(EM_D_CONN) }; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setShort("eID", id); + if (q != null) { + aNBT.setTag("eDATA", q.toNbt()); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + id = aNBT.getShort("eID"); + if (aNBT.hasKey("eDATA")) { + q = loadPacketFromNBT(aNBT.getCompoundTag("eDATA")); + } + } + + protected abstract T loadPacketFromNBT(NBTTagCompound nbt); + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (MOVE_AT == aTick % 20) { + if (q == null) { + getBaseMetaTileEntity().setActive(false); + } else { + getBaseMetaTileEntity().setActive(true); + moveAround(aBaseMetaTileEntity); + } + } + } + } + + public abstract void moveAround(IGregTechTileEntity aBaseMetaTileEntity); + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + if (id > 0) { + return new String[] { + translateToLocalFormatted("tt.keyword.ID", clientLocale) + ": " + EnumChatFormatting.AQUA + id, + translateToLocalFormatted("tt.keyword.Content", clientLocale) + ": " + + EnumChatFormatting.AQUA + + (q != null ? q.getContentString() : 0), + translateToLocalFormatted("tt.keyword.PacketHistory", clientLocale) + ": " + + EnumChatFormatting.RED + + (q != null ? q.getTraceSize() : 0), }; + } + return new String[] { + translateToLocalFormatted("tt.keyword.Content", clientLocale) + ": " + + EnumChatFormatting.AQUA + + (q != null ? q.getContentString() : 0), + translateToLocalFormatted("tt.keyword.PacketHistory", clientLocale) + ": " + + EnumChatFormatting.RED + + (q != null ? q.getTraceSize() : 0), }; + } + + @Override + public byte getColorization() { + return getBaseMetaTileEntity().getColorization(); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java new file mode 100644 index 0000000000..7664f13f42 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java @@ -0,0 +1,128 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.util.CommonValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class GT_MetaTileEntity_Hatch_DynamoMulti extends GT_MetaTileEntity_Hatch { + + public final int Amperes; + + public GT_MetaTileEntity_Hatch_DynamoMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.hatch.dynamomulti.desc.0") }); // Multiple Ampere Energy + // Extractor for Multiblocks + Amperes = aAmp; + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_DynamoMulti(String aName, int aTier, int aAmp, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + Amperes = aAmp; + } + + public GT_MetaTileEntity_Hatch_DynamoMulti(int aID, String aName, String aNameRegional, int aTier, int i, + String[] description, int aAmp) { + super(aID, aName, aNameRegional, aTier, 0, description); + Amperes = aAmp; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 128L * Amperes; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return 512L + V[mTier] * 4L * Amperes; + } + + @Override + public long maxAmperesOut() { + return Amperes; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_DynamoMulti(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java new file mode 100644 index 0000000000..d94370ed97 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java @@ -0,0 +1,225 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT; +import static com.github.technus.tectech.util.CommonValues.TRANSFER_AT; +import static com.github.technus.tectech.util.CommonValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Energy; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.PowerLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatch_DynamoMulti + implements IConnectsToEnergyTunnel { + + public GT_MetaTileEntity_Hatch_DynamoTunnel(int ID, String unlocalisedName, String localisedName, int tier, + int amps) { + super( + ID, + unlocalisedName, + localisedName, + tier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.hatch.dynamotunnel.desc.0"), + translateToLocal("gt.blockmachines.hatch.dynamotunnel.desc.1") + ": " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(amps * V[tier]) + + EnumChatFormatting.RESET + + " EU/t" }, + amps); + + TT_Utility.setTier(tier, this); + } + + public GT_MetaTileEntity_Hatch_DynamoTunnel(String aName, int aTier, int aAmp, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_OUT_LASER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_OUT_LASER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier]; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return V[mTier] * 24L * Amperes; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.LASER; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_DynamoTunnel(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + byte Tick = (byte) (aTick % 20); + if (TRANSFER_AT == Tick) { + if (aBaseMetaTileEntity.getStoredEU() > 0) { + setEUVar(aBaseMetaTileEntity.getStoredEU() - Amperes); + if (aBaseMetaTileEntity.getStoredEU() < 0) { + setEUVar(0); + } + } + if (aBaseMetaTileEntity.getStoredEU() > getMinimumStoredEU()) { + moveAround(aBaseMetaTileEntity); + } + } + } + } + + private void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + byte color = getBaseMetaTileEntity().getColorization(); + if (color < 0) { + return; + } + final ForgeDirection front = aBaseMetaTileEntity.getFrontFacing(); + final ForgeDirection opposite = front.getOpposite(); + for (short dist = 1; dist < 1000; dist++) { + + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity + .getIGregTechTileEntityAtSideAndDistance(front, dist); + if (tGTTileEntity != null && tGTTileEntity.getColorization() == color) { + IMetaTileEntity aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyTunnel + && opposite == tGTTileEntity.getFrontFacing()) { + if (maxEUOutput() > ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUInput()) { + aMetaTileEntity.doExplosion(maxEUOutput()); + setEUVar(aBaseMetaTileEntity.getStoredEU() - maxEUOutput()); + return; + } else if (maxEUOutput() + == ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUInput()) { + long diff = Math.min( + Amperes * 20L * maxEUOutput(), + Math.min( + ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUStore() + - aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU(), + aBaseMetaTileEntity.getStoredEU())); + + setEUVar(aBaseMetaTileEntity.getStoredEU() - diff); + + ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).setEUVar( + aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU() + diff); + } + return; + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy) { + if (((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).connectionCount < 2) { + return; + } else { + ((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).markUsed(); + } + } else { + return; + } + } else { + if (tGTTileEntity instanceof PowerLogicHost) { + PowerLogic logic = ((PowerLogicHost) tGTTileEntity).getPowerLogic(opposite); + if (logic == null || !logic.canUseLaser() || opposite != tGTTileEntity.getFrontFacing()) { + return; + } + + long ampsUsed = logic.injectEnergy(maxEUOutput(), Amperes); + setEUVar(aBaseMetaTileEntity.getStoredEU() - ampsUsed * maxEUOutput()); + } + return; + } + } else { + return; + } + } + } + + @Override + public boolean canConnect(ForgeDirection side) { + return isOutputFacing(side); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java new file mode 100644 index 0000000000..20c3b993f5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java @@ -0,0 +1,134 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.util.CommonValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class GT_MetaTileEntity_Hatch_EnergyMulti extends GT_MetaTileEntity_Hatch { + + public final int Amperes; + + public GT_MetaTileEntity_Hatch_EnergyMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.hatch.energymulti.desc.0"), + translateToLocalFormatted("gt.blockmachines.hatch.energymulti.desc.2", aAmp + (aAmp >> 2)), + translateToLocalFormatted("gt.blockmachines.hatch.energymulti.desc.3", aAmp) }); + Amperes = aAmp; + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_EnergyMulti(String aName, int aTier, int aAmp, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + Amperes = aAmp; + } + + public GT_MetaTileEntity_Hatch_EnergyMulti(int aID, String aName, String aNameRegional, int aTier, int i, + String[] description, int aAmp) { + super(aID, aName, aNameRegional, aTier, 0, description); + Amperes = aAmp; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 128L * Amperes; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return 512L + V[mTier] * 4L * Amperes; + } + + @Override + public long maxAmperesIn() { + return Amperes + (Amperes >> 2); + } + + @Override + public long maxWorkingAmperesIn() { + return Amperes; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_EnergyMulti(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java new file mode 100644 index 0000000000..30b8f32685 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java @@ -0,0 +1,152 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT; +import static com.github.technus.tectech.util.CommonValues.TRANSFER_AT; +import static com.github.technus.tectech.util.CommonValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class GT_MetaTileEntity_Hatch_EnergyTunnel extends GT_MetaTileEntity_Hatch_EnergyMulti + implements IConnectsToEnergyTunnel { + + public GT_MetaTileEntity_Hatch_EnergyTunnel(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.hatch.energytunnel.desc.0"), + translateToLocal("gt.blockmachines.hatch.energytunnel.desc.1") + ": " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(aAmp * V[aTier]) + + EnumChatFormatting.RESET + + " EU/t" }, + aAmp); // Energy injecting terminal for Multiblocks + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_EnergyTunnel(String aName, int aTier, int aAmp, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_IN_LASER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, OVERLAYS_ENERGY_IN_LASER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier]; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return V[mTier] * 24L * Amperes; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.LASER; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_EnergyTunnel(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean canConnect(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + byte Tick = (byte) (aTick % 20); + if (TRANSFER_AT == Tick) { + if (aBaseMetaTileEntity.getStoredEU() > 0) { + setEUVar(aBaseMetaTileEntity.getStoredEU() - Amperes); + if (aBaseMetaTileEntity.getStoredEU() < 0) { + setEUVar(0); + } + } + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java new file mode 100644 index 0000000000..38dd876553 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java @@ -0,0 +1,181 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; + +/** + * Created by Tec on 03.04.2017. + */ +public class GT_MetaTileEntity_Hatch_Holder extends GT_MetaTileEntity_Hatch implements IAddGregtechLogo { + + private static Textures.BlockIcons.CustomIcon EM_H; + private static Textures.BlockIcons.CustomIcon EM_H_ACTIVE; + + public GT_MetaTileEntity_Hatch_Holder(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.holder.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.holder.desc.1") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_Holder(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_H_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/EM_HOLDER_ACTIVE"); + EM_H = new Textures.BlockIcons.CustomIcon("iconsets/EM_HOLDER"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(EM_H_ACTIVE) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(EM_H) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Holder(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + // if(aBaseMetaTileEntity.isActive()) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); + // else if(heat>0) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); + // else + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO) + .setSize(18, 18) + .setPos(151, 63)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK) + .setPos(46, 17) + .setSize(84, 60)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_RACK_LARGE) + .setPos(68, 27) + .setSize(40, 40)) + .widget(new SlotWidget(new BaseSlot(inventoryHandler, 0) { + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean isEnabled() { + return !getBaseMetaTileEntity().isActive(); + } + }).setPos(79, 38)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.BUTTON_STANDARD_LIGHT_16x16) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new DrawableWidget() + .setDrawable( + () -> getBaseMetaTileEntity().isActive() ? TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON + : TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new FakeSyncWidget.BooleanSyncer( + () -> getBaseMetaTileEntity().isActive(), + val -> getBaseMetaTileEntity().setActive(val))); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java new file mode 100644 index 0000000000..03c9cfbf3c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java @@ -0,0 +1,102 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; +import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_DataConnector { + + private boolean delDelay = true; + + public GT_MetaTileEntity_Hatch_InputData(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.datain.desc.0"), + translateToLocal("gt.blockmachines.hatch.datain.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.datain.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_InputData(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_InputData(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new QuantumDataPacket(nbt); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source) { + return null; + } + + public void setContents(QuantumDataPacket qIn) { + if (qIn == null) { + this.q = null; + } else { + if (qIn.getContent() > 0) { + this.q = qIn; + delDelay = true; + } else { + this.q = null; + } + } + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + if (delDelay) { + delDelay = false; + } else { + setContents(null); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java new file mode 100644 index 0000000000..50e9eebd76 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java @@ -0,0 +1,246 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; +import static com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DataConnector.EM_D_ACTIVE; +import static com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DataConnector.EM_D_CONN; +import static com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DataConnector.EM_D_SIDES; +import static com.github.technus.tectech.util.CommonValues.MOVE_AT; +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +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.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.mechanics.dataTransport.InventoryDataPacket; +import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; +import gregtech.api.objects.GT_RenderedTexture; + +public class GT_MetaTileEntity_Hatch_InputDataItems extends GT_MetaTileEntity_Hatch_DataAccess + implements IConnectsToDataPipe { + + public boolean delDelay = true; + private ItemStack[] stacks; + + private String clientLocale = "en_US"; + + public GT_MetaTileEntity_Hatch_InputDataItems(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_InputDataItems(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GT_RenderedTexture( + EM_D_ACTIVE, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GT_RenderedTexture(EM_D_CONN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GT_RenderedTexture( + EM_D_SIDES, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GT_RenderedTexture(EM_D_CONN) }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_InputDataItems(this.mName, this.mTier, mDescriptionArray, this.mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source) { + return null; + } + + public void setContents(InventoryDataPacket iIn) { + if (iIn == null) { + stacks = null; + } else { + if (iIn.getContent().length > 0) { + stacks = iIn.getContent(); + delDelay = true; + } else { + stacks = null; + } + } + } + + @Override + public void onRemoval() { + stacks = null; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + NBTTagCompound stacksTag = new NBTTagCompound(); + if (stacks != null) { + stacksTag.setInteger("count", stacks.length); + for (int i = 0; i < stacks.length; i++) { + stacksTag.setTag(Integer.toString(i), stacks[i].writeToNBT(new NBTTagCompound())); + } + } + aNBT.setTag("data_stacks", stacksTag); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + NBTTagCompound stacksTag = aNBT.getCompoundTag("data_stacks"); + int count = stacksTag.getInteger("count"); + if (count > 0) { + ArrayList stacks = new ArrayList<>(); + for (int i = 0; i < count; i++) { + ItemStack stack = ItemStack.loadItemStackFromNBT(stacksTag.getCompoundTag(Integer.toString(i))); + if (stack != null) { + stacks.add(stack); + } + } + if (stacks.size() > 0) { + this.stacks = stacks.toArray(nullItem); + } + } + } + + @Override + public int getSizeInventory() { + return stacks != null ? stacks.length : 0; + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + return stacks != null && aIndex < stacks.length ? stacks[aIndex] : null; + } + + @Override + public boolean shouldDropItemAt(int index) { + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (MOVE_AT == aTick % 20) { + if (stacks == null) { + getBaseMetaTileEntity().setActive(false); + } else { + getBaseMetaTileEntity().setActive(true); + if (delDelay) { + delDelay = false; + } else { + setContents(null); + } + } + } + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.datainass.desc.0"), + translateToLocal("gt.blockmachines.hatch.datainass.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.datainass.desc.2") }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { translateToLocalFormatted("tt.keyphrase.Content_Stack_Count", clientLocale) + ": " + + (stacks == null ? 0 : stacks.length) }; + } + + @Override + public byte getColorization() { + return getBaseMetaTileEntity().getColorization(); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java new file mode 100644 index 0000000000..7e769123bc --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java @@ -0,0 +1,116 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; +import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_DataConnector { + + public GT_MetaTileEntity_Hatch_OutputData(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.dataout.desc.0"), + translateToLocal("gt.blockmachines.hatch.dataout.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.dataout.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_OutputData(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_OutputData(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new QuantumDataPacket(nbt); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isOutputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + IConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof GT_MetaTileEntity_Hatch_InputData) { + ((GT_MetaTileEntity_Hatch_InputData) next).setContents(q); + break; + } + source = current; + current = next; + } + q = null; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source /* ==this */) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); + if (color < 0) { + return null; + } + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + if (next == null) { + return null; + } + IMetaTileEntity meta = next.getMetaTileEntity(); + if (meta instanceof GT_MetaTileEntity_Pipe_Data) { + ((GT_MetaTileEntity_Pipe_Data) meta).markUsed(); + return (IConnectsToDataPipe) meta; + } else if (meta instanceof GT_MetaTileEntity_Hatch_InputData + && ((GT_MetaTileEntity_Hatch_InputData) meta).getColorization() == color + && ((GT_MetaTileEntity_Hatch_InputData) meta).canConnectData( + base.getFrontFacing() + .getOpposite())) { + return (IConnectsToDataPipe) meta; + } + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java new file mode 100644 index 0000000000..0cdf1b969b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java @@ -0,0 +1,141 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.dataTransport.InventoryDataPacket; +import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +public class GT_MetaTileEntity_Hatch_OutputDataItems + extends GT_MetaTileEntity_Hatch_DataConnector { + + public GT_MetaTileEntity_Hatch_OutputDataItems(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.dataoutass.desc.0"), + translateToLocal("gt.blockmachines.hatch.dataoutass.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.dataoutass.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_OutputDataItems(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_OutputDataItems( + this.mName, + this.mTier, + this.mDescriptionArray, + this.mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + protected InventoryDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new InventoryDataPacket(nbt); + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isOutputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + IConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof GT_MetaTileEntity_Hatch_InputDataItems) { + ((GT_MetaTileEntity_Hatch_InputDataItems) next).setContents(q); + break; + } + source = current; + current = next; + } + q = null; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source /* ==this */) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); + if (color < 0) { + return null; + } + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + if (next == null) { + return null; + } + IMetaTileEntity meta = next.getMetaTileEntity(); + if (meta instanceof GT_MetaTileEntity_Pipe_Data) { + ((GT_MetaTileEntity_Pipe_Data) meta).markUsed(); + return (IConnectsToDataPipe) meta; + } else if (meta instanceof GT_MetaTileEntity_Hatch_InputDataItems + && ((GT_MetaTileEntity_Hatch_InputDataItems) meta).getColorization() == color + && ((GT_MetaTileEntity_Hatch_InputDataItems) meta).canConnectData( + base.getFrontFacing() + .getOpposite())) { + return (IConnectsToDataPipe) meta; + } + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java new file mode 100644 index 0000000000..90f0267695 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java @@ -0,0 +1,559 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; + +/** + * Created by danie_000 on 15.12.2016. + */ +public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch implements IAddGregtechLogo, IAddUIWidgets { + + public int pointer = 0; + public int param = -1; + public double value0D = 0; + public double value1D = 0; + public double input0D = 0; + public double input1D = 0; + private static Textures.BlockIcons.CustomIcon ScreenON; + private static Textures.BlockIcons.CustomIcon ScreenOFF; + + private String clientLocale = "en_US"; + + public GT_MetaTileEntity_Hatch_Param(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + EnumChatFormatting.DARK_RED + + "Deprecated; Now you can set parameter by clicking LED on multiblock GUI.", + EnumChatFormatting.DARK_RED + + "If it doesn't work, try removing Parametrizer from multiblock structure." }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_Param(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/PARAM"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/PARAM_ACTIVE"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(ScreenON) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(ScreenOFF) }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Hatch_Param(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyword.Parametrizer", clientLocale) + " " + + translateToLocalFormatted("tt.keyword.ID", clientLocale) + + ": " + + EnumChatFormatting.GREEN + + param, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 0D: " + EnumChatFormatting.AQUA + value0D, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 1D: " + EnumChatFormatting.BLUE + value1D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 0D: " + EnumChatFormatting.GOLD + input0D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 1D: " + + EnumChatFormatting.YELLOW + + input1D, }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("ePointer", pointer); + aNBT.setDouble("eValue0D", value0D); + aNBT.setDouble("eValue1D", value1D); + aNBT.setDouble("eInput0D", input0D); + aNBT.setDouble("eInput1D", input1D); + aNBT.setInteger("eParam", param); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + pointer = aNBT.getInteger("ePointer"); + if (aNBT.hasKey("eFloats") || aNBT.hasKey("eValue0i") + || aNBT.hasKey("eValue1i") + || aNBT.hasKey("eInput0i") + || aNBT.hasKey("eInput1i")) { + boolean usesFloat = aNBT.getBoolean("eFloats"); + if (usesFloat) { + value0D = Double.longBitsToDouble(aNBT.getLong("eValue0i")); + value1D = Double.longBitsToDouble(aNBT.getLong("eValue1i")); + input0D = Double.longBitsToDouble(aNBT.getLong("eInput0i")); + input1D = Double.longBitsToDouble(aNBT.getLong("eInput1i")); + } else { + value0D = aNBT.getLong("eValue0i"); + value1D = aNBT.getLong("eValue1i"); + input0D = aNBT.getLong("eInput0i"); + input1D = aNBT.getLong("eInput1i"); + } + } else { + value0D = aNBT.getDouble("eValue0D"); + value1D = aNBT.getDouble("eValue1D"); + input0D = aNBT.getDouble("eInput0D"); + input1D = aNBT.getDouble("eInput1D"); + } + param = aNBT.getInteger("eParam"); + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(112, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + final boolean isAdvanced = mTier > 5; + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(43, 4) + .setSize(90, 72)); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param -= shift ? 16 : 4, + 7, + 4, + GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? -16 : -4); + } + } else { + value0D -= shift ? 4096 : 256; + } + }, 7, 22, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? -16 : -4); + } else { + secondRow.set(true); + } + } else { + value1D -= shift ? 4096 : 256; + } + }, 7, 40, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); + } else { + value0D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp |= 1L << (long) columnPointer.get(); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp |= 1L << (long) columnPointer.get(); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D /= shift ? 4096 : 256; + value1D /= shift ? 4096 : 256; + } + }, + 7, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_S : GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param -= shift ? 2 : 1, + 25, + 4, + GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? -2 : -1); + } + } else { + value0D -= shift ? 16 : 1; + } + }, 25, 22, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? -2 : -1); + } else { + secondRow.set(true); + } + } else { + value1D -= shift ? 16 : 1; + } + }, 25, 40, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(0); + } else { + value0D = Double.longBitsToDouble(0); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp &= ~(1L << (long) columnPointer.get()); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp &= ~(1L << (long) columnPointer.get()); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D /= shift ? 16 : 2; + value1D /= shift ? 16 : 2; + } + }, + 25, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_C : GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_X); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param += shift ? 2 : 1, + 133, + 4, + GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? 2 : 1); + } + } else { + value0D += shift ? 16 : 1; + } + }, 133, 22, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? 2 : 1); + } else { + secondRow.set(true); + } + } else { + value1D += shift ? 16 : 1; + } + }, 133, 40, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(~Double.doubleToLongBits(value1D)); + } else { + value0D = Double.longBitsToDouble(~Double.doubleToLongBits(value1D)); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp ^= 1L << (long) columnPointer.get(); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp ^= 1L << (long) columnPointer.get(); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D *= shift ? 16 : 2; + value1D *= shift ? 16 : 2; + } + }, + 133, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_T : GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param += shift ? 16 : 4, + 151, + 4, + GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? 16 : 4); + } + } else { + value0D += shift ? 4096 : 256; + } + }, 151, 22, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? 16 : 4); + } else { + secondRow.set(true); + } + } else { + value1D += shift ? 4096 : 256; + } + }, 151, 40, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + value0D = input0D; + value1D = input1D; + } else { + value0D *= shift ? 4096 : 256; + value1D *= shift ? 4096 : 256; + } + }, + 151, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_IF : GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> pointer, val -> pointer = val)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> param, val -> param = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value0D, val -> value0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value1D, val -> value1D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input0D, val -> input0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input1D, val -> input1D = val)); + + final String CIRCLED_0 = "\u24EA"; + final String CIRCLED_1 = "\u2460"; + final String ARROW_DOWN = "\u2b07"; + final String ARROW_UP = "\u2b06"; + builder.widget( + TextWidget.dynamicString(() -> (isAdvanced ? "Parameters X: " : "Parameters: ") + param) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_DOWN + TT_Utility.formatNumberExp(input0D)) + .setSynced(false) + .setDefaultColor(0x22ddff) + .setPos(46, 16)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_DOWN + TT_Utility.formatNumberExp(input1D)) + .setSynced(false) + .setDefaultColor(0x00ffff) + .setPos(46, 24)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_UP + TT_Utility.formatNumberExp(value0D)) + .setSynced(false) + .setDefaultColor(0x00bbff) + .setPos(46, 33)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_UP + TT_Utility.formatNumberExp(value1D)) + .setSynced(false) + .setDefaultColor(0x0077ff) + .setPos(46, 41)) + .widget( + TextWidget + .dynamicString( + () -> CIRCLED_0 + ARROW_UP + TT_Utility.longBitsToShortString(Double.doubleToLongBits(value0D))) + .setSynced(false) + .setDefaultColor(0x00bbff) + .setScale(.5f) + .setTextAlignment(Alignment.CenterLeft) + .setPos(46, 50)) + .widget( + TextWidget + .dynamicString( + () -> CIRCLED_1 + ARROW_UP + TT_Utility.longBitsToShortString(Double.doubleToLongBits(value1D))) + .setSynced(false) + .setDefaultColor(0x0077ff) + .setScale(.5f) + .setTextAlignment(Alignment.CenterLeft) + .setPos(46, 58)); + if (isAdvanced) { + builder.widget( + TextWidget.dynamicString( + () -> "Pointer " + Integer.toHexString(pointer | 0x10000) + .substring(1)) + .setSynced(false) + .setDefaultColor(0x0033ff) + .setPos(46, 66)); + } + } + + private void addChangeParamButton(ModularWindow.Builder builder, OnClick onClick, int xPos, int yPos, + IDrawable overlay1, IDrawable overlay2) { + final boolean isAdvanced = mTier > 5; + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + AtomicInteger columnPointer = new AtomicInteger(pointer & 0xff); + AtomicBoolean secondRow = new AtomicBoolean((pointer & 0x0100) != 0); + onClick.accept(clickData.shift, columnPointer, secondRow); + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (isAdvanced) { + if (columnPointer.get() >= 64) { + columnPointer.set(63); + } else if (columnPointer.get() < 0) { + columnPointer.set(0); + } + pointer = secondRow.get() ? columnPointer.get() + 0x100 : columnPointer.get(); + } + if (param > 9) { + param = 9; + } else if (param < -1) { + param = -1; + } + }) + .setPlayClickSound(false) + .setBackground( + overlay2 != null ? new IDrawable[] { GT_UITextures.BUTTON_STANDARD, overlay1, overlay2 } + : new IDrawable[] { GT_UITextures.BUTTON_STANDARD, overlay1 }) + .setSize(18, 18) + .setPos(xPos, yPos)); + } + + @FunctionalInterface + private interface OnClick { + + void accept(boolean shift, AtomicInteger columnPointer, AtomicBoolean secondRow); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java new file mode 100644 index 0000000000..42a7e0cd81 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java @@ -0,0 +1,291 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +/** + * Created by danie_000 on 15.12.2016. + */ +public class GT_MetaTileEntity_Hatch_ParamText extends GT_MetaTileEntity_Hatch_Param { + + public String value0s = ""; + public String value1s = ""; + + private String clientLocale = "en_US"; + + public GT_MetaTileEntity_Hatch_ParamText(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_ParamText(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Hatch_ParamText(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyword.Parametrizer", clientLocale) + " " + + translateToLocalFormatted("tt.keyword.ID", clientLocale) + + ": " + + EnumChatFormatting.GREEN + + param, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 0S: " + + EnumChatFormatting.DARK_AQUA + + value0s, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 1S: " + + EnumChatFormatting.DARK_BLUE + + value1s, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 0D: " + EnumChatFormatting.AQUA + value0D, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 1D: " + EnumChatFormatting.BLUE + value1D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 0D: " + EnumChatFormatting.GOLD + input0D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 1D: " + + EnumChatFormatting.YELLOW + + input1D, }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setString("eIeValue0S", value0s); + aNBT.setString("eIeValue1S", value1s); + aNBT.removeTag("ePointer"); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + value0s = aNBT.getString("eIeValue0S"); + value1s = aNBT.getString("eIeValue1S"); + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_GENERAL, + EnumChatFormatting.DARK_RED + "Deprecated; Now you can set parameter by clicking LED on multiblock GUI.", + EnumChatFormatting.DARK_RED + "If it doesn't work, try removing Parametrizer from multiblock structure.", }; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(148, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_PARAMETRIZER_TXT) + .setPos(7, 4) + .setSize(162, 72)); + + addChangeNumberButton(builder, -16, -4, 7, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE); + addChangeNumberButton(builder, -2, -1, 25, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL); + addChangeNumberButton(builder, 2, 1, 133, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL); + addChangeNumberButton(builder, 16, 4, 151, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE); + + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> param, val -> param = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value0D, val -> value0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value1D, val -> value1D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input0D, val -> input0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input1D, val -> input1D = val)); + // .widget(new FakeSyncWidget.StringSyncer(() -> value0s, val -> value0s = val)) + // .widget(new FakeSyncWidget.StringSyncer(() -> value1s, val -> value1s = val)); + + final String CIRCLED_0 = "\u24EA"; + final String CIRCLED_1 = "\u2460"; + final String ARROW_DOWN = "\u2b07"; + final String ARROW_UP = "\u2b06"; + builder.widget( + TextWidget.dynamicString(() -> "Parameters: " + param) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)) + .widget( + new TextWidget(CIRCLED_0 + ARROW_UP).setDefaultColor(0x00bbff) + .setPos(10, 29)) + .widget( + new TextWidget(CIRCLED_1 + ARROW_UP).setDefaultColor(0x0077ff) + .setPos(10, 44)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_DOWN + TT_Utility.formatNumberExp(input0D)) + .setSynced(false) + .setDefaultColor(0x22ddff) + .setPos(10, 56)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_DOWN + TT_Utility.formatNumberExp(input1D)) + .setSynced(false) + .setDefaultColor(0x00ffff) + .setPos(10, 65)); + + addTextField(builder, true); + addTextField(builder, false); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, int changeNumberShift, int changeNumber, int xPos, + IDrawable overlay) { + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + param += clickData.shift ? changeNumberShift : changeNumber; + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (param > 9) { + param = 9; + } else if (param < -1) { + param = -1; + } + }) + .setPlayClickSound(false) + .setBackground(GT_UITextures.BUTTON_STANDARD, overlay, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID) + .setSize(18, 18) + .setPos(xPos, 4)); + } + + private void addTextField(ModularWindow.Builder builder, boolean isIndex0) { + TextFieldWidget widget = new TextFieldWidget(); + builder.widget( + widget.setGetter(() -> isIndex0 ? value0s : value1s) + .setSetter(str -> { + double val; + try { + val = parse(str); + } catch (Exception e) { + // This shouldn't happen as long as validator works + str = ""; + val = 0; + } + if (isIndex0) { + value0s = str; + value0D = val; + } else { + value1s = str; + value1D = val; + } + }) + .setValidator(str -> { + try { + parse(str); + return str; + } catch (Exception e) { + return widget.getLastText() + .size() > 0 ? widget.getLastText() + .get(0) : ""; + } + }) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(26, isIndex0 ? 26 : 41) + .setSize(138, 12)); + } + + private double parse(String str) { + double val; + if (str.contains("b")) { + String[] split = str.split("b"); + val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else if (str.contains("x")) { + String[] split = str.split("x"); + val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else { + val = TT_Utility.stringToDouble(str); + } + return val; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java new file mode 100644 index 0000000000..2b65ba607e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java @@ -0,0 +1,470 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.util.CommonValues.MULTI_CHECK_AT; +import static com.github.technus.tectech.util.TT_Utility.getUniqueIdentifier; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.Mods.OpenComputers; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; + +/** + * Created by Tec on 03.04.2017. + */ +public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implements IAddGregtechLogo, IAddUIWidgets { + + private static Textures.BlockIcons.CustomIcon EM_R; + private static Textures.BlockIcons.CustomIcon EM_R_ACTIVE; + public int heat = 0; + private float overClock = 1, overVolt = 1; + private static final Map componentBinds = new HashMap<>(); + + private String clientLocale = "en_US"; + + public GT_MetaTileEntity_Hatch_Rack(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 4, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.rack.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.rack.desc.1") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_Rack(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("eHeat", heat); + aNBT.setFloat("eOverClock", overClock); + aNBT.setFloat("eOverVolt", overVolt); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + heat = aNBT.getInteger("eHeat"); + overClock = aNBT.getFloat("eOverClock"); + overVolt = aNBT.getFloat("eOverVolt"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_R_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/EM_RACK_ACTIVE"); + EM_R = new Textures.BlockIcons.CustomIcon("iconsets/EM_RACK"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(EM_R_ACTIVE) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(EM_R) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Rack(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (aBaseMetaTileEntity.isActive() || heat > 500) { + return false; + } + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (aBaseMetaTileEntity.isActive() || heat > 500) { + return false; + } + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + // if(aBaseMetaTileEntity.isActive()) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); + // else if(heat>0) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); + // else + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + private int getComputationPower(float overclock, float overvolt, boolean tickingComponents) { + float computation = 0, heat = 0; + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + RackComponent comp = componentBinds.get(getUniqueIdentifier(mInventory[i])); + if (comp == null) { + continue; + } + if (tickingComponents) { + if (this.heat > comp.maxHeat) { + mInventory[i] = null; + continue; + } else if (comp.subZero || this.heat >= 0) { + heat += (1f + comp.coEff * this.heat / 10000f) + * (comp.heat > 0 ? comp.heat * overclock * overclock * overvolt : comp.heat); + // =MAX(0;MIN(MIN($B4;1*C$3+C$3-0,25);1+RAND()+(C$3-1)-($B4-1)/2)) + if (overvolt * 10f > 7f + TecTech.RANDOM.nextFloat()) { + computation += comp.computation * Math.max( + 0, + Math.min( + Math.min(overclock, overvolt + overvolt - 0.25), + 1 + TecTech.RANDOM.nextFloat() + (overvolt - 1) - (overclock - 1) / 2)); + } + } + } else { + computation += comp.computation * overclock; + } + } + if (tickingComponents) { + this.heat += Math.ceil(heat); + } + return (int) Math.floor(computation); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + public int tickComponents(float oc, float ov) { + if (oc > 3 + TecTech.RANDOM.nextFloat() || ov > 2 + TecTech.RANDOM.nextFloat()) { + getBaseMetaTileEntity().setToFire(); + } + overClock = oc; + overVolt = ov; + return getComputationPower(overClock, overVolt, true); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (aTick % 20 == MULTI_CHECK_AT) { + if (heat > 0) { + float heatC = 0; + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + RackComponent comp = componentBinds.get(getUniqueIdentifier(mInventory[i])); + if (comp == null) { + continue; + } + if (heat > comp.maxHeat) { + mInventory[i] = null; + } else if (comp.heat < 0) { + heatC += comp.heat * (heat / 10000f); + } + } + heat += Math.max(-heat, Math.ceil(heatC)); + } + + if (heat > 0) { + heat -= Math.max(heat / 1000, 1); + } else if (heat < 0) { + heat -= Math.min(heat / 1000, -1); + } + + if (heat > 10000) { + aBaseMetaTileEntity.setToFire(); + } else if (heat > 9000) { + aBaseMetaTileEntity.setOnFire(); + } else if (heat < -10000) { + heat = -10000; + } + } + } + } + + @Override + public int getSizeInventory() { // HACK TO NOT DROP CONTENTS!!! + return heat > 500 || getBaseMetaTileEntity().isActive() ? 0 : mInventory.length; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyphrase.Base_computation", clientLocale) + ": " + + EnumChatFormatting.AQUA + + getComputationPower(1, 0, false), + translateToLocalFormatted("tt.keyphrase.After_overclocking", clientLocale) + ": " + + EnumChatFormatting.AQUA + + getComputationPower(overClock, 0, false), + translateToLocalFormatted("tt.keyphrase.Heat_Accumulated", clientLocale) + ": " + + EnumChatFormatting.RED + + (heat + 99) / 100 + + EnumChatFormatting.RESET + + " %" }; + // heat==0? --> ((heat+9)/10) = 0 + // Heat==1-10? --> 1 + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO) + .setSize(18, 18) + .setPos(151, 63)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK) + .setPos(46, 17) + .setSize(84, 60)); + + Pos2d[] positions = new Pos2d[] { new Pos2d(68, 27), new Pos2d(90, 27), new Pos2d(68, 49), new Pos2d(90, 49), }; + for (int i = 0; i < positions.length; i++) { + builder.widget(new SlotWidget(new BaseSlot(inventoryHandler, i) { + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean isEnabled() { + return !getBaseMetaTileEntity().isActive() && heat <= 0; + } + }).setBackground(getGUITextureSet().getItemSlot(), TecTechUITextures.OVERLAY_SLOT_RACK) + .setPos(positions[i])); + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BUTTON_STANDARD_LIGHT_16x16) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new DrawableWidget() + .setDrawable( + () -> getBaseMetaTileEntity().isActive() ? TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON + : TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new FakeSyncWidget.BooleanSyncer( + () -> getBaseMetaTileEntity().isActive(), + val -> getBaseMetaTileEntity().setActive(val))); + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BUTTON_STANDARD_LIGHT_16x16) + .setPos(152, 41) + .setSize(16, 16)) + .widget( + new DrawableWidget() + .setDrawable( + () -> heat > 0 ? TecTechUITextures.OVERLAY_BUTTON_HEAT_ON + : TecTechUITextures.OVERLAY_BUTTON_HEAT_OFF) + .setPos(152, 41) + .setSize(16, 16)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> heat, val -> heat = val)); + } + } + + public static void run() { // 20k heat cap max! + new RackComponent(ItemList.Circuit_Primitive.get(1), 1, 4, 0, 500, true); // Primitive Circuit + new RackComponent(ItemList.Circuit_Basic.get(1), 4, 8, 0, 1000, true); // Basic Circuit + new RackComponent(ItemList.Circuit_Microprocessor.get(1), 6, 8, 0, 1250, true); + new RackComponent(ItemList.Circuit_Good.get(1), 6, 9, -.05f, 1500, true); // Good Circuit + new RackComponent(ItemList.Circuit_Integrated_Good.get(1), 7, 9, -.075f, 1750, true); + new RackComponent(ItemList.Circuit_Processor.get(1), 8, 9, -.07f, 1800, true); + new RackComponent(ItemList.Circuit_Parts_Advanced.get(1), 1, 2, -.05f, 2000, true); + new RackComponent(ItemList.Circuit_Nanoprocessor.get(1), 8, 10, -.09f, 2250, true); // Advanced Circuit + new RackComponent(ItemList.Circuit_Advanced.get(1), 8, 10, -.1f, 2500, true); + new RackComponent(ItemList.Circuit_Data.get(1), 9, 1, -.1f, 3000, true); // EV Circuit + new RackComponent(ItemList.Circuit_Nanocomputer.get(1), 11, 10, -.125f, 3300, true); + new RackComponent(ItemList.Circuit_Quantumprocessor.get(1), 13, 10, -.15f, 3600, true); + new RackComponent(ItemList.Circuit_Elite.get(1), 12, 10, -.15F, 3500, true); // IV Circuit + new RackComponent(ItemList.Circuit_Elitenanocomputer.get(1), 14, 10, -.15F, 4000, true); + new RackComponent(ItemList.Circuit_Quantumcomputer.get(1), 16, 10, -.15F, 4500, true); + new RackComponent(ItemList.Circuit_Crystalprocessor.get(1), 18, 10, -.15F, 5000, true); + new RackComponent(ItemList.Circuit_Master.get(1), 16, 12, -.2F, 5000, true); // LuV Circuit + new RackComponent(ItemList.Circuit_Masterquantumcomputer.get(1), 16, 13, -.2F, 5100, true); + new RackComponent(ItemList.Circuit_Crystalcomputer.get(1), 20, 14, -.25F, 5200, true); + new RackComponent(ItemList.Circuit_Neuroprocessor.get(1), 24, 15, -.3F, 5300, true); + new RackComponent(ItemList.Circuit_Quantummainframe.get(1), 22, 14, -.3F, 5200, true); // ZPM Circuit + new RackComponent(ItemList.Circuit_Ultimatecrystalcomputer.get(1), 26, 16, -.3F, 5400, true); + new RackComponent(ItemList.Circuit_Wetwarecomputer.get(1), 30, 18, -.3F, 5600, true); + new RackComponent(ItemList.Circuit_Crystalmainframe.get(1), 30, 18, -.35F, 5500, true); // UV Circuit + new RackComponent(ItemList.Circuit_Wetwaresupercomputer.get(1), 35, 22, -.3F, 5700, true); + new RackComponent(ItemList.Circuit_Wetwaremainframe.get(1), 38, 25, -.4F, 6000, true); // UHV Circuit + + new RackComponent("IC2:ic2.reactorVent", 0, -1, 10f, 1000, false); + new RackComponent("IC2:ic2.reactorVentCore", 0, -1, 20f, 2500, false); + new RackComponent("IC2:ic2.reactorVentGold", 0, -1, 40f, 5000, false); + new RackComponent("IC2:ic2.reactorVentDiamond", 0, -1, 80f, 10000, false); // 2x oc + + if (NewHorizonsCoreMod.isModLoaded()) { + // GTNH-GT5u circuits + // these components causes crashes when used with the original GT5u + new RackComponent(ItemList.NandChip.get(1), 2, 6, 0, 750, true); // Primitive Circuit + new RackComponent(ItemList.Circuit_Biowarecomputer.get(1), 40, 26, -.35F, 5900, true); + new RackComponent(ItemList.Circuit_Biowaresupercomputer.get(1), 42, 30, -.4F, 6200, true); + new RackComponent(ItemList.Circuit_Biomainframe.get(1), 44, 28, -.4F, 6000, true); // UEV Circuit + new RackComponent(ItemList.Circuit_Bioprocessor.get(1), 34, 20, -.35F, 5800, true); + + new RackComponent("dreamcraft:item.HighEnergyCircuitParts", 3, 2, -.1f, 9001, true); + new RackComponent("dreamcraft:item.HighEnergyFlowCircuit", 24, 16, -.25f, 10000, true); + new RackComponent("dreamcraft:item.NanoCircuit", 50, 35, -.45f, 8000, true); + new RackComponent("dreamcraft:item.PikoCircuit", 64, 40, -.5f, 8500, true); + new RackComponent("dreamcraft:item.QuantumCircuit", 128, 48, -.6f, 9000, true); + } + + if (OpenComputers.isModLoaded()) { + new RackComponent("OpenComputers:item.oc.Transistor", 0, 1, 0f, 100, true); // Transistor + new RackComponent("OpenComputers:item.oc.Microchip0", 7, 12, -.05f, 1500, true); // chip t1 + new RackComponent("OpenComputers:item.oc.Microchip1", 18, 20, -.1f, 3000, true); // chip t2 + new RackComponent("OpenComputers:item.oc.Microchip2", 25, 22, -.15f, 4500, true); // chip t3 + new RackComponent("OpenComputers:item.oc.ALU", 10, 15, -.05f, 3000, true); // alu + new RackComponent("OpenComputers:item.oc.ControlUnit", 25, 18, -.05f, 1500, true); // cu + + new RackComponent("OpenComputers:item.oc.ComponentBus0", 42, 30, -.05f, 1500, true); // bus t1 + new RackComponent("OpenComputers:item.oc.ComponentBus1", 70, 50, -.1f, 3000, true); // bus t2 + new RackComponent("OpenComputers:item.oc.ComponentBus2", 105, 72, -.15f, 4500, true); // bus t3 + + new RackComponent("OpenComputers:item.oc.CPU0", 106, 73, -.1f, 1500, true); // cpu t1 + new RackComponent("OpenComputers:item.oc.CPU1", 226, 153, -.15f, 3000, true); // cpu t2 + new RackComponent("OpenComputers:item.oc.CPU2", 374, 241, -.2f, 4500, true); // cpu t3 + + new RackComponent("OpenComputers:item.oc.GraphicsCard0", 20, 27, -.1f, 1500, true); // gpu t1 + new RackComponent("OpenComputers:item.oc.GraphicsCard1", 62, 67, -.2f, 3000, true); // gpu t2 + new RackComponent("OpenComputers:item.oc.GraphicsCard2", 130, 111, -.3f, 4500, true); // gpu t3 + + new RackComponent("OpenComputers:item.oc.APU0", 350, 234, -.1f, 1500, true); // apu t2 + new RackComponent("OpenComputers:item.oc.APU1", 606, 398, -.2f, 4500, true); // apu t3 + new RackComponent("OpenComputers:item.oc.APU2", 1590, 1006, -.3f, 9000, true); // apu tC + } + } + + public static class RackComponent implements Comparable { + + private final String unlocalizedName; + private final float heat, coEff, computation, maxHeat; + private final boolean subZero; + + RackComponent(ItemStack is, float computation, float heat, float coEff, float maxHeat, boolean subZero) { + this(getUniqueIdentifier(is), computation, heat, coEff, maxHeat, subZero); + } + + RackComponent(String is, float computation, float heat, float coEff, float maxHeat, boolean subZero) { + unlocalizedName = is; + this.heat = heat; + this.coEff = coEff; + this.computation = computation; + this.maxHeat = maxHeat; + this.subZero = subZero; + componentBinds.put(unlocalizedName, this); + if (DEBUG_MODE) { + TecTech.LOGGER.info("Component registered: " + unlocalizedName); + } + } + + @Override + public int compareTo(RackComponent o) { + return unlocalizedName.compareTo(o.unlocalizedName); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof RackComponent) { + return compareTo((RackComponent) obj) == 0; + } + return false; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java new file mode 100644 index 0000000000..6ecbe67d22 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java @@ -0,0 +1,474 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; +import static org.lwjgl.opengl.GL11.GL_BLEND; +import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.glBlendFunc; +import static org.lwjgl.opengl.GL11.glColor4f; +import static org.lwjgl.opengl.GL11.glDisable; +import static org.lwjgl.opengl.GL11.glEnable; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.GlStateManager; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; + +/** + * Created by danie_000 on 15.12.2016. + */ +public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch + implements IAddGregtechLogo, IAddUIWidgets { + + private static Textures.BlockIcons.CustomIcon ScreenON; + private static Textures.BlockIcons.CustomIcon ScreenOFF; + public short[] matrix = new short[] { 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, + 500 }; + public byte selection = -1, mode = 0, status = -128; // all 8 bits set + + private String clientLocale = "en_US"; + + public GT_MetaTileEntity_Hatch_Uncertainty(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, ""); + TT_Utility.setTier(aTier, this); + regenerate(); + } + + public GT_MetaTileEntity_Hatch_Uncertainty(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + regenerate(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/UC"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/UC_ACTIVE"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(ScreenON) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture(ScreenOFF) }; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && (aTick & 15) == 0) { + if (mode == 0) { + aBaseMetaTileEntity.setActive(false); + status = -128; + } else { + aBaseMetaTileEntity.setActive(true); + shift(); + compute(); + } + } + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Hatch_Uncertainty(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyword.Status", clientLocale) + ": " + EnumChatFormatting.GOLD + status }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("mSel", selection); + aNBT.setByte("mMode", mode); + aNBT.setByte("mStatus", status); + NBTTagCompound mat = new NBTTagCompound(); + for (int i = 0; i < 16; i++) { + mat.setShort(Integer.toString(i), matrix[i]); + } + aNBT.setTag("mMat", mat); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + selection = aNBT.getByte("mSel"); + mode = aNBT.getByte("mMode"); + status = aNBT.getByte("mStatus"); + NBTTagCompound mat = aNBT.getCompoundTag("mMat"); + for (int i = 0; i < 16; i++) { + matrix[i] = mat.getShort(Integer.toString(i)); + } + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.certain.desc.0"), // Feeling + // certain, + // or + // not? + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.hatch.certain.desc.1") // Schrödinger equation in a box + }; + } + + private boolean balanceCheck(int sideLenY, short... masses) { + float inequality = 0; + for (int i = 0; i < masses.length >> 1; i++) { + inequality += Math.abs(masses[i] - masses[masses.length - i - 1]); + } + return inequality < masses.length << 7; + } + + public void regenerate() { + for (int i = 0; i < matrix.length; i++) { + matrix[i] = (short) TecTech.RANDOM.nextInt(1000); + } + } + + public byte compute() { + int result = 0; + switch (mode) { + case 1: // ooo oxo ooo + result = balanceCheck(4, matrix) ? 0 : 1; + break; + case 2: // ooo xox ooo + result += balanceCheck( + 4, + matrix[0], + matrix[4], + matrix[1], + matrix[5], + matrix[2], + matrix[6], + matrix[3], + matrix[7]) ? 0 : 1; + result += balanceCheck( + 4, + matrix[8], + matrix[12], + matrix[9], + matrix[13], + matrix[10], + matrix[14], + matrix[11], + matrix[15]) ? 0 : 2; + break; + case 3: // oxo xox oxo + result += balanceCheck( + 2, + matrix[0], + matrix[4], + matrix[8], + matrix[12], + matrix[1], + matrix[5], + matrix[9], + matrix[13]) ? 0 : 1; + result += balanceCheck( + 4, + matrix[0], + matrix[4], + matrix[1], + matrix[5], + matrix[2], + matrix[6], + matrix[3], + matrix[7]) ? 0 : 2; + result += balanceCheck( + 4, + matrix[8], + matrix[12], + matrix[9], + matrix[13], + matrix[10], + matrix[14], + matrix[11], + matrix[15]) ? 0 : 4; + result += balanceCheck( + 2, + matrix[2], + matrix[6], + matrix[10], + matrix[14], + matrix[3], + matrix[7], + matrix[11], + matrix[15]) ? 0 : 8; + break; + case 4: // xox ooo xox + result += balanceCheck(2, matrix[0], matrix[4], matrix[1], matrix[5]) ? 0 : 1; + result += balanceCheck(2, matrix[8], matrix[12], matrix[9], matrix[13]) ? 0 : 2; + result += balanceCheck(2, matrix[2], matrix[6], matrix[3], matrix[7]) ? 0 : 4; + result += balanceCheck(2, matrix[10], matrix[14], matrix[11], matrix[15]) ? 0 : 8; + break; + case 5: // xox oxo xox + result += balanceCheck(2, matrix[0], matrix[4], matrix[1], matrix[5]) ? 0 : 1; + result += balanceCheck(2, matrix[8], matrix[12], matrix[9], matrix[13]) ? 0 : 2; + result += balanceCheck(4, matrix) ? 0 : 4; + result += balanceCheck(2, matrix[2], matrix[6], matrix[3], matrix[7]) ? 0 : 8; + result += balanceCheck(2, matrix[10], matrix[14], matrix[11], matrix[15]) ? 0 : 16; + break; + } + return status = (byte) result; + } + + private void shift() { + int i = TecTech.RANDOM.nextInt(16), j = TecTech.RANDOM.nextInt(128); + matrix[i] += ((matrix[i] & 1) == 0 ? 2 : -2) * j >> 5; + matrix[i] += j == 0 ? 1 : 0; + if (matrix[i] < 0) { + matrix[i] = 0; + } else if (matrix[i] > 1000) { + matrix[i] = 999; + } + } + + public byte update(int newMode) { + if (newMode == mode) { + return status; + } + if (newMode < 0 || newMode > 5) { + newMode = 0; + } + mode = (byte) newMode; + regenerate(); + compute(); + return status; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(112, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + final boolean isAdvanced = mTier > 7; + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(43, 4) + .setSize(90, 72)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_MONITOR) + .setPos(46, 27) + .setSize(46, 46)); + + int[] xPositions = new int[] { 7, 25, 133, 151 }; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + final int index = i * 4 + j; + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (selection == -1) { + selection = (byte) index; + } else { + short temp = matrix[selection]; + matrix[selection] = matrix[index]; + matrix[index] = temp; + selection = -1; + } + compute(); + }) + .setPlayClickSound(false) + .setBackground(GT_UITextures.BUTTON_STANDARD, TecTechUITextures.OVERLAY_BUTTON_UNCERTAINTY[index]) + .setPos(xPositions[i], 4 + j * 18) + .setSize(18, 18)) + .widget(new FakeSyncWidget.ShortSyncer(() -> matrix[index], val -> matrix[index] = val)); + } + } + builder.widget(new FakeSyncWidget.ByteSyncer(() -> selection, val -> selection = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> mode, val -> mode = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> status, val -> status = val)); + + builder.widget( + new TextWidget().setStringSupplier(() -> "Status: " + (status == 0 ? "OK" : "NG")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)); + + for (int i = 0; i < 9; i++) { + final int index = i; + builder.widget(new DrawableWidget().setDrawable(() -> { + UITexture valid = TecTechUITextures.PICTURE_UNCERTAINTY_VALID[index]; + UITexture invalid = TecTechUITextures.PICTURE_UNCERTAINTY_INVALID[index]; + switch (mode) { + case 1: // ooo oxo ooo + if (index == 4) return status == 0 ? valid : invalid; + break; + case 2: // ooo xox ooo + if (index == 3) return (status & 1) == 0 ? valid : invalid; + if (index == 5) return (status & 2) == 0 ? valid : invalid; + break; + case 3: // oxo xox oxo + if (index == 1) return (status & 1) == 0 ? valid : invalid; + if (index == 3) return (status & 2) == 0 ? valid : invalid; + if (index == 5) return (status & 4) == 0 ? valid : invalid; + if (index == 7) return (status & 8) == 0 ? valid : invalid; + break; + case 4: // xox ooo xox + if (index == 0) return (status & 1) == 0 ? valid : invalid; + if (index == 2) return (status & 2) == 0 ? valid : invalid; + if (index == 6) return (status & 4) == 0 ? valid : invalid; + if (index == 8) return (status & 8) == 0 ? valid : invalid; + break; + case 5: // xox oxo xox + if (index == 0) return (status & 1) == 0 ? valid : invalid; + if (index == 2) return (status & 2) == 0 ? valid : invalid; + if (index == 4) return (status & 4) == 0 ? valid : invalid; + if (index == 6) return (status & 8) == 0 ? valid : invalid; + if (index == 8) return (status & 16) == 0 ? valid : invalid; + break; + } + return null; + }) + .setPos(55 + (index % 3) * 12, 36 + (index / 3) * 12) + .setSize(4, 4)); + } + + for (int i = 0; i < 16; i++) { + final int index = i; + builder.widget(new DrawableWidget() { + + @Override + public void draw(float partialTicks) { + if (isAdvanced) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(1f, 1f, 1f, (float) matrix[index] / 1000f); + + // super.draw but without disabling blend + GlStateManager.pushMatrix(); + getDrawable().draw(Pos2d.ZERO, getSize(), partialTicks); + GlStateManager.popMatrix(); + + glDisable(GL_BLEND); + glColor4f(1f, 1f, 1f, 1f); + } else { + if (TecTech.RANDOM.nextInt(1000) < matrix[index]) { + super.draw(partialTicks); + } + } + } + }.setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_INDICATOR) + .setPos(47 + (i / 4) * 12, 28 + (i % 4) * 12) + .setSize(8, 8)) + .widget( + new DrawableWidget() + .setDrawable(() -> selection == index ? TecTechUITextures.PICTURE_UNCERTAINTY_SELECTED : null) + .setPos(46 + (i / 4) * 12, 27 + (i % 4) * 12) + .setSize(10, 10)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_WirelessMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_WirelessMulti.java new file mode 100644 index 0000000000..3d3f417b51 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_WirelessMulti.java @@ -0,0 +1,216 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_WIRELESS_LASER; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_16A; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_4A; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_64A; +import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.BLUE; +import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.BOLD; +import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.GRAY; +import static gregtech.api.enums.GT_Values.AuthorColen; +import static gregtech.api.enums.GT_Values.V; +import static java.lang.Long.min; + +import java.math.BigInteger; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.IGlobalWirelessEnergy; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IWirelessEnergyHatchInformation; +import gregtech.api.metatileentity.MetaTileEntity; + +public class GT_MetaTileEntity_Hatch_WirelessMulti extends GT_MetaTileEntity_Hatch_EnergyMulti + implements IGlobalWirelessEnergy, IWirelessEnergyHatchInformation { + + private final BigInteger eu_transferred_per_operation = BigInteger + .valueOf(Amperes * V[mTier] * ticks_between_energy_addition); + private final long eu_transferred_per_operation_long = eu_transferred_per_operation.longValue(); + + private String owner_uuid; + private String owner_name; + + public GT_MetaTileEntity_Hatch_WirelessMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { GRAY + "Stores energy globally in a network, up to 2^(2^31) EU.", + GRAY + "Does not connect to wires. This block withdraws EU from the network.", + AuthorColen + GRAY + BOLD + " & " + BLUE + BOLD + "Cloud" }, + aAmp); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_Hatch_WirelessMulti(String aName, int aTier, int aAmp, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + private ITexture[] TEXTURE_OVERLAY; + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + switch (Amperes) { + case 4: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_MULTI_4A; + break; + case 16: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_MULTI_16A; + break; + case 64: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_MULTI_64A; + break; + default: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_LASER; + break; + } + return new ITexture[] { aBaseTexture, TEXTURE_OVERLAY[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + switch (Amperes) { + case 4: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_MULTI_4A; + break; + case 16: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_MULTI_16A; + break; + case 64: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_MULTI_64A; + break; + default: + TEXTURE_OVERLAY = OVERLAYS_ENERGY_IN_WIRELESS_LASER; + break; + } + return new ITexture[] { aBaseTexture, TEXTURE_OVERLAY[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return Amperes * V[mTier]; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return totalStorage(V[mTier]) * Amperes / 2; + } + + @Override + public long maxAmperesIn() { + return Amperes; + } + + @Override + public long maxWorkingAmperesIn() { + return Amperes; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_WirelessMulti(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.WIRELESS; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isServerSide()) { + // On first tick find the player name and attempt to add them to the map. + + // UUID and username of the owner. + owner_uuid = aBaseMetaTileEntity.getOwnerUuid() + .toString(); + owner_name = aBaseMetaTileEntity.getOwnerName(); + + strongCheckOrAddUser(owner_uuid, owner_name); + + tryFetchingEnergy(); + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + super.onPreTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + + // This is set up in a way to be as optimised as possible. If a user has a relatively plentiful energy + // network + // it should make no difference to them. Minimising the number of operations on BigInteger is essential. + + // Every ticks_between_energy_addition add eu_transferred_per_operation to internal EU storage from network. + if (aTick % ticks_between_energy_addition == 0L) { + tryFetchingEnergy(); + } + } + } + + private void tryFetchingEnergy() { + long currentEU = getBaseMetaTileEntity().getStoredEU(); + long maxEU = maxEUStore(); + long euToTransfer = min(maxEU - currentEU, eu_transferred_per_operation_long); + if (euToTransfer <= 0) return; // nothing to transfer + if (!addEUToGlobalEnergyMap(owner_uuid, -euToTransfer)) return; + setEUVar(currentEU + euToTransfer); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java new file mode 100644 index 0000000000..c01a17af86 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java @@ -0,0 +1,5101 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +public abstract class ForgeOfGodsRingsStructureString { + + public static final String[][] SECOND_RING = { { + + " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBEC CEBB ", + " BEEC CEEB ", + " EEC CEE ", + " EC CE ", + " EC CCCCC CE ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " EC CCCCC CE ", + " EC CE ", + " EEC CEE ", + " BEEC CEEB ", + " BBEC CEBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC D CCBB ", + " BBEC D CEBB ", + " BBBEEC DD CEEBBB ", + " EEEEC D CEEEE ", + " EEEC DD CEEE ", + " EEEC CCCCC CEEE ", + " EEC CHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHC CEE ", + " EEEC CCCCC CEEE ", + " EEEC DD CEEE ", + " EEEEC D CEEEE ", + " BBBEEC DD CEEBBB ", + " BBEC D CEBB ", + " BBCC D CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBEC CEBB ", + " BBBEEC CEEBBB ", + " BBBBEEEEC CEEEEBBBB ", + " EEEEEEEC CEEEEEEE ", + " EEEEEEEC CCCCC CEEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEEC CCCCC CEEEEEEE ", + " EEEEEEEC CEEEEEEE ", + " BBBBEEEEC CEEEEBBBB ", + " BBBEEC CEEBBB ", + " BBEC CEBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " ", + " ", + " ", + " ", + " BBB BBB ", + " BBBBEEE EEEBBBB ", + " BBBEEEEEEE EEEEEEEBBB ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " BBBEEEEEEE EEEEEEEBBB ", + " BBBBEEE EEEBBBB ", + " BBB BBB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBBBBEEEE EEEEBBBBB ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " BBBBBEEEE EEEEBBBBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " BBBEEEEE EEEEEBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBEEEEE EEEEEBBB ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBBBBEEE EEEBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBEEE EEEBBBBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBEEEE EEEEBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBEEEE EEEEBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BBBBEE EEBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBEE EEBBBB ", + " BB BB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BEEEE EEEEB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BEEEE EEEEB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBEEE EEEBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBEEE EEEBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BBBBE EBBBB ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " BBBBE EBBBB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBB BBBBBBBBB ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " BBBBBBBBB BBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBB BBBBBBBBBBBB ", + " EEEEEEEEEEEE EEEEEEEEEEEE ", + " EEEEEEEKKKKK KKKKKEEEEEEE ", + " EEEEEEEEEEEE EEEEEEEEEEEE ", + " BBBBBBBBBBBB BBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEKKKKKKKKKKKKKKKEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " } }; + + public static final String[][] THIRD_RING = { + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEC CEBBB ", + " EEEC CEEE ", + " EEC CEE ", + " EEC CCCCC CEE ", + " EC CC CC CE ", + " EC C C CE ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " EC C C CE ", + " EC CC CC CE ", + " EEC CCCCC CEE ", + " EEC CEE ", + " EEEC CEEE ", + " BBBEC CEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBCCD CCBB ", + " BBBEC DD CEBBB ", + " BBBEEEC D CEEEBBB ", + " EEEEEC DD CEEEEE ", + " EEEEEC DCCCCC CEEEEE ", + " EEEEC CCHHHHHCC CEEEE ", + " EEEEC CHHHHHHHHHC CEEEE ", + " EEEC CHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHC CEEE ", + " EEEEC CHHHHHHHHHC CEEEE ", + " EEEEC CCHHHHHCC CEEEE ", + " EEEEEC CCCCCD CEEEEE ", + " EEEEEC DD CEEEEE ", + " BBBEEEC D CEEEBBB ", + " BBBEC DD CEBBB ", + " BBCC DCCBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEC CEBBB ", + " BBBBEEEC CEEEBBBB ", + " BEEEEEEC CEEEEEEB ", + " EEEEEEEC CCCCC CEEEEEEE ", + " EEEEEEC CC CC CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC CC CC CEEEEEE ", + " EEEEEEEC CCCCC CEEEEEEE ", + " BEEEEEEC CEEEEEEB ", + " BBBBEEEC CEEEBBBB ", + " BBBEC CEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBBBEEEE EEEEBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBEEEE EEEEBBBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BBBBBEE EEBBBBB ", + " BEEEEEEE EEEEEEEB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BEEEEEEE EEEEEEEB ", + " BBBBBEE EEBBBBB ", + " BB BB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBEEEE EEEEBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBEEEE EEEEBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BBBBBE EBBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBBE EBBBBB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBEEE EEEBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBEEE EEEBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BEEE EEEB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BEEE EEEB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BBBE EBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBE EBBB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI EEEE ", + " EEEI IEEE ", + " EEEI EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEII IIEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBB BBBBBBBBB ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEEIII IIIEEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " BBBBBBBBB BBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBB BBBBBBBBBBB ", + " EEEEEEEEEEE EEEEEEEEEEE ", + " EEEEEEIIIII IIIIIEEEEEE ", + " EEEEEEEEEEE EEEEEEEEEEE ", + " BBBBBBBBBBB BBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEIIIIIIIIIIIIIEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBB ", + " EEEEEEEEEEEEE ", + " EEEEEEEEEEEEE ", + " EEEEEEEEEEEEE ", + " BBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " } }; + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java new file mode 100644 index 0000000000..bbf9e56f89 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java @@ -0,0 +1,5429 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +public abstract class ForgeOfGodsStructureString { + + public static final String[][] MAIN_STRUCTURE = { { + " ", + " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BB BB ", + " B DDD DDD B ", + " DDFD DFDD ", + " DDADD DDADD ", + " DFDD DDFD ", + " DDD DDD ", + " ", + " ", + " ", + " DDD DDD ", + " DFDD DDFD ", + " DDADD DDADD ", + " DDFD DFDD ", + " B DDD DDD B ", + " BB BB ", + " BB BB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BEEBBBBB BBBBBEEB ", + " BEEEECCCCBCCCCEEEEB ", + " BEEECEE CFC EECEEEB ", + " BECEEE CFC EEECEB ", + " BCEE CFC EECB ", + " BCEE CCCFC EECB ", + " BC CFFCCFC CB ", + " BCCCCFCCFCFCCCCCB ", + " BFFFCCF~FCCFFFB ", + " BCCCCCFCFCCFCCCCB ", + " BC CFCCFFC CB ", + " BCEE CFCCC EECB ", + " BCEE CFC EECB ", + " BECEEE CFC EEECEB ", + " BEEECEE CFC EECEEEB ", + " BEEEECCCCBCCCCEEEEB ", + " BEEBBBBB BBBBBEEB ", + " BB BB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " BB BB ", + " BBEEBBB BBBEEBB ", + " BEEEEEEB BEEEEEEB ", + " BEEDDDDDBBBBBDDDDDEEB ", + " BEEDEE EEDEEB ", + " BEDE EDEB ", + " BED DEB ", + " BED DEB ", + " BB BB ", + " B B ", + " B B ", + " B B ", + " BB BB ", + " BED DEB ", + " BED DEB ", + " BEDE EDEB ", + " BEEDEE EEDEEB ", + " BEEDDDDDBBBBBDDDDDEEB ", + " BEEEEEEB BEEEEEEB ", + " BBEEBBB BBBEEBB ", + " BB BB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BEEEEB BEEEEB ", + " BEEDDBBB BBBDDEEB ", + " BED DEB ", + " BED DEB ", + " BB BB ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " BB BB ", + " BED DEB ", + " BED DEB ", + " BEEDDBBB BBBDDEEB ", + " BEEEEB BEEEEB ", + " BBBB BBBB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " BB BB ", + " BEEBB BBEEB ", + " BBB BEB ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " BEB BEB ", + " BEBBB BBEEB ", + " BB BB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BB BB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BB BB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BBBBB ", + " BBCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " EEC CEE ", + " EC CE ", + " EC CE ", + " C CCC C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C CCC C ", + " EC CE ", + " EC CE ", + " EEC CEE ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCBB ", + " BBBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BBBBB ", + " BBCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEEC CEEBBB ", + " BBEEEEC DDCEEEEBB ", + " EEEEEEC DDD CEEEEEE ", + " EEEEEC CCCDD CEEEEE ", + " EEEEEC CHHHC CEEEEE ", + " EEEEEC CHHHC CEEEEE ", + " EEEEEC CHHHC CEEEEE ", + " EEEEEC DDCCC CEEEEE ", + " EEEEEEC DDD CEEEEEE ", + " BBEEEECDD CEEEEBB ", + " BBBEEC CEEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCBB ", + " BBBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BBBBB ", + " BBCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEEC CEEBBB ", + " BBBBEEEEC CEEEEBBBB ", + " BBEEEEEEEEC CEEEEEEEEBB ", + " EEEEEEEEEC CCC CEEEEEEEEE ", + " EEEEEEEEEC C C CEEEEEEEEE ", + " EEEEEEEEEC C C CEEEEEEEEE ", + " EEEEEEEEEC C C CEEEEEEEEE ", + " EEEEEEEEEC CCC CEEEEEEEEE ", + " BBEEEEEEEEC CEEEEEEEEBB ", + " BBBBEEEEC CEEEEBBBB ", + " BBBEEC CEEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCBB ", + " BBBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBBBEEEE EEEEBBBB ", + " BBBBBEEEEEEEE EEEEEEEEBBBBB ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " EEEEEEEEEGGGG GGGGEEEEEEEEE ", + " EEEEEEEGGGGGG GGGGGGEEEEEEE ", + " EEEEEEEEEGGGG GGGGEEEEEEEEE ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " BBBBBEEEEEEEE EEEEEEEEBBBBB ", + " BBBBEEEE EEEEBBBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BBBBBEE EEBBBBB ", + " BBBEEEEEEE EEEEEEEBBB ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEGGGG GGGGEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " BBBEEEEEEE EEEEEEEBBB ", + " BBBBBEE EEBBBBB ", + " BB BB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBBBBEEE EEEBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEGGG GGGEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBEEE EEEBBBBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEEGG GGEEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEGGG GGGEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEGGG GGGEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEEGG GGEEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEGGG GGGEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBB BBBBBBBBBB ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEGGGG GGGGEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " BBBBBBBBBB BBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBB BBBBBBBBBBBBB ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " EEEEEEEGGGGGG GGGGGGEEEEEEE ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " BBBBBBBBBBBBB BBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEGGGGGGGGGGGGGGGEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " } }; +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java new file mode 100644 index 0000000000..afa09dd193 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java @@ -0,0 +1,1767 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.TecTech.eyeOfHarmonyRecipeStorage; +import static com.github.technus.tectech.thing.CustomItemList.astralArrayFabricator; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.eyeOfHarmonyRenderBlock; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsBA0; +import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES; +import static com.github.technus.tectech.util.TT_Utility.toStandardForm; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +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.enums.GT_HatchElement.OutputHatch; +import static gregtech.api.enums.GT_Values.AuthorColen; +import static gregtech.api.util.GT_ParallelHelper.calculateChancedOutputMultiplier; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static java.lang.Math.exp; +import static java.lang.Math.max; +import static java.lang.Math.pow; +import static net.minecraft.util.EnumChatFormatting.BLUE; +import static net.minecraft.util.EnumChatFormatting.GOLD; +import static net.minecraft.util.EnumChatFormatting.GRAY; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nonnull; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.recipe.EyeOfHarmonyRecipe; +import com.github.technus.tectech.recipe.TecTechRecipeMaps; +import com.github.technus.tectech.thing.block.TileEyeOfHarmony; +import com.github.technus.tectech.thing.casing.TT_Container_Casings; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.FluidStackLong; +import com.github.technus.tectech.util.ItemStackLong; +import com.google.common.collect.ImmutableList; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IGlobalWirelessEnergy; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Output_ME; + +@SuppressWarnings("SpellCheckingInspection") +public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_MultiblockBase_EM + implements IConstructable, IGlobalWirelessEnergy, ISurvivalConstructable { + + public static final boolean EOH_DEBUG_MODE = false; + private static final long MOLTEN_SPACETIME_PER_FAILURE_TIER = 14_400L; + private static final double SPACETIME_FAILURE_BASE = 2; + private static final String TOOLTIP_BAR = GOLD + + "---------------------------------------------------------------------------------------"; + + // Region variables. + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + + private int spacetimeCompressionFieldMetadata = -1; + private int timeAccelerationFieldMetadata = -1; + private int stabilisationFieldMetadata = -1; + + private static final double SPACETIME_CASING_DIFFERENCE_DISCOUNT_PERCENTAGE = 0.03; + private static final double TIME_ACCEL_DECREASE_CHANCE_PER_TIER = 0.0925; + // % Increase in recipe chance and % decrease in yield per tier. + private static final double STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER = 0.05; + private static final double LOG_CONSTANT = Math.log(1.7); + private static final double PARALLEL_MULTIPLIER_CONSTANT = 1.63; + private static final long POWER_DIVISION_CONSTANT = 9; + private static final int TOTAL_CASING_TIERS_WITH_POWER_PENALTY = 8; + private static final long PRECISION_MULTIPLIER = 1_000_000; + + private String userUUID = ""; + private BigInteger outputEU_BigInt = BigInteger.ZERO; + private long startEU = 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 * 5); // 200 blocks max per + // placement. + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 16, 16, 0, realBudget, source, actor, false, true); + } + + protected static final String STRUCTURE_PIECE_MAIN = "main"; + + // Multiblock structure. + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " C C ", " CCCCCCCCC ", + " C C ", " CCCCCCCCC ", + " C C ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " C C ", " DDDDD ", + " DDCDCDD ", " CCCCDCCDCCDCCCC ", + " DDDDDDD ", " CCCCDCCDCCDCCCC ", + " DDCDCDD ", " DDDDD ", + " C C ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " D ", " D ", + " DDDDDDD ", " DD DD ", + " D EEE D ", " CCC D EAAAE D CCC ", + " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", + " D EEE D ", " DD DD ", + " DDDDDDD ", " D ", + " D ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " D ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DD DD ", " CC CC ", + " ", " ", + " ", " ", + " ", " D ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " A ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDAA AADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " A ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDA ADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " " }, + { " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " " }, + { " ", " ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " DA AD ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " ", + " " }, + { " ", " C C ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DA AD ", " CC CC ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " C C ", + " " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " CCCCCCC ", " C C ", + " DDDDDDD ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " D D ", + " D D ", "CCD DCC", + " D D ", "CCD DCC", + " D D ", " D D ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " DDDDDDD ", " C C ", + " C C " }, + { " CCHHHHHCC ", " DDDDD ", + " DD DD ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CD DC", + " D D ", "CD DC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " DD DD ", " DDDDD ", + " C C " }, + { " CHHHHHHHC ", " DDCDCDD ", + " D EEE D ", " ", + " C C ", " E E ", + " C C ", " E E ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CCE ECC", + " DE ED ", "CCE ECC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " E E ", + " C C ", " E E ", + " C C ", " ", + " D EEE D ", " DDCDCDD ", + " C C " }, + { " CHHCCCHHC ", " CCCCDCCDCCDCCCC ", + " CCC D EAAAE D CCC ", " CC CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " C C ", " CC CC ", + " C C ", " C C ", + "CCD DCC", "CD DC", + "CCE ECC", "CCA ACC", + "CDA ADC", "CCA ACC", + "CCE ECC", "CD DC", + "CCD DCC", " C C ", + " C C ", " CC CC ", + " C C ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC CC ", + " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", + " CCCCCCCCC " }, + { " CHHC~CHHC ", " DDDDDDD ", + " DDD EAAAE DDD ", " DD DD ", + " CDAA AADC ", " DA AD ", + " CDA ADC ", " DA AD ", + " DA AD ", " DA AD ", + " D D ", " D D ", + " D D ", " D D ", + " DE ED ", "CDA ADC", + " DA AD ", "CDA ADC", + " DE ED ", " D D ", + " D D ", " D D ", + " D D ", " DA AD ", + " DA AD ", " DA AD ", + " CDA ADC ", " DA AD ", + " CDAA AADC ", " DD DD ", + " DDD EAAAE DDD ", " DDDDDDD ", + " C C " }, + { " CHHCCCHHC ", " CCCCDCCDCCDCCCC ", + " CCC D EAAAE D CCC ", " CC CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " C C ", " CC CC ", + " C C ", " C C ", + "CCD DCC", "CD DC", + "CCE ECC", "CCA ACC", + "CDA ADC", "CCA ACC", + "CCE ECC", "CD DC", + "CCD DCC", " C C ", + " C C ", " CC CC ", + " C C ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC CC ", + " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", + " CCCCCCCCC " }, + { " CHHHHHHHC ", " DDCDCDD ", + " D EEE D ", " ", + " C C ", " E E ", + " C C ", " E E ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CCE ECC", + " DE ED ", "CCE ECC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " E E ", + " C C ", " E E ", + " C C ", " ", + " D EEE D ", " DDCDCDD ", + " C C " }, + { " CCHHHHHCC ", " DDDDD ", + " DD DD ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CD DC", + " D D ", "CD DC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " DD DD ", " DDDDD ", + " C C " }, + { " CCCCCCC ", " C C ", + " DDDDDDD ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " D D ", + " D D ", "CCD DCC", + " D D ", "CCD DCC", + " D D ", " D D ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " DDDDDDD ", " C C ", + " C C " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " ", " C C ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DA AD ", " CC CC ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " C C ", + " " }, + { " ", " ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " DA AD ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " ", + " " }, + { " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " " }, + { " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDA ADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " A ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDAA AADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " A ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " D ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DD DD ", " CC CC ", + " ", " ", + " ", " ", + " ", " D ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " D ", " D ", + " DDDDDDD ", " DD DD ", + " D EEE D ", " CCC D EAAAE D CCC ", + " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", + " D EEE D ", " DD DD ", + " DDDDDDD ", " D ", + " D ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " C C ", " DDDDD ", + " DDCDCDD ", " CCCCDCCDCCDCCCC ", + " DDDDDDD ", " CCCCDCCDCCDCCCC ", + " DDCDCDD ", " DDDDD ", + " C C ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " C C ", " CCCCCCCCC ", + " C C ", " CCCCCCCCC ", + " C C ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " } })) + .addElement( + 'A', + withChannel( + "spacetime compression", + ofBlocksTiered( + (block, meta) -> block == TT_Container_Casings.SpacetimeCompressionFieldGenerators ? meta : null, + ImmutableList.of( + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 0), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 1), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 2), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 3), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 4), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 5), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 6), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 7), + Pair.of(TT_Container_Casings.SpacetimeCompressionFieldGenerators, 8)), + -1, + (t, meta) -> t.spacetimeCompressionFieldMetadata = meta, + t -> t.spacetimeCompressionFieldMetadata))) + .addElement( + 'S', + withChannel( + "stabilisation", + ofBlocksTiered( + (block, meta) -> block == TT_Container_Casings.StabilisationFieldGenerators ? meta : null, + ImmutableList.of( + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 0), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 1), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 2), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 3), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 4), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 5), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 6), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 7), + Pair.of(TT_Container_Casings.StabilisationFieldGenerators, 8)), + -1, + (t, meta) -> t.stabilisationFieldMetadata = meta, + t -> t.stabilisationFieldMetadata))) + .addElement('C', ofBlock(sBlockCasingsBA0, 11)) + .addElement('D', ofBlock(sBlockCasingsBA0, 10)) + .addElement( + 'H', + buildHatchAdder(GT_MetaTileEntity_EM_EyeOfHarmony.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus) + .casingIndex(texturePage << 7) + .dot(1) + .buildAndChain(sBlockCasingsBA0, 12)) + .addElement( + 'E', + withChannel( + "time dilation", + ofBlocksTiered( + (block, meta) -> block == TT_Container_Casings.TimeAccelerationFieldGenerator ? meta : null, + ImmutableList.of( + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 0), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 1), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 2), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 3), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 4), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 5), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 6), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 7), + Pair.of(TT_Container_Casings.TimeAccelerationFieldGenerator, 8)), + -1, + (t, meta) -> t.timeAccelerationFieldMetadata = meta, + t -> t.timeAccelerationFieldMetadata))) + .build(); + + private double hydrogenOverflowProbabilityAdjustment; + private double heliumOverflowProbabilityAdjustment; + private double stellarPlasmaOverflowProbabilityAdjustment; + private static final long TICKS_BETWEEN_HATCH_DRAIN = EOH_DEBUG_MODE ? 10 : 20; + + private List outputItems = new ArrayList<>(); + private List outputFluids = new ArrayList<>(); + + private void calculateInputFluidExcessValues(final long hydrogenRecipeRequirement, + final long heliumRecipeRequirement) { + + double hydrogenStored = getHydrogenStored(); + double heliumStored = getHeliumStored(); + double stellarPlasmaStored = getStellarPlasmaStored(); + + double hydrogenExcessPercentage = hydrogenStored / hydrogenRecipeRequirement - 1; + double heliumExcessPercentage = heliumStored / heliumRecipeRequirement - 1; + double stellarPlasmaExcessPercentage = stellarPlasmaStored + / (heliumRecipeRequirement * (12.4 / 1_000_000f) * parallelAmount) - 1; + + hydrogenOverflowProbabilityAdjustment = 1 - exp(-pow(30 * hydrogenExcessPercentage, 2)); + heliumOverflowProbabilityAdjustment = 1 - exp(-pow(30 * heliumExcessPercentage, 2)); + stellarPlasmaOverflowProbabilityAdjustment = 1 - exp(-pow(30 * stellarPlasmaExcessPercentage, 2)); + } + + private double recipeChanceCalculator() { + double chance = currentRecipe.getBaseRecipeSuccessChance() + - timeAccelerationFieldMetadata * TIME_ACCEL_DECREASE_CHANCE_PER_TIER + + stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; + + if (parallelAmount > 1) { + chance -= stellarPlasmaOverflowProbabilityAdjustment; + } else { + chance -= (hydrogenOverflowProbabilityAdjustment + heliumOverflowProbabilityAdjustment); + } + + return MathHelper.clamp_double(chance, 0.0, 1.0); + } + + private double recipeYieldCalculator() { + double yield = 1.0 - stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; + + if (parallelAmount > 1) { + yield -= stellarPlasmaOverflowProbabilityAdjustment; + } else { + yield -= (hydrogenOverflowProbabilityAdjustment + heliumOverflowProbabilityAdjustment); + } + return MathHelper.clamp_double(yield, 0.0, 1.0); + } + + private int recipeProcessTimeCalculator(final long recipeTime, final long recipeSpacetimeCasingRequired) { + + // Tier 1 recipe. + // Tier 2 spacetime blocks. + // = 3% discount. + + // Tier 1 recipe. + // Tier 3 spacetime blocks. + // = 3%*3% = 5.91% discount. + + final long spacetimeCasingDifference = (recipeSpacetimeCasingRequired - spacetimeCompressionFieldMetadata); + final double recipeTimeDiscounted = recipeTime * pow(2.0, -timeAccelerationFieldMetadata) + * pow(1 - SPACETIME_CASING_DIFFERENCE_DISCOUNT_PERCENTAGE, -spacetimeCasingDifference) + / max(1, pow(2, currentCircuitMultiplier)); + return (int) Math.max(recipeTimeDiscounted, 1.0); + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + public GT_MetaTileEntity_EM_EyeOfHarmony(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_EyeOfHarmony(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_EyeOfHarmony(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + + spacetimeCompressionFieldMetadata = -1; + timeAccelerationFieldMetadata = -1; + stabilisationFieldMetadata = -1; + + // Check structure of multi. + if (!structureCheck_EM(STRUCTURE_PIECE_MAIN, 16, 16, 0)) { + return false; + } + + // Make sure there are no Crafting Input Buffers/Buses/Slaves. + if (!mDualInputHatches.isEmpty()) { + return false; + } + + // Check if there is 1 output bus, and it is a ME output bus. + { + if (mOutputBusses.size() != 1) { + return false; + } + + if (!(mOutputBusses.get(0) instanceof GT_MetaTileEntity_Hatch_OutputBus_ME)) { + return false; + } + } + + // Check if there is 1 output hatch, and they are ME output hatches. + { + if (mOutputHatches.size() != 1) { + return false; + } + + if (!(mOutputHatches.get(0) instanceof GT_MetaTileEntity_Hatch_Output_ME)) { + return false; + } + } + + // Check there is 1 input bus, and it is not a stocking input bus. + { + if (mInputBusses.size() != 1) { + return false; + } + + if (mInputBusses.get(0) instanceof GT_MetaTileEntity_Hatch_InputBus_ME) { + return false; + } + } + + // Make sure there are no energy hatches. + { + if (mEnergyHatches.size() > 0) { + return false; + } + + if (mExoticEnergyHatches.size() > 0) { + return false; + } + } + + // Make sure there are 2 input hatches. + if (mInputHatches.size() != 2) { + return false; + } + + mHardHammer = true; + mSoftHammer = true; + mScrewdriver = true; + mCrowbar = true; + mSolderingTool = true; + mWrench = true; + return true; + } + + private boolean animationsEnabled = true; + + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + animationsEnabled = !animationsEnabled; + aPlayer.addChatMessage( + new ChatComponentText("Animations are now " + (animationsEnabled ? "enabled" : "disabled") + ".")); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Spacetime Manipulator, EOH") + .addInfo(TOOLTIP_BAR) + .addInfo("Creates a pocket of spacetime that is bigger on the inside using transdimensional") + .addInfo("engineering. Certified Time Lord regulation compliant. This multi uses too much EU") + .addInfo("to be handled with conventional means. All EU requirements are handled directly by") + .addInfo("your wireless EU network.") + .addInfo(TOOLTIP_BAR) + .addInfo("This multiblock will constantly consume hydrogen and helium when it is not running a") + .addInfo("recipe once per second. It will store this internally, you can see the totals by") + .addInfo("using a scanner. This multi also has three tiered blocks with " + RED + 9 + GRAY + " tiers") + .addInfo("each. They are as follows and have the associated effects on the multi.") + .addInfo(BLUE + "Spacetime Compression Field Generator:") + .addInfo("- The tier of this block determines what recipes can be run. If the multiblocks") + .addInfo(" spacetime compression field block exceeds the requirements of the recipe it") + .addInfo( + " will decrease the processing time by " + RED + + formatNumbers(SPACETIME_CASING_DIFFERENCE_DISCOUNT_PERCENTAGE * 100) + + "%" + + GRAY + + " per tier over the requirement (multiplicative).") + .addInfo(BLUE + "Time Dilation Field Generator:") + .addInfo( + "- Decreases the time required for a recipe by " + RED + + "50%" + + GRAY + + " per tier of block (multiplicative).") + .addInfo( + " Decreases the probability of a recipe succeeding by " + RED + + formatNumbers(TIME_ACCEL_DECREASE_CHANCE_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive)") + .addInfo(BLUE + "Stabilisation Field Generator:") + .addInfo( + "- Increases the probability of a recipe succeeding by " + RED + + formatNumbers(STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive).") + .addInfo( + " Decreases the yield of a recipe by " + RED + + formatNumbers(STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive). ") + .addInfo(" > Low tier stabilisation field generators have a power output penalty.") + .addInfo( + " The power output penalty for using Crude Stabilisation Field Generators is " + RED + + formatNumbers( + STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * TOTAL_CASING_TIERS_WITH_POWER_PENALTY + * 100) + + "%" + + GRAY + + ".") + .addInfo( + " This penalty decreases by " + RED + + formatNumbers(STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive).") + .addInfo(TOOLTIP_BAR) + .addInfo("Going over a recipe requirement on hydrogen or helium has a penalty on yield and recipe chance.") + .addInfo("All stored hydrogen and helium is consumed during a craft. The associated formulas are:") + .addInfo(GREEN + "Overflow ratio = (Stored fluid / Recipe requirement) - 1") + .addInfo(GREEN + "Adjustment value = 1 - exp(-(30 * Overflow ratio)^2)") + .addInfo("The Adjustment value is then subtracted from the total yield and recipe chance.") + .addInfo(TOOLTIP_BAR) + .addInfo("It should be noted that base recipe chance is determined per recipe and yield always starts") + .addInfo("at 1 and subtracts depending on penalties. All fluid/item outputs are multiplied by the") + .addInfo("yield. Failure fluid is exempt.") + .addInfo(TOOLTIP_BAR) + .addInfo("This multiblock can only output to ME output buses/hatches.") + .addInfo(TOOLTIP_BAR) + .addInfo("This multiblock can be overclocked by placing a programmed circuit into the input bus.") + .addInfo( + "E.g. A circuit of 2 will provide 2 OCs, 16x EU input and 0.25x the time. EU output is unaffected.") + .addInfo("All outputs are equal. All item and fluid output chances & amounts per recipe are unaffected.") + .addInfo(TOOLTIP_BAR) + .addInfo( + "If a recipe fails the EOH will output " + GREEN + + "Success chance * " + + formatNumbers(MOLTEN_SPACETIME_PER_FAILURE_TIER) + + " * (" + + SPACETIME_FAILURE_BASE + + ")^(Recipe tier)" + + GRAY + + "L of molten") + .addInfo( + MaterialsUEVplus.SpaceTime.getLocalizedNameForItem("%material") + + " instead of fluid/item outputs and output as much EU as a successful recipe.") + .addInfo(TOOLTIP_BAR) + .addInfo( + "This multiblock can perform parallel processing by placing Astral Array Fabricators into the input bus.") + .addInfo("The amount of parallel is calculated via these formulas:") + .addInfo(GREEN + "Parallel exponent = floor(log(8 * Astral Array amount) / log(1.7))") + .addInfo(GREEN + "Parallel = 2^(Parallel exponent)") + .addInfo("If the EOH is running parallel recipes, the power calculation changes.") + .addInfo("The power needed for parallel processing is calculated as follows:") + .addInfo(GREEN + "total EU = ((EU output - EU input * 1.63) / 9) * 2.3^(Parallel exponent - 1)") + .addInfo( + "Furthermore, if parallel recipes are run, the recipes consume " + + MaterialsUEVplus.RawStarMatter.getLocalizedNameForItem("%material")) + .addInfo("instead of helium and hydrogen. Overflow penalties still apply.") + .addInfo( + "The required amount of fluid to start a recipe is " + GREEN + + "12.4 / 10^6 * Helium amount * Parallel" + + GRAY + + ".") + .addInfo("The success or failure of each parallel is determined independently.") + .addInfo(TOOLTIP_BAR) + .addInfo("Animations can be disabled by using a screwdriver on the multiblock.") + .addSeparator() + .addStructureInfo("Eye of Harmony structure is too complex! See schematic for details.") + .addStructureInfo( + EnumChatFormatting.GOLD + "896" + EnumChatFormatting.GRAY + " Reinforced Spatial Structure Casing.") + .addStructureInfo( + EnumChatFormatting.GOLD + "534" + EnumChatFormatting.GRAY + " Reinforced Temporal Structure Casing.") + .addStructureInfo( + EnumChatFormatting.GOLD + "31" + + EnumChatFormatting.GRAY + + " Infinite SpaceTime Energy Boundary Casing.") + .addStructureInfo( + EnumChatFormatting.GOLD + "168" + EnumChatFormatting.GRAY + " Time Dilation Field Generator.") + .addStructureInfo( + EnumChatFormatting.GOLD + "48" + EnumChatFormatting.GRAY + " Stabilisation Field Generator.") + .addStructureInfo( + EnumChatFormatting.GOLD + "138" + EnumChatFormatting.GRAY + " Spacetime Compression Field Generator.") + .addStructureInfo("--------------------------------------------") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 2 + EnumChatFormatting.GRAY + " input hatches.") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " ME output hatch.") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " input bus.") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " ME output bus.") + .addStructureInfo("--------------------------------------------") + .beginStructureBlock(33, 33, 33, false) + .toolTipFinisher(AuthorColen.substring(8) + EnumChatFormatting.GRAY + "&" + CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_BHG"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_BHG_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][12], + new TT_RenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][12] }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM(STRUCTURE_PIECE_MAIN, 16, 16, 0, stackSize, hintsOnly); + } + + private final Map validFluidMap = new HashMap<>() { + + private static final long serialVersionUID = -8452610443191188130L; + + { + put(Materials.Hydrogen.mGas, 0L); + put(Materials.Helium.mGas, 0L); + put(MaterialsUEVplus.RawStarMatter.mFluid, 0L); + } + }; + + private void drainFluidFromHatchesAndStoreInternally() { + List fluidStacks = getStoredFluids(); + for (FluidStack fluidStack : fluidStacks) { + if (validFluidMap.containsKey(fluidStack.getFluid())) { + validFluidMap.merge(fluidStack.getFluid(), (long) fluidStack.amount, Long::sum); + fluidStack.amount = 0; + } + } + updateSlots(); + } + + @Override + public RecipeMap getRecipeMap() { + // Only for visual + return TecTechRecipeMaps.eyeOfHarmonyRecipes; + } + + private EyeOfHarmonyRecipe currentRecipe; + + // Counter for lag prevention. + private long lagPreventer = 0; + + // Check for recipe every recipeCheckInterval ticks. + private static final long RECIPE_CHECK_INTERVAL = 3 * 20; + private long currentCircuitMultiplier = 0; + private long astralArrayAmount = 0; + private long parallelAmount = 1; + private long successfulParallelAmount = 0; + private double yield = 0; + private BigInteger usedEU = BigInteger.ZERO; + private FluidStackLong stellarPlasma; + private FluidStackLong starMatter; + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + ItemStack controllerStack = getControllerSlot(); + if (controllerStack == null) { + return SimpleCheckRecipeResult.ofFailure("no_planet_block"); + } + + lagPreventer++; + if (lagPreventer < RECIPE_CHECK_INTERVAL) { + lagPreventer = 0; + // No item in multi gui slot. + + currentRecipe = eyeOfHarmonyRecipeStorage.recipeLookUp(controllerStack); + if (currentRecipe == null) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + CheckRecipeResult result = processRecipe(currentRecipe); + if (!result.wasSuccessful()) currentRecipe = null; + return result; + } + return CheckRecipeResultRegistry.NO_RECIPE; + } + + private long getHydrogenStored() { + return validFluidMap.get(Materials.Hydrogen.mGas); + } + + private long getHeliumStored() { + return validFluidMap.get(Materials.Helium.mGas); + } + + private long getStellarPlasmaStored() { + return validFluidMap.get(MaterialsUEVplus.RawStarMatter.mFluid); + } + + public CheckRecipeResult processRecipe(EyeOfHarmonyRecipe recipeObject) { + + // Get circuit damage, clamp it and then use it later for overclocking. + currentCircuitMultiplier = 0; + if (!mInputBusses.isEmpty()) { + for (ItemStack itemStack : mInputBusses.get(0) + .getRealInventory()) { + if (GT_Utility.isAnyIntegratedCircuit(itemStack)) { + currentCircuitMultiplier = MathHelper.clamp_int(itemStack.getItemDamage(), 0, 24); + break; + } + } + } + + astralArrayAmount = 0; + + for (ItemStack itemStack : mInputBusses.get(0) + .getRealInventory()) { + if (itemStack != null && itemStack.isItemEqual(astralArrayFabricator.get(1))) { + astralArrayAmount += itemStack.stackSize; + } + } + + long parallelExponent = 1; + + if (astralArrayAmount != 0) { + parallelExponent = (long) Math.floor(Math.log(8 * astralArrayAmount) / LOG_CONSTANT); + parallelAmount = (long) pow(2, parallelExponent); + } else { + parallelAmount = 1; + } + + // Debug mode, overwrites the required fluids to initiate the recipe to 100L of each. + if (parallelAmount > 1) { + if ((EOH_DEBUG_MODE && getStellarPlasmaStored() < 100) || (!EOH_DEBUG_MODE && getStellarPlasmaStored() + < currentRecipe.getHeliumRequirement() * (12.4 / 1_000_000f) * parallelAmount)) { + return SimpleCheckRecipeResult.ofFailure("no_stellar_plasma"); + } + } + + if (parallelAmount == 1) { + if ((EOH_DEBUG_MODE && getHydrogenStored() < 100) + || (!EOH_DEBUG_MODE && getHydrogenStored() < currentRecipe.getHydrogenRequirement() * parallelAmount)) { + return SimpleCheckRecipeResult.ofFailure("no_hydrogen"); + } + + if ((EOH_DEBUG_MODE && getHeliumStored() < 100) + || (!EOH_DEBUG_MODE && getHeliumStored() < currentRecipe.getHeliumRequirement() * parallelAmount)) { + return SimpleCheckRecipeResult.ofFailure("no_helium"); + } + } + + if (spacetimeCompressionFieldMetadata == -1) { + return CheckRecipeResultRegistry + .insufficientMachineTier((int) recipeObject.getSpacetimeCasingTierRequired()); + } + + // Check tier of spacetime compression blocks is high enough. + if ((spacetimeCompressionFieldMetadata + 1) < recipeObject.getSpacetimeCasingTierRequired()) { + return CheckRecipeResultRegistry + .insufficientMachineTier((int) recipeObject.getSpacetimeCasingTierRequired()); + } + + // Calculate multipliers used in power calculations + double powerMultiplier = Math.max(1, Math.pow(2.3, (parallelExponent - 1))); + + // Determine EU recipe input + startEU = recipeObject.getEUStartCost(); + + // Calculate normal EU values + double outputEUPenalty = (TOTAL_CASING_TIERS_WITH_POWER_PENALTY - stabilisationFieldMetadata) + * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; + outputEU_BigInt = BigInteger.valueOf((long) (recipeObject.getEUOutput() * (1 - outputEUPenalty))); + usedEU = BigInteger.valueOf(-startEU) + .multiply(BigInteger.valueOf((long) Math.pow(4, currentCircuitMultiplier))); + + // Calculate parallel EU values + if (parallelAmount > 1) { + outputEU_BigInt = outputEU_BigInt + .multiply(BigInteger.valueOf((long) (powerMultiplier * PRECISION_MULTIPLIER))) + .divide(BigInteger.valueOf(PRECISION_MULTIPLIER * POWER_DIVISION_CONSTANT)); + + usedEU = usedEU + .multiply( + BigInteger.valueOf((long) (powerMultiplier * PARALLEL_MULTIPLIER_CONSTANT * PRECISION_MULTIPLIER))) + .divide(BigInteger.valueOf(PRECISION_MULTIPLIER * POWER_DIVISION_CONSTANT)); + } + + // Remove EU from the users network. + if (!addEUToGlobalEnergyMap(userUUID, usedEU)) { + return SimpleCheckRecipeResult.ofFailure("insufficient_power_no_val"); + } + + mMaxProgresstime = recipeProcessTimeCalculator( + recipeObject.getRecipeTimeInTicks(), + recipeObject.getSpacetimeCasingTierRequired()); + + calculateInputFluidExcessValues(recipeObject.getHydrogenRequirement(), recipeObject.getHeliumRequirement()); + + if (EOH_DEBUG_MODE) { + hydrogenOverflowProbabilityAdjustment = 0; + heliumOverflowProbabilityAdjustment = 0; + stellarPlasmaOverflowProbabilityAdjustment = 0; + } + + successChance = recipeChanceCalculator(); + currentRecipeRocketTier = currentRecipe.getRocketTier(); + + // Reduce internal storage by input fluid quantity required for recipe. + if (parallelAmount > 1) { + validFluidMap.put(MaterialsUEVplus.RawStarMatter.mFluid, 0L); + } else { + validFluidMap.put(Materials.Hydrogen.mGas, 0L); + validFluidMap.put(Materials.Helium.mGas, 0L); + } + + yield = recipeYieldCalculator(); + if (EOH_DEBUG_MODE) { + successChance = 1; // Debug recipes, sets them to 100% output chance. + } + + // Return copies of the output objects. + outputFluids = recipeObject.getOutputFluids(); + outputItems = recipeObject.getOutputItems(); + + // Star matter is always the last element in the array. + starMatter = new FluidStackLong(outputFluids.get(outputFluids.size() - 1)); + + // And stellar plasma is the second last. + stellarPlasma = new FluidStackLong(outputFluids.get(outputFluids.size() - 2)); + + successfulParallelAmount = (long) calculateChancedOutputMultiplier( + (int) (10000 * successChance), + (int) parallelAmount); + // Iterate over item output list and apply yield & successful parallel values. + for (ItemStackLong itemStackLong : outputItems) { + itemStackLong.stackSize *= yield * successfulParallelAmount; + } + + // Iterate over fluid output list and apply yield & successful parallel values. + for (FluidStackLong fluidStackLong : outputFluids) { + fluidStackLong.amount *= yield * successfulParallelAmount; + } + + updateSlots(); + + if (animationsEnabled) { + createRenderBlock(currentRecipe); + } + + recipeRunning = true; + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + private void createRenderBlock(final EyeOfHarmonyRecipe currentRecipe) { + + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetY; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), eyeOfHarmonyRenderBlock); + TileEyeOfHarmony rendererTileEntity = (TileEyeOfHarmony) this.getBaseMetaTileEntity() + .getWorld() + .getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + + rendererTileEntity.setTier(currentRecipe.getRocketTier()); + + int recipeSpacetimeTier = (int) currentRecipe.getSpacetimeCasingTierRequired(); + + // Star is a larger size depending on the spacetime tier of the recipe. + rendererTileEntity.setSize((1 + recipeSpacetimeTier)); + + // Star rotates faster the higher tier time dilation you use in the multi. + // Lower value = faster rotation speed. + rendererTileEntity.setRotationSpeed((1 + timeAccelerationFieldMetadata) / 2.0f); + } + + private double successChance; + private long currentRecipeRocketTier; + + private void outputFailedChance() { + long failedParallelAmount = parallelAmount - successfulParallelAmount; + if (failedParallelAmount > 0) { + // 2^Tier spacetime released upon recipe failure. + outputFluidToAENetwork( + MaterialsUEVplus.SpaceTime.getMolten(1), + (long) ((successChance * MOLTEN_SPACETIME_PER_FAILURE_TIER + * pow(SPACETIME_FAILURE_BASE, currentRecipeRocketTier + 1)) * failedParallelAmount)); + } + super.outputAfterRecipe_EM(); + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + destroyRenderBlock(); + recipeRunning = false; + } + + @Override + public void onBlockDestroyed() { + super.onBlockDestroyed(); + destroyRenderBlock(); + } + + private void destroyRenderBlock() { + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetY; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + } + + public void outputAfterRecipe_EM() { + recipeRunning = false; + eRequiredData = 0L; + + destroyRenderBlock(); + + // Output EU + addEUToGlobalEnergyMap(userUUID, outputEU_BigInt); + + startEU = 0; + outputEU_BigInt = BigInteger.ZERO; + + outputFailedChance(); + + if (successfulParallelAmount > 0) { + for (ItemStackLong itemStack : outputItems) { + outputItemToAENetwork(itemStack.itemStack, itemStack.stackSize); + } + + for (FluidStackLong fluidStack : outputFluids) { + outputFluidToAENetwork(fluidStack.fluidStack, fluidStack.amount); + } + } + + // Clear the array list for new recipes. + outputItems = new ArrayList<>(); + outputFluids = new ArrayList<>(); + + // Do other stuff from TT superclasses. E.g. outputting fluids. + super.outputAfterRecipe_EM(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + + if (aTick == 1) { + userUUID = String.valueOf(getBaseMetaTileEntity().getOwnerUuid()); + String userName = getBaseMetaTileEntity().getOwnerName(); + strongCheckOrAddUser(userUUID, userName); + } + + if (!recipeRunning && mMachine) { + if ((aTick % TICKS_BETWEEN_HATCH_DRAIN) == 0) { + drainFluidFromHatchesAndStoreInternally(); + } + } + } + + private boolean recipeRunning = false; + + // Will void if AE network is full. + private void outputItemToAENetwork(ItemStack item, long amount) { + + if ((item == null) || (amount <= 0)) { + return; + } + + if (amount < Integer.MAX_VALUE) { + ItemStack tmpItem = item.copy(); + tmpItem.stackSize = (int) amount; + ((GT_MetaTileEntity_Hatch_OutputBus_ME) mOutputBusses.get(0)).store(tmpItem); + } else { + // For item stacks > Int max. + while (amount >= Integer.MAX_VALUE) { + ItemStack tmpItem = item.copy(); + tmpItem.stackSize = Integer.MAX_VALUE; + ((GT_MetaTileEntity_Hatch_OutputBus_ME) mOutputBusses.get(0)).store(tmpItem); + amount -= Integer.MAX_VALUE; + } + ItemStack tmpItem = item.copy(); + tmpItem.stackSize = (int) amount; + ((GT_MetaTileEntity_Hatch_OutputBus_ME) mOutputBusses.get(0)).store(tmpItem); + } + } + + private void outputFluidToAENetwork(FluidStack fluid, long amount) { + + if ((fluid == null) || (amount <= 0)) { + return; + } + + if (amount < Integer.MAX_VALUE) { + FluidStack tmpFluid = fluid.copy(); + tmpFluid.amount = (int) amount; + ((GT_MetaTileEntity_Hatch_Output_ME) mOutputHatches.get(0)).tryFillAE(tmpFluid); + } else { + // For fluidStacks > Int max. + while (amount >= Integer.MAX_VALUE) { + FluidStack tmpFluid = fluid.copy(); + tmpFluid.amount = Integer.MAX_VALUE; + ((GT_MetaTileEntity_Hatch_Output_ME) mOutputHatches.get(0)).tryFillAE(tmpFluid); + amount -= Integer.MAX_VALUE; + } + FluidStack tmpFluid = fluid.copy(); + tmpFluid.amount = (int) amount; + ((GT_MetaTileEntity_Hatch_Output_ME) mOutputHatches.get(0)).tryFillAE(tmpFluid); + } + } + + @Override + public String[] getInfoData() { + ArrayList str = new ArrayList<>(Arrays.asList(super.getInfoData())); + str.add(GOLD + "---------------- Control Block Statistics ----------------"); + if (spacetimeCompressionFieldMetadata < 0) { + str.add("Spacetime Compression Field Grade: None"); + } else { + str.add( + "Spacetime Compression Field Grade: " + EOH_TIER_FANCY_NAMES[spacetimeCompressionFieldMetadata] + + RESET + + " (" + + YELLOW + + spacetimeCompressionFieldMetadata + + RESET + + ")"); + } + if (timeAccelerationFieldMetadata < 0) { + str.add("Time Dilation Field Grade: None"); + } else { + str.add( + "Time Dilation Field Grade: " + EOH_TIER_FANCY_NAMES[timeAccelerationFieldMetadata] + + RESET + + " (" + + YELLOW + + timeAccelerationFieldMetadata + + RESET + + ")"); + } + if (stabilisationFieldMetadata < 0) { + str.add("Stabilisation Field Grade: None"); + } else { + str.add( + "Stabilisation Field Grade: " + EOH_TIER_FANCY_NAMES[stabilisationFieldMetadata] + + RESET + + " (" + + YELLOW + + stabilisationFieldMetadata + + RESET + + ")"); + } + str.add(GOLD + "----------------- Internal Fluids Stored ----------------"); + validFluidMap.forEach( + (key, value) -> str.add(BLUE + key.getLocalizedName() + RESET + " : " + RED + formatNumbers(value))); + if (recipeRunning) { + str.add(GOLD + "---------------------- Other Stats ---------------"); + str.add("Recipe Success Chance: " + RED + formatNumbers(100 * successChance) + RESET + "%"); + str.add("Recipe Yield: " + RED + formatNumbers(100 * yield) + RESET + "%"); + str.add("Astral Array Fabricators detected: " + RED + formatNumbers(astralArrayAmount)); + str.add("Total Parallel: " + RED + formatNumbers(parallelAmount)); + str.add("EU Output: " + RED + toStandardForm(outputEU_BigInt) + RESET + " EU"); + str.add("EU Input: " + RED + toStandardForm(usedEU.abs()) + RESET + " EU"); + int currentMaxProgresstime = Math.max(maxProgresstime(), 1); + if (starMatter != null && starMatter.fluidStack != null) { + FluidStackLong starMatterOutput = new FluidStackLong( + starMatter.fluidStack, + (long) (starMatter.amount * yield * successChance * parallelAmount)); + str.add( + "Average " + starMatterOutput.fluidStack.getLocalizedName() + + " Output: " + + RED + + formatNumbers(starMatterOutput.amount) + + RESET + + " L, " + + YELLOW + + formatNumbers(starMatterOutput.amount * 20.0 / currentMaxProgresstime) + + RESET + + " L/s"); + + FluidStackLong stellarPlasmaOutput = new FluidStackLong( + MaterialsUEVplus.RawStarMatter.getFluid(0), + (long) (stellarPlasma.amount * yield * successChance * parallelAmount)); + str.add( + "Average " + stellarPlasmaOutput.fluidStack.getLocalizedName() + + " Output: " + + RED + + formatNumbers(stellarPlasmaOutput.amount) + + RESET + + " L, " + + YELLOW + + formatNumbers(stellarPlasmaOutput.amount * 20.0 / currentMaxProgresstime) + + RESET + + " L/s"); + } + BigInteger euPerTick = (outputEU_BigInt.subtract(usedEU.abs())) + .divide(BigInteger.valueOf(currentMaxProgresstime)); + + str.add("Estimated EU/t: " + RED + toStandardForm(euPerTick) + RESET + " EU/t"); + } + str.add(GOLD + "-----------------------------------------------------"); + return str.toArray(new String[0]); + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return new String[] { "Eye of Harmony multiblock" }; + } + + // NBT save/load strings. + private static final String EYE_OF_HARMONY = "eyeOfHarmonyOutput"; + private static final String NUMBER_OF_ITEMS_NBT_TAG = EYE_OF_HARMONY + "numberOfItems"; + private static final String NUMBER_OF_FLUIDS_NBT_TAG = EYE_OF_HARMONY + "numberOfFluids"; + private static final String ITEM_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "itemOutput"; + private static final String FLUID_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "fluidOutput"; + private static final String RECIPE_RUNNING_NBT_TAG = EYE_OF_HARMONY + "recipeRunning"; + private static final String CURRENT_RECIPE_STAR_MATTER_TAG = EYE_OF_HARMONY + "recipeStarMatter"; + private static final String CURRENT_RECIPE_STELLAR_PLASMA_TAG = EYE_OF_HARMONY + "recipeStellarPlasma"; + private static final String CURRENT_RECIPE_FIXED_OUTPUTS_TAG = EYE_OF_HARMONY + "recipeFixedOutputs"; + private static final String RECIPE_SUCCESS_CHANCE_NBT_TAG = EYE_OF_HARMONY + "recipeSuccessChance"; + private static final String ROCKET_TIER_NBT_TAG = EYE_OF_HARMONY + "rocketTier"; + private static final String CURRENT_CIRCUIT_MULTIPLIER_TAG = EYE_OF_HARMONY + "currentCircuitMultiplier"; + private static final String ANIMATIONS_ENABLED = EYE_OF_HARMONY + "animationsEnabled"; + private static final String CALCULATED_EU_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "outputEU_BigInt"; + private static final String PARALLEL_AMOUNT_NBT_TAG = EYE_OF_HARMONY + "parallelAmount"; + private static final String YIELD_NBT_TAG = EYE_OF_HARMONY + "yield"; + private static final String SUCCESSFUL_PARALLEL_AMOUNT_NBT_TAG = EYE_OF_HARMONY + "successfulParallelAmount"; + private static final String ASTRAL_ARRAY_AMOUNT_NBT_TAG = EYE_OF_HARMONY + "astralArrayAmount"; + private static final String CALCULATED_EU_INPUT_NBT_TAG = EYE_OF_HARMONY + "usedEU"; + + // Sub tags, less specific names required. + private static final String STACK_SIZE = "stackSize"; + private static final String ITEM_STACK_NBT_TAG = "itemStack"; + private static final String FLUID_AMOUNT = "fluidAmount"; + private static final String FLUID_STACK_NBT_TAG = "fluidStack"; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + // Save the quantity of fluid stored inside the controller. + validFluidMap.forEach((key, value) -> aNBT.setLong("stored." + key.getUnlocalizedName(), value)); + + aNBT.setBoolean(RECIPE_RUNNING_NBT_TAG, recipeRunning); + aNBT.setDouble(RECIPE_SUCCESS_CHANCE_NBT_TAG, successChance); + aNBT.setLong(ROCKET_TIER_NBT_TAG, currentRecipeRocketTier); + aNBT.setLong(CURRENT_CIRCUIT_MULTIPLIER_TAG, currentCircuitMultiplier); + aNBT.setBoolean(ANIMATIONS_ENABLED, animationsEnabled); + aNBT.setLong(PARALLEL_AMOUNT_NBT_TAG, parallelAmount); + aNBT.setLong(SUCCESSFUL_PARALLEL_AMOUNT_NBT_TAG, successfulParallelAmount); + aNBT.setDouble(YIELD_NBT_TAG, yield); + aNBT.setLong(ASTRAL_ARRAY_AMOUNT_NBT_TAG, astralArrayAmount); + aNBT.setByteArray(CALCULATED_EU_OUTPUT_NBT_TAG, outputEU_BigInt.toByteArray()); + aNBT.setByteArray(CALCULATED_EU_INPUT_NBT_TAG, usedEU.toByteArray()); + + // Store damage values/stack sizes of GT items being outputted. + NBTTagCompound itemStackListNBTTag = new NBTTagCompound(); + itemStackListNBTTag.setLong(NUMBER_OF_ITEMS_NBT_TAG, outputItems.size()); + + int index = 0; + for (ItemStackLong itemStackLong : outputItems) { + // Save stack size to NBT. + itemStackListNBTTag.setLong(index + STACK_SIZE, itemStackLong.stackSize); + + // Save ItemStack to NBT. + aNBT.setTag(index + ITEM_STACK_NBT_TAG, itemStackLong.itemStack.writeToNBT(new NBTTagCompound())); + + index++; + } + + aNBT.setTag(ITEM_OUTPUT_NBT_TAG, itemStackListNBTTag); + + // Store damage values/stack sizes of GT fluids being outputted. + NBTTagCompound fluidStackListNBTTag = new NBTTagCompound(); + fluidStackListNBTTag.setLong(NUMBER_OF_FLUIDS_NBT_TAG, outputFluids.size()); + + int indexFluids = 0; + for (FluidStackLong fluidStackLong : outputFluids) { + // Save fluid amount to NBT. + fluidStackListNBTTag.setLong(indexFluids + FLUID_AMOUNT, fluidStackLong.amount); + + // Save FluidStack to NBT. + aNBT.setTag(indexFluids + FLUID_STACK_NBT_TAG, fluidStackLong.fluidStack.writeToNBT(new NBTTagCompound())); + + indexFluids++; + } + + aNBT.setTag(FLUID_OUTPUT_NBT_TAG, fluidStackListNBTTag); + + if (starMatter != null && starMatter.fluidStack != null) { + + NBTTagCompound fixedRecipeOutputs = new NBTTagCompound(); + + fixedRecipeOutputs.setLong(0 + FLUID_AMOUNT, starMatter.amount); + aNBT.setTag(CURRENT_RECIPE_STAR_MATTER_TAG, starMatter.fluidStack.writeToNBT(new NBTTagCompound())); + + fixedRecipeOutputs.setLong(1 + FLUID_AMOUNT, stellarPlasma.amount); + aNBT.setTag(CURRENT_RECIPE_STELLAR_PLASMA_TAG, stellarPlasma.fluidStack.writeToNBT(new NBTTagCompound())); + + aNBT.setTag(CURRENT_RECIPE_FIXED_OUTPUTS_TAG, fixedRecipeOutputs); + } + + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + + // Load the quantity of fluid stored inside the controller. + validFluidMap + .forEach((key, value) -> validFluidMap.put(key, aNBT.getLong("stored." + key.getUnlocalizedName()))); + + // Load other stuff from NBT. + recipeRunning = aNBT.getBoolean(RECIPE_RUNNING_NBT_TAG); + successChance = aNBT.getDouble(RECIPE_SUCCESS_CHANCE_NBT_TAG); + currentRecipeRocketTier = aNBT.getLong(ROCKET_TIER_NBT_TAG); + currentCircuitMultiplier = aNBT.getLong(CURRENT_CIRCUIT_MULTIPLIER_TAG); + animationsEnabled = aNBT.getBoolean(ANIMATIONS_ENABLED); + parallelAmount = aNBT.getLong(PARALLEL_AMOUNT_NBT_TAG); + yield = aNBT.getDouble(YIELD_NBT_TAG); + successfulParallelAmount = aNBT.getLong(SUCCESSFUL_PARALLEL_AMOUNT_NBT_TAG); + astralArrayAmount = aNBT.getLong(ASTRAL_ARRAY_AMOUNT_NBT_TAG); + outputEU_BigInt = new BigInteger(aNBT.getByteArray(CALCULATED_EU_OUTPUT_NBT_TAG)); + usedEU = new BigInteger(aNBT.getByteArray(CALCULATED_EU_INPUT_NBT_TAG)); + + // Load damage values/stack sizes of GT items being outputted and convert back to items. + NBTTagCompound tempItemTag = aNBT.getCompoundTag(ITEM_OUTPUT_NBT_TAG); + + // Iterate over all stored items. + for (int index = 0; index < tempItemTag.getInteger(NUMBER_OF_ITEMS_NBT_TAG); index++) { + + // Load stack size from NBT. + long stackSize = tempItemTag.getLong(index + STACK_SIZE); + + // Load ItemStack from NBT. + ItemStack itemStack = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag(index + ITEM_STACK_NBT_TAG)); + + outputItems.add(new ItemStackLong(itemStack, stackSize)); + } + + // Load damage values/fluid amounts of GT fluids being outputted and convert back to fluids. + NBTTagCompound tempFluidTag = aNBT.getCompoundTag(FLUID_OUTPUT_NBT_TAG); + + // Iterate over all stored fluids. + for (int indexFluids = 0; indexFluids < tempFluidTag.getInteger(NUMBER_OF_FLUIDS_NBT_TAG); indexFluids++) { + + // Load fluid amount from NBT. + long fluidAmount = tempFluidTag.getLong(indexFluids + FLUID_AMOUNT); + + // Load FluidStack from NBT. + FluidStack fluidStack = FluidStack + .loadFluidStackFromNBT(aNBT.getCompoundTag(indexFluids + FLUID_STACK_NBT_TAG)); + + outputFluids.add(new FluidStackLong(fluidStack, fluidAmount)); + } + + tempFluidTag = aNBT.getCompoundTag(CURRENT_RECIPE_FIXED_OUTPUTS_TAG); + starMatter = new FluidStackLong( + FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag(CURRENT_RECIPE_STAR_MATTER_TAG)), + tempFluidTag.getLong(0 + FLUID_AMOUNT)); + stellarPlasma = new FluidStackLong( + FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag(CURRENT_RECIPE_STELLAR_PLASMA_TAG)), + tempFluidTag.getLong(1 + FLUID_AMOUNT)); + + super.loadNBTData(aNBT); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_ForgeOfGods.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_ForgeOfGods.java new file mode 100644 index 0000000000..6d6d7fdb43 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_ForgeOfGods.java @@ -0,0 +1,2385 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.GodforgeCasings; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.forgeOfGodsRenderBlock; +import static com.github.technus.tectech.util.GodforgeMath.allowModuleConnection; +import static com.github.technus.tectech.util.GodforgeMath.calculateEnergyDiscountForModules; +import static com.github.technus.tectech.util.GodforgeMath.calculateFuelConsumption; +import static com.github.technus.tectech.util.GodforgeMath.calculateMaxFuelFactor; +import static com.github.technus.tectech.util.GodforgeMath.calculateMaxHeatForModules; +import static com.github.technus.tectech.util.GodforgeMath.calculateMaxParallelForModules; +import static com.github.technus.tectech.util.GodforgeMath.calculateProcessingVoltageForModules; +import static com.github.technus.tectech.util.GodforgeMath.calculateSpeedBonusForModules; +import static com.github.technus.tectech.util.GodforgeMath.calculateStartupFuelConsumption; +import static com.github.technus.tectech.util.GodforgeMath.queryMilestoneStats; +import static com.github.technus.tectech.util.GodforgeMath.setMiscModuleParameters; +import static com.github.technus.tectech.util.TT_Utility.toExponentForm; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.enums.Mods.Avaritia; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GT_ModHandler.getModItem; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static java.lang.Math.floor; +import static java.lang.Math.log; +import static java.lang.Math.max; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.CustomItemList; +import com.github.technus.tectech.thing.block.GodforgeGlassBlock; +import com.github.technus.tectech.thing.block.TileForgeOfGods; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_BaseModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_ExoticModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_MoltenModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_PlasmaModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_SmeltingModule; +import com.github.technus.tectech.util.CommonValues; +import com.google.common.math.LongMath; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.MainAxisAlignment; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Interactable; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.FluidNameHolderWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.Scrollable; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.util.GT_HatchElementBuilder; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.IGT_HatchAdder; + +public class GT_MetaTileEntity_EM_ForgeOfGods extends GT_MetaTileEntity_MultiblockBase_EM + implements IConstructable, ISurvivalConstructable { + + private static Textures.BlockIcons.CustomIcon ScreenON; + + private int fuelConsumptionFactor = 1; + private int selectedFuelType = 0; + private int internalBattery = 0; + private int maxBatteryCharge = 100; + private int gravitonShardsAvailable = 0; + private int gravitonShardsSpent = 0; + private int ringAmount = 1; + private int stellarFuelAmount = 0; + private int neededStartupFuel = 0; + private long fuelConsumption = 0; + private long totalRecipesProcessed = 0; + private long totalFuelConsumed = 0; + private float totalExtensionsBuilt = 0; + private float powerMilestonePercentage = 0; + private float recipeMilestonePercentage = 0; + private float fuelMilestonePercentage = 0; + private float structureMilestonePercentage = 0; + private float invertedPowerMilestonePercentage = 0; + private float invertedRecipeMilestonePercentage = 0; + private float invertedFuelMilestonePercentage = 0; + private float invertedStructureMilestonePercentage = 0; + private BigInteger totalPowerConsumed = BigInteger.ZERO; + private boolean batteryCharging = false; + private boolean inversion = false; + public ArrayList moduleHatches = new ArrayList<>(); + protected ItemStackHandler inputSlotHandler = new ItemStackHandler(16); + + private static final int FUEL_CONFIG_WINDOW_ID = 9; + private static final int UPGRADE_TREE_WINDOW_ID = 10; + private static final int INDIVIDUAL_UPGRADE_WINDOW_ID = 11; + private static final int BATTERY_CONFIG_WINDOW_ID = 12; + private static final int MILESTONE_WINDOW_ID = 13; + private static final int INDIVIDUAL_MILESTONE_WINDOW_ID = 14; + private static final int MANUAL_INSERTION_WINDOW_ID = 15; + private static final int TEXTURE_INDEX = 960; + private static final int[] FIRST_SPLIT_UPGRADES = new int[] { 12, 13, 14 }; + private static final long POWER_MILESTONE_CONSTANT = LongMath.pow(10, 15); + private static final long RECIPE_MILESTONE_CONSTANT = LongMath.pow(10, 7); + private static final long FUEL_MILESTONE_CONSTANT = 10_000; + private static final long RECIPE_MILESTONE_T7_CONSTANT = RECIPE_MILESTONE_CONSTANT * LongMath.pow(6, 6); + private static final long FUEL_MILESTONE_T7_CONSTANT = FUEL_MILESTONE_CONSTANT * LongMath.pow(3, 6); + private static final BigInteger POWER_MILESTONE_T7_CONSTANT = BigInteger.valueOf(POWER_MILESTONE_CONSTANT) + .multiply(BigInteger.valueOf(LongMath.pow(9, 6))); + private static final double POWER_LOG_CONSTANT = Math.log(9); + private static final double RECIPE_LOG_CONSTANT = Math.log(6); + private static final double FUEL_LOG_CONSTANT = Math.log(3); + protected static final String STRUCTURE_PIECE_MAIN = "main"; + protected static final String STRUCTURE_PIECE_SECOND_RING = "second_ring"; + protected static final String STRUCTURE_PIECE_THIRD_RING = "third_ring"; + private static final String TOOLTIP_BAR = EnumChatFormatting.BLUE + "--------------------------------------------"; + private static final ItemStack STELLAR_FUEL = Avaritia.isModLoaded() ? getModItem(Avaritia.ID, "Resource", 1, 8) + : GT_OreDictUnificator.get(OrePrefixes.block, Materials.CosmicNeutronium, 1); + + private final boolean debugMode = true; + + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + int realBudget = elementBudget >= 1000 ? elementBudget : Math.min(1000, elementBudget * 5); + // 1000 blocks max per placement. + int built = survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 63, 20, 1, realBudget, env, false, true); + if (isUpgradeActive(26) && stackSize.stackSize > 1) { + built += survivialBuildPiece( + STRUCTURE_PIECE_SECOND_RING, + stackSize, + 55, + 11, + -67, + realBudget, + env, + false, + true); + } + if (isUpgradeActive(29) && stackSize.stackSize > 2) { + built += survivialBuildPiece( + STRUCTURE_PIECE_THIRD_RING, + stackSize, + 47, + 13, + -76, + realBudget, + env, + false, + true); + } + return built; + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + public static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape(STRUCTURE_PIECE_MAIN, ForgeOfGodsStructureString.MAIN_STRUCTURE) + .addShape(STRUCTURE_PIECE_SECOND_RING, ForgeOfGodsRingsStructureString.SECOND_RING) + .addShape(STRUCTURE_PIECE_THIRD_RING, ForgeOfGodsRingsStructureString.THIRD_RING) + .addElement('A', classicHatches(TEXTURE_INDEX + 3, 1, GodforgeCasings, 3)) + .addElement('B', ofBlock(GodforgeCasings, 0)) + .addElement('C', ofBlock(GodforgeCasings, 1)) + .addElement('D', ofBlock(GodforgeCasings, 2)) + .addElement('E', ofBlock(GodforgeCasings, 3)) + .addElement('F', ofBlock(GodforgeCasings, 4)) + .addElement('G', ofBlock(GodforgeCasings, 5)) + .addElement('H', ofBlock(GodforgeGlassBlock.INSTANCE, 0)) + .addElement('I', ofBlock(GodforgeCasings, 7)) + .addElement( + 'J', + GT_HatchElementBuilder.builder() + .atLeast(moduleElement.Module) + .casingIndex(TEXTURE_INDEX) + .dot(3) + .buildAndChain(GodforgeCasings, 0)) + .addElement('K', ofBlock(GodforgeCasings, 6)) + .build(); + + public GT_MetaTileEntity_EM_ForgeOfGods(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_ForgeOfGods(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_ForgeOfGods(mName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/GODFORGE_CONTROLLER"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX + 1), + new TT_RenderedExtendedFacingTexture(ScreenON) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX + 1) }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM(STRUCTURE_PIECE_MAIN, 63, 14, 1, stackSize, hintsOnly); + if (isUpgradeActive(26) && stackSize.stackSize > 1) { + buildPiece(STRUCTURE_PIECE_SECOND_RING, stackSize, hintsOnly, 55, 11, -67); + } + if (isUpgradeActive(29) && stackSize.stackSize > 2) { + buildPiece(STRUCTURE_PIECE_THIRD_RING, stackSize, hintsOnly, 47, 13, -76); + } + } + + private final ArrayList validFuelList = new ArrayList<>() { + + { + add(MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1)); + add(MaterialsUEVplus.RawStarMatter.getFluid(1)); + add(MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(1)); + } + }; + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + + moduleHatches.clear(); + + // Check structure of multi. + if (!structureCheck_EM(STRUCTURE_PIECE_MAIN, 63, 14, 1)) { + return false; + } + + // Check there is 1 input bus. + if (mInputBusses.size() != 1) { + return false; + } + + // Make sure there are no energy hatches. + + if (mEnergyHatches.size() > 0) { + return false; + } + + if (mExoticEnergyHatches.size() > 0) { + return false; + } + + // Make sure there is 1 input hatch. + if (mInputHatches.size() != 1) { + return false; + } + + if (isUpgradeActive(26) && checkPiece(STRUCTURE_PIECE_SECOND_RING, 55, 11, -67)) { + ringAmount = 2; + if (isUpgradeActive(29) && checkPiece(STRUCTURE_PIECE_THIRD_RING, 47, 13, -76)) { + ringAmount = 3; + } + } + + mHardHammer = true; + mSoftHammer = true; + mScrewdriver = true; + mCrowbar = true; + mSolderingTool = true; + mWrench = true; + return true; + } + + int ticker = 0; + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + ticker++; + // Check and drain fuel + if (ticker % (5 * SECONDS) == 0) { + ticker = 0; + FluidStack fluidInHatch = null; + if (mInputHatches != null && mInputHatches.size() != 0) { + fluidInHatch = mInputHatches.get(0) + .getFluid(); + } + int maxModuleCount = 8; + + if (upgrades[26]) { + maxModuleCount += 4; + } + if (upgrades[29]) { + maxModuleCount += 4; + } + if (getBaseMetaTileEntity().isAllowedToWork()) { + if (internalBattery == 0) { + + for (ItemStack itemStack : mInputBusses.get(0) + .getRealInventory()) { + if (itemStack != null && itemStack.isItemEqual(STELLAR_FUEL)) { + stellarFuelAmount += itemStack.stackSize; + itemStack.stackSize = 0; + } + } + neededStartupFuel = calculateStartupFuelConsumption(this); + if (stellarFuelAmount >= neededStartupFuel) { + stellarFuelAmount -= neededStartupFuel; + increaseBattery(neededStartupFuel); + } + } else { + fuelConsumption = (long) calculateFuelConsumption(this) * 5 * (batteryCharging ? 2 : 1); + if (fluidInHatch != null && fluidInHatch.isFluidEqual(validFuelList.get(selectedFuelType))) { + FluidStack fluidNeeded = new FluidStack( + validFuelList.get(selectedFuelType), + (int) fuelConsumption); + FluidStack fluidReal = mInputHatches.get(0) + .drain(fluidNeeded.amount, true); + if (fluidReal == null || fluidReal.amount < fluidNeeded.amount) { + reduceBattery(fuelConsumptionFactor); + } else { + totalFuelConsumed += getFuelFactor(); + if (batteryCharging) { + increaseBattery(fuelConsumptionFactor); + } + } + } else { + reduceBattery(fuelConsumptionFactor); + } + } + } else { + reduceBattery(fuelConsumptionFactor); + } + + determineCompositionMilestoneLevel(); + checkInversionStatus(); + determineMilestoneProgress(); + if (!debugMode) { + determineGravitonShardAmount(); + } + + // Do module calculations and checks + if (moduleHatches.size() > 0 && internalBattery > 0 && moduleHatches.size() <= maxModuleCount) { + for (GT_MetaTileEntity_EM_BaseModule module : moduleHatches) { + if (allowModuleConnection(module, this)) { + module.connect(); + calculateMaxHeatForModules(module, this); + calculateSpeedBonusForModules(module, this); + calculateMaxParallelForModules(module, this); + calculateEnergyDiscountForModules(module, this); + setMiscModuleParameters(module, this); + queryMilestoneStats(module, this); + if (!upgrades[28]) { + calculateProcessingVoltageForModules(module, this); + } + } else { + module.disconnect(); + } + } + } else if (moduleHatches.size() > maxModuleCount) { + for (GT_MetaTileEntity_EM_BaseModule module : moduleHatches) { + module.disconnect(); + } + } + if (mEfficiency < 0) mEfficiency = 0; + fixAllMaintenance(); + } + } + } + + public boolean addModuleToMachineList(IGregTechTileEntity tileEntity, int baseCasingIndex) { + if (tileEntity == null) { + return false; + } + IMetaTileEntity metaTileEntity = tileEntity.getMetaTileEntity(); + if (metaTileEntity == null) { + return false; + } + if (metaTileEntity instanceof GT_MetaTileEntity_EM_BaseModule) { + return moduleHatches.add((GT_MetaTileEntity_EM_BaseModule) metaTileEntity); + } + return false; + } + + public enum moduleElement implements IHatchElement { + + Module(GT_MetaTileEntity_EM_ForgeOfGods::addModuleToMachineList, GT_MetaTileEntity_EM_BaseModule.class) { + + @Override + public long count(GT_MetaTileEntity_EM_ForgeOfGods tileEntity) { + return tileEntity.moduleHatches.size(); + } + }; + + private final List> mteClasses; + private final IGT_HatchAdder adder; + + @SafeVarargs + moduleElement(IGT_HatchAdder adder, + Class... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + this.adder = adder; + } + + @Override + public List> mteClasses() { + return mteClasses; + } + + public IGT_HatchAdder adder() { + return adder; + } + } + + private void createRenderBlock() { + + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetY; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), forgeOfGodsRenderBlock); + TileForgeOfGods rendererTileEntity = (TileForgeOfGods) this.getBaseMetaTileEntity() + .getWorld() + .getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + + rendererTileEntity.setRenderSize(20); + rendererTileEntity.setRenderRotationSpeed(5); + } + + @Override + public String[] getInfoData() { + ArrayList str = new ArrayList<>(Arrays.asList(super.getInfoData())); + str.add(TOOLTIP_BAR); + str.add("Number of Rings: " + EnumChatFormatting.GOLD + ringAmount); + str.add("Total Upgrades Unlocked: " + EnumChatFormatting.GOLD + getTotalActiveUpgrades()); + str.add("Connected Modules: " + EnumChatFormatting.GOLD + moduleHatches.size()); + str.add(TOOLTIP_BAR); + return str.toArray(new String[0]); + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + createRenderBlock(); + } + + @Override + public void onRemoval() { + if (moduleHatches != null && moduleHatches.size() > 0) { + for (GT_MetaTileEntity_EM_BaseModule module : moduleHatches) { + module.disconnect(); + } + } + super.onRemoval(); + } + + protected void fixAllMaintenance() { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (doesBindPlayerInventory()) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(4, 4) + .setSize(190, 85)); + } else { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_NO_INVENTORY) + .setPos(4, 4) + .setSize(190, 171)); + } + buildContext.addSyncedWindow(UPGRADE_TREE_WINDOW_ID, this::createUpgradeTreeWindow); + buildContext.addSyncedWindow(INDIVIDUAL_UPGRADE_WINDOW_ID, this::createIndividualUpgradeWindow); + buildContext.addSyncedWindow(FUEL_CONFIG_WINDOW_ID, this::createFuelConfigWindow); + buildContext.addSyncedWindow(BATTERY_CONFIG_WINDOW_ID, this::createBatteryWindow); + buildContext.addSyncedWindow(MILESTONE_WINDOW_ID, this::createMilestoneWindow); + buildContext.addSyncedWindow(INDIVIDUAL_MILESTONE_WINDOW_ID, this::createIndividualMilestoneWindow); + buildContext.addSyncedWindow(MANUAL_INSERTION_WINDOW_ID, this::createManualInsertionWindow); + builder.widget( + new ButtonWidget().setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(UPGRADE_TREE_WINDOW_ID); + }) + .setSize(16, 16) + .setBackground(() -> { + List button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_ARROW_BLUE_UP); + return button.toArray(new IDrawable[0]); + }) + .addTooltip("Path of Celestial Transcendence") + .setPos(174, 167) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_SMALL) + .setPos(174, 183) + .setSize(16, 6)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(FUEL_CONFIG_WINDOW_ID); + } + }) + .setSize(16, 16) + .setBackground(() -> { + List button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_HEAT_ON); + return button.toArray(new IDrawable[0]); + }) + .addTooltip(translateToLocal("fog.button.fuelconfig.tooltip")) + .setPos(174, 110) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + TextWidget.dynamicText(this::storedFuel) + .setDefaultColor(EnumChatFormatting.WHITE) + .setPos(6, 8) + .setSize(74, 34)) + .widget(createPowerSwitchButton()) + .widget(createBatteryButton(builder)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> { + if (val) { + getBaseMetaTileEntity().enableWorking(); + } else { + getBaseMetaTileEntity().disableWorking(); + } + })) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + checkMachine_EM(this.getBaseMetaTileEntity(), null); + } + }) + .setSize(16, 16) + .setBackground(() -> { + List button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_CYCLIC_BLUE); + return button.toArray(new IDrawable[0]); + }) + .addTooltip(translateToLocal("fog.button.structurecheck.tooltip")) + .setPos(8, 91) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(MILESTONE_WINDOW_ID); + } + }) + .setSize(16, 16) + .setBackground(() -> { + List button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_FLAG); + return button.toArray(new IDrawable[0]); + }) + .addTooltip(translateToLocal("fog.button.milestones.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 91)); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_LOGO) + .setSize(18, 18) + .setPos(172, 67)); + } + + @Override + protected ButtonWidget createPowerSwitchButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (getBaseMetaTileEntity().isAllowedToWork()) { + getBaseMetaTileEntity().disableWorking(); + } else { + getBaseMetaTileEntity().enableWorking(); + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (getBaseMetaTileEntity().isAllowedToWork()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED); + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 148 : 172) + .setSize(16, 16); + button.addTooltip("Power Switch") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } + + protected Widget createBatteryButton(IWidgetBuilder builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (clickData.mouseButton == 0) { + batteryCharging = !batteryCharging; + } else if (clickData.mouseButton == 1 && !widget.isClient() && upgrades[8]) { + widget.getContext() + .openSyncedWindow(BATTERY_CONFIG_WINDOW_ID); + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (batteryCharging) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_BATTERY_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_BATTERY_OFF); + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, 129) + .setSize(16, 16); + button.addTooltip(translateToLocal("fog.button.battery.tooltip.01")) + .addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.battery.tooltip.02")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> batteryCharging, val -> batteryCharging = val), + builder); + return button; + } + + protected ModularWindow createBatteryWindow(final EntityPlayer player) { + final int WIDTH = 78; + final int HEIGHT = 52; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add( + Alignment.BottomRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) + .add(WIDTH - 3, 0) + .subtract(0, 10))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.batteryinfo") + .setPos(3, 4) + .setSize(74, 20)) + .widget( + new NumericWidget().setSetter(val -> maxBatteryCharge = (int) val) + .setGetter(() -> maxBatteryCharge) + .setBounds(1, Integer.MAX_VALUE) + .setDefaultValue(100) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(70, 18) + .setPos(4, 25) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD)); + return builder.build(); + } + + protected ModularWindow createFuelConfigWindow(final EntityPlayer player) { + final int WIDTH = 78; + final int HEIGHT = 130; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add( + Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) + .add(WIDTH - 3, 0))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fuelconsumption") + .setPos(3, 2) + .setSize(74, 34)) + .widget( + new NumericWidget().setSetter(val -> fuelConsumptionFactor = (int) val) + .setGetter(() -> fuelConsumptionFactor) + .setBounds(1, calculateMaxFuelFactor(this)) + .setDefaultValue(1) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(70, 18) + .setPos(4, 35) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD)) + .widget( + new DrawableWidget().setDrawable(ModularUITextures.ICON_INFO) + .setPos(64, 24) + .setSize(10, 10) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.0")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.1")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.2")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.3")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.4")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fueltype") + .setPos(3, 57) + .setSize(74, 24)) + .widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fuelusage") + .setPos(3, 100) + .setSize(74, 20)) + .widget( + TextWidget.dynamicText(this::fuelUsage) + .setPos(3, 115) + .setSize(74, 15)) + .widget( + new MultiChildWidget().addChild( + new FluidNameHolderWidget( + () -> MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1) + .getUnlocalizedName() + .substring(6), + (String) -> MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1) + .getUnlocalizedName()) { + + @Override + public void buildTooltip(List tooltip) { + FluidStack fluid = createFluidStack(); + addFluidNameInfo(tooltip, fluid); + addAdditionalFluidInfo(tooltip, fluid); + } + }.setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(1, 1) + .setSize(16, 16)) + .addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + selectedFuelType = 0; + }) + .setBackground(() -> { + if (selectedFuelType == 0) { + return new IDrawable[] { TecTechUITextures.SLOT_OUTLINE_GREEN }; + } else { + return new IDrawable[] {}; + } + }) + .setSize(18, 18) + .attachSyncer(new FakeSyncWidget.IntegerSyncer(this::getFuelType, this::setFuelType), builder)) + + .setPos(6, 82) + .setSize(18, 18)) + .widget( + new MultiChildWidget().addChild( + new FluidNameHolderWidget( + () -> MaterialsUEVplus.RawStarMatter.getFluid(1) + .getUnlocalizedName() + .substring(6), + (String) -> MaterialsUEVplus.RawStarMatter.getFluid(1) + .getUnlocalizedName()) { + + @Override + public void buildTooltip(List tooltip) { + FluidStack fluid = createFluidStack(); + addFluidNameInfo(tooltip, fluid); + addAdditionalFluidInfo(tooltip, fluid); + } + }.setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(1, 1) + .setSize(16, 16)) + .addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + selectedFuelType = 1; + }) + .setBackground(() -> { + if (selectedFuelType == 1) { + return new IDrawable[] { TecTechUITextures.SLOT_OUTLINE_GREEN }; + } else { + return new IDrawable[] {}; + } + }) + .setSize(18, 18)) + .setPos(29, 82) + .setSize(18, 18) + .attachSyncer(new FakeSyncWidget.IntegerSyncer(this::getFuelType, this::setFuelType), builder)) + .widget( + new MultiChildWidget().addChild( + new FluidNameHolderWidget( + () -> MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(1) + .getUnlocalizedName() + .substring(6), + (String) -> MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(1) + .getUnlocalizedName()) { + + @Override + public void buildTooltip(List tooltip) { + FluidStack fluid = createFluidStack(); + addFluidNameInfo(tooltip, fluid); + addAdditionalFluidInfo(tooltip, fluid); + } + }.setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(1, 1) + .setSize(16, 16)) + .addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + selectedFuelType = 2; + }) + .setBackground(() -> { + if (selectedFuelType == 2) { + return new IDrawable[] { TecTechUITextures.SLOT_OUTLINE_GREEN }; + } else { + return new IDrawable[] {}; + } + }) + .setSize(18, 18)) + .setPos(52, 82) + .setSize(18, 18) + .attachSyncer(new FakeSyncWidget.IntegerSyncer(this::getFuelType, this::setFuelType), builder)); + + return builder.build(); + } + + private final int[] milestoneProgress = new int[] { 0, 0, 0, 0 }; + + protected ModularWindow createMilestoneWindow(final EntityPlayer player) { + final int WIDTH = 400; + final int HEIGHT = 300; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(TecTechUITextures.BACKGROUND_SPACE); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.widget(createMilestoneButton(0, 80, 100, new Pos2d(62, 24))); + builder.widget(createMilestoneButton(1, 70, 98, new Pos2d(263, 25))); + builder.widget(createMilestoneButton(2, 100, 100, new Pos2d(52, 169))); + builder.widget(createMilestoneButton(3, 100, 100, new Pos2d(248, 169))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.powermilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(77, 45) + .setSize(50, 30)); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.recipemilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(268, 45) + .setSize(60, 30)); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fuelmilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(77, 190) + .setSize(50, 30)); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.purchasablemilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(268, 190) + .setSize(60, 30)); + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(37, 70) + .setSize(130, 7)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(233, 70) + .setSize(130, 7)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(37, 215) + .setSize(130, 7)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(233, 215) + .setSize(130, 7)); + builder.widget( + new ProgressBar().setProgress(() -> powerMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 70) + .addTooltip(milestoneProgressText(0, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new ProgressBar().setProgress(() -> recipeMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_PURPLE, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 70) + .addTooltip(milestoneProgressText(1, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new ProgressBar().setProgress(() -> fuelMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BLUE, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 215) + .addTooltip(milestoneProgressText(2, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new ProgressBar().setProgress(() -> structureMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 215) + .addTooltip(milestoneProgressText(3, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new ProgressBar().setProgress(() -> invertedPowerMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RED_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 70) + .addTooltip(milestoneProgressText(0, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new ProgressBar().setProgress(() -> invertedRecipeMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_PURPLE_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 70) + .addTooltip(milestoneProgressText(1, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new ProgressBar().setProgress(() -> invertedFuelMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BLUE_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 215) + .addTooltip(milestoneProgressText(2, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new ProgressBar().setProgress(() -> invertedStructureMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 215) + .addTooltip(milestoneProgressText(3, false)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(382, 6)); + return builder.build(); + } + + protected ModularWindow createIndividualMilestoneWindow(final EntityPlayer player) { + final int WIDTH = 150; + final int HEIGHT = 150; + int symbol_width; + int symbol_height; + String milestoneType; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + UITexture symbol; + switch (currentMilestoneID) { + case 1 -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION; + symbol_width = 54; + symbol_height = 75; + milestoneType = "recipe"; + } + case 2 -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST; + symbol_width = 75; + symbol_height = 75; + milestoneType = "fuel"; + } + case 3 -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION; + symbol_width = 75; + symbol_height = 75; + milestoneType = "purchasable"; + } + default -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE; + symbol_width = 60; + symbol_height = 75; + milestoneType = "power"; + } + } + + builder.setBackground(TecTechUITextures.BACKGROUND_GLOW_WHITE); + builder.setDraggable(true); + builder.widget( + ButtonWidget.closeWindowButton(true) + .setPos(134, 4)) + .widget( + new DrawableWidget().setDrawable(symbol) + .setSize(symbol_width, symbol_height) + .setPos((WIDTH - symbol_width) / 2, (HEIGHT - symbol_height) / 2)) + .widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG." + milestoneType + "milestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(0, 8) + .setSize(150, 15)) + .widget( + TextWidget.dynamicText(this::inversionStatusText) + .setDefaultColor(EnumChatFormatting.AQUA) + .setTextAlignment(Alignment.Center) + .setScale(0.8f) + .setPos(0, 120) + .setSize(150, 15)) + .widget( + TextWidget.dynamicText(() -> totalMilestoneProgress(currentMilestoneID)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.Center) + .setPos(5, 30) + .setSize(140, 30)) + .widget( + TextWidget.dynamicText(() -> currentMilestone(currentMilestoneID)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.Center) + .setPos(5, 50) + .setSize(140, 30)) + .widget( + TextWidget.dynamicText(() -> milestoneProgressText(currentMilestoneID, true)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setSize(140, 30) + .setPos(5, 70)) + .widget( + TextWidget.dynamicText(() -> gravitonShardAmountText(currentMilestoneID)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setSize(140, 30) + .setPos(5, 90)); + + return builder.build(); + } + + private int currentMilestoneID = 0; + + private Widget createMilestoneButton(int milestoneID, int width, int height, Pos2d pos) { + return new ButtonWidget().setOnClick((clickData, widget) -> { + currentMilestoneID = milestoneID; + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(INDIVIDUAL_MILESTONE_WINDOW_ID); + } + }) + .setSize(width, height) + .setBackground(() -> switch (milestoneID) { + case 1 -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION_GLOW }; + case 2 -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST_GLOW }; + case 3 -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION_GLOW }; + default -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE_GLOW }; + }) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.milestoneinfo")) + .setPos(pos) + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + + private int currentUpgradeID = 0; + private int currentColorCode = 0; + private int currentMilestoneBG = 0; + private int gravitonShardCost = 0; + private int[] prereqUpgrades = new int[] {}; + private int[] followupUpgrades = new int[] {}; + private boolean allPrereqRequired = false; + private boolean isUpradeSplitStart = false; + private boolean[] upgrades = new boolean[31]; + + protected ModularWindow createUpgradeTreeWindow(final EntityPlayer player) { + final Scrollable scrollable = new Scrollable().setVerticalScroll(); + final int PARENT_WIDTH = 300; + final int PARENT_HEIGHT = 1000; + ModularWindow.Builder builder = ModularWindow.builder(PARENT_WIDTH, PARENT_HEIGHT); + scrollable.widget( + createUpgradeBox(0, 0, 3, new int[] {}, false, new int[] { 1 }, false, 0, new Pos2d(126, 56), scrollable)) + .widget( + createUpgradeBox( + 1, + 0, + 1, + new int[] { 0 }, + false, + new int[] { 2, 3 }, + false, + 1, + new Pos2d(126, 116), + scrollable)) + .widget( + createUpgradeBox( + 2, + 0, + 2, + new int[] { 1 }, + false, + new int[] { 4, 5 }, + false, + 1, + new Pos2d(96, 176), + scrollable)) + .widget( + createUpgradeBox( + 3, + 0, + 2, + new int[] { 1 }, + false, + new int[] { 5, 6 }, + false, + 1, + new Pos2d(156, 176), + scrollable)) + .widget( + createUpgradeBox( + 4, + 0, + 0, + new int[] { 2 }, + false, + new int[] { 8 }, + false, + 1, + new Pos2d(66, 236), + scrollable)) + .widget( + createUpgradeBox( + 5, + 0, + 3, + new int[] { 2, 3 }, + false, + new int[] { 7 }, + false, + 1, + new Pos2d(126, 236), + scrollable)) + .widget( + createUpgradeBox( + 6, + 0, + 1, + new int[] { 3 }, + false, + new int[] { 10 }, + false, + 1, + new Pos2d(186, 236), + scrollable)) + .widget( + createUpgradeBox( + 7, + 0, + 3, + new int[] { 5 }, + false, + new int[] { 8, 9, 10 }, + false, + 2, + new Pos2d(126, 296), + scrollable)) + .widget( + createUpgradeBox( + 8, + 0, + 0, + new int[] { 4, 7 }, + true, + new int[] { 11 }, + false, + 2, + new Pos2d(56, 356), + scrollable)) + .widget( + createUpgradeBox( + 9, + 0, + 2, + new int[] { 7 }, + false, + new int[] {}, + false, + 2, + new Pos2d(126, 356), + scrollable)) + .widget( + createUpgradeBox( + 10, + 0, + 1, + new int[] { 6, 7 }, + true, + new int[] { 11 }, + false, + 2, + new Pos2d(196, 356), + scrollable)) + .widget( + createUpgradeBox( + 11, + 0, + 3, + new int[] { 8, 10 }, + false, + new int[] { 12, 13, 14 }, + false, + 2, + new Pos2d(126, 416), + scrollable)) + .widget( + createUpgradeBox( + 12, + 1, + 2, + new int[] { 11 }, + false, + new int[] { 17 }, + true, + 3, + new Pos2d(66, 476), + scrollable)) + .widget( + createUpgradeBox( + 13, + 2, + 1, + new int[] { 11 }, + false, + new int[] { 18 }, + true, + 3, + new Pos2d(126, 476), + scrollable)) + .widget( + createUpgradeBox( + 14, + 3, + 0, + new int[] { 11 }, + false, + new int[] { 15, 19 }, + true, + 3, + new Pos2d(186, 476), + scrollable)) + .widget( + createUpgradeBox( + 15, + 3, + 1, + new int[] { 14 }, + false, + new int[] {}, + false, + 4, + new Pos2d(246, 496), + scrollable)) + .widget( + createUpgradeBox( + 16, + 1, + 1, + new int[] { 17 }, + false, + new int[] {}, + false, + 4, + new Pos2d(6, 556), + scrollable)) + .widget( + createUpgradeBox( + 17, + 1, + 0, + new int[] { 12 }, + false, + new int[] { 16, 20 }, + false, + 3, + new Pos2d(66, 536), + scrollable)) + .widget( + createUpgradeBox( + 18, + 2, + 1, + new int[] { 13 }, + false, + new int[] { 21 }, + false, + 3, + new Pos2d(126, 536), + scrollable)) + .widget( + createUpgradeBox( + 19, + 3, + 0, + new int[] { 14 }, + false, + new int[] { 22 }, + false, + 3, + new Pos2d(186, 536), + scrollable)) + .widget( + createUpgradeBox( + 20, + 1, + 0, + new int[] { 17 }, + false, + new int[] { 23 }, + false, + 3, + new Pos2d(66, 596), + scrollable)) + .widget( + createUpgradeBox( + 21, + 2, + 1, + new int[] { 18 }, + false, + new int[] { 23 }, + false, + 3, + new Pos2d(126, 596), + scrollable)) + .widget( + createUpgradeBox( + 22, + 3, + 1, + new int[] { 19 }, + false, + new int[] { 23 }, + false, + 3, + new Pos2d(186, 596), + scrollable)) + .widget( + createUpgradeBox( + 23, + 0, + 0, + new int[] { 20, 21, 22 }, + false, + new int[] { 24 }, + false, + 4, + new Pos2d(126, 656), + scrollable)) + .widget( + createUpgradeBox( + 24, + 0, + 1, + new int[] { 23 }, + false, + new int[] { 25 }, + false, + 5, + new Pos2d(126, 718), + scrollable)) + .widget( + createUpgradeBox( + 25, + 0, + 1, + new int[] { 24 }, + false, + new int[] { 26 }, + false, + 6, + new Pos2d(36, 758), + scrollable)) + .widget( + createUpgradeBox( + 26, + 0, + 3, + new int[] { 25 }, + false, + new int[] { 27 }, + false, + 7, + new Pos2d(36, 848), + scrollable)) + .widget( + createUpgradeBox( + 27, + 0, + 2, + new int[] { 26 }, + false, + new int[] { 28 }, + false, + 8, + new Pos2d(126, 888), + scrollable)) + .widget( + createUpgradeBox( + 28, + 0, + 0, + new int[] { 27 }, + false, + new int[] { 29 }, + false, + 9, + new Pos2d(216, 848), + scrollable)) + .widget( + createUpgradeBox( + 29, + 0, + 3, + new int[] { 28 }, + false, + new int[] { 30 }, + false, + 10, + new Pos2d(216, 758), + scrollable)) + .widget( + createUpgradeBox( + 30, + 0, + 3, + new int[] { 29 }, + false, + new int[] {}, + false, + 12, + new Pos2d(126, 798), + scrollable)) + .widget(new TextWidget("").setPos(0, 945)); + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_STAR) + .setPos(0, 350) + .setSize(300, 300)) + .widget( + scrollable.setSize(292, 292) + .setPos(4, 354)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(282, 354)); + if (debugMode) { + builder.widget( + new MultiChildWidget() + .addChild( + new ButtonWidget().setOnClick((clickData, widget) -> upgrades = new boolean[31]) + .setSize(40, 15) + .setBackground(GT_UITextures.BUTTON_STANDARD) + .addTooltip(translateToLocal("fog.debug.resetbutton.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .addChild( + new TextWidget(translateToLocal("fog.debug.resetbutton.text")) + .setTextAlignment(Alignment.Center) + .setScale(0.57f) + .setMaxWidth(36) + .setPos(3, 3)) + .addChild( + new NumericWidget().setSetter(val -> gravitonShardsAvailable = (int) val) + .setGetter(() -> gravitonShardsAvailable) + .setBounds(0, 112) + .setDefaultValue(0) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(25, 18) + .setPos(4, 16) + .addTooltip(translateToLocal("fog.debug.gravitonshardsetter.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD)) + .addChild( + new ButtonWidget().setOnClick((clickData, widget) -> Arrays.fill(upgrades, true)) + .setSize(40, 15) + .setBackground(GT_UITextures.BUTTON_STANDARD) + .addTooltip(translateToLocal("fog.debug.unlockall.text")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(0, 35)) + .addChild( + new TextWidget(translateToLocal("fog.debug.unlockall.text")).setTextAlignment(Alignment.Center) + .setScale(0.57f) + .setMaxWidth(36) + .setPos(3, 38)) + .setPos(4, 354)); + + } + return builder.build(); + } + + protected ModularWindow createIndividualUpgradeWindow(final EntityPlayer player) { + UITexture background; + UITexture overlay; + UITexture milestoneSymbol; + float widthRatio; + switch (currentColorCode) { + case 1 -> { + background = TecTechUITextures.BACKGROUND_GLOW_PURPLE; + overlay = TecTechUITextures.PICTURE_OVERLAY_PURPLE; + } + case 2 -> { + background = TecTechUITextures.BACKGROUND_GLOW_ORANGE; + overlay = TecTechUITextures.PICTURE_OVERLAY_ORANGE; + } + case 3 -> { + background = TecTechUITextures.BACKGROUND_GLOW_GREEN; + overlay = TecTechUITextures.PICTURE_OVERLAY_GREEN; + } + default -> { + background = TecTechUITextures.BACKGROUND_GLOW_BLUE; + overlay = TecTechUITextures.PICTURE_OVERLAY_BLUE; + } + } + switch (currentMilestoneBG) { + case 1 -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION; + widthRatio = 0.72f; + } + case 2 -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST; + widthRatio = 1f; + } + case 3 -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION; + widthRatio = 1f; + } + default -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE; + widthRatio = 0.8f; + } + } + int WIDTH = 250; + int HEIGHT = 250; + int LORE_POS = 110; + if (currentUpgradeID == 0) { + WIDTH = 300; + HEIGHT = 300; + LORE_POS = 85; + } + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT) + .setBackground(background) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(WIDTH - 15, 3)) + .widget( + new DrawableWidget().setDrawable(milestoneSymbol) + .setPos((int) ((1 - widthRatio / 2) * WIDTH / 2), HEIGHT / 4) + .setSize((int) (WIDTH / 2 * widthRatio), HEIGHT / 2)) + .widget( + new DrawableWidget().setDrawable(overlay) + .setPos(WIDTH / 4, HEIGHT / 4) + .setSize(WIDTH / 2, HEIGHT / 2)) + .widget( + new MultiChildWidget() + .addChild( + new TextWidget(translateToLocal("fog.upgrade.tt." + (currentUpgradeID))) + .setTextAlignment(Alignment.Center) + .setDefaultColor(EnumChatFormatting.GOLD) + .setSize(WIDTH - 15, 30) + .setPos(9, 5)) + .addChild( + new TextWidget(translateToLocal("fog.upgrade.text." + (currentUpgradeID))) + .setTextAlignment(Alignment.CenterLeft) + .setDefaultColor(0x9c9c9c) + .setSize(WIDTH - 15, LORE_POS - 30) + .setPos(9, 30)) + .addChild( + new TextWidget( + EnumChatFormatting.ITALIC + translateToLocal("fog.upgrade.lore." + (currentUpgradeID))) + .setTextAlignment(Alignment.Center) + .setDefaultColor(0x9c9c9c) + .setSize(WIDTH - 15, (int) (HEIGHT * 0.9) - LORE_POS) + .setPos(9, LORE_POS)) + .addChild( + new TextWidget( + translateToLocal("gt.blockmachines.multimachine.FOG.shardcost") + " " + + EnumChatFormatting.BLUE + + gravitonShardCost).setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(70) + .setDefaultColor(0x9c9c9c) + .setPos(11, HEIGHT - 25)) + .addChild( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.availableshards")) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(90) + .setDefaultColor(0x9c9c9c) + .setPos(WIDTH - 87, HEIGHT - 25)) + .addChild( + TextWidget.dynamicText(this::gravitonShardAmount) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(90) + .setDefaultColor(0x9c9c9c) + .setPos(WIDTH - 27, HEIGHT - 18))) + .setSize(WIDTH, HEIGHT) + + .widget(new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + int unlockedPrereqUpgrades = 0; + int unlockedFollowupUpgrades = 0; + int unlockedSplitUpgrades = 0; + if (!upgrades[currentUpgradeID]) { + for (int prereqUpgrade : prereqUpgrades) { + if (upgrades[prereqUpgrade]) { + unlockedPrereqUpgrades++; + } + } + if (allPrereqRequired) { + if (unlockedPrereqUpgrades == prereqUpgrades.length + && gravitonShardsAvailable >= gravitonShardCost) { + gravitonShardsAvailable -= gravitonShardCost; + gravitonShardsSpent += gravitonShardCost; + upgrades[currentUpgradeID] = true; + } + } else if (unlockedPrereqUpgrades > 0 || prereqUpgrades.length == 0) { + if (isUpradeSplitStart) { + for (int splitUpgrade : FIRST_SPLIT_UPGRADES) { + if (upgrades[splitUpgrade]) { + unlockedSplitUpgrades++; + } + } + unlockedSplitUpgrades -= (ringAmount - 1); + } + if (unlockedSplitUpgrades <= 0 && gravitonShardsAvailable >= gravitonShardCost) { + gravitonShardsAvailable -= gravitonShardCost; + gravitonShardsSpent += gravitonShardCost; + upgrades[currentUpgradeID] = true; + } + } + } else { + for (int followupUpgrade : followupUpgrades) { + if (upgrades[followupUpgrade]) { + unlockedFollowupUpgrades++; + } + } + if (unlockedFollowupUpgrades == 0) { + gravitonShardsAvailable += gravitonShardCost; + gravitonShardsSpent -= gravitonShardCost; + upgrades[currentUpgradeID] = false; + } + } + }) + .setSize(40, 15) + .setBackground(() -> { + if (upgrades[currentUpgradeID]) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED }; + } else { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD }; + } + }) + .addTooltip(translateToLocal("fog.upgrade.confirm")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .addChild( + new TextWidget(translateToLocal("fog.upgrade.confirm")).setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(36) + .setPos(3, 5)) + .addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(MANUAL_INSERTION_WINDOW_ID); + widget.getContext() + .closeWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + widget.getContext() + .closeWindow(UPGRADE_TREE_WINDOW_ID); + } + }) + .setBackground(TecTechUITextures.BUTTON_CELESTIAL_32x32) + .setPos(50, 50)) + .setPos(WIDTH / 2 - 21, (int) (HEIGHT * 0.9))); + return builder.build(); + } + + /** + * @param upgradeID ID of the upgrade + * @param colorCode Number deciding which colored background to use, 0 for blue, 1 for purple, 2 for + * orange and 3 for green + * @param milestone Number deciding which milestone symbol to display in the background, 0 for charge, + * 1 for conversion, 2 for catalyst and 3 for composition + * @param prerequisiteUpgradeIDs IDs of the prior upgrades directly connected to the current one + * @param requireAllPrerequisites Decides how many connected prerequisite upgrades have to be unlocked to be able to + * unlock this one. True means ALL, False means AT LEAST ONE + * @param followingUpgradeIDs IDs of the following upgrades directly connected to the current one + * @param isStartOfSplit Whether this upgrade is one of the initial split upgrades + * @param shardCost How many graviton shards are needed to unlock this upgrade + * @param pos Position of the upgrade inside the scrollableWidget + */ + private Widget createUpgradeBox(int upgradeID, int colorCode, int milestone, int[] prerequisiteUpgradeIDs, + boolean requireAllPrerequisites, int[] followingUpgradeIDs, boolean isStartOfSplit, int shardCost, Pos2d pos, + IWidgetBuilder builder) { + return new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + currentUpgradeID = upgradeID; + currentColorCode = colorCode; + currentMilestoneBG = milestone; + gravitonShardCost = shardCost; + prereqUpgrades = prerequisiteUpgradeIDs; + allPrereqRequired = requireAllPrerequisites; + followupUpgrades = followingUpgradeIDs; + isUpradeSplitStart = isStartOfSplit; + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + }) + .setSize(40, 15) + .setBackground(() -> { + if (upgrades[upgradeID]) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED }; + } else { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD }; + } + }) + .addTooltip(translateToLocal("fog.upgrade.tt." + upgradeID)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .addChild( + new TextWidget(translateToLocal("fog.upgrade.tt." + upgradeID)).setTextAlignment(Alignment.Center) + .setScale(0.57f) + .setMaxWidth(36) + .setPos(3, 3)) + .setPos(pos) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> upgrades[upgradeID], val -> upgrades[upgradeID] = val), + builder); + } + + List inputs = new ArrayList<>( + Arrays.asList( + ItemList.Electric_Motor_UMV.get(13L), + ItemList.Electric_Pump_UXV.get(32L), + ItemList.Electric_Piston_UXV.get(32L), + ItemList.Robot_Arm_UXV.get(32L), + ItemList.Superconducting_Magnet_Solenoid_UIV.get(48L), + ItemList.NaquadriaSupersolid.get(32L), + CustomItemList.astralArrayFabricator.get(36L), + CustomItemList.Machine_Multi_EyeOfHarmony.get(2L))); + + protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { + final int WIDTH = 189; + final int HEIGHT = 84; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + final MultiChildWidget columns = new MultiChildWidget(); + final DynamicPositionedColumn column1 = new DynamicPositionedColumn(); + final DynamicPositionedColumn column2 = new DynamicPositionedColumn(); + final DynamicPositionedColumn column3 = new DynamicPositionedColumn(); + List columnList = Arrays.asList(column1, column2, column3); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add(Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT))) + .subtract(5, 0) + .add(0, 4)); + builder.widget( + SlotGroup.ofItemHandler(inputSlotHandler, 4) + .startFromSlot(0) + .endAtSlot(15) + .phantom(false) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(111, 6)); + for (int i = 0; i < inputs.size(); i++) { + int index = i; + int cleanDiv4 = index / 4; + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.BUTTON_STANDARD_PRESSED) + .setPos(6 + cleanDiv4 * 36, 6 + index % 4 * 18) + .setSize(18, 18)); + columnList.get(cleanDiv4) + .addChild( + new ItemDrawable().setItem(inputs.get(index)) + .asWidget() + .dynamicTooltip(() -> { + List tooltip = new ArrayList<>(); + tooltip.add( + inputs.get(index) != null ? inputs.get(index) + .getDisplayName() : ""); + return tooltip; + }) + .setSize(16, 16)); + } + + columns.addChild( + column1.setSpace(2) + .setAlignment(MainAxisAlignment.SPACE_BETWEEN) + .setSize(34, 72) + .setPos(1, 1)); + columns.addChild( + column2.setSpace(2) + .setAlignment(MainAxisAlignment.SPACE_BETWEEN) + .setSize(34, 72) + .setPos(37, 1)); + columns.addChild( + column3.setSpace(2) + .setAlignment(MainAxisAlignment.SPACE_BETWEEN) + .setSize(34, 72) + .setPos(73, 1)); + builder.widget( + columns.setSize(72, 72) + .setPos(6, 6)); + return builder.build(); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Material Manipulator") // Machine Type: + .addInfo("Controller block for the Forge of Gods") // Controller + .addInfo("Uses a Star to to manipulate metals") + .addSeparator() + .beginStructureBlock(1, 4, 2, false) + .addStructureInfo("Output bus/hatch has to be the ME variant") + .addStructureInfo("Dot 2 of Input Hatch is the Fuel Input Hatch") + .addInputHatch("Any Infinite Spacetime Casing", 1) + .addInputHatch("Any Infinite Spacetime Casing", 2) // Fuel + // Input + // Hatch + .addInputBus("Any Infinite Spacetime Casing", 1) + .addOutputBus("Any Infinite Spacetime Casing", 1) + .addOutputHatch("Any Infinite Spacetime Casing", 1) + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + + @Override + public boolean energyFlowOnRunningTick(ItemStack aStack, boolean allowProduction) { + return true; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return new String[] { "Forge of Gods multiblock" }; + } + + public int getFuelType() { + return selectedFuelType; + } + + private void setFuelType(int fuelType) { + selectedFuelType = fuelType; + } + + public int getFuelFactor() { + return fuelConsumptionFactor; + } + + public boolean isUpgradeActive(int upgradeID) { + return upgrades[upgradeID]; + } + + public int getRingAmount() { + return ringAmount; + } + + public int getTotalActiveUpgrades() { + int totalUpgrades = 0; + for (boolean upgrade : upgrades) { + if (upgrade) { + totalUpgrades++; + } + } + return totalUpgrades; + } + + private Text fuelUsage() { + return new Text(fuelConsumption + " L/5s"); + } + + private Text gravitonShardAmount() { + EnumChatFormatting enoughGravitonShards = EnumChatFormatting.RED; + if (gravitonShardsAvailable >= gravitonShardCost) { + enoughGravitonShards = EnumChatFormatting.GREEN; + } + return new Text(enoughGravitonShards + Integer.toString(gravitonShardsAvailable)); + + } + + private Text storedFuel() { + if (internalBattery == 0) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.storedstartupfuel") + " " + + stellarFuelAmount + + "/" + + neededStartupFuel); + } + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.storedfuel") + " " + + internalBattery + + "/" + + maxBatteryCharge); + } + + private void checkInversionStatus() { + int inversionChecker = 0; + for (int progress : milestoneProgress) { + if (progress < 7) { + break; + } + inversionChecker++; + } + inversion = inversionChecker == 4; + } + + private Text inversionStatusText() { + String inversionStatus = ""; + if (inversion) { + inversionStatus = EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.inversion"); + } + return new Text(inversionStatus); + } + + private void determineCompositionMilestoneLevel() { + int[] uniqueModuleCount = new int[5]; + int smelting = 0; + int molten = 0; + int plasma = 0; + int exotic = 0; + int exoticMagmatter = 0; + for (GT_MetaTileEntity_EM_BaseModule module : moduleHatches) { + if (module instanceof GT_MetaTileEntity_EM_SmeltingModule) { + uniqueModuleCount[0] = 1; + smelting++; + continue; + } + if (module instanceof GT_MetaTileEntity_EM_MoltenModule) { + uniqueModuleCount[1] = 1; + molten++; + continue; + } + if (module instanceof GT_MetaTileEntity_EM_PlasmaModule) { + uniqueModuleCount[2] = 1; + plasma++; + continue; + } + if (module instanceof GT_MetaTileEntity_EM_ExoticModule) { + if (!((GT_MetaTileEntity_EM_ExoticModule) module).isMagmatterModeOn()) { + uniqueModuleCount[3] = 1; + exotic++; + } else { + uniqueModuleCount[4] = 1; + exoticMagmatter++; + } + } + + } + totalExtensionsBuilt = Arrays.stream(uniqueModuleCount) + .sum() + ringAmount + - 1; + if (inversion) { + totalExtensionsBuilt += (smelting - 1 + + (molten - 1) * 2 + + (plasma - 1) * 3 + + (exotic - 1) * 4 + + (exoticMagmatter - 1) * 5) / 5f; + } + milestoneProgress[3] = (int) Math.floor(totalExtensionsBuilt); + } + + private void determineMilestoneProgress() { + int closestRelevantSeven; + float rawProgress; + float actualProgress; + if (milestoneProgress[0] < 7) { + powerMilestonePercentage = (float) max( + (log((totalPowerConsumed.divide(BigInteger.valueOf(POWER_MILESTONE_CONSTANT))).longValue()) + / POWER_LOG_CONSTANT + 1), + 0) / 7; + milestoneProgress[0] = (int) floor(powerMilestonePercentage * 7); + } + if (inversion) { + rawProgress = (totalPowerConsumed.divide(POWER_MILESTONE_T7_CONSTANT) + .floatValue() - 1) / 7; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + milestoneProgress[0] = 7 + (int) floor(rawProgress * 7); + if (closestRelevantSeven % 2 == 0) { + invertedPowerMilestonePercentage = actualProgress; + powerMilestonePercentage = 1 - invertedPowerMilestonePercentage; + } else { + powerMilestonePercentage = actualProgress; + invertedPowerMilestonePercentage = 1 - powerMilestonePercentage; + } + } + + if (milestoneProgress[1] < 7) { + recipeMilestonePercentage = (float) max( + (log(totalRecipesProcessed * 1f / RECIPE_MILESTONE_CONSTANT) / RECIPE_LOG_CONSTANT + 1), + 0) / 7; + milestoneProgress[1] = (int) floor(recipeMilestonePercentage * 7); + } + if (inversion) { + rawProgress = (((float) totalRecipesProcessed / RECIPE_MILESTONE_T7_CONSTANT) - 1) / 7; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + milestoneProgress[1] = 7 + (int) floor(rawProgress * 7); + if (closestRelevantSeven % 2 == 0) { + invertedRecipeMilestonePercentage = actualProgress; + recipeMilestonePercentage = 1 - invertedRecipeMilestonePercentage; + } else { + recipeMilestonePercentage = actualProgress; + invertedRecipeMilestonePercentage = 1 - recipeMilestonePercentage; + } + } + if (milestoneProgress[2] < 7) { + fuelMilestonePercentage = (float) max( + (log(totalFuelConsumed * 1f / FUEL_MILESTONE_CONSTANT) / FUEL_LOG_CONSTANT + 1), + 0) / 7; + milestoneProgress[2] = (int) floor(fuelMilestonePercentage * 7); + } + if (inversion) { + rawProgress = (((float) totalFuelConsumed / FUEL_MILESTONE_T7_CONSTANT) - 1) / 7; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + milestoneProgress[2] = 7 + (int) floor(rawProgress * 7); + if ((closestRelevantSeven % 2) == 0) { + invertedFuelMilestonePercentage = actualProgress; + fuelMilestonePercentage = 1 - invertedFuelMilestonePercentage; + } else { + fuelMilestonePercentage = actualProgress; + invertedFuelMilestonePercentage = 1 - fuelMilestonePercentage; + } + } + + if (milestoneProgress[3] < 7) { + structureMilestonePercentage = totalExtensionsBuilt / 7f; + } + if (inversion) { + rawProgress = (totalExtensionsBuilt - 7) / 7f; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + if ((closestRelevantSeven % 2) == 0) { + invertedStructureMilestonePercentage = actualProgress; + structureMilestonePercentage = 1 - invertedStructureMilestonePercentage; + } else { + structureMilestonePercentage = actualProgress; + invertedStructureMilestonePercentage = 1 - structureMilestonePercentage; + } + } + } + + private void determineGravitonShardAmount() { + int sum = 0; + for (int progress : milestoneProgress) { + if (!inversion) { + progress = Math.min(progress, 7); + } + sum += progress * (progress + 1) / 2; + } + gravitonShardsAvailable = sum - gravitonShardsSpent; + } + + private Text gravitonShardAmountText(int milestoneID) { + int sum; + int progress = milestoneProgress[milestoneID]; + if (!inversion) { + progress = Math.min(progress, 7); + } + sum = progress * (progress + 1) / 2; + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.shardgain") + ": " + EnumChatFormatting.GRAY + sum); + } + + private Text totalMilestoneProgress(int milestoneID) { + long progress; + BigInteger bigProgress; + String suffix; + boolean shift = Interactable.hasShiftDown(); + switch (milestoneID) { + case 1 -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.recipes"); + progress = totalRecipesProcessed; + } + case 2 -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.fuel"); + progress = totalFuelConsumed; + } + case 3 -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.extensions"); + progress = milestoneProgress[3]; + } + default -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.power"); + bigProgress = totalPowerConsumed; + if (!shift && (totalPowerConsumed.compareTo(BigInteger.valueOf(1_000L)) > 0)) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + toExponentForm(bigProgress) + + " " + + suffix); + } else { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + bigProgress + + " " + + suffix); + } + } + } + if (!shift) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + formatNumbers(progress) + + " " + + suffix); + } else { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + progress + + " " + + suffix); + } + + } + + private Text currentMilestone(int milestoneID) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.milestoneprogress") + ": " + + EnumChatFormatting.GRAY + + milestoneProgress[milestoneID]); + } + + private Text milestoneProgressText(int milestoneID, boolean formatting) { + long max; + BigInteger bigMax; + String suffix; + String progressText = translateToLocal("gt.blockmachines.multimachine.FOG.progress"); + Text done = new Text(translateToLocal("gt.blockmachines.multimachine.FOG.milestonecomplete")); + if (Interactable.hasShiftDown()) { + formatting = false; + done = new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.milestonecomplete") + EnumChatFormatting.DARK_RED + + "?"); + } + switch (milestoneID) { + case 0: + if (milestoneProgress[0] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.power"); + if (inversion) { + bigMax = POWER_MILESTONE_T7_CONSTANT.multiply(BigInteger.valueOf(milestoneProgress[0] - 5)); + } else { + bigMax = BigInteger.valueOf(LongMath.pow(9, milestoneProgress[0])) + .multiply(BigInteger.valueOf(LongMath.pow(10, 15))); + } + if (formatting && (totalPowerConsumed.compareTo(BigInteger.valueOf(1_000L)) > 0)) { + return new Text( + progressText + ": " + EnumChatFormatting.GRAY + toExponentForm(bigMax) + " " + suffix); + } else { + return new Text(progressText + ": " + EnumChatFormatting.GRAY + bigMax + " " + suffix); + } + } else { + return done; + } + case 1: + if (milestoneProgress[1] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.recipes"); + if (inversion) { + max = RECIPE_MILESTONE_T7_CONSTANT * (milestoneProgress[1] - 5); + } else { + max = LongMath.pow(6, milestoneProgress[1]) * LongMath.pow(10, 7); + } + break; + } else { + return done; + } + case 2: + if (milestoneProgress[2] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.fuel"); + if (inversion) { + max = FUEL_MILESTONE_T7_CONSTANT * (milestoneProgress[2] - 5); + } else { + max = LongMath.pow(3, milestoneProgress[2]) * LongMath.pow(10, 4); + } + break; + } else { + return done; + } + case 3: + if (milestoneProgress[3] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.extensions"); + max = milestoneProgress[3] + 1; + break; + } else { + return done; + } + default: + return new Text("Error"); + } + if (formatting) { + return new Text(progressText + ": " + EnumChatFormatting.GRAY + formatNumbers(max) + " " + suffix); + } else { + return new Text(progressText + ": " + EnumChatFormatting.GRAY + max + " " + suffix); + } + } + + private void increaseBattery(int amount) { + if ((internalBattery + amount) <= maxBatteryCharge) { + internalBattery += amount; + } else { + batteryCharging = false; + } + } + + public void reduceBattery(int amount) { + if (internalBattery - amount <= 0) { + internalBattery = 0; + if (moduleHatches.size() > 0) { + for (GT_MetaTileEntity_EM_BaseModule module : moduleHatches) { + module.disconnect(); + } + } + } else { + internalBattery -= amount; + totalFuelConsumed += amount; + } + + } + + public int getBatteryCharge() { + return internalBattery; + } + + public int getMaxBatteryCharge() { + return maxBatteryCharge; + } + + public void addTotalPowerConsumed(BigInteger amount) { + totalPowerConsumed = totalPowerConsumed.add(amount); + } + + public void addTotalRecipesProcessed(long amount) { + totalRecipesProcessed += amount; + } + + @Override + protected void setHatchRecipeMap(GT_MetaTileEntity_Hatch_Input hatch) {} + + @Override + public void setItemNBT(NBTTagCompound NBT) { + NBT.setInteger("selectedFuelType", selectedFuelType); + NBT.setInteger("fuelConsumptionFactor", fuelConsumptionFactor); + NBT.setInteger("internalBattery", internalBattery); + NBT.setBoolean("batteryCharging", batteryCharging); + NBT.setInteger("batterySize", maxBatteryCharge); + NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); + NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); + NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); + NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); + NBT.setLong("totalFuelConsumed", totalFuelConsumed); + NBT.setInteger("starFuelStored", stellarFuelAmount); + + // Store booleanArray of all upgrades + NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); + + int upgradeIndex = 0; + for (Boolean upgrade : upgrades) { + upgradeBooleanArrayNBTTag.setBoolean("upgrade" + upgradeIndex, upgrade); + upgradeIndex++; + } + + NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); + super.saveNBTData(NBT); + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + NBT.setInteger("selectedFuelType", selectedFuelType); + NBT.setInteger("fuelConsumptionFactor", fuelConsumptionFactor); + NBT.setInteger("internalBattery", internalBattery); + NBT.setBoolean("batteryCharging", batteryCharging); + NBT.setInteger("batterySize", maxBatteryCharge); + NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); + NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); + NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); + NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); + NBT.setLong("totalFuelConsumed", totalFuelConsumed); + NBT.setInteger("starFuelStored", stellarFuelAmount); + + // Store booleanArray of all upgrades + NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); + + int upgradeIndex = 0; + for (Boolean upgrade : upgrades) { + upgradeBooleanArrayNBTTag.setBoolean("upgrade" + upgradeIndex, upgrade); + upgradeIndex++; + } + + NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(NBTTagCompound NBT) { + selectedFuelType = NBT.getInteger("selectedFuelType"); + fuelConsumptionFactor = NBT.getInteger("fuelConsumptionFactor"); + internalBattery = NBT.getInteger("internalBattery"); + batteryCharging = NBT.getBoolean("batteryCharging"); + maxBatteryCharge = NBT.getInteger("batterySize"); + gravitonShardsAvailable = NBT.getInteger("gravitonShardsAvailable"); + gravitonShardsSpent = NBT.getInteger("gravitonShardsSpent"); + totalPowerConsumed = new BigInteger(NBT.getByteArray("totalPowerConsumed")); + totalRecipesProcessed = NBT.getLong("totalRecipesProcessed"); + totalFuelConsumed = NBT.getLong("totalFuelConsumed"); + stellarFuelAmount = NBT.getInteger("starFuelStored"); + + NBTTagCompound tempBooleanTag = NBT.getCompoundTag("upgrades"); + + for (int upgradeIndex = 0; upgradeIndex < 31; upgradeIndex++) { + boolean upgrade = tempBooleanTag.getBoolean("upgrade" + upgradeIndex); + upgrades[upgradeIndex] = upgrade; + } + + super.loadNBTData(NBT); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java new file mode 100644 index 0000000000..1be94b4333 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java @@ -0,0 +1,525 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_NEUTRAL; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_OK; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_TOO_LOW; +import static com.github.technus.tectech.util.CommonValues.MULTI_CHECK_AT; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +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_Utility.filterValidMTEs; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.client.renderer.texture.IIconRegister; +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.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Rack; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.IGT_HatchAdder; +import gregtech.api.util.shutdown.ShutDownReason; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockBase_EM + implements ISurvivalConstructable { + + // region variables + private final ArrayList eRacks = new ArrayList<>(); + + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + // endregion + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.computer.hint.0"), // 1 - Classic/Data Hatches or + // Computer casing + translateToLocal("gt.blockmachines.multimachine.em.computer.hint.1"), // 2 - Rack Hatches or Advanced + // computer casing + }; + + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape("front", transpose(new String[][] { { " AA" }, { " AA" }, { " ~A" }, { " AA" } })) + .addShape("cap", transpose(new String[][] { { "-CB" }, { " DD" }, { " DD" }, { "-CB" } })) + .addShape("slice", transpose(new String[][] { { "-CB" }, { " ED" }, { " ED" }, { "-CB" } })) + .addShape("back", transpose(new String[][] { { " AA" }, { " AA" }, { " AA" }, { " AA" } })) + .addElement('B', ofBlock(sBlockCasingsTT, 1)) + .addElement('C', ofBlock(sBlockCasingsTT, 2)) + .addElement('D', ofBlock(sBlockCasingsTT, 3)) + .addElement( + 'A', + buildHatchAdder(GT_MetaTileEntity_EM_computer.class) + .atLeast( + Energy.or(HatchElement.EnergyMulti), + Maintenance, + HatchElement.Uncertainty, + HatchElement.OutputData) + .casingIndex(textureOffset + 1) + .dot(1) + .buildAndChain(ofBlock(sBlockCasingsTT, 1))) + .addElement('E', ofChain(RackHatchElement.INSTANCE.newAny(textureOffset + 3, 2), ofBlock(sBlockCasingsTT, 3))) + .build(); + // endregion + + // region parameters + protected Parameters.Group.ParameterIn overclock, overvolt; + protected Parameters.Group.ParameterOut maxCurrentTemp, availableData; + + private static final INameFunction OC_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.0"); // Overclock ratio + private static final INameFunction OV_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.1"); // Overvoltage ratio + private static final INameFunction MAX_TEMP_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.0"); // Current max. heat + private static final INameFunction COMPUTE_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.1"); // Produced computation + private static final IStatusFunction OC_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), 0, 1, 1, 3); + private static final IStatusFunction OV_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), .7, .8, 1.2, 2); + private static final IStatusFunction MAX_TEMP_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), -10000, 0, 0, 5000); + private static final IStatusFunction COMPUTE_STATUS = (base, p) -> { + if (base.eAvailableData < 0) { + return STATUS_TOO_LOW; + } + if (base.eAvailableData == 0) { + return STATUS_NEUTRAL; + } + return STATUS_OK; + }; + // endregion + + public GT_MetaTileEntity_EM_computer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + eCertainMode = 5; + eCertainStatus = -128; // no-brain value + } + + public GT_MetaTileEntity_EM_computer(String aName) { + super(aName); + eCertainMode = 5; + eCertainStatus = -128; // no-brain value + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_computer(mName); + } + + @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0 = parametrization.getGroup(0); + overclock = hatch_0.makeInParameter(0, 1, OC_NAME, OC_STATUS); + overvolt = hatch_0.makeInParameter(1, 1, OV_NAME, OV_STATUS); + maxCurrentTemp = hatch_0.makeOutParameter(0, 0, MAX_TEMP_NAME, MAX_TEMP_STATUS); + availableData = hatch_0.makeOutParameter(1, 0, COMPUTE_NAME, COMPUTE_STATUS); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + for (GT_MetaTileEntity_Hatch_Rack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + eRacks.clear(); + if (!structureCheck_EM("front", 1, 2, 0)) { + return false; + } + if (!structureCheck_EM("cap", 1, 2, -1)) { + return false; + } + byte offset = -2, totalLen = 4; + while (offset > -16) { + if (!structureCheck_EM("slice", 1, 2, offset)) { + break; + } + totalLen++; + offset--; + } + if (totalLen > 17) { + return false; + } + if (!structureCheck_EM("cap", 1, 2, ++offset)) { + return false; + } + if (!structureCheck_EM("back", 1, 2, --offset)) { + return false; + } + eCertainMode = (byte) Math.min(totalLen / 3, 5); + for (GT_MetaTileEntity_Hatch_Rack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(iGregTechTileEntity.isActive()); + } + return eUncertainHatches.size() == 1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setDouble("computation", availableData.get()); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (availableData != null) { + availableData.set(aNBT.getDouble("computation")); + eAvailableData = (long) availableData.get(); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && mMachine + && !aBaseMetaTileEntity.isActive() + && aTick % 20 == MULTI_CHECK_AT) { + double maxTemp = 0; + for (GT_MetaTileEntity_Hatch_Rack rack : filterValidMTEs(eRacks)) { + if (rack.heat > maxTemp) { + maxTemp = rack.heat; + } + } + maxCurrentTemp.set(maxTemp); + } + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + parametrization.setToDefaults(false, true); + eAvailableData = 0; + double maxTemp = 0; + double overClockRatio = overclock.get(); + double overVoltageRatio = overvolt.get(); + if (Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) { + return SimpleCheckRecipeResult.ofFailure("no_computing"); + } + if (overclock.getStatus(true).isOk && overvolt.getStatus(true).isOk) { + float eut = V[8] * (float) overVoltageRatio * (float) overClockRatio; + if (eut < Integer.MAX_VALUE - 7) { + mEUt = -(int) eut; + } else { + mEUt = -(int) V[8]; + return CheckRecipeResultRegistry.POWER_OVERFLOW; + } + short thingsActive = 0; + int rackComputation; + + for (GT_MetaTileEntity_Hatch_Rack rack : filterValidMTEs(eRacks)) { + if (rack.heat > maxTemp) { + maxTemp = rack.heat; + } + rackComputation = rack.tickComponents((float) overClockRatio, (float) overVoltageRatio); + if (rackComputation > 0) { + eAvailableData += rackComputation; + thingsActive += 4; + } + rack.getBaseMetaTileEntity() + .setActive(true); + } + + for (GT_MetaTileEntity_Hatch_InputData di : eInputData) { + if (di.q != null) // ok for power losses + { + thingsActive++; + } + } + + if (thingsActive > 0 && eCertainStatus == 0) { + thingsActive += eOutputData.size(); + eAmpereFlow = 1 + (thingsActive >> 2); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + maxCurrentTemp.set(maxTemp); + availableData.set(eAvailableData); + return SimpleCheckRecipeResult.ofSuccess("computing"); + } else { + eAvailableData = 0; + mEUt = -(int) V[8]; + eAmpereFlow = 1; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + maxCurrentTemp.set(maxTemp); + availableData.set(eAvailableData); + return SimpleCheckRecipeResult.ofSuccess("no_computing"); + } + } + return SimpleCheckRecipeResult.ofFailure("no_computing"); + } + + @Override + public void outputAfterRecipe_EM() { + if (!eOutputData.isEmpty()) { + Vec3Impl pos = new Vec3Impl( + getBaseMetaTileEntity().getXCoord(), + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); + + QuantumDataPacket pack = new QuantumDataPacket(eAvailableData / eOutputData.size()).unifyTraceWith(pos); + if (pack == null) { + return; + } + for (GT_MetaTileEntity_Hatch_InputData hatch : eInputData) { + if (hatch.q == null || hatch.q.contains(pos)) { + continue; + } + pack = pack.unifyPacketWith(hatch.q); + if (pack == null) { + return; + } + } + + for (GT_MetaTileEntity_Hatch_OutputData o : eOutputData) { + o.q = pack; + } + } + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.computer.name")) // Machine Type: Quantum + // Computer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.computer.desc.0")) // Controller block of + // the Quantum Computer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.computer.desc.1")) // Used to generate + // computation (and heat) + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginVariableStructureBlock(2, 2, 4, 4, 5, 16, false) + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.certain.tier.07.name"), + translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), + 1) // Uncertainty Resolver: Any Computer Casing on first or last slice + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), + 1) // Optical Connector: Any Computer Casing on first or last slice + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.rack.tier.08.name"), + translateToLocal("tt.keyword.Structure.AnyAdvComputerCasingExceptOuter"), + 2) // Computer Rack: Any Advanced Computer Casing, except the outer ones + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.param.tier.05.name"), + translateToLocal("tt.keyword.Structure.Optional") + " " + + translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), + 2) // Parametrizer: (optional) Any Computer Casing on first or last slice + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), 1) // Energy + // Hatch: + // Any + // Computer + // Casing + // on + // first + // or + // last + // slice + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), 1) // Maintenance + // Hatch: + // Any + // Computer + // Casing + // on + // first + // or + // last + // slice + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_COMPUTER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_COMPUTER_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][3], + new TT_RenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][3] }; + } + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return GT_MetaTileEntity_EM_switch.activitySound; + } + + @Override + public void onRemoval() { + super.onRemoval(); + for (GT_MetaTileEntity_Hatch_Rack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + } + + @Override + protected void extraExplosions_EM() { + for (MetaTileEntity tTileEntity : eRacks) { + tTileEntity.getBaseMetaTileEntity() + .doExplosion(V[9]); + } + } + + @Override + protected long getAvailableData_EM() { + return eAvailableData; + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + eAvailableData = 0; + for (GT_MetaTileEntity_Hatch_Rack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + } + + @Override + protected void afterRecipeCheckFailed() { + super.afterRecipeCheckFailed(); + for (GT_MetaTileEntity_Hatch_Rack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + } + + public final boolean addRackToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Rack) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eRacks.add((GT_MetaTileEntity_Hatch_Rack) aMetaTileEntity); + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("front", 1, 2, 0, stackSize, hintsOnly); + structureBuild_EM("cap", 1, 2, -1, stackSize, hintsOnly); + + byte offset = -2; + for (int rackSlices = Math.min(stackSize.stackSize, 12); rackSlices > 0; rackSlices--) { + structureBuild_EM("slice", 1, 2, offset--, stackSize, hintsOnly); + } + + structureBuild_EM("cap", 1, 2, offset--, stackSize, hintsOnly); + structureBuild_EM("back", 1, 2, offset, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + int built; + built = survivialBuildPiece("front", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + built = survivialBuildPiece("cap", stackSize, 1, 2, -1, elementBudget, source, actor, false, true); + if (built >= 0) return built; + + byte offset = -2; + for (int rackSlices = Math.min(stackSize.stackSize, 12); rackSlices > 0; rackSlices--) { + built = survivialBuildPiece("slice", stackSize, 1, 2, offset--, elementBudget, source, actor, false, true); + if (built >= 0) return built; + } + built = survivialBuildPiece("cap", stackSize, 1, 2, offset--, elementBudget, source, actor, false, true); + if (built >= 0) return built; + return survivialBuildPiece("back", stackSize, 1, 2, offset, elementBudget, source, actor, false, true); + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + private enum RackHatchElement implements IHatchElement { + + INSTANCE; + + @Override + public List> mteClasses() { + return Collections.singletonList(GT_MetaTileEntity_Hatch_Rack.class); + } + + @Override + public IGT_HatchAdder adder() { + return GT_MetaTileEntity_EM_computer::addRackToMachineList; + } + + @Override + public long count(GT_MetaTileEntity_EM_computer t) { + return t.eRacks.size(); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java new file mode 100644 index 0000000000..bbf719542b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java @@ -0,0 +1,302 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.mechanics.dataTransport.InventoryDataPacket; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputDataItems; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputDataItems; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +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_DataAccess; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.IGT_HatchAdder; + +public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockBase_EM + implements ISurvivalConstructable { + + // region variables + private final ArrayList eStacksDataOutputs = new ArrayList<>(); + private final ArrayList eDataAccessHatches = new ArrayList<>(); + private boolean slave = false; + // endregion + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.databank.hint.0"), // 1 - Classic Hatches or high power + // casing + translateToLocal("gt.blockmachines.multimachine.em.databank.hint.1"), // 2 - Data Access/Data Bank Master + // Hatches or + // computer casing + }; + + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + "main", + transpose( + new String[][] { { "BCCCB", "BDDDB", "BDDDB" }, { "BC~CB", "BAAAB", "BDDDB" }, + { "BCCCB", "BDDDB", "BDDDB" } })) + .addElement('A', ofBlock(sBlockCasingsTT, 1)) + .addElement('B', ofBlock(sBlockCasingsTT, 2)) + .addElement('C', classicHatches(textureOffset, 1, sBlockCasingsTT, 0)) + .addElement( + 'D', + buildHatchAdder(GT_MetaTileEntity_EM_dataBank.class) + .atLeast(DataBankHatches.OutboundConnector, DataBankHatches.InboundConnector) + .casingIndex(textureOffset + 1) + .dot(2) + .buildAndChain(DataBankHatches.DataStick.newAny(textureOffset + 1, 2), ofBlock(sBlockCasingsTT, 1))) + .build(); + // endregion + + public GT_MetaTileEntity_EM_dataBank(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_dataBank(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_dataBank(mName); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.databank.name")) // Machine Type: Data Bank + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.databank.desc.0")) // Controller block of + // the Data Bank + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.databank.desc.1")) // Used to supply + // Assembling Lines + // with more Data Sticks + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.databank.desc.2")) // and give multiple + // Assembling + // Lines access to the same Data + // Stick + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginStructureBlock(5, 3, 3, false) + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataAccessHatch"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Data Access Hatch: Any Computer Casing + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.dataoutass.tier.07.name"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Data Bank Master Connector: Any Computer Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Energy Hatch: Any + // High Power Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Maintenance + // Hatch: Any High + // Power Casing + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + eDataAccessHatches.clear(); + eStacksDataOutputs.clear(); + slave = false; + return structureCheck_EM("main", 2, 1, 0); + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + if (eDataAccessHatches.size() > 0 && eStacksDataOutputs.size() > 0) { + mEUt = -(int) V[slave ? 6 : 4]; + eAmpereFlow = 1 + (long) eStacksDataOutputs.size() * eDataAccessHatches.size(); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return SimpleCheckRecipeResult.ofSuccess("providing_data"); + } + return SimpleCheckRecipeResult.ofFailure("no_data"); + } + + @Override + public void outputAfterRecipe_EM() { + ArrayList stacks = new ArrayList<>(); + for (IInventory dataAccess : eDataAccessHatches) { + int count = dataAccess.getSizeInventory(); + for (int i = 0; i < count; i++) { + ItemStack stack = dataAccess.getStackInSlot(i); + if (stack != null) { + stacks.add(stack); + } + } + } + if (stacks.size() > 0) { + ItemStack[] arr = stacks.toArray(nullItem); + for (GT_MetaTileEntity_Hatch_OutputDataItems hatch : eStacksDataOutputs) { + hatch.q = new InventoryDataPacket(arr); + } + } else { + for (GT_MetaTileEntity_Hatch_OutputDataItems hatch : eStacksDataOutputs) { + hatch.q = null; + } + } + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][1], + new TT_RenderedExtendedFacingTexture( + aActive ? GT_MetaTileEntity_MultiblockBase_EM.ScreenON + : GT_MetaTileEntity_MultiblockBase_EM.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][1] }; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_hi_freq"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + public final boolean addDataBankHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputDataItems) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eStacksDataOutputs.add((GT_MetaTileEntity_Hatch_OutputDataItems) aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess + && !(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputDataItems)) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDataAccessHatches.add(aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputDataItems) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + slave = true; + return eDataAccessHatches.add(aMetaTileEntity); + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 2, 1, 0, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 2, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + private enum DataBankHatches implements IHatchElement { + + DataStick(GT_MetaTileEntity_Hatch_DataAccess.class) { + + @Override + public long count(GT_MetaTileEntity_EM_dataBank t) { + return t.eDataAccessHatches.size(); + } + }, + OutboundConnector(GT_MetaTileEntity_Hatch_OutputDataItems.class) { + + @Override + public long count(GT_MetaTileEntity_EM_dataBank t) { + return t.eStacksDataOutputs.size(); + } + }, + InboundConnector(GT_MetaTileEntity_Hatch_InputDataItems.class) { + + @Override + public long count(GT_MetaTileEntity_EM_dataBank t) { + return t.eDataAccessHatches.size(); + } + }; + + private final List> mteClasses; + + @SafeVarargs + DataBankHatches(Class... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + } + + @Override + public List> mteClasses() { + return mteClasses; + } + + @Override + public IGT_HatchAdder adder() { + return GT_MetaTileEntity_EM_dataBank::addDataBankHatchToMachineList; + } + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java new file mode 100644 index 0000000000..577fae6d4b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java @@ -0,0 +1,315 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTech_API.mEUtoRF; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { + + private static final int maxRepairedDamagePerOperation = 1000; + private static final long usedEuPerDurability = 1000; + private static final int usedUumPerDurability = 1; + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + // 1 - Classic Hatches or High Power Casing + translateToLocal("gt.blockmachines.multimachine.em.infuser.hint"), }; + + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + "main", + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "BBB", "BAB", "BBB" }, { "A~A", "AAA", "AAA" }, + { "BBB", "BAB", "BBB" }, { "CCC", "CCC", "CCC" } })) + .addElement('A', ofBlock(sBlockCasingsTT, 4)) + .addElement('B', ofBlock(sBlockCasingsTT, 7)) + .addElement( + 'C', + ofHatchAdderOptional( + GT_MetaTileEntity_EM_infuser::addClassicToMachineList, + textureOffset, + 1, + sBlockCasingsTT, + 0)) + .build(); + // endregion + + public GT_MetaTileEntity_EM_infuser(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + minRepairStatus = (byte) getIdealStatus(); + eDismantleBoom = true; + } + + public GT_MetaTileEntity_EM_infuser(String aName) { + super(aName); + minRepairStatus = (byte) getIdealStatus(); + eDismantleBoom = true; + } + + private boolean isItemStackFullyCharged(ItemStack stack) { + if (stack == null) { + return true; + } + Item item = stack.getItem(); + if (stack.stackSize == 1) { + if (item instanceof IElectricItem) { + return ElectricItem.manager.getCharge(stack) >= ((IElectricItem) item).getMaxCharge(stack); + } else if (TecTech.hasCOFH && item instanceof IEnergyContainerItem) { + return ((IEnergyContainerItem) item).getEnergyStored(stack) + >= ((IEnergyContainerItem) item).getMaxEnergyStored(stack); + } + } + return true; + } + + private boolean isItemStackFullyRepaired(ItemStack stack) { + if (stack == null) { + return true; + } + Item item = stack.getItem(); + return !item.isRepairable() || item.getMaxDamage(stack) <= 0 || item.getDamage(stack) <= 0; + } + + private long doChargeItemStack(IElectricItem item, ItemStack stack) { + try { + double euDiff = item.getMaxCharge(stack) - ElectricItem.manager.getCharge(stack); + long remove = (long) Math.ceil( + ElectricItem.manager.charge(stack, Math.min(euDiff, getEUVar()), item.getTier(stack), true, false)); + setEUVar(getEUVar() - remove); + if (getEUVar() < 0) { + setEUVar(0); + } + return remove; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + return 0; + } + + private long doChargeItemStackRF(IEnergyContainerItem item, ItemStack stack) { + try { + long RF = Math + .min(item.getMaxEnergyStored(stack) - item.getEnergyStored(stack), getEUVar() * mEUtoRF / 100L); + RF = item.receiveEnergy(stack, RF > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) RF, false); + RF = RF * 100L / mEUtoRF; + setEUVar(getEUVar() - RF); + if (getEUVar() < 0) { + setEUVar(0); + } + return RF; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + return 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_infuser(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return structureCheck_EM("main", 1, 2, 0); + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + for (GT_MetaTileEntity_Hatch_InputBus inputBus : mInputBusses) { + if (inputBus instanceof GT_MetaTileEntity_Hatch_InputBus_ME) continue; + for (int i = 0; i < inputBus.getSizeInventory(); i++) { + ItemStack itemStackInBus = inputBus.getStackInSlot(i); + if (itemStackInBus == null) continue; + Item item = itemStackInBus.getItem(); + if (itemStackInBus.stackSize != 1 || item == null) continue; + if (isItemStackFullyCharged(itemStackInBus) && isItemStackFullyRepaired(itemStackInBus)) { + if (addOutput(itemStackInBus)) { + this.depleteInput(itemStackInBus); + } + } else { + mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; + return SimpleCheckRecipeResult.ofSuccess("charging"); + } + } + } + return SimpleCheckRecipeResult.ofFailure("no_chargeable_item"); + } + + @Override + public void outputAfterRecipe_EM() { + boolean itemProcessed = false; + startRecipeProcessing(); + for (GT_MetaTileEntity_Hatch_InputBus inputBus : mInputBusses) { + if (inputBus instanceof GT_MetaTileEntity_Hatch_InputBus_ME) continue; + for (int i = 0; i < inputBus.getSizeInventory(); i++) { + ItemStack itemStackInBus = inputBus.getStackInSlot(i); + if (itemStackInBus == null) continue; + Item item = itemStackInBus.getItem(); + if (itemStackInBus.stackSize != 1 || item == null) continue; + if (isItemStackFullyCharged(itemStackInBus) && isItemStackFullyRepaired(itemStackInBus)) { + itemProcessed = true; + if (addOutput(itemStackInBus)) { + this.depleteInput(itemStackInBus); + } + } else { + if (item.isRepairable()) { + FluidStack uum = getStoredFluids().stream() + .filter( + fluid -> Materials.UUMatter.getFluid(1) + .isFluidEqual(fluid)) + .findAny() + .orElse(null); + if (uum != null) { + int repairedDamage = Math + .min(item.getDamage(itemStackInBus), maxRepairedDamagePerOperation); + long euCost = repairedDamage * usedEuPerDurability; + if (getEUVar() >= euCost && depleteInput( + new FluidStack(Materials.UUMatter.mFluid, repairedDamage * usedUumPerDurability))) { + item.setDamage( + itemStackInBus, + Math.max(item.getDamage(itemStackInBus) - repairedDamage, 0)); + setEUVar(Math.min(getEUVar() - euCost, 0)); + } + } + } + if (item instanceof IElectricItem) { + doChargeItemStack((IElectricItem) item, itemStackInBus); + return; + } else if (TecTech.hasCOFH && item instanceof IEnergyContainerItem) { + doChargeItemStackRF((IEnergyContainerItem) item, itemStackInBus); + return; + } + } + } + } + endRecipeProcessing(); + if (!itemProcessed) { + afterRecipeCheckFailed(); + } + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + // Machine Type: Energy Infuser + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.infuser.name")) + // Controller block of the Energy Infuser + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.0")) + // Can be used to charge items (lossless) + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.1")) + // Can be fed with UU-Matter to repair items + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.2")) + // Stocking Bus is not supported + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.3")) + .addSeparator() + .beginStructureBlock(3, 5, 3, false) + // Controller: Front 3rd layer center + .addController(translateToLocal("tt.keyword.Structure.FrontCenter3rd")) + .addOtherStructurePart( + // High Power + translateToLocal("gt.blockcasingsTT.0.name"), + translateToLocal("gt.blockmachines.multimachine.em.infuser.Structure.HighPowerCasing")) + // Casing: Layer + // 1 and 5 + .addOtherStructurePart( + // Molecular Coil + translateToLocal("gt.blockcasingsTT.7.name"), + translateToLocal("gt.blockmachines.multimachine.em.infuser.Structure.MolecularCoil")) + // Layer 2 and 4 + .addOtherStructurePart( + // Molecular + translateToLocal("gt.blockcasingsTT.4.name"), + translateToLocal("gt.blockmachines.multimachine.em.infuser.Structure.MolecularCasing")) + // Casing: Layer + // 3 (hollow) + // Energy Hatch: Any High Power Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) + // Maintenance Hatch: Any High Power Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) + .toolTipFinisher(CommonValues.TEC_MARK_GENERAL); + return tt; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_whooum"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 2, 0, stackSize, hintsOnly); + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java new file mode 100644 index 0000000000..fce7913613 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java @@ -0,0 +1,823 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.github.technus.tectech.util.CommonValues.VN; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.recipe.RecipeMaps.scannerFakeRecipes; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; +import static mcp.mobius.waila.api.SpecialChars.GREEN; +import static mcp.mobius.waila.api.SpecialChars.RED; +import static mcp.mobius.waila.api.SpecialChars.RESET; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.recipe.TecTechRecipeMaps; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Holder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_AssemblyLineUtils; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.IGT_HatchAdder; +import gregtech.api.util.shutdown.ShutDownReason; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +/** + * Created by danie_000 on 17.12.2016. + */ +@SuppressWarnings("unchecked") +public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockBase_EM + implements ISurvivalConstructable { + + public static final String machine = "EM Machinery"; + public static final String crafter = "EM Crafting"; + // region variables + private final ArrayList eHolders = new ArrayList<>(); + private GT_Recipe.GT_Recipe_AssemblyLine tRecipe; + private static final String assembly = "Assembly line"; + private static final String scanner = "Scanner"; + private String machineType = assembly; + private ItemStack holdItem; + private long computationRemaining, computationRequired; + + private static LinkedHashMap lServerNames; + + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.research.hint.0"), // 1 - Classic/Data Hatches or + // Computer casing + translateToLocal("gt.blockmachines.multimachine.em.research.hint.1"), // 2 - Holder Hatch + }; + + private String clientLocale = "en_US"; + // endregion + + // region structure + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + "main", + transpose( + new String[][] { { " ", " A ", " A ", "AAA", "AAA", "AAA", "AAA" }, + { "AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB" }, + { " ", " C ", " ", " ", "ACA", "CCC", "DDD" }, + { " ", " E ", " ", " ", "A~A", "CCC", "DDD" }, + { " ", " C ", " ", " ", "ACA", "CCC", "DDD" }, + { "AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB" }, + { " ", " A ", " A ", "AAA", "AAA", "AAA", "AAA" } })) + .addElement('A', ofBlock(sBlockCasingsTT, 1)) + .addElement('B', ofBlock(sBlockCasingsTT, 2)) + .addElement('C', ofBlock(sBlockCasingsTT, 3)) + .addElement( + 'D', + buildHatchAdder(GT_MetaTileEntity_EM_research.class) + .atLeast(Energy.or(HatchElement.EnergyMulti), Maintenance, HatchElement.InputData) + .casingIndex(textureOffset + 1) + .dot(1) + .buildAndChain(ofBlock(sBlockCasingsTT, 1))) + .addElement('E', HolderHatchElement.INSTANCE.newAny(textureOffset + 3, 2)) + .build(); + // endregion + + public GT_MetaTileEntity_EM_research(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_research(String aName) { + super(aName); + } + + private void makeStick() { + mInventory[1].setTagCompound(new NBTTagCompound()); + mInventory[1].setStackDisplayName( + GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName()) + " Construction Data"); + GT_Utility.ItemNBT.setBookTitle( + mInventory[1], + GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName()) + " Construction Data"); + NBTTagCompound tNBT = mInventory[1].getTagCompound(); // code above makes it not null + + tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound())); + tNBT.setInteger("time", tRecipe.mDuration); + tNBT.setInteger("eu", tRecipe.mEUt); + for (int i = 0; i < tRecipe.mInputs.length; i++) { + tNBT.setTag(String.valueOf(i), tRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); + } + for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { + tNBT.setTag("f" + i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); + } + tNBT.setString( + "author", + EnumChatFormatting.BLUE + "Tec" + + EnumChatFormatting.DARK_BLUE + + "Tech" + + EnumChatFormatting.WHITE + + " Assembling Line Recipe Generator"); + NBTTagList tNBTList = new NBTTagList(); + tNBTList.appendTag( + new NBTTagString( + "Construction plan for " + tRecipe.mOutput.stackSize + + ' ' + + GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName()) + + ". Needed EU/t: " + + tRecipe.mEUt + + " Production time: " + + tRecipe.mDuration / 20)); + for (int i = 0; i < tRecipe.mInputs.length; i++) { + if (tRecipe.mInputs[i] != null) { + tNBTList.appendTag( + new NBTTagString( + "Input Bus " + (i + 1) + + ": " + + tRecipe.mInputs[i].stackSize + + ' ' + + GT_LanguageManager.getTranslation(tRecipe.mInputs[i].getDisplayName()))); + } + } + for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { + if (tRecipe.mFluidInputs[i] != null) { + tNBTList.appendTag( + new NBTTagString( + "Input Hatch " + (i + 1) + + ": " + + tRecipe.mFluidInputs[i].amount + + "L " + + GT_LanguageManager.getTranslation(tRecipe.mFluidInputs[i].getLocalizedName()))); + } + } + tNBT.setTag("pages", tNBTList); + } + + static { + try { + Class GT_Assemblyline_Server = Class.forName("gregtech.api.util.GT_Assemblyline_Server"); + lServerNames = (LinkedHashMap) GT_Assemblyline_Server.getField("lServerNames") + .get(null); + } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { + lServerNames = null; + } + } + + private void makeStick2() { + String s = tRecipe.mOutput.getDisplayName(); + if (getBaseMetaTileEntity().isServerSide()) { + if (lServerNames != null) { + s = lServerNames.get(tRecipe.mOutput.getDisplayName()); + if (s == null) { + s = tRecipe.mOutput.getDisplayName(); + } + } else { + s = tRecipe.mOutput.getDisplayName(); + } + } + mInventory[1].setTagCompound(new NBTTagCompound()); + mInventory[1].setStackDisplayName(s + " Construction Data"); + GT_Utility.ItemNBT.setBookTitle(mInventory[1], s + " Construction Data"); + + NBTTagCompound tNBT = mInventory[1].getTagCompound(); + + tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound())); + tNBT.setInteger("time", tRecipe.mDuration); + tNBT.setInteger("eu", tRecipe.mEUt); + for (int i = 0; i < tRecipe.mInputs.length; i++) { + tNBT.setTag("" + i, tRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); + } + for (int i = 0; i < tRecipe.mOreDictAlt.length; i++) { + if (tRecipe.mOreDictAlt[i] != null && tRecipe.mOreDictAlt[i].length > 0) { + tNBT.setInteger("a" + i, tRecipe.mOreDictAlt[i].length); + for (int j = 0; j < tRecipe.mOreDictAlt[i].length; j++) { + tNBT.setTag("a" + i + ":" + j, tRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound())); + } + } + } + for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { + tNBT.setTag("f" + i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); + } + tNBT.setString( + "author", + EnumChatFormatting.BLUE + "Tec" + + EnumChatFormatting.DARK_BLUE + + "Tech" + + EnumChatFormatting.WHITE + + ' ' + + machineType + + " Recipe Generator"); + NBTTagList tNBTList = new NBTTagList(); + s = tRecipe.mOutput.getDisplayName(); + if (getBaseMetaTileEntity().isServerSide()) { + s = lServerNames.get(tRecipe.mOutput.getDisplayName()); + if (s == null) { + s = tRecipe.mOutput.getDisplayName(); + } + } + tNBTList.appendTag( + new NBTTagString( + "Construction plan for " + tRecipe.mOutput.stackSize + + " " + + s + + ". Needed EU/t: " + + tRecipe.mEUt + + " Production time: " + + (tRecipe.mDuration / 20))); + for (int i = 0; i < tRecipe.mInputs.length; i++) { + if (tRecipe.mOreDictAlt[i] != null) { + int count = 0; + StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": "); + for (ItemStack tStack : tRecipe.mOreDictAlt[i]) { + if (tStack != null) { + s = tStack.getDisplayName(); + if (getBaseMetaTileEntity().isServerSide()) { + s = lServerNames.get(tStack.getDisplayName()); + if (s == null) s = tStack.getDisplayName(); + } + + tBuilder.append(count == 0 ? "" : "\nOr ") + .append(tStack.stackSize) + .append(" ") + .append(s); + count++; + } + } + if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString())); + } else if (tRecipe.mInputs[i] != null) { + s = tRecipe.mInputs[i].getDisplayName(); + if (getBaseMetaTileEntity().isServerSide()) { + s = lServerNames.get(tRecipe.mInputs[i].getDisplayName()); + if (s == null) { + s = tRecipe.mInputs[i].getDisplayName(); + } + } + tNBTList.appendTag( + new NBTTagString("Input Bus " + (i + 1) + ": " + tRecipe.mInputs[i].stackSize + " " + s)); + } + } + for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { + if (tRecipe.mFluidInputs[i] != null) { + s = tRecipe.mFluidInputs[i].getLocalizedName(); + if (getBaseMetaTileEntity().isServerSide()) { + s = lServerNames.get(tRecipe.mFluidInputs[i].getLocalizedName()); + if (s == null) { + s = tRecipe.mFluidInputs[i].getLocalizedName(); + } + } + tNBTList.appendTag( + new NBTTagString("Input Hatch " + (i + 1) + ": " + tRecipe.mFluidInputs[i].amount + "L " + s)); + } + } + tNBT.setTag("pages", tNBTList); + + mInventory[1].setTagCompound(tNBT); + } + + private boolean iterateRecipes() { + for (GT_Recipe ttRecipe : TecTechRecipeMaps.researchStationFakeRecipes.getAllRecipes()) { + if (GT_Utility.areStacksEqual(ttRecipe.mInputs[0], holdItem, true)) { + computationRequired = computationRemaining = ttRecipe.mDuration * 20L; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + eRequiredData = (short) (ttRecipe.mSpecialValue >>> 16); + eAmpereFlow = (short) (ttRecipe.mSpecialValue & 0xFFFF); + mEUt = Math.min(ttRecipe.mEUt, -ttRecipe.mEUt); + eHolders.get(0) + .getBaseMetaTileEntity() + .setActive(true); + return true; + } + } + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_research(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + for (GT_MetaTileEntity_Hatch_Holder rack : filterValidMTEs(eHolders)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + eHolders.clear(); + + if (!structureCheck_EM("main", 1, 3, 4)) { + return false; + } + + for (GT_MetaTileEntity_Hatch_Holder rack : filterValidMTEs(eHolders)) { + rack.getBaseMetaTileEntity() + .setActive(iGregTechTileEntity.isActive()); + } + return eHolders.size() == 1; + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + ItemStack controllerStack = getControllerSlot(); + tRecipe = null; + if (!eHolders.isEmpty() && eHolders.get(0).mInventory[0] != null) { + holdItem = eHolders.get(0).mInventory[0].copy(); + if (ItemList.Tool_DataStick.isStackEqual(controllerStack, false, true)) { + switch (machineType) { + case scanner -> { + for (GT_Recipe.GT_Recipe_AssemblyLine assRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { + if (GT_Utility.areStacksEqual(assRecipe.mResearchItem, holdItem, true)) { + boolean failScanner = true; + for (GT_Recipe scannerRecipe : scannerFakeRecipes.getAllRecipes()) { + if (GT_Utility.areStacksEqual(scannerRecipe.mInputs[0], holdItem, true)) { + failScanner = false; + break; + } + } + if (failScanner) { + return SimpleCheckRecipeResult.ofFailure("wrongRequirements"); + } + this.tRecipe = assRecipe; + // Scanner mode should consume item first + eHolders.get(0).mInventory[0] = null; + mInventory[1] = null; + // Set property + computationRequired = computationRemaining = assRecipe.mResearchTime; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + eRequiredData = 1; + eAmpereFlow = 1; + mEUt = -524288; + eHolders.get(0) + .getBaseMetaTileEntity() + .setActive(true); + return SimpleCheckRecipeResult.ofSuccess("scanning"); + } + } + } + case assembly -> { + for (GT_Recipe.GT_Recipe_AssemblyLine assRecipe : TecTechRecipeMaps.researchableALRecipeList) { + if (GT_Utility.areStacksEqual(assRecipe.mResearchItem, holdItem, true)) { + tRecipe = assRecipe; + // if found + if (iterateRecipes()) return SimpleCheckRecipeResult.ofSuccess("researching"); + } + } + } + } + } else { + return CheckRecipeResultRegistry.NO_DATA_STICKS; + } + } + holdItem = null; + computationRequired = computationRemaining = 0; + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + return SimpleCheckRecipeResult.ofFailure("no_research_item"); + } + + @Override + public void outputAfterRecipe_EM() { + if (!eHolders.isEmpty()) { + switch (machineType) { + case assembly -> { + if (tRecipe != null && ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)) { + eHolders.get(0) + .getBaseMetaTileEntity() + .setActive(false); + eHolders.get(0).mInventory[0] = null; + if (lServerNames == null) { + makeStick(); + } else { + try { + makeStick2(); + } catch (NoSuchFieldError e) { + makeStick(); + } + } + } + } + case scanner -> { + mInventory[1] = ItemList.Tool_DataStick.get(1); + GT_AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(mInventory[1], tRecipe); + eHolders.get(0) + .getBaseMetaTileEntity() + .setActive(false); + } + } + } + computationRequired = computationRemaining = 0; + tRecipe = null; + holdItem = null; + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.research.name")) // Machine Type: Research + // Station + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.0")) // Controller block of + // the Research Station + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.1")) // Used to scan Data + // Sticks for + // Assembling Line Recipes + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.2")) // Needs to be fed with + // computation to work + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.3")) // Does not consume the + // item until + // the Data Stick is written + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginStructureBlock(3, 7, 7, false) + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.holder.tier.09.name"), + translateToLocal("tt.keyword.Structure.CenterPillar"), + 2) // Object Holder: Center of the front pillar + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyComputerCasingBackMain"), + 1) // Optical Connector: Any Computer Casing on the backside of the main body + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingBackMain"), 1) // Energy Hatch: + // Any Computer + // Casing on the + // backside of + // the main body + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingBackMain"), 1) // Maintenance + // Hatch: + // Any + // Computer + // Casing on + // the + // backside + // of the + // main body + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + public String[] getInfoData() { + long storedEnergy = 0; + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + return new String[] { translateToLocalFormatted("tt.keyphrase.Energy_Hatches", clientLocale) + ":", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + (mEUt <= 0 ? translateToLocalFormatted("tt.keyphrase.Probably_uses", clientLocale) + ": " + : translateToLocalFormatted("tt.keyphrase.Probably_makes", clientLocale) + ": ") + + EnumChatFormatting.RED + + GT_Utility.formatNumbers(Math.abs(mEUt)) + + EnumChatFormatting.RESET + + " EU/t " + + translateToLocalFormatted("tt.keyword.at", clientLocale) + + " " + + EnumChatFormatting.RED + + GT_Utility.formatNumbers(eAmpereFlow) + + EnumChatFormatting.RESET + + " A", + translateToLocalFormatted("tt.keyphrase.Tier_Rating", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + VN[getMaxEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.GREEN + + VN[getMinEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " " + + translateToLocalFormatted("tt.keyphrase.Amp_Rating", clientLocale) + + ": " + + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(eMaxAmpereFlow) + + EnumChatFormatting.RESET + + " A", + translateToLocalFormatted("tt.keyword.Problems", clientLocale) + ": " + + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + + EnumChatFormatting.RESET + + " " + + translateToLocalFormatted("tt.keyword.Efficiency", clientLocale) + + ": " + + EnumChatFormatting.YELLOW + + mEfficiency / 100.0F + + EnumChatFormatting.RESET + + " %", + translateToLocalFormatted("tt.keyword.PowerPass", clientLocale) + ": " + + EnumChatFormatting.BLUE + + ePowerPass + + EnumChatFormatting.RESET + + " " + + translateToLocalFormatted("tt.keyword.SafeVoid", clientLocale) + + ": " + + EnumChatFormatting.BLUE + + eSafeVoid, + translateToLocalFormatted("tt.keyphrase.Computation_Available", clientLocale) + ": " + + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(eAvailableData) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(eRequiredData) + + EnumChatFormatting.RESET, + translateToLocalFormatted("tt.keyphrase.Computation_Remaining", clientLocale) + ":", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(computationRemaining / 20L) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(computationRequired / 20L) }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][3], + new TT_RenderedExtendedFacingTexture( + aActive ? GT_MetaTileEntity_MultiblockBase_EM.ScreenON + : GT_MetaTileEntity_MultiblockBase_EM.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][3] }; + } + + @Override + public void onRemoval() { + super.onRemoval(); + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + } + + @Override + protected void extraExplosions_EM() { + for (MetaTileEntity tTileEntity : eHolders) { + tTileEntity.getBaseMetaTileEntity() + .doExplosion(V[9]); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("eComputationRemaining", computationRemaining); + aNBT.setLong("eComputationRequired", computationRequired); + aNBT.setString("eMachineType", machineType); + if (holdItem != null) { + aNBT.setTag("eHold", holdItem.writeToNBT(new NBTTagCompound())); + } else { + aNBT.removeTag("eHold"); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + computationRemaining = aNBT.getLong("eComputationRemaining"); + computationRequired = aNBT.getLong("eComputationRequired"); + machineType = aNBT.hasKey("eMachineType") ? aNBT.getString("eMachineType") : assembly; + if (aNBT.hasKey("eHold")) { + holdItem = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("eHold")); + } else { + holdItem = null; + } + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + computationRequired = computationRemaining = 0; + tRecipe = null; + holdItem = null; + } + + @Override + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isServerSide()) { + if (computationRemaining > 0) { + tRecipe = null; + if (holdItem != null) { + if (ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)) { + for (GT_Recipe.GT_Recipe_AssemblyLine tRecipe : TecTechRecipeMaps.researchableALRecipeList) { + if (GT_Utility.areStacksEqual(tRecipe.mResearchItem, holdItem, true)) { + this.tRecipe = tRecipe; + break; + } + } + } + } + if (tRecipe == null) { + holdItem = null; + computationRequired = computationRemaining = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + } + } + } + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (computationRemaining <= 0) { + computationRemaining = 0; + mProgresstime = mMaxProgresstime; + return true; + } else { + computationRemaining -= eAvailableData; + mProgresstime = 1; + return super.onRunningTick(aStack); + } + } + + public final boolean addHolderToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Holder) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eHolders.add((GT_MetaTileEntity_Hatch_Holder) aMetaTileEntity); + } + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + super.onRightclick(aBaseMetaTileEntity, aPlayer); + + if (!aBaseMetaTileEntity.isClientSide() && aPlayer instanceof EntityPlayerMP) { + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + } else { + return true; + } + return true; + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + switch (machineType) { + case scanner -> machineType = assembly; + case assembly -> machineType = scanner; + } + aPlayer.addChatComponentMessage( + new ChatComponentTranslation( + "gt.blockmachines.multimachine.em.research.mode." + machineType.replace(" ", "_"))); + } + + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + tag.setBoolean("hasProblems", (getIdealStatus() - getRepairStatus()) > 0); + tag.setFloat("efficiency", mEfficiency / 100.0F); + tag.setBoolean("incompleteStructure", (getBaseMetaTileEntity().getErrorDisplayID() & 64) != 0); + tag.setString("machineType", machineType); + tag.setLong("computation", (computationRequired - computationRemaining) / 20L); + tag.setLong("computationRequired", computationRequired / 20L); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + final NBTTagCompound tag = accessor.getNBTData(); + + if (tag.getBoolean("incompleteStructure")) { + currentTip.add(RED + "** INCOMPLETE STRUCTURE **" + RESET); + } + currentTip.add( + (tag.getBoolean("hasProblems") ? (RED + "** HAS PROBLEMS **") : GREEN + "Running Fine") + RESET + + " Efficiency: " + + tag.getFloat("efficiency") + + "%"); + currentTip.add("Mode: " + tag.getString("machineType")); + currentTip.add( + String.format( + "Computation: %,d / %,d", + tag.getInteger("computation"), + tag.getInteger("computationRequired"))); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 3, 4, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 1, 3, 4, elementBudget, source, actor, false, true); + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + private enum HolderHatchElement implements IHatchElement { + + INSTANCE; + + @Override + public List> mteClasses() { + return Collections.singletonList(GT_MetaTileEntity_Hatch_Holder.class); + } + + @Override + public IGT_HatchAdder adder() { + return GT_MetaTileEntity_EM_research::addHolderToMachineList; + } + + @Override + public long count(GT_MetaTileEntity_EM_research t) { + return t.eHolders.size(); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java new file mode 100644 index 0000000000..b408e63af4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -0,0 +1,291 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_HIGH; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_LOW; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_NEUTRAL; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_OK; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_TOO_LOW; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_WRONG; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + "1 - Classic/Data Hatches or Computer casing", // 1 - Classic/Data Hatches or Computer casing + }; + + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + "main", + transpose(new String[][] { { "BBB", "BBB", "BBB" }, { "B~B", "BAB", "BBB" }, { "BBB", "BBB", "BBB" } })) + .addElement('A', ofBlock(sBlockCasingsTT, 3)) + .addElement( + 'B', + ofHatchAdderOptional( + GT_MetaTileEntity_EM_switch::addClassicToMachineList, + textureOffset + 1, + 1, + sBlockCasingsTT, + 1)) + .build(); + // endregion + + // region parameters + private static final INameFunction ROUTE_NAME = (base, + p) -> (p.parameterId() == 0 ? translateToLocal("tt.keyword.Destination") + " " + : translateToLocal("tt.keyword.Weight") + " ") + p.hatchId(); + private static final IStatusFunction WEI_STATUS = (base, p) -> { + double v = p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + if (v < 0) return STATUS_TOO_LOW; + if (v == 0) return STATUS_LOW; + if (Double.isInfinite(v)) return STATUS_HIGH; + return STATUS_OK; + }; + private static final IStatusFunction DST_STATUS = (base, p) -> { + if (base.weight[p.hatchId()].getStatus(false).isOk) { + double v = p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + v = (int) v; + if (v <= 0) return STATUS_TOO_LOW; + return STATUS_OK; + } + return STATUS_NEUTRAL; + }; + protected Parameters.Group.ParameterIn[] dst; + protected Parameters.Group.ParameterIn[] weight; + // endregion + + public GT_MetaTileEntity_EM_switch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_switch(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_switch(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return structureCheck_EM("main", 1, 1, 0); + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + short thingsActive = 0; + for (GT_MetaTileEntity_Hatch_InputData di : eInputData) { + if (di.q != null) { + thingsActive++; + } + } + + if (thingsActive > 0) { + thingsActive += eOutputData.size(); + mEUt = -(int) V[7]; + eAmpereFlow = 1 + (thingsActive >> 2); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return SimpleCheckRecipeResult.ofSuccess("routing"); + } + return SimpleCheckRecipeResult.ofFailure("no_routing"); + } + + @Override + public void outputAfterRecipe_EM() { + if (!eOutputData.isEmpty()) { + double total = 0; + double weight; + for (int i = 0; i < 10; i++) { // each param pair + weight = this.weight[i].get(); + if (weight > 0 && dst[i].get() >= 0) { + total += weight; // Total weighted div + } + } + + Vec3Impl pos = new Vec3Impl( + getBaseMetaTileEntity().getXCoord(), + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); + + QuantumDataPacket pack = new QuantumDataPacket(0L).unifyTraceWith(pos); + if (pack == null) { + return; + } + for (GT_MetaTileEntity_Hatch_InputData hatch : eInputData) { + if (hatch.q == null || hatch.q.contains(pos)) { + continue; + } + pack = pack.unifyPacketWith(hatch.q); + if (pack == null) { + return; + } + } + + long remaining = pack.getContent(); + + double dest; + for (int i = 0; i < 10; i++) { + dest = dst[i].get(); + weight = this.weight[i].get(); + if (weight > 0 && dest >= 0) { + int outIndex = (int) dest - 1; + if (outIndex < 0 || outIndex >= eOutputData.size()) { + continue; + } + GT_MetaTileEntity_Hatch_OutputData out = eOutputData.get(outIndex); + if (Double.isInfinite(total)) { + if (Double.isInfinite(weight)) { + out.q = new QuantumDataPacket(remaining).unifyTraceWith(pack); + break; + } + } else { + long part = (long) Math.floor(pack.getContent() * weight / total); + if (part > 0) { + remaining -= part; + if (remaining > 0) { + out.q = new QuantumDataPacket(part).unifyTraceWith(pack); + } else if (part + remaining > 0) { + out.q = new QuantumDataPacket(part + remaining).unifyTraceWith(pack); + break; + } else { + break; + } + } + } + } + } + } + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.switch.name")) // Machine Type: Network + // Switch With QoS + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.switch.desc.0")) // Controller block of the + // Network + // Switch With QoS + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.switch.desc.1")) // Used to route and + // distribute computation + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.switch.desc.2")) // Needs a Parametrizer to + // be configured + .addSeparator() + .beginStructureBlock(3, 3, 3, false) + .addController(translateToLocal("tt.keyword.Structure.FrontCenter")) // Controller: Front center + .addCasingInfoMin(translateToLocal("gt.blockcasingsTT.1.name"), 0, false) // 0x Computer Casing + // (minimum) + .addOtherStructurePart( + translateToLocal("gt.blockcasingsTT.3.name"), + translateToLocal("tt.keyword.Structure.Center")) // Advanced Computer Casing: Center + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Data Connector: Any Computer Casing + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.param.tier.05.name"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Parametrizer: Any Computer Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 1) // Energy Hatch: Any + // Computer Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 1) // Maintenance + // Hatch: Any + // Computer Casing + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][1], + new TT_RenderedExtendedFacingTexture( + aActive ? GT_MetaTileEntity_MultiblockBase_EM.ScreenON + : GT_MetaTileEntity_MultiblockBase_EM.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][1] }; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_hi_freq"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + @Override + protected void parametersInstantiation_EM() { + dst = new Parameters.Group.ParameterIn[10]; + weight = new Parameters.Group.ParameterIn[10]; + for (int i = 0; i < 10; i++) { + Parameters.Group hatch = parametrization.getGroup(i); + dst[i] = hatch.makeInParameter(0, i, ROUTE_NAME, DST_STATUS); + weight[i] = hatch.makeInParameter(1, 0, ROUTE_NAME, WEI_STATUS); + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java new file mode 100644 index 0000000000..d6ab5fa6eb --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java @@ -0,0 +1,221 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.HatchElement.DynamoMulti; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.HatchElement.EnergyMulti; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.GregTech_API.sBlockCasings1; +import static gregtech.api.enums.GT_HatchElement.Dynamo; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_MultiblockBase_EM + implements ISurvivalConstructable { + + @Override + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { + if (!hasMaintenanceChecks) turnOffMaintenance(); + if (!mMachine) { + aBaseMetaTileEntity.disableWorking(); + } + } + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.transformer.hint"), // 1 - Energy IO Hatches or High + // Power Casing + }; + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + "main", + new String[][] { { "111", "1~1", "111", }, { "111", "101", "111", }, { "111", "111", "111", }, }) + .addElement('0', ofBlock(sBlockCasings1, 15)) + .addElement( + '1', + buildHatchAdder(GT_MetaTileEntity_EM_transformer.class).atLeast(Energy, EnergyMulti, Dynamo, DynamoMulti) + .casingIndex(textureOffset) + .dot(1) + .buildAndChain(onElementPass(t -> t.casingCount++, ofBlock(sBlockCasingsTT, 0)))) + .build(); + private int casingCount = 0; + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + // endregion + + public GT_MetaTileEntity_EM_transformer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + turnOffMaintenance(); + eDismantleBoom = true; + } + + public GT_MetaTileEntity_EM_transformer(String aName) { + super(aName); + turnOffMaintenance(); + eDismantleBoom = true; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_transformer(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + casingCount = 0; + return structureCheck_EM("main", 1, 1, 0) && casingCount >= 5; + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + if (ePowerPass) { + mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; + } else { + mEfficiencyIncrease = 0; + mMaxProgresstime = 0; + } + eAmpereFlow = 0; + mEUt = 0; + return ePowerPass ? SimpleCheckRecipeResult.ofSuccess("routing") + : SimpleCheckRecipeResult.ofFailure("no_routing"); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.transformer.name")) // Machine Type: + // Transformer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.0")) // Controller block of + // the + // Active Transformer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.1")) // Can transform to + // and from any + // voltage + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.2")) // Only 0.004% power + // loss, HAYO! + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.3")) // Will explode if + // broken while + // running + .addSeparator() + .beginStructureBlock(3, 3, 3, false) + .addController(translateToLocal("tt.keyword.Structure.FrontCenter")) // Controller: Front center + .addCasingInfoMin(translateToLocal("gt.blockcasingsTT.0.name"), 5, false) // 5x High Power Casing + // (minimum) + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.SuperconductingCoilBlock"), + translateToLocal("tt.keyword.Structure.Center")) // SuperconductingCoilBlock: Center + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Energy Hatch: Any + // High Power Casing + .addDynamoHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Dynamo Hatch: Any + // High Power Casing + .toolTipFinisher(CommonValues.TEC_MARK_GENERAL); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][0], + new TT_RenderedExtendedFacingTexture( + aActive ? GT_MetaTileEntity_MultiblockBase_EM.ScreenON + : GT_MetaTileEntity_MultiblockBase_EM.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][0] }; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_noise"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + return true; + } + + @Override + public boolean doRandomMaintenanceDamage() { + return true; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((aTick & 31) == 31) { + ePowerPass = aBaseMetaTileEntity.isAllowedToWork(); + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java new file mode 100644 index 0000000000..4ae61796a5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -0,0 +1,348 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.loader.MainLoader.microwaving; +import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_OK; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_TOO_HIGH; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_TOO_LOW; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_WRONG; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTech_API.sBlockCasings4; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; +import static net.minecraft.util.AxisAlignedBB.getBoundingBox; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.HashSet; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +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.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.shutdown.ShutDownReason; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { + + // region variables + private boolean hasBeenPausedThisCycle = false; + // endregion + + // region structure + // use multi A energy inputs, use less power the longer it runs + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.tm.microwave.hint.0"), // 1 - Classic Hatches or Clean + // Stainless Steel + // Casing + translateToLocal("gt.blockmachines.multimachine.tm.microwave.hint.1"), // Also acts like a hopper so give it + // an Output + // Bus + }; + + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + "main", + transpose( + new String[][] { { "AAAAA", "A---A", "A---A", "A---A", "AAAAA" }, + { "AAAAA", "A---A", "A---A", "A---A", "AAAAA" }, { "AA~AA", "A---A", "A---A", "A---A", "AAAAA" }, + { "ABBBA", "BAAAB", "BAAAB", "BAAAB", "ABBBA" } })) + .addElement('A', ofBlock(sBlockCasings4, 1)) + .addElement( + 'B', + ofHatchAdderOptional(GT_MetaTileEntity_TM_microwave::addClassicToMachineList, 49, 1, sBlockCasings4, 1)) + .build(); + // endregion + + // region parameters + protected Parameters.Group.ParameterIn powerSetting, timerSetting; + protected Parameters.Group.ParameterOut timerValue, remainingTime; + private static final INameFunction POWER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgi.0"); // Power setting + private static final INameFunction TIMER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgi.1"); // Timer setting + + private static final INameFunction TIMER_VALUE_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.0"); // Timer value + private static final INameFunction TIMER_REMAINING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.1"); // Timer remaining + private static final IStatusFunction POWER_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), 300, 1000, 1000, Double.POSITIVE_INFINITY); + private static final IStatusFunction TIMER_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value <= 0) return STATUS_TOO_LOW; + if (value > 3000) return STATUS_TOO_HIGH; + return STATUS_OK; + }; + // endregion + + public GT_MetaTileEntity_TM_microwave(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_TM_microwave(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TM_microwave(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return structureCheck_EM("main", 2, 2, 0); + } + + @Override + @NotNull + public CheckRecipeResult checkProcessing_EM() { + hasBeenPausedThisCycle = false; + if ((int) powerSetting.get() < 300 || timerSetting.get() <= 0 || timerSetting.get() > 3000) { + return SimpleCheckRecipeResult.ofFailure("invalid_timer"); + } + if (remainingTime.get() <= 0) { + remainingTime.set(timerSetting.get()); + timerValue.set(0); + } + mEUt = -((int) powerSetting.get() >> 1); + eAmpereFlow = 1; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return SimpleCheckRecipeResult.ofSuccess("microwaving"); + } + + @Override + public void outputAfterRecipe_EM() { + if (hasBeenPausedThisCycle) { + return; // skip timer and actions if paused + } + timerValue.set(timerValue.get() + 1); + remainingTime.set(timerSetting.get() - timerValue.get()); + IGregTechTileEntity mte = getBaseMetaTileEntity(); + Vec3Impl xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 2)); + double xPos = mte.getXCoord() + 0.5f + xyzOffsets.get0(); + double yPos = mte.getYCoord() + 0.5f + xyzOffsets.get1(); + double zPos = mte.getZCoord() + 0.5f + xyzOffsets.get2(); + AxisAlignedBB aabb = getBoundingBox(-2, -2, -2, 2, 2, 2).offset(xPos, yPos, zPos); + xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -4, 0)); + Vec3Impl xyzExpansion = getExtendedFacing().getWorldOffset(new Vec3Impl(1, 0, 1)) + .abs(); + int power = (int) powerSetting.get(); + int damagingFactor = Math.min(power >> 6, 8) + Math.min(power >> 8, 24) + + Math.min(power >> 12, 48) + + (power >> 18); + + ArrayList itemsToOutput = new ArrayList<>(); + HashSet tickedStuff = new HashSet<>(); + + boolean inside = true; + do { + for (Object entity : mte.getWorld() + .getEntitiesWithinAABBExcludingEntity(null, aabb)) { + if (entity instanceof Entity) { + if (tickedStuff.add((Entity) entity)) { + if (inside && entity instanceof EntityItem) { + GT_Recipe tRecipe = RecipeMaps.microwaveRecipes.findRecipe( + mte, + null, + true, + 128, + null, + null, + new ItemStack[] { ((EntityItem) entity).getEntityItem() }); + if (tRecipe == null || tRecipe.mInputs[0].stackSize != 1) { + itemsToOutput.add(((EntityItem) entity).getEntityItem()); + } else { + ItemStack newStuff = tRecipe.getOutput(0) + .copy(); + newStuff.stackSize = ((EntityItem) entity).getEntityItem().stackSize; + itemsToOutput.add(newStuff); + } + ((EntityItem) entity).delayBeforeCanPickup = 2; + ((EntityItem) entity).setDead(); + } else if (entity instanceof EntityLivingBase) { + if (!GT_Utility.isWearingFullElectroHazmat((EntityLivingBase) entity)) { + ((EntityLivingBase) entity).attackEntityFrom(microwaving, damagingFactor); + } + } + } + } + } + aabb.offset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); + aabb = aabb.expand(xyzExpansion.get0() * 1.5, xyzExpansion.get1() * 1.5, xyzExpansion.get2() * 1.5); + inside = false; + damagingFactor >>= 1; + } while (damagingFactor > 0); + + mOutputItems = itemsToOutput.toArray(nullItem); + + if (remainingTime.get() <= 0) { + mte.getWorld() + .playSoundEffect(xPos, yPos, zPos, Reference.MODID + ":microwave_ding", 1, 1); + stopMachine(); + } + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.tm.microwave.name")) // Machine Type: + // Microwave Grinder + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.0")) // Controller block of + // the + // Microwave Grinder + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.1")) // Starts a timer when + // enabled + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.2")) // While the timer is + // running + // anything inside the machine + // will take damage + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.3")) // The machine will also + // collect + // any items inside of it + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.4")) // Can be configured + // with a Parametrizer + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.5")) // (Do not insert a + // Wither) + .addSeparator() + .beginStructureBlock(5, 4, 5, true) + .addController(translateToLocal("tt.keyword.Structure.FrontCenter")) // Controller: Front center + .addCasingInfoMin(translateToLocal("tt.keyword.Structure.StainlessSteelCasing"), 60, false) // 60x + // Stainless + // Steel + // Casing (minimum) + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), + 2) // Output Bus: Any outer casing on the bottom layer + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.param.tier.05.name"), + translateToLocal("tt.keyword.Structure.Optional") + " " + + translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), + 2) // Parametrizer: (optional) Any outer casing on the bottom layer + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), 1) // Energy Hatch: Any + // outer casing on + // the bottom layer + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), 1) // Maintenance + // Hatch: Any + // outer casing + // on the + // bottom layer + .toolTipFinisher(CommonValues.THETA_MOVEMENT); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][49], + new TT_RenderedExtendedFacingTexture( + aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE + : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) }; + } else if (side == facing.getOpposite()) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][49], + aActive ? Textures.BlockIcons.casingTexturePages[0][52] + : Textures.BlockIcons.casingTexturePages[0][53] }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][49] }; + } + + @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0 = parametrization.getGroup(0, true); + powerSetting = hatch_0.makeInParameter(0, 1000, POWER_SETTING_NAME, POWER_STATUS); + timerSetting = hatch_0.makeInParameter(1, 360, TIMER_SETTING_NAME, TIMER_STATUS); + + timerValue = hatch_0.makeOutParameter(0, 0, TIMER_VALUE_NAME, TIMER_STATUS); + remainingTime = hatch_0.makeOutParameter(1, 360, TIMER_REMAINING_NAME, TIMER_STATUS); + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + remainingTime.set(timerSetting.get()); + timerValue.set(0); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (eSafeVoid) { + hasBeenPausedThisCycle = true; + } + return hasBeenPausedThisCycle || super.onRunningTick(aStack); // consume eu and other resources if not paused + } + + // TODO Why is the basetype 1?? + @Override + public byte getTileEntityBaseType() { + return 1; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 2, 2, 0, stackSize, hintsOnly); + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java new file mode 100644 index 0000000000..d3fa0401e6 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -0,0 +1,1080 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.generateTeslaNodeMap; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.powerTeslaNodeMap; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsBA0; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.HatchElement.DynamoMulti; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.HatchElement.EnergyMulti; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.HatchElement.Param; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_HIGH; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_LOW; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_NEUTRAL; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_OK; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_TOO_HIGH; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_TOO_LOW; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_WRONG; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_WTF; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.Dynamo; +import static gregtech.api.enums.GT_HatchElement.Energy; +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 static gregtech.api.util.GT_Utility.filterValidMTEs; +import static java.lang.Math.min; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import javax.annotation.Nonnull; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.spark.RendererMessage; +import com.github.technus.tectech.mechanics.spark.ThaumSpark; +import com.github.technus.tectech.mechanics.tesla.ITeslaConnectable; +import com.github.technus.tectech.mechanics.tesla.ITeslaConnectableSimple; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Capacitor; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; +import com.google.common.collect.Multimap; +import com.google.common.collect.MultimapBuilder; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.StructureUtility; +import com.gtnewhorizon.structurelib.util.ItemStackPredicate; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.IGT_HatchAdder; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.common.blocks.GT_Item_Machines; + +public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM + implements ISurvivalConstructable, ITeslaConnectable { + + // Interface fields + private final Multimap teslaNodeMap = MultimapBuilder.treeKeys() + .linkedListValues() + .build(); + private final HashSet sparkList = new HashSet<>(); + private int sparkCount = 10; + + // region variables + private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TOWER; // Default + // is 32 + private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TRANSCEIVER; // Default + // is + // 16 + private static final int transferRadiusCoverUltimateFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_COVER; // Default + // is + // 16 + private static final int plasmaRangeMultiT1 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1; // Default + // is 2 + private static final int plasmaRangeMultiT2 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2; // Default + // is 4 + private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM; // Default is + // 100 + private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN; // Default + // is 50 + private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON; // Default is 50 + private static final boolean visualEffect = TecTech.configTecTech.TESLA_VISUAL_EFFECT; // Default is true + // Default is {1, 1, 1} + private static final int[] plasmaTierLoss = new int[] { TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0, + TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T1, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T2 }; + private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_LOSS_FACTOR_OVERDRIVE; // Default is + // 0.25F; + private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; // Default is false + + // Face icons + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + + private int mTier = 0; // Determines max voltage (LV to ZPM) + private int plasmaTier = 0; // 0 is None, 1 is Helium or Nitrogen, 2 is Radon (Does not match actual plasma tiers) + + private FluidStack[] mOutputFluidsQueue; // Used to buffer the fluid outputs, so the tesla takes a second to 'cool' + // any plasma it + // would output as a gas + + private final ArrayList eCapacitorHatches = new ArrayList<>(); // Capacitor + // hatches which + // determine the + // max voltage + // tier and count + // of amps + + private long energyCapacity = 0; // Total energy storage limited by capacitors + private long outputVoltageMax = 0; // Tesla voltage output limited by capacitors + private int vTier = -1; // Tesla voltage tier limited by capacitors + private long outputCurrentMax = 0; // Tesla current output limited by capacitors + + // outputVoltage and current after settings + private long outputVoltage; + private long outputCurrent; + + // Prevents unnecessary offset calculation, saving on lag + private byte oldRotation = -1; + private ForgeDirection oldOrientation = ForgeDirection.UNKNOWN; + // Location of the center of the sphere on top of the tower, used as the Thaumcraft lightning and origin + public Vec3Impl posTop = Vec3Impl.NULL_VECTOR; + // endregion + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.hint.0"), // 1 - Classic Hatches, Capacitor + // Hatches or Tesla + // Base Casing + translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.hint.1"), // 2 - ""Titanium frames"" + }; + + private static final IStructureDefinition STRUCTURE_DEFINITION = IStructureDefinition + .builder() + .addShape( + "main", + transpose( + new String[][] { { " ", " ", " BBB ", " BBB ", " BBB ", " ", " " }, + { " ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " " }, + { " ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " " }, + { " ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " " }, + { " ", " ", " BBB ", " BCB ", " BBB ", " ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " DDD ", " D D ", " D C D ", " D D ", " DDD ", " " }, + { " EE~EE ", "EAAAAAE", "EADDDAE", "EADADAE", "EADDDAE", "EAAAAAE", " EEEEE " } })) + .addElement('A', ofBlock(sBlockCasingsBA0, 6)) + .addElement('B', ofBlock(sBlockCasingsBA0, 7)) + .addElement('C', ofBlock(sBlockCasingsBA0, 8)) + .addElement( + 'D', + ofBlocksTiered( + (block, meta) -> block != sBlockCasingsBA0 ? null + : meta <= 5 ? Integer.valueOf(meta) : meta == 9 ? 6 : null, + IntStream.range(0, 7) + .map(tier -> tier == 6 ? 9 : tier) + .mapToObj(meta -> Pair.of(sBlockCasingsBA0, meta)) + .collect(Collectors.toList()), + -1, + (t, v) -> t.mTier = v, + t -> t.mTier)) + .addElement( + 'E', + buildHatchAdder(GT_MetaTileEntity_TM_teslaCoil.class) + .atLeast( + CapacitorHatchElement.INSTANCE, + EnergyMulti, + Energy, + DynamoMulti, + Dynamo, + InputHatch, + OutputHatch, + Param, + Maintenance) + .dot(1) + .casingIndex(textureOffset + 16 + 6) + .buildAndChain(sBlockCasingsBA0, 6)) + .addElement('F', new IStructureElement() { + + private IIcon[] mIcons; + + @Override + public boolean check(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z) { + TileEntity tBase = world.getTileEntity(x, y, z); + if (tBase instanceof BaseMetaPipeEntity tPipeBase) { + if (tPipeBase.isInvalidTileEntity()) return false; + return tPipeBase.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame; + } + return false; + } + + @Override + public boolean spawnHint(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z, + ItemStack trigger) { + if (mIcons == null) { + mIcons = new IIcon[6]; + Arrays + .fill(mIcons, Materials._NULL.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon()); + } + StructureLibAPI.hintParticleTinted(world, x, y, z, mIcons, Materials._NULL.mRGBa); + return true; + } + + @Override + public boolean placeBlock(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z, + ItemStack trigger) { + ItemStack tFrameStack = GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Titanium, 1); + if (!GT_Utility.isStackValid(tFrameStack) + || !(tFrameStack.getItem() instanceof ItemBlock tFrameStackItem)) return false; + return tFrameStackItem + .placeBlockAt(tFrameStack, null, world, x, y, z, 6, 0, 0, 0, Items.feather.getDamage(tFrameStack)); + } + + @Override + public PlaceResult survivalPlaceBlock(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z, + ItemStack trigger, IItemSource source, EntityPlayerMP actor, Consumer chatter) { + if (check(t, world, x, y, z)) return PlaceResult.SKIP; + ItemStack tFrameStack = source + .takeOne(s -> GT_Item_Machines.getMetaTileEntity(s) instanceof GT_MetaPipeEntity_Frame, true); + if (tFrameStack == null) return PlaceResult.REJECT; + return StructureUtility.survivalPlaceBlock( + tFrameStack, + ItemStackPredicate.NBTMode.IGNORE_KNOWN_INSIGNIFICANT_TAGS, + null, + false, + world, + x, + y, + z, + source, + actor, + chatter); + } + }) + .build(); + // endregion + + // region parameters + protected Parameters.Group.ParameterIn popogaSetting, histLowSetting, histHighSetting, transferRadiusTowerSetting, + transferRadiusTransceiverSetting, transferRadiusCoverUltimateSetting, outputVoltageSetting, + outputCurrentSetting, sortTimeMinSetting, overDriveSetting; + protected Parameters.Group.ParameterOut popogaDisplay, transferRadiusTowerDisplay, transferRadiusTransceiverDisplay, + transferRadiusCoverUltimateDisplay, outputVoltageDisplay, outputCurrentDisplay, energyCapacityDisplay, + energyStoredDisplay, energyFractionDisplay, sortTimeDisplay; + + private static final INameFunction HYSTERESIS_LOW_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.0"); // Hysteresis low setting + private static final INameFunction HYSTERESIS_HIGH_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.1"); // Hysteresis high setting + private static final INameFunction TRANSFER_RADIUS_TOWER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.2"); // Tesla Towers transfer radius + // setting + private static final INameFunction TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.3"); // Tesla Transceiver transfer + // radius setting + private static final INameFunction TRANSFER_RADIUS_COVER_ULTIMATE_SETTING_NAME = ( + base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.4"); // Tesla Ultimate Cover + // transfer radius + // setting + private static final INameFunction OUTPUT_VOLTAGE_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.5"); // Output voltage setting + private static final INameFunction OUTPUT_CURRENT_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.6"); // Output current setting + private static final INameFunction SCAN_TIME_MIN_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.7"); // Scan time Min setting + private static final INameFunction OVERDRIVE_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.8"); // Overdrive setting + private static final INameFunction POPOGA_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.9"); // Unused + + private static final INameFunction TRANSFER_RADIUS_TOWER_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.0"); // Tesla Towers transfer radius + // display + private static final INameFunction TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.1"); // Tesla Transceiver transfer + // radius display + private static final INameFunction TRANSFER_RADIUS_COVER_ULTIMATE_DISPLAY_NAME = ( + base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.2"); // Tesla Ultimate Cover + // transfer radius + // display + private static final INameFunction OUTPUT_VOLTAGE_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.3"); // Output voltage display + private static final INameFunction OUTPUT_CURRENT_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.4"); // Output current display + private static final INameFunction ENERGY_CAPACITY_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.5"); // Energy Capacity display + private static final INameFunction ENERGY_STORED_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.6"); // Energy Stored display + private static final INameFunction ENERGY_FRACTION_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.7"); // Energy Fraction display + private static final INameFunction SCAN_TIME_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.8"); // Scan time display + + private static final IStatusFunction HYSTERESIS_LOW_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) { + return STATUS_WRONG; + } + if (value <= 0.05) return STATUS_TOO_LOW; + if (value > base.histHighSetting.get()) return STATUS_TOO_HIGH; + return STATUS_OK; + }; + private static final IStatusFunction HYSTERESIS_HIGH_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + if (value <= base.histLowSetting.get()) return STATUS_TOO_LOW; + if (value > 0.95) return STATUS_TOO_HIGH; + return STATUS_OK; + }; + private static final IStatusFunction TRANSFER_RADIUS_TOWER_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value < 0) return STATUS_TOO_LOW; + if (value > transferRadiusTowerFromConfig) return STATUS_HIGH; + if (value < transferRadiusTowerFromConfig) return STATUS_LOW; + return STATUS_OK; + }; + private static final IStatusFunction TRANSFER_RADIUS_TRANSCEIVER_STATUS = (base, + p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value < 0) return STATUS_TOO_LOW; + if (value > transferRadiusTransceiverFromConfig) return STATUS_HIGH; + if (value < transferRadiusTransceiverFromConfig) return STATUS_LOW; + return STATUS_OK; + }; + private static final IStatusFunction TRANSFER_RADIUS_COVER_ULTIMATE_STATUS = (base, + p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value < 0) return STATUS_TOO_LOW; + if (value > transferRadiusCoverUltimateFromConfig) return STATUS_HIGH; + if (value < transferRadiusCoverUltimateFromConfig) return STATUS_LOW; + return STATUS_OK; + }; + private static final IStatusFunction OUTPUT_VOLTAGE_OR_CURRENT_STATUS = (base, + p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (long) value; + if (value == -1) return STATUS_OK; + if (value <= 0) return STATUS_TOO_LOW; + return STATUS_OK; + }; + private static final IStatusFunction SCAN_TIME_MIN_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value < 100) return STATUS_TOO_LOW; + if (value == 100) return STATUS_OK; + return STATUS_HIGH; + }; + private static final IStatusFunction OVERDRIVE_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value < 0) return STATUS_TOO_LOW; + if (value == 0) return STATUS_LOW; + return STATUS_HIGH; + }; + private static final IStatusFunction POPOGA_STATUS = (base, p) -> { + if (base.getBaseMetaTileEntity() + .getWorld() + .isThundering()) { + return STATUS_WTF; + } + return STATUS_NEUTRAL; + }; + private static final IStatusFunction SCAN_TIME_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value == 0) return STATUS_HIGH; + return STATUS_LOW; + }; + private static final IStatusFunction POWER_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (long) value; + if (value > 0) { + return STATUS_OK; + } else { + return STATUS_LOW; + } + }; + private static final IStatusFunction ENERGY_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + if (base.energyFractionDisplay.get() > base.histHighSetting.get()) { + return STATUS_HIGH; + } else if (base.energyFractionDisplay.get() < base.histLowSetting.get()) { + return STATUS_LOW; + } else { + return STATUS_OK; + } + }; + // endregion + + public GT_MetaTileEntity_TM_teslaCoil(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_TM_teslaCoil(String aName) { + super(aName); + } + + private float getRangeMulti(int mTier, int vTier) { + // By Default: + // Helium and Nitrogen Plasmas will double the range + // Radon will quadruple the range + int plasmaBoost; + switch (plasmaTier) { + case 2: + plasmaBoost = plasmaRangeMultiT2; + break; + case 1: + plasmaBoost = plasmaRangeMultiT1; + break; + default: + plasmaBoost = 1; + } + + // Over-tiered coils will add +25% range + if (vTier > mTier) { + return 1.25F * plasmaBoost; + } + return 1F * plasmaBoost; + } + + private void checkPlasmaBoost() { + // If there's fluid in the queue, try to output it + // That way it takes at least a second to 'process' the plasma + if (mOutputFluidsQueue != null) { + mOutputFluids = mOutputFluidsQueue; + mOutputFluidsQueue = null; + } + + for (GT_MetaTileEntity_Hatch_Input fluidHatch : mInputHatches) { + if (fluidHatch.mFluid != null) { + if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) + && fluidHatch.mFluid.amount >= heliumUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - heliumUse; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[] { Materials.Helium.getGas(heliumUse) }; + } + plasmaTier = 1; + return; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) + && fluidHatch.mFluid.amount >= nitrogenUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - nitrogenUse; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[] { Materials.Nitrogen.getGas(nitrogenUse) }; + } + plasmaTier = 1; + return; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) + && fluidHatch.mFluid.amount >= radonUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - radonUse; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[] { Materials.Radon.getGas(radonUse) }; + } + plasmaTier = 2; + return; + } + } + } + plasmaTier = 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TM_teslaCoil(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + for (GT_MetaTileEntity_Hatch_Capacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(false); + } + eCapacitorHatches.clear(); + + mTier = -1; + + if (structureCheck_EM("main", 3, 16, 0)) { + for (GT_MetaTileEntity_Hatch_Capacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(iGregTechTileEntity.isActive()); + } + + // Only recalculate offsets on orientation or rotation change + if (oldRotation != getExtendedFacing().ordinal() + || oldOrientation != iGregTechTileEntity.getFrontFacing()) { + oldRotation = (byte) getExtendedFacing().ordinal(); + oldOrientation = iGregTechTileEntity.getFrontFacing(); + + Vec3Impl posBMTE = new Vec3Impl( + getBaseMetaTileEntity().getXCoord(), + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); + + // Calculate coordinates of the middle bottom + posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, 0, 2)) + .add(posBMTE); + + // Calculate coordinates of the top sphere + posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -14, 2)) + .add(posBMTE); + } + // Generate node map + if (!getBaseMetaTileEntity().isClientSide()) { + teslaSimpleNodeSetAdd(this); + generateTeslaNodeMap(this); + } + return true; + } + return false; + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + checkPlasmaBoost(); + + if (!histHighSetting.getStatus(false).isOk || !histLowSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_hysteresis"); + if (!transferRadiusTowerSetting.getStatus(false).isOk || !transferRadiusTransceiverSetting.getStatus(false).isOk + || !transferRadiusCoverUltimateSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_transfer_radius"); + if (!outputVoltageSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_voltage_setting"); + if (!outputCurrentSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_current_setting"); + if (!sortTimeMinSetting.getStatus(false).isOk) return SimpleCheckRecipeResult.ofFailure("invalid_time_setting"); + if (!overDriveSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_overdrive_setting"); + + mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; + vTier = -1; + long[] capacitorData; + for (GT_MetaTileEntity_Hatch_Capacitor cap : filterValidMTEs(eCapacitorHatches)) { + if (cap.getCapacitors()[0] > vTier) { + vTier = (int) cap.getCapacitors()[0]; + } + } + + energyCapacity = 0; + outputCurrentMax = 0; + + if (vTier < 0) { + // Returning true to allow for 'passive running' + outputVoltageMax = 0; + return SimpleCheckRecipeResult.ofSuccess("routing"); + } else if (vTier > mTier && getEUVar() > 0) { + explodeMultiblock(); + } + + outputVoltageMax = V[vTier + 1]; + for (GT_MetaTileEntity_Hatch_Capacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(true); + capacitorData = cap.getCapacitors(); + if (capacitorData[0] < vTier) { + if (getEUVar() > 0 && capacitorData[0] != 0) { + cap.getBaseMetaTileEntity() + .setToFire(); + } + eCapacitorHatches.remove(cap); + } else { + outputCurrentMax += capacitorData[1]; + energyCapacity += capacitorData[2]; + } + } + return SimpleCheckRecipeResult.ofSuccess("routing"); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.name")) // Machine Type: Tesla + // Tower + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.0")) // Controller block of + // the Tesla Tower + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.1")) // Used to transmit + // power to Tesla + // Coil Covers and Tesla + // Transceivers + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.2")) // Can be fed with + // Helium/Nitrogen/Radon Plasma to + // increase the range + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.3")) // Transmitted voltage + // depends on + // the used Tesla Capacitor tier + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.4")) // Primary Tesla + // Windings need to + // be at least the same tier as + // the Tesla Capacitor + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginStructureBlock(7, 17, 7, false) + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.capacitor.tier.03.name"), + translateToLocal("tt.keyword.Structure.AnyTeslaBaseCasingOuter"), + 1) // Capacitor Hatch: Any outer Tesla Base Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyTeslaBaseCasingOuter"), 1) // Energy Hatch: + // Any outer Tesla + // Base Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyTeslaBaseCasingOuter"), 1) // Maintenance + // Hatch: Any + // outer Tesla + // Base Casing + .toolTipFinisher(CommonValues.THETA_MOVEMENT); + return tt; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_TOWER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_TOWER_ACTIVE"); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][16 + 6], + new TT_RenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][16 + 6] }; + } + + @Override + public void onRemoval() { + super.onRemoval(); + if (!getBaseMetaTileEntity().isClientSide()) { + teslaSimpleNodeSetRemove(this); + for (GT_MetaTileEntity_Hatch_Capacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(false); + } + } + } + + @Override + public void onUnload() { + if (!getBaseMetaTileEntity().isClientSide()) { + teslaSimpleNodeSetRemove(this); + } + } + + @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0 = parametrization.getGroup(0, true); + Parameters.Group hatch_1 = parametrization.getGroup(1, true); + Parameters.Group hatch_2 = parametrization.getGroup(2, true); + Parameters.Group hatch_3 = parametrization.getGroup(3, true); + Parameters.Group hatch_4 = parametrization.getGroup(4, true); + Parameters.Group hatch_5 = parametrization.getGroup(5, true); + Parameters.Group hatch_6 = parametrization.getGroup(6, true); + Parameters.Group hatch_7 = parametrization.getGroup(7, true); + Parameters.Group hatch_8 = parametrization.getGroup(8, true); + Parameters.Group hatch_9 = parametrization.getGroup(9, true); + + histLowSetting = hatch_0.makeInParameter(0, 0.25, HYSTERESIS_LOW_SETTING_NAME, HYSTERESIS_LOW_STATUS); + popogaSetting = hatch_0.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + histHighSetting = hatch_1.makeInParameter(0, 0.75, HYSTERESIS_HIGH_SETTING_NAME, HYSTERESIS_HIGH_STATUS); + popogaSetting = hatch_1.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTowerSetting = hatch_2.makeInParameter( + 0, + transferRadiusTowerFromConfig, + TRANSFER_RADIUS_TOWER_SETTING_NAME, + TRANSFER_RADIUS_TOWER_STATUS); + popogaSetting = hatch_2.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTransceiverSetting = hatch_3.makeInParameter( + 0, + transferRadiusTransceiverFromConfig, + TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME, + TRANSFER_RADIUS_TRANSCEIVER_STATUS); + transferRadiusCoverUltimateSetting = hatch_3.makeInParameter( + 1, + transferRadiusCoverUltimateFromConfig, + TRANSFER_RADIUS_COVER_ULTIMATE_SETTING_NAME, + TRANSFER_RADIUS_COVER_ULTIMATE_STATUS); + outputVoltageSetting = hatch_4 + .makeInParameter(0, -1, OUTPUT_VOLTAGE_SETTING_NAME, OUTPUT_VOLTAGE_OR_CURRENT_STATUS); + popogaSetting = hatch_4.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + outputCurrentSetting = hatch_5 + .makeInParameter(0, -1, OUTPUT_CURRENT_SETTING_NAME, OUTPUT_VOLTAGE_OR_CURRENT_STATUS); + popogaSetting = hatch_5.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_6.makeInParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_6.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + sortTimeMinSetting = hatch_7.makeInParameter(0, 100, SCAN_TIME_MIN_SETTING_NAME, SCAN_TIME_MIN_STATUS); + popogaSetting = hatch_7.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + overDriveSetting = hatch_8.makeInParameter(0, 0, OVERDRIVE_SETTING_NAME, OVERDRIVE_STATUS); + popogaSetting = hatch_8.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_9.makeInParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_9.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + + popogaDisplay = hatch_0.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_0.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_1.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_1.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTowerDisplay = hatch_2 + .makeOutParameter(0, 0, TRANSFER_RADIUS_TOWER_DISPLAY_NAME, TRANSFER_RADIUS_TOWER_STATUS); + popogaDisplay = hatch_2.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTransceiverDisplay = hatch_3 + .makeOutParameter(0, 0, TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME, TRANSFER_RADIUS_TRANSCEIVER_STATUS); + transferRadiusCoverUltimateDisplay = hatch_3 + .makeOutParameter(1, 0, TRANSFER_RADIUS_COVER_ULTIMATE_DISPLAY_NAME, TRANSFER_RADIUS_COVER_ULTIMATE_STATUS); + outputVoltageDisplay = hatch_4.makeOutParameter(0, 0, OUTPUT_VOLTAGE_DISPLAY_NAME, POWER_STATUS); + popogaDisplay = hatch_4.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + outputCurrentDisplay = hatch_5.makeOutParameter(0, 0, OUTPUT_CURRENT_DISPLAY_NAME, POWER_STATUS); + energyCapacityDisplay = hatch_5.makeOutParameter(1, 0, ENERGY_CAPACITY_DISPLAY_NAME, ENERGY_STATUS); + energyStoredDisplay = hatch_6.makeOutParameter(0, 0, ENERGY_STORED_DISPLAY_NAME, ENERGY_STATUS); + energyFractionDisplay = hatch_6.makeOutParameter(1, 0, ENERGY_FRACTION_DISPLAY_NAME, ENERGY_STATUS); + sortTimeDisplay = hatch_7.makeOutParameter(0, 0, SCAN_TIME_DISPLAY_NAME, SCAN_TIME_STATUS); + popogaDisplay = hatch_7.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_8.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_8.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_9.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_9.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("eEnergyCapacity", energyCapacity); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + energyCapacity = aNBT.getLong("eEnergyCapacity"); + teslaSimpleNodeSetAdd(this); + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { + cap.getBaseMetaTileEntity() + .setActive(false); + } + + ePowerPass = false; + setEUVar(0); + energyStoredDisplay.set(0); + energyFractionDisplay.set(0); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + // Hysteresis based ePowerPass setting + float energyFrac = (float) getEUVar() / energyCapacity; + + energyCapacityDisplay.set(energyCapacity); + energyStoredDisplay.set(getEUVar()); + energyFractionDisplay.set(energyFrac); + + if (!ePowerPass && energyFrac > histHighSetting.get()) { + ePowerPass = true; + } else if (ePowerPass && energyFrac < histLowSetting.get()) { + ePowerPass = false; + } + + // Power Limit Settings + if (outputVoltageSetting.get() > 0) { + outputVoltage = min(outputVoltageMax, (long) outputVoltageSetting.get()); + } else { + outputVoltage = outputVoltageMax; + } + outputVoltageDisplay.set(outputVoltage); + + if (outputCurrentSetting.get() > 0) { + outputCurrent = min(outputCurrentMax, (long) outputCurrentSetting.get()); + } else { + outputCurrent = outputCurrentMax; + } + + // Range calculation and display + int transferRadiusTower = getTeslaTransmissionRange(); + transferRadiusTowerDisplay.set(transferRadiusTower); + transferRadiusTransceiverDisplay.set(transferRadiusTower * 2); + transferRadiusCoverUltimateDisplay.set(transferRadiusTower); + + // Power transfer + outputCurrentDisplay.set(powerTeslaNodeMap(this)); + + // TODO Encapsulate the spark sender + sparkCount--; + if (sparkCount == 0 && visualEffect) { + IGregTechTileEntity mte = getBaseMetaTileEntity(); + sparkCount = 10; + if (!sparkList.isEmpty()) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new RendererMessage.RendererData(sparkList), + mte.getWorld().provider.dimensionId, + mte.getXCoord(), + mte.getYCoord(), + mte.getZCoord(), + 256); + sparkList.clear(); + } + } + return true; + } + + @Override + public long maxEUStore() { + // Setting the power here so that the tower looses all it's charge once disabled + // This also stops it from exploding + return getBaseMetaTileEntity().isActive() ? energyCapacity * 2 : 0; + } + + @Override + public long getEUVar() { + // Same reason as maxEUStore, set to 1 instead of zero so it doesn't drain constantly + return getBaseMetaTileEntity().isActive() ? super.getEUVar() : 1; + } + + private boolean addCapacitorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Capacitor) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eCapacitorHatches.add((GT_MetaTileEntity_Hatch_Capacitor) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + return false; + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 3, 16, 0, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 3, 16, 0, elementBudget, source, actor, false, true); + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public byte getTeslaReceptionCapability() { + return 0; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 0; + } + + @Override + public Multimap getTeslaNodeMap() { + return teslaNodeMap; + } + + @Override + public HashSet getSparkList() { + return sparkList; + } + + @Override + public byte getTeslaTransmissionCapability() { + return 1; + } + + @Override + public int getTeslaTransmissionRange() { + return (int) (transferRadiusTowerSetting.get() * getRangeMulti(mTier, vTier)); + } + + @Override + public boolean isOverdriveEnabled() { + return overDriveSetting.get() > 0; + } + + @Override + public int getTeslaEnergyLossPerBlock() { + return plasmaTierLoss[plasmaTier]; + } + + @Override + public float getTeslaOverdriveLossCoefficient() { + return overDriveLoss; + } + + @Override + public long getTeslaOutputVoltage() { + return outputVoltage; + } + + @Override + public long getTeslaOutputCurrent() { + return outputCurrent; + } + + @Override + public boolean teslaDrainEnergy(long teslaVoltageDrained) { + if (getEUVar() < teslaVoltageDrained) { + return false; + } + + setEUVar(getEUVar() - teslaVoltageDrained); + return true; + } + + @Override + public boolean isTeslaReadyToReceive() { + return !this.ePowerPass; + } + + @Override + public long getTeslaStoredEnergy() { + return getEUVar(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return posTop; + } + + @Override + public Integer getTeslaDimension() { + return this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + if (this.getEUVar() + teslaVoltageInjected <= (this.maxEUStore() / 2)) { + this.getBaseMetaTileEntity() + .increaseStoredEnergyUnits(teslaVoltageInjected, true); + return true; + } + return false; + } + + private enum CapacitorHatchElement implements IHatchElement { + + INSTANCE; + + @Override + public List> mteClasses() { + return Collections.singletonList(GT_MetaTileEntity_Hatch_Capacitor.class); + } + + @Override + public IGT_HatchAdder adder() { + return GT_MetaTileEntity_TM_teslaCoil::addCapacitorToMachineList; + } + + @Override + public long count(GT_MetaTileEntity_TM_teslaCoil gt_metaTileEntity_tm_teslaCoil) { + return gt_metaTileEntity_tm_teslaCoil.eCapacitorHatches.size(); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java new file mode 100644 index 0000000000..20a9582521 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -0,0 +1,2823 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.loader.TecTechConfig.POWERLESS_MODE; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static com.github.technus.tectech.util.CommonValues.MULTI_CHECK_AT; +import static com.github.technus.tectech.util.CommonValues.RECIPE_AT; +import static com.github.technus.tectech.util.CommonValues.TEC_MARK_GENERAL; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.github.technus.tectech.util.CommonValues.VN; +import static com.github.technus.tectech.util.TT_Utility.getTier; +import static gregtech.api.enums.GT_HatchElement.InputBus; +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.enums.GT_HatchElement.OutputBus; +import static gregtech.api.enums.GT_HatchElement.OutputHatch; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GT_Utility.filterValidMTEs; +import static java.lang.Math.min; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; +import org.lwjgl.opengl.GL11; + +import com.github.technus.tectech.Reference; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DataConnector; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Uncertainty; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.google.common.collect.Iterables; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.IAlignment; +import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.util.Vec3Impl; +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IBindPlayerInventoryUI; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GT_HatchElementBuilder; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.IGT_HatchAdder; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gregtech.api.util.shutdown.SimpleShutDownReason; +import gregtech.common.GT_Pollution; +import gregtech.common.tileentities.machines.IDualInputHatch; + +/** + * Created by danie_000 on 27.10.2016. + */ +public abstract class GT_MetaTileEntity_MultiblockBase_EM + extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase + implements IAlignment, IBindPlayerInventoryUI { + // region Client side variables (static - one per class) + + // Front icon holders - static so it is default one for my blocks + // just add new static ones in your class and and override getTexture + protected static Textures.BlockIcons.CustomIcon ScreenOFF; + protected static Textures.BlockIcons.CustomIcon ScreenON; + + /** Base ID for the LED window popup. LED 1 I0 will have ID 100, LED 1 I1 101... */ + protected static int LED_WINDOW_BASE_ID = 100; + + // Sound resource - same as with screen but override getActivitySound + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_lo_freq"); + + @SideOnly(Side.CLIENT) + private SoundLoop activitySoundLoop; + // endregion + + // region HATCHES ARRAYS - they hold info about found hatches, add hatches to them... (auto structure magic does it + // tho) + + // HATCHES!!!, should be added and removed in check machine + protected ArrayList eParamHatches = new ArrayList<>(); + protected ArrayList eUncertainHatches = new ArrayList<>(); + // multi amp hatches in/out + protected ArrayList eEnergyMulti = new ArrayList<>(); + protected ArrayList eDynamoMulti = new ArrayList<>(); + // data hatches + protected ArrayList eInputData = new ArrayList<>(); + protected ArrayList eOutputData = new ArrayList<>(); + + // endregion + + // region parameters + public final Parameters parametrization; + // endregion + + // region Control variables + + // should explode on dismatle?, set it in constructor, if true machine will explode if invalidated structure while + // active + protected boolean eDismantleBoom = false; + + // what is the amount of A required + public long eAmpereFlow = 1; // analogue of EU/t but for amperes used (so eu/t is actually eu*A/t) USE ONLY POSITIVE + // NUMBERS! + + // set to what you need it to be in check recipe + // data required to operate + protected long eRequiredData = 0; + + // Counter for the computation timeout. Will be initialized one to the max time and then only decreased. + protected int eComputationTimeout = MAX_COMPUTATION_TIMEOUT; + + // Max timeout of computation in ticks + protected static int MAX_COMPUTATION_TIMEOUT = 100; + + // are parameters correct - change in check recipe/output/update params etc. (maintenance status boolean) + protected boolean eParameters = true; + + // what type of certainty inconvenience is used - can be used as in Computer - more info in uncertainty hatch + protected byte eCertainMode = 0, eCertainStatus = 0; + + // minimal repair status to make the machine even usable (how much unfixed fixed stuff is needed) + // if u need to force some things to be fixed - u might need to override doRandomMaintenanceDamage + protected byte minRepairStatus = 3; + + // whether there is a maintenance hatch in the multi and whether checks are necessary (for now only used in a + // transformer) + protected boolean hasMaintenanceChecks = true; + + // is power pass cover present + public boolean ePowerPassCover = false; + + // functionality toggles - changed by buttons in gui also + public boolean ePowerPass = false, eSafeVoid = false; + + // endregion + + // region READ ONLY unless u really need to change it + + // max amperes machine can take in after computing it to the lowest tier (exchange packets to min tier count) + protected long eMaxAmpereFlow = 0, eMaxAmpereGen = 0; + + // What is the max and minimal tier of eu hatches installed + private long maxEUinputMin = 0, maxEUinputMax = 0, maxEUoutputMin = 0, maxEUoutputMax = 0; + + // read only unless you are making computation generator - read computer class + protected long eAvailableData = 0; // data being available + + // just some info - private so hidden + private boolean explodedThisTick = false; + + /** Flag if the new long power variable should be used */ + protected boolean useLongPower = false; + + // Locale-aware formatting of numbers. + protected static NumberFormatMUI numberFormat; + static { + numberFormat = new NumberFormatMUI(); + numberFormat.setMaximumFractionDigits(8); + } + + // endregion + + protected GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + parametrization = new Parameters(this); + parametersInstantiation_EM(); + parametrization.setToDefaults(true, true); + } + + protected GT_MetaTileEntity_MultiblockBase_EM(String aName) { + super(aName); + parametrization = new Parameters(this); + parametersInstantiation_EM(); + parametrization.setToDefaults(true, true); + } + + // region SUPER STRUCT + + /** + * Gets structure + * + * @return STATIC INSTANCE OF STRUCTURE + */ + public abstract IStructureDefinition getStructure_EM(); + + @SuppressWarnings("unchecked") + private IStructureDefinition getStructure_EM_Internal() { + return (IStructureDefinition) getStructure_EM(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return getStructure_EM_Internal(); + } + + public final boolean structureCheck_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + return getStructure_EM_Internal().check( + this, + piece, + baseMetaTileEntity.getWorld(), + getExtendedFacing(), + baseMetaTileEntity.getXCoord(), + baseMetaTileEntity.getYCoord(), + baseMetaTileEntity.getZCoord(), + horizontalOffset, + verticalOffset, + depthOffset, + !mMachine); + } + + public final boolean structureBuild_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset, + ItemStack trigger, boolean hintsOnly) { + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + return getStructure_EM_Internal().buildOrHints( + this, + trigger, + piece, + baseMetaTileEntity.getWorld(), + getExtendedFacing(), + baseMetaTileEntity.getXCoord(), + baseMetaTileEntity.getYCoord(), + baseMetaTileEntity.getZCoord(), + horizontalOffset, + verticalOffset, + depthOffset, + hintsOnly); + } + // endregion + + // region METHODS TO OVERRIDE - general functionality, recipe check, output + + /** + * Check structure here, also add hatches + * + * @param iGregTechTileEntity - the tile entity + * @param itemStack - what is in the controller input slot + * @return is structure valid + */ + protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + + /** + * Checks Recipes (when all machine is complete and can work) + *

+ * can get/set Parameters here also + * + * @deprecated Use {@link #createProcessingLogic()} ()} or {@link #checkProcessing_EM()} + * + * @param itemStack item in the controller + * @return is recipe is valid + */ + @Deprecated + public boolean checkRecipe_EM(ItemStack itemStack) { + return false; + } + + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + if (processingLogic == null) { + return checkRecipe_EM(getControllerSlot()) ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.NO_RECIPE; + } + return super.checkProcessing(); + } + + /** + * Put EM stuff from outputEM into EM output hatches here or do other stuff - it is basically on recipe succeded + *

+ * based on "machine state" do output, this must move to outputEM to EM output hatches and can also modify output + * items/fluids/EM, remaining EM is NOT overflowed. (Well it can be overflowed if machine didn't finished, + * soft-hammered/disabled/not enough EU) Setting available data processing + */ + public void outputAfterRecipe_EM() {} + // endregion + + // region tooltip and scanner result + + public ArrayList getFullLedDescriptionIn(int hatchNo, int paramID) { + ArrayList list = new ArrayList<>(); + list.add( + EnumChatFormatting.WHITE + "ID: " + + EnumChatFormatting.AQUA + + hatchNo + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + paramID + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + "I " + + parametrization.getStatusIn(hatchNo, paramID).name.get()); + list.add( + EnumChatFormatting.WHITE + "Value: " + + EnumChatFormatting.AQUA + + numberFormat.format(parametrization.getIn(hatchNo, paramID))); + try { + list.add(parametrization.groups[hatchNo].parameterIn[paramID].getBrief()); + } catch (NullPointerException | IndexOutOfBoundsException e) { + list.add("Unused"); + } + return list; + } + + public ArrayList getFullLedDescriptionOut(int hatchNo, int paramID) { + ArrayList list = new ArrayList<>(); + list.add( + EnumChatFormatting.WHITE + "ID: " + + EnumChatFormatting.AQUA + + hatchNo + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + paramID + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + "O " + + parametrization.getStatusOut(hatchNo, paramID).name.get()); + list.add( + EnumChatFormatting.WHITE + "Value: " + + EnumChatFormatting.AQUA + + numberFormat.format(parametrization.getOut(hatchNo, paramID))); + try { + list.add(parametrization.groups[hatchNo].parameterOut[paramID].getBrief()); + } catch (NullPointerException | IndexOutOfBoundsException e) { + list.add("Unused"); + } + return list; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addInfo("Nothing special just override me") + .toolTipFinisher(TEC_MARK_GENERAL); + return tt; + } + + /** + * scanner gives it + */ + @Override + public String[] getInfoData() { // TODO Do it + long storedEnergy = 0; + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + return new String[] { "Progress:", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime / 20) + + EnumChatFormatting.RESET + + " s / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime / 20) + + EnumChatFormatting.RESET + + " s", + "Energy Hatches:", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + (getPowerFlow() * eAmpereFlow <= 0 ? "Probably uses: " : "Probably makes: ") + EnumChatFormatting.RED + + GT_Utility.formatNumbers(Math.abs(getPowerFlow())) + + EnumChatFormatting.RESET + + " EU/t at " + + EnumChatFormatting.RED + + GT_Utility.formatNumbers(eAmpereFlow) + + EnumChatFormatting.RESET + + " A", + "Tier Rating: " + EnumChatFormatting.YELLOW + + VN[getMaxEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.GREEN + + VN[getMinEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " Amp Rating: " + + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(eMaxAmpereFlow) + + EnumChatFormatting.RESET + + " A", + "Problems: " + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + + EnumChatFormatting.RESET + + " Efficiency: " + + EnumChatFormatting.YELLOW + + mEfficiency / 100.0F + + EnumChatFormatting.RESET + + " %", + "PowerPass: " + EnumChatFormatting.BLUE + + ePowerPass + + EnumChatFormatting.RESET + + " SafeVoid: " + + EnumChatFormatting.BLUE + + eSafeVoid, + "Computation: " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(eAvailableData) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(eRequiredData) + + EnumChatFormatting.RESET }; + } + + /** + * should it work with scanner? HELL YES + */ + @Override + public boolean isGivingInformation() { + return true; + } + + // endregion + + // region GUI/SOUND/RENDER + + /** + * add more textures + */ + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + /** + * actually use textures + */ + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][4], + new TT_RenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][4] }; + } + + /** + * should return your activity sound + */ + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + /** + * plays the sounds auto magically + */ + @SideOnly(Side.CLIENT) + protected void soundMagic(ResourceLocation activitySound) { + if (getBaseMetaTileEntity().isActive()) { + if (activitySoundLoop == null) { + activitySoundLoop = new SoundLoop(activitySound, getBaseMetaTileEntity(), false, true); + Minecraft.getMinecraft() + .getSoundHandler() + .playSound(activitySoundLoop); + } + } else { + if (activitySoundLoop != null) { + activitySoundLoop = null; + } + } + } + + // endregion + + // region Methods to maybe override (if u implement certain stuff) + + /** + * is the thing inside controller a valid item to make the machine work + */ + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + /** + * how much damage to apply to thing in controller - not sure how it does it + */ + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + /** + * called when removing from map - not when unloading? //todo check + */ + @Override + public void onRemoval() { + try { + if (ePowerPass && getEUVar() > V[3] + || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) { + explodeMultiblock(); + } + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + + /** + * prevents spontaneous explosions when the chunks unloading would cause them should cover 3 chunks radius + */ + protected boolean areChunksAroundLoaded_EM() { + if (this.isValid() && getBaseMetaTileEntity().isServerSide()) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + return base.getWorld() + .doChunksNearChunkExist(base.getXCoord(), base.getYCoord(), base.getZCoord(), 3); + // todo check if it is actually checking if chunks are loaded + } else { + return false; + } + } + + /** + * instantiate parameters in CONSTRUCTOR! CALLED ONCE on creation, don't call it in your classes + */ + protected void parametersInstantiation_EM() {} + + /** + * It is automatically called OFTEN update status of parameters in guis (and "machine state" if u wish) Called + * before check recipe, before outputting, and every second the machine is complete + *

+ * good place to update parameter statuses, default implementation handles it well + * + * @param machineBusy is machine doing stuff + */ + protected void parametersStatusesWrite_EM(boolean machineBusy) { // todo unimplement? + if (!machineBusy) { + for (Parameters.Group.ParameterIn parameterIn : parametrization.parameterInArrayList) { + if (parameterIn != null) { + parameterIn.updateStatus(); + } + } + } else { + for (Parameters.Group hatch : parametrization.groups) { + if (hatch != null && hatch.updateWhileRunning) { + for (Parameters.Group.ParameterIn in : hatch.parameterIn) { + if (in != null) { + in.updateStatus(); + } + } + } + } + } + for (Parameters.Group.ParameterOut parameterOut : parametrization.parameterOutArrayList) { + if (parameterOut != null) { + parameterOut.updateStatus(); + } + } + } + + /** + * For extra types of hatches initiation, LOOK HOW IT IS CALLED! in onPostTick + * + * @param mMachine was the machine considered complete at that point in onPostTick + */ + protected void hatchInit_EM(boolean mMachine) {} + + /** + * called when the multiblock is exploding - if u want to add more EXPLOSIONS, for ex. new types of hatches also + * have to explode + */ + protected void extraExplosions_EM() {} // For that extra hatches explosions, and maybe some MOORE EXPLOSIONS + + /** + * Get Available data, Override only on data outputters should return mAvailableData that is set in check recipe + * + * @return available data + */ + protected long getAvailableData_EM() { + long result = 0; + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + Vec3Impl pos = new Vec3Impl( + baseMetaTileEntity.getXCoord(), + baseMetaTileEntity.getYCoord(), + baseMetaTileEntity.getZCoord()); + for (GT_MetaTileEntity_Hatch_InputData in : eInputData) { + if (in.q != null) { + Long value = in.q.contentIfNotInTrace(pos); + if (value != null) { + result += value; + } + } + } + return result; + } + + protected long getPowerFlow() { + return useLongPower ? lEUt : mEUt; + } + + protected void setPowerFlow(long lEUt) { + if (useLongPower) { + this.lEUt = lEUt; + } else { + mEUt = (int) Math.min(Integer.MAX_VALUE, lEUt); + } + } + + @Override + protected long getActualEnergyUsage() { + return -(useLongPower ? lEUt : mEUt) * eAmpereFlow * 10_000 / Math.max(1_000, mEfficiency); + } + + /** + * Extra hook on cyclic updates (not really needed for machines smaller than 1 chunk) BUT NEEDED WHEN - machine + * blocks are not touching each other or they don't implement IMachineBlockUpdateable (ex. air,stone,weird TE's) + */ + protected boolean cyclicUpdate_EM() { + return mUpdate <= -1000; // set to false to disable cyclic update + // default is once per 50s; mUpdate is decremented every tick + } + + /** + * get pollution per tick + * + * @param itemStack what is in controller + * @return how much pollution is produced + */ + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + /** + * EM pollution per tick + * + * @param itemStack - item in controller + * @return how much excess matter is there + */ + public float getExcessMassPerTick_EM(ItemStack itemStack) { + return 0f; + } + + /** + * triggered if machine is not allowed to work after completing a recipe, override to make it not shutdown for + * instance (like turbines). bu just replacing it with blank - active transformer is doing it + *

+ * CALLED DIRECTLY when soft hammered to offline state - usually should stop the machine unless some other mechanics + * should do it + */ + protected void notAllowedToWork_stopMachine_EM() { + stopMachine(); + } + + /** + * store data + */ + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("eMaxGenEUmin", maxEUoutputMin); + aNBT.setLong("eMaxGenEUmax", maxEUoutputMax); + aNBT.setLong("eGenRating", eMaxAmpereGen); + aNBT.setLong("eMaxEUmin", maxEUinputMin); + aNBT.setLong("eMaxEUmax", maxEUinputMax); + aNBT.setLong("eRating", eAmpereFlow); + aNBT.setLong("eMaxA", eMaxAmpereFlow); + aNBT.setLong("eDataR", eRequiredData); + aNBT.setLong("eDataA", eAvailableData); + aNBT.setByte("eCertainM", eCertainMode); + aNBT.setByte("eCertainS", eCertainStatus); + aNBT.setByte("eMinRepair", minRepairStatus); + aNBT.setBoolean("eParam", eParameters); + aNBT.setBoolean("ePass", ePowerPass); + aNBT.setBoolean("ePowerPassCover", ePowerPassCover); + aNBT.setBoolean("eVoid", eSafeVoid); + aNBT.setBoolean("eBoom", eDismantleBoom); + aNBT.setBoolean("eOK", mMachine); + // Ensures compatibility + if (mOutputItems != null) { + aNBT.setInteger("mOutputItemsLength", mOutputItems.length); + for (int i = 0; i < mOutputItems.length; i++) { + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + } + } + + // Ensures compatibility + if (mOutputFluids != null) { + aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length); + for (int i = 0; i < mOutputFluids.length; i++) { + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + } + } + + aNBT.setInteger("eOutputStackCount", 0); + aNBT.removeTag("outputEM"); + + NBTTagCompound paramI = new NBTTagCompound(); + for (int i = 0; i < parametrization.iParamsIn.length; i++) { + paramI.setDouble(Integer.toString(i), parametrization.iParamsIn[i]); + } + aNBT.setTag("eParamsInD", paramI); + + NBTTagCompound paramO = new NBTTagCompound(); + for (int i = 0; i < parametrization.iParamsOut.length; i++) { + paramO.setDouble(Integer.toString(i), parametrization.iParamsOut[i]); + } + aNBT.setTag("eParamsOutD", paramO); + + NBTTagCompound paramIs = new NBTTagCompound(); + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + paramIs.setByte(Integer.toString(i), parametrization.eParamsInStatus[i].getOrdinalByte()); + } + aNBT.setTag("eParamsInS", paramIs); + + NBTTagCompound paramOs = new NBTTagCompound(); + for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) { + paramOs.setByte(Integer.toString(i), parametrization.eParamsOutStatus[i].getOrdinalByte()); + } + aNBT.setTag("eParamsOutS", paramOs); + } + + /** + * load data + */ + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + maxEUoutputMin = aNBT.getLong("eMaxGenEUmin"); + maxEUoutputMax = aNBT.getLong("eMaxGenEUmax"); + eMaxAmpereGen = aNBT.getLong("eGenRating"); + maxEUinputMin = aNBT.getLong("eMaxEUmin"); + maxEUinputMax = aNBT.getLong("eMaxEUmax"); + eAmpereFlow = aNBT.hasKey("eRating") ? aNBT.getLong("eRating") : 1; + eMaxAmpereFlow = aNBT.getLong("eMaxA"); + eRequiredData = aNBT.getLong("eDataR"); + eAvailableData = aNBT.getLong("eDataA"); + eCertainMode = aNBT.getByte("eCertainM"); + eCertainStatus = aNBT.getByte("eCertainS"); + minRepairStatus = aNBT.hasKey("eMinRepair") ? aNBT.getByte("eMinRepair") : 3; + eParameters = !aNBT.hasKey("eParam") || aNBT.getBoolean("eParam"); + ePowerPass = aNBT.getBoolean("ePass"); + ePowerPassCover = aNBT.getBoolean("ePowerPassCover"); + eSafeVoid = aNBT.getBoolean("eVoid"); + eDismantleBoom = aNBT.getBoolean("eBoom"); + mMachine = aNBT.getBoolean("eOK"); + + // Ensures compatibility + int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength"); + if (aOutputItemsLength > 0) { + mOutputItems = new ItemStack[aOutputItemsLength]; + for (int i = 0; i < mOutputItems.length; i++) { + mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + } + + // Ensures compatibility + int aOutputFluidsLength = aNBT.getInteger("mOutputFluidsLength"); + if (aOutputFluidsLength > 0) { + mOutputFluids = new FluidStack[aOutputFluidsLength]; + for (int i = 0; i < mOutputFluids.length; i++) { + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + } + } + + if (aNBT.hasKey("eParamsIn") && aNBT.hasKey("eParamsOut") && aNBT.hasKey("eParamsB")) { + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); + NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB"); + for (int i = 0; i < 10; i++) { + if (paramB.getBoolean(Integer.toString(i))) { + parametrization.iParamsIn[i] = Float.intBitsToFloat(paramI.getInteger(Integer.toString(i))); + parametrization.iParamsOut[i] = Float.intBitsToFloat(paramO.getInteger(Integer.toString(i))); + } else { + parametrization.iParamsIn[i] = paramI.getInteger(Integer.toString(i)); + parametrization.iParamsOut[i] = paramO.getInteger(Integer.toString(i)); + } + } + } else { + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsInD"); + for (int i = 0; i < parametrization.iParamsIn.length; i++) { + parametrization.iParamsIn[i] = paramI.getDouble(Integer.toString(i)); + } + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOutD"); + for (int i = 0; i < parametrization.iParamsOut.length; i++) { + parametrization.iParamsOut[i] = paramO.getDouble(Integer.toString(i)); + } + } + + NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS"); + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + parametrization.eParamsInStatus[i] = LedStatus.getStatus(paramIs.getByte(Integer.toString(i))); + } + + NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS"); + for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) { + parametrization.eParamsOutStatus[i] = LedStatus.getStatus(paramOs.getByte(Integer.toString(i))); + } + } + + /** + * Override if needed but usually call super method at start! On machine stop - NOT called directly when soft + * hammered to offline state! - it SHOULD cause a full stop like power failure does + */ + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + if (!ShutDownReasonRegistry.isRegistered(reason.getID())) { + throw new RuntimeException(String.format("Reason %s is not registered for registry", reason.getID())); + } + for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { + data.q = null; + } + + mOutputItems = null; + mOutputFluids = null; + mEfficiency = 0; + mEfficiencyIncrease = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + eAvailableData = 0; + hatchesStatusUpdate_EM(); + getBaseMetaTileEntity().disableWorking(); + getBaseMetaTileEntity().setShutDownReason(reason); + getBaseMetaTileEntity().setShutdownStatus(true); + if (reason.wasCritical()) { + sendSound(INTERRUPT_SOUND_INDEX); + } + } + + /** + * After recipe check failed helper method so i don't have to set that params to nothing at all times + */ + protected void afterRecipeCheckFailed() { + + for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { + data.q = null; + } + + mOutputItems = null; + mOutputFluids = null; + mEfficiency = 0; + mEfficiencyIncrease = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + eAvailableData = 0; + } + + /** + * cyclic check even when not working, called LESS frequently + */ + private boolean cyclicUpdate() { + if (cyclicUpdate_EM()) { + mUpdate = 0; + return true; + } + return false; + } + + /** + * mining level... + */ + @Override + public byte getTileEntityBaseType() { + return 3; + } + + // endregion + + // region internal + + /** + * internal check machine + */ + @Override + public final boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return checkMachine_EM(iGregTechTileEntity, itemStack); + } + + /** + * internal check recipe + */ + @Override + public final boolean checkRecipe(ItemStack itemStack) { // do recipe checks, based on "machine content and state" + hatchesStatusUpdate_EM(); + startRecipeProcessing(); + boolean result = checkRecipe_EM(itemStack); // if had no - set default params + endRecipeProcessing(); + hatchesStatusUpdate_EM(); + return result; + } + + @NotNull + @Override + public final CheckRecipeResult checkProcessing() { + hatchesStatusUpdate_EM(); + CheckRecipeResult result = checkProcessing_EM(); + hatchesStatusUpdate_EM(); + return result; + } + + /** + * callback for updating parameters and new hatches + */ + protected void hatchesStatusUpdate_EM() { + if (getBaseMetaTileEntity().isClientSide()) { + return; + } + boolean busy = mMaxProgresstime > 0; + if (busy) { // write from buffer to hatches only + for (GT_MetaTileEntity_Hatch_Param hatch : filterValidMTEs(eParamHatches)) { + if (hatch.param < 0) { + continue; + } + int hatchId = hatch.param; + if (parametrization.groups[hatchId] != null && parametrization.groups[hatchId].updateWhileRunning) { + parametrization.iParamsIn[hatchId] = hatch.value0D; + parametrization.iParamsIn[hatchId + 10] = hatch.value1D; + } + hatch.input0D = parametrization.iParamsOut[hatchId]; + hatch.input1D = parametrization.iParamsOut[hatchId + 10]; + } + } else { // if has nothing to do update all + for (GT_MetaTileEntity_Hatch_Param hatch : filterValidMTEs(eParamHatches)) { + if (hatch.param < 0) { + continue; + } + int hatchId = hatch.param; + parametrization.iParamsIn[hatchId] = hatch.value0D; + parametrization.iParamsIn[hatchId + 10] = hatch.value1D; + hatch.input0D = parametrization.iParamsOut[hatchId]; + hatch.input1D = parametrization.iParamsOut[hatchId + 10]; + } + } + for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) { + eCertainStatus = uncertainty.update(eCertainMode); + } + eAvailableData = getAvailableData_EM(); + parametersStatusesWrite_EM(busy); + } + + @Deprecated + public final int getAmountOfOutputs() { + throw new NoSuchMethodError("Deprecated Do not use"); + } + // endregion + + // region TICKING functions + + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) {} + + @Override + public final void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + isFacingValid(aBaseMetaTileEntity.getFrontFacing()); + if (getBaseMetaTileEntity().isClientSide()) { + StructureLibAPI.queryAlignment((IAlignmentProvider) aBaseMetaTileEntity); + } + onFirstTick_EM(aBaseMetaTileEntity); + } + + /** + * called every tick the machines is active + */ + @Override + public boolean onRunningTick(ItemStack aStack) { + return onRunningTickCheck(aStack); + } + + public boolean onRunningTickCheck_EM(ItemStack aStack) { + if (eRequiredData > eAvailableData) { + if (!checkComputationTimeout()) { + if (energyFlowOnRunningTick_EM(aStack, false)) { + stopMachine(SimpleShutDownReason.ofCritical("computation_loss")); + } + return false; + } + } + return energyFlowOnRunningTick_EM(aStack, true); + } + + public boolean onRunningTickCheck(ItemStack aStack) { + if (eRequiredData > eAvailableData) { + if (!checkComputationTimeout()) { + if (energyFlowOnRunningTick(aStack, false)) { + stopMachine(SimpleShutDownReason.ofCritical("computation_loss")); + } + return false; + } + } + return energyFlowOnRunningTick(aStack, true); + } + + /** + * CAREFUL!!! it calls most of the callbacks, like everything else in here + */ + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + explodedThisTick = false; + if (mEfficiency < 0) { + mEfficiency = 0; + } + + if (--mUpdate == 0 || --mStartUpCheck == 0 + || cyclicUpdate() + || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + clearHatches_EM(); + + if (aBaseMetaTileEntity instanceof BaseTileEntity) { + ((BaseTileEntity) aBaseMetaTileEntity).ignoreUnloadedChunks = mMachine; + } + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + + if (!mMachine) { + if (ePowerPass && getEUVar() > V[3] + || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) { + explodeMultiblock(); + } + } + + if (eUncertainHatches.size() > 1) { + mMachine = false; + } + + if (mMachine) { + setupHatches_EM(); + + setupEnergyHatchesVariables_EM(); + + if (getEUVar() > maxEUStore()) { + setEUVar(maxEUStore()); + } + } else { + maxEUinputMin = 0; + maxEUinputMax = 0; + eMaxAmpereFlow = 0; + setEUVar(0); + } + hatchInit_EM(mMachine); + } + + if (mStartUpCheck < 0) { // E + if (mMachine) { // S + byte Tick = (byte) (aTick % 20); + if (MULTI_CHECK_AT == Tick) { + maintenance_EM(); + } + + if (getRepairStatus() >= minRepairStatus) { // S + if (MULTI_CHECK_AT == Tick) { + hatchesStatusUpdate_EM(); + } + + dischargeController_EM(aBaseMetaTileEntity); + chargeController_EM(aBaseMetaTileEntity); + + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { // Start + if (onRunningTick(mInventory[1])) { // Compute EU + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) { + stopMachine(ShutDownReasonRegistry.POLLUTION_FAIL); + } + + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { // progress increase + // and done + hatchesStatusUpdate_EM(); + + outputAfterRecipe_EM(); + + addClassicOutputs_EM(); + + updateSlots(); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe()) { + mEfficiency = Math.max( + 0, + min( + mEfficiency + mEfficiencyIncrease, + getMaxEfficiency(mInventory[1]) + - (getIdealStatus() - getRepairStatus()) * 1000)); + } else { + afterRecipeCheckFailed(); + } + updateSlots(); + } else { + notAllowedToWork_stopMachine_EM(); + } + } + } // else {//failed to consume power/resources - inside on running tick + // stopMachine(); + // } + } else if (RECIPE_AT == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe()) { + mEfficiency = Math.max( + 0, + min( + mEfficiency + mEfficiencyIncrease, + getMaxEfficiency(mInventory[1]) + - (getIdealStatus() - getRepairStatus()) * 1000)); + } else { + afterRecipeCheckFailed(); + } + updateSlots(); + } // else notAllowedToWork_stopMachine_EM(); //it is already stopped here + } + } else { // not repaired + stopMachine(ShutDownReasonRegistry.NO_REPAIR); + } + } else { // not complete + stopMachine(ShutDownReasonRegistry.STRUCTURE_INCOMPLETE); + } + } + + aBaseMetaTileEntity.setErrorDisplayID( + aBaseMetaTileEntity.getErrorDisplayID() & -512 | (mWrench ? 0 : 1) + | (mScrewdriver ? 0 : 2) + | (mSoftHammer ? 0 : 4) + | (mHardHammer ? 0 : 8) + | (mSolderingTool ? 0 : 16) + | (mCrowbar ? 0 : 32) + | (mMachine ? 0 : 64) + | (eCertainStatus == 0 ? 0 : 128) + | (eParameters ? 0 : 256)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0; + setMufflers(active); + } else { + soundMagic(getActivitySound()); + } + } + + protected void addClassicOutputs_EM() { + if (mOutputItems != null) { + for (ItemStack tStack : mOutputItems) { + if (tStack != null) { + addOutput(tStack); + } + } + } + mOutputItems = null; + + if (mOutputFluids != null) { + if (mOutputFluids.length == 1) { + for (FluidStack tStack : mOutputFluids) { + if (tStack != null) { + addOutput(tStack); + } + } + } else if (mOutputFluids.length > 1) { + addFluidOutputs(mOutputFluids); + } + } + mOutputFluids = null; + } + + protected void maintenance_EM() { + if (GT_MetaTileEntity_MultiBlockBase.disableMaintenance) { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } else { + for (GT_MetaTileEntity_Hatch_Maintenance tHatch : filterValidMTEs(mMaintenanceHatches)) { + if (tHatch.mAuto + && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) { + tHatch.autoMaintainance(); + } + if (tHatch.mWrench) { + mWrench = true; + } + if (tHatch.mScrewdriver) { + mScrewdriver = true; + } + if (tHatch.mSoftHammer) { + mSoftHammer = true; + } + if (tHatch.mHardHammer) { + mHardHammer = true; + } + if (tHatch.mSolderingTool) { + mSolderingTool = true; + } + if (tHatch.mCrowbar) { + mCrowbar = true; + } + + tHatch.mWrench = false; + tHatch.mScrewdriver = false; + tHatch.mSoftHammer = false; + tHatch.mHardHammer = false; + tHatch.mSolderingTool = false; + tHatch.mCrowbar = false; + } + } + } + + protected void clearHatches_EM() { + mDualInputHatches.clear(); + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : filterValidMTEs(eOutputData)) { + hatch_data.id = -1; + } + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : filterValidMTEs(eInputData)) { + hatch_data.id = -1; + } + + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : filterValidMTEs(eUncertainHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(false); + } + for (GT_MetaTileEntity_Hatch_Param hatch : filterValidMTEs(eParamHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(false); + } + + eUncertainHatches.clear(); + eEnergyMulti.clear(); + eParamHatches.clear(); + eDynamoMulti.clear(); + eOutputData.clear(); + eInputData.clear(); + } + + protected void setupHatches_EM() { + short id = 1; + + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : filterValidMTEs(eOutputData)) { + hatch_data.id = id++; + } + id = 1; + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : filterValidMTEs(eInputData)) { + hatch_data.id = id++; + } + + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : filterValidMTEs(eUncertainHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(true); + } + for (GT_MetaTileEntity_Hatch_Param hatch : filterValidMTEs(eParamHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(true); + } + } + + protected void setupEnergyHatchesVariables_EM() { + if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty() + || !mDynamoHatches.isEmpty() + || !eDynamoMulti.isEmpty()) { + maxEUinputMin = V[15]; + maxEUinputMax = V[0]; + maxEUoutputMin = V[15]; + maxEUoutputMax = V[0]; + for (GT_MetaTileEntity_Hatch_Energy hatch : filterValidMTEs(mEnergyHatches)) { + if (hatch.maxEUInput() < maxEUinputMin) { + maxEUinputMin = hatch.maxEUInput(); + } + if (hatch.maxEUInput() > maxEUinputMax) { + maxEUinputMax = hatch.maxEUInput(); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : filterValidMTEs(eEnergyMulti)) { + if (hatch.maxEUInput() < maxEUinputMin) { + maxEUinputMin = hatch.maxEUInput(); + } + if (hatch.maxEUInput() > maxEUinputMax) { + maxEUinputMax = hatch.maxEUInput(); + } + } + for (GT_MetaTileEntity_Hatch_Dynamo hatch : filterValidMTEs(mDynamoHatches)) { + if (hatch.maxEUOutput() < maxEUoutputMin) { + maxEUoutputMin = hatch.maxEUOutput(); + } + if (hatch.maxEUOutput() > maxEUoutputMax) { + maxEUoutputMax = hatch.maxEUOutput(); + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti hatch : filterValidMTEs(eDynamoMulti)) { + if (hatch.maxEUOutput() < maxEUoutputMin) { + maxEUoutputMin = hatch.maxEUOutput(); + } + if (hatch.maxEUOutput() > maxEUoutputMax) { + maxEUoutputMax = hatch.maxEUOutput(); + } + } + eMaxAmpereFlow = 0; + eMaxAmpereGen = 0; + // counts only full amps + for (GT_MetaTileEntity_Hatch_Energy hatch : filterValidMTEs(mEnergyHatches)) { + eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin; + } + for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : filterValidMTEs(eEnergyMulti)) { + eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin * hatch.Amperes; + } + for (GT_MetaTileEntity_Hatch_Dynamo hatch : filterValidMTEs(mDynamoHatches)) { + eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin; + } + for (GT_MetaTileEntity_Hatch_DynamoMulti hatch : filterValidMTEs(eDynamoMulti)) { + eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin * hatch.Amperes; + } + } else { + maxEUinputMin = 0; + maxEUinputMax = 0; + eMaxAmpereFlow = 0; + maxEUoutputMin = 0; + maxEUoutputMax = 0; + eMaxAmpereGen = 0; + } + } + + protected void dischargeController_EM(IGregTechTileEntity aBaseMetaTileEntity) { + if (ePowerPass && getEUVar() > getMinimumStoredEU()) { + powerPass(aBaseMetaTileEntity); + } + } + + protected final void powerPass(IGregTechTileEntity aBaseMetaTileEntity) { + long euVar; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : filterValidMTEs(mDynamoHatches)) { + euVar = tHatch.maxEUOutput() * tHatch.maxAmperesOut(); + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity + .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.maxAmperesOut()), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) { + euVar = tHatch.maxEUOutput() * tHatch.maxAmperesOut(); + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity + .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.maxAmperesOut()), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + } + + protected final void powerPass_EM(IGregTechTileEntity aBaseMetaTileEntity) { + long euVar; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : filterValidMTEs(mDynamoHatches)) { + euVar = tHatch.maxEUOutput(); + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, 1), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) { + euVar = tHatch.maxEUOutput() * tHatch.Amperes; + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity + .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.Amperes), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + } + + protected void chargeController_EM(IGregTechTileEntity aBaseMetaTileEntity) { + powerInput(); + } + + protected final void powerInput() { + long euVar; + for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar()); + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar()); + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + } + + protected final void powerInput_EM() { + long euVar; + for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = tHatch.maxEUInput(); + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = tHatch.maxEUInput() * tHatch.Amperes; + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + } + + // endregion + + // region EFFICIENCY AND FIXING LIMITS + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getIdealStatus() { + return super.getIdealStatus() + 2; + } + + @Override + public int getRepairStatus() { + return super.getRepairStatus() + (eCertainStatus == 0 ? 1 : 0) + (eParameters ? 1 : 0); + } + + // endregion + + // region ENERGY!!!! + + // new method + public boolean energyFlowOnRunningTick_EM(ItemStack aStack, boolean allowProduction) { + long euFlow = getPowerFlow() * eAmpereFlow; // quick scope sign + if (allowProduction && euFlow > 0) { + addEnergyOutput_EM(getPowerFlow() * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); + } else if (euFlow < 0) { + if (POWERLESS_MODE) { + return true; + } + if (!drainEnergyInput_EM( + getPowerFlow(), + getPowerFlow() * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency), + eAmpereFlow)) { + criticalStopMachine(); + return false; + } + } + return true; + } + + public boolean energyFlowOnRunningTick(ItemStack aStack, boolean allowProduction) { + long euFlow = getPowerFlow() * eAmpereFlow; // quick scope sign + if (allowProduction && euFlow > 0) { + addEnergyOutput_EM(getPowerFlow() * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); + } else if (euFlow < 0) { + if (POWERLESS_MODE) { + return true; + } + if (!drainEnergyInput( + getPowerFlow() * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency), + eAmpereFlow)) { + criticalStopMachine(); + return false; + } + } + return true; + } + + @Override + public long maxEUStore() { + return Math.max(maxEUinputMin * (eMaxAmpereFlow << 3), maxEUoutputMin * (eMaxAmpereGen << 3)); + } + + @Override + public final long getMinimumStoredEU() { + return maxEUStore() >> 1; + } + + @Override + public final long maxAmperesIn() { + return 0L; + } + + @Override + public final long maxAmperesOut() { + return 0L; + } + + @Deprecated + @Override + public final boolean addEnergyOutput(long eu) { + return addEnergyOutput_EM(eu, 1); + } + + public boolean addEnergyOutput_EM(long EU, long Amperes) { + if (EU < 0) { + EU = -EU; + } + if (Amperes < 0) { + Amperes = -Amperes; + } + long euVar = EU * Amperes; + long diff; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : filterValidMTEs(mDynamoHatches)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } + diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity() + .getStoredEU(); + if (diff > 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + return true; + } + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } + diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity() + .getStoredEU(); + if (diff > 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + return true; + } + } + } + setEUVar(min(getEUVar() + euVar, maxEUStore())); + return false; + } + + @Deprecated + @Override + public final boolean drainEnergyInput(long eu) { + return drainEnergyInput_EM(0, eu, 1); + } + + public boolean drainEnergyInput_EM(long EUtTierVoltage, long EUtEffective, long Amperes) { + long EUuse = EUtEffective * Amperes; + if (EUuse == 0) { + return true; + } + if (maxEUinputMin == 0) { + return false; + } + if (EUuse < 0) { + EUuse = -EUuse; + } + if (EUuse > getEUVar() || // not enough power + (EUtTierVoltage == 0 ? EUuse > getMaxInputEnergy() : (EUtTierVoltage > maxEUinputMax) || // TIER IS + // BASED ON + // BEST HATCH! + // not total + // EUtEffective + // input + (EUtTierVoltage * Amperes - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)) { // EUuse==0? --> (EUuse + // - 1) / maxEUinputMin + // + 1 = 1! //if + // not too much A + if (DEBUG_MODE) { + TecTech.LOGGER.debug("L1 " + EUuse + ' ' + getEUVar() + ' ' + (EUuse > getEUVar())); + TecTech.LOGGER.debug("L2 " + EUtEffective + ' ' + maxEUinputMax + ' ' + (EUtEffective > maxEUinputMax)); + TecTech.LOGGER.debug("L3 " + Amperes + ' ' + getMaxInputEnergy()); + TecTech.LOGGER.debug( + "L4 " + ((EUuse - 1) / maxEUinputMin + 1) + + ' ' + + eMaxAmpereFlow + + ' ' + + ((EUuse - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); + } + return false; + } + // sub eu + setEUVar(getEUVar() - EUuse); + return true; + } + + public boolean drainEnergyInput(long EUtEffective, long Amperes) { + long EUuse = EUtEffective * Amperes; + if (EUuse == 0) { + return true; + } + if (maxEUinputMin == 0) { + return false; + } + if (EUuse < 0) { + EUuse = -EUuse; + } + // not enough power + if (EUuse > getEUVar() || EUuse > getMaxInputEnergy()) { // EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! + // //if not too much + // A + return false; + } + // sub eu + setEUVar(getEUVar() - EUuse); + return true; + } + + // new method + public final boolean overclockAndPutValuesIn_EM(long EU, int time) { // TODO revise + if (EU == 0L) { + setPowerFlow(0); + mMaxProgresstime = time; + return true; + } + long tempEUt = Math.max(EU, V[1]); + long tempTier = maxEUinputMax >> 2; + while (tempEUt < tempTier) { + tempEUt <<= 2; + time >>= 1; + EU = time == 0 ? EU >> 1 : EU << 2; // U know, if the time is less than 1 tick make the machine use less + // power + } + if (EU > Integer.MAX_VALUE || EU < Integer.MIN_VALUE) { + setPowerFlow(Integer.MAX_VALUE - 1); + mMaxProgresstime = Integer.MAX_VALUE - 1; + return false; + } + setPowerFlow(EU); + mMaxProgresstime = time == 0 ? 1 : time; + return true; + } // Use in EM check recipe return statement if you want overclocking + + /** + * Use {@link #getMaxInputVoltage()} + */ + @Deprecated + public final long getMaxInputVoltageSum() { + return getMaxInputVoltage(); + } + + /** + * Use {@link #getMaxInputEu()} + */ + @Deprecated + public final long getMaxInputEnergy() { + return getMaxInputEu(); + } + + /** + * Use {@link #getMaxInputEu()} + */ + @Deprecated + public final long getMaxInputEnergy_EM() { + return getMaxInputEu(); + } + + // new Method + public final int getMaxEnergyInputTier_EM() { + return getTier(maxEUinputMax); + } + + // new Method + public final int getMinEnergyInputTier_EM() { + return getTier(maxEUinputMin); + } + + public final long getMaxAmpereFlowAtMinTierOfEnergyHatches() { + return eAmpereFlow; + } + + @Override + public List getExoticAndNormalEnergyHatchList() { + List list = new ArrayList<>(); + list.addAll(mEnergyHatches); + list.addAll(eEnergyMulti); + return list; + } + + @Override + public List getExoticEnergyHatches() { + List list = new ArrayList<>(); + list.addAll(eEnergyMulti); + return list; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public final void explodeMultiblock() { + if (explodedThisTick) { + return; + } + explodedThisTick = true; + if (!TecTech.configTecTech.BOOM_ENABLE) { + TecTech.proxy.broadcast( + "Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord() + + ' ' + + getBaseMetaTileEntity().getYCoord() + + ' ' + + getBaseMetaTileEntity().getZCoord()); + StackTraceElement[] ste = Thread.currentThread() + .getStackTrace(); + TecTech.proxy.broadcast("Multi Explode BOOM! " + ste[2].toString()); + return; + } + extraExplosions_EM(); + GT_Pollution.addPollution(getBaseMetaTileEntity(), 600000); + mInventory[1] = null; + @SuppressWarnings("unchecked") + Iterable allHatches = Iterables.concat( + mInputBusses, + mOutputBusses, + mInputHatches, + mOutputHatches, + mDynamoHatches, + mMufflerHatches, + mEnergyHatches, + mMaintenanceHatches, + eParamHatches, + eEnergyMulti, + eUncertainHatches, + eDynamoMulti, + eInputData, + eOutputData); + for (MetaTileEntity tTileEntity : allHatches) { + if (tTileEntity != null && tTileEntity.getBaseMetaTileEntity() != null) { + tTileEntity.getBaseMetaTileEntity() + .doExplosion(V[9]); + } + } + getBaseMetaTileEntity().doExplosion(V[15]); + } + + @Override + public void doExplosion(long aExplosionPower) { + if (!TecTech.configTecTech.BOOM_ENABLE) { + TecTech.proxy.broadcast( + "Multi DoExplosion BOOM! " + getBaseMetaTileEntity().getXCoord() + + ' ' + + getBaseMetaTileEntity().getYCoord() + + ' ' + + getBaseMetaTileEntity().getZCoord()); + StackTraceElement[] ste = Thread.currentThread() + .getStackTrace(); + TecTech.proxy.broadcast("Multi DoExplosion BOOM! " + ste[2].toString()); + return; + } + explodeMultiblock(); + super.doExplosion(aExplosionPower); + } // Redirecting to explodemultiblock + // endregion + + // region adder methods + @Override + public final boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof IDualInputHatch) { + return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { + return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { + return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + } + return false; + } + + public final boolean addClassicToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof IDualInputHatch) { + return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { + return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { + return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + } + return false; + } + + public final boolean addElementalToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + + return false; + } + + public final boolean addElementalMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + + return false; + } + + @Override + public final boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + + return false; + } + + @Override + public final boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof IDualInputHatch) { + ((IDualInputHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + + return false; + } + + @Override + public final boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + + return false; + } + + @Deprecated + @Override + public final boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + return false; + } + + @Deprecated + @Override + public final boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + return false; + } + + // New Method + public final boolean addEnergyIOToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addElementalInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + + return false; + } + + // NEW METHOD + public final boolean addElementalOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + + return false; + } + + // NEW METHOD + public final boolean addParametrizerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addUncertainToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + } + return false; + } + + @Override + public final boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addClassicMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + } + return false; + } + // endregion + + protected static IStructureElement classicHatches( + int casingIndex, int dot, Block casingBlock, int casingMeta) { + return GT_HatchElementBuilder.builder() + .atLeast( + InputBus, + InputHatch, + OutputHatch, + OutputBus, + Maintenance, + Muffler, + HatchElement.EnergyMulti, + HatchElement.DynamoMulti, + HatchElement.InputData, + HatchElement.OutputData, + HatchElement.Uncertainty) + .casingIndex(casingIndex) + .dot(dot) + .buildAndChain(casingBlock, casingMeta); + } + + protected static IStructureElement allHatches(int casingIndex, + int dot, Block casingBlock, int casingMeta) { + return GT_HatchElementBuilder.builder() + .atLeast( + InputBus, + InputHatch, + OutputHatch, + OutputBus, + Maintenance, + Muffler, + HatchElement.EnergyMulti, + HatchElement.DynamoMulti, + HatchElement.InputData, + HatchElement.OutputData, + HatchElement.Uncertainty) + .casingIndex(casingIndex) + .dot(dot) + .buildAndChain(casingBlock, casingMeta); + } + + public enum HatchElement implements IHatchElement { + + Param(GT_MetaTileEntity_MultiblockBase_EM::addParametrizerToMachineList, GT_MetaTileEntity_Hatch_Param.class) { + + @Override + public long count(GT_MetaTileEntity_MultiblockBase_EM t) { + return t.eParamHatches.size(); + } + }, + Uncertainty(GT_MetaTileEntity_MultiblockBase_EM::addUncertainToMachineList, + GT_MetaTileEntity_Hatch_Uncertainty.class) { + + @Override + public long count(GT_MetaTileEntity_MultiblockBase_EM t) { + return t.eUncertainHatches.size(); + } + }, + EnergyMulti(GT_MetaTileEntity_MultiblockBase_EM::addEnergyInputToMachineList, + GT_MetaTileEntity_Hatch_EnergyMulti.class) { + + @Override + public long count(GT_MetaTileEntity_MultiblockBase_EM t) { + return t.eEnergyMulti.size(); + } + }, + DynamoMulti(GT_MetaTileEntity_MultiblockBase_EM::addDynamoToMachineList, + GT_MetaTileEntity_Hatch_DynamoMulti.class) { + + @Override + public long count(GT_MetaTileEntity_MultiblockBase_EM t) { + return t.eDynamoMulti.size(); + } + }, + InputData(GT_MetaTileEntity_MultiblockBase_EM::addDataConnectorToMachineList, + GT_MetaTileEntity_Hatch_InputData.class) { + + @Override + public long count(GT_MetaTileEntity_MultiblockBase_EM t) { + return t.eInputData.size(); + } + }, + OutputData(GT_MetaTileEntity_MultiblockBase_EM::addDataConnectorToMachineList, + GT_MetaTileEntity_Hatch_OutputData.class) { + + @Override + public long count(GT_MetaTileEntity_MultiblockBase_EM t) { + return t.eOutputData.size(); + } + },; + + private final List> mteClasses; + private final IGT_HatchAdder adder; + + @SafeVarargs + HatchElement(IGT_HatchAdder adder, + Class... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + this.adder = adder; + } + + @Override + public List> mteClasses() { + return mteClasses; + } + + public IGT_HatchAdder adder() { + return adder; + } + } + + /** + * Check if the computation timeout is still active + * + * @return True if the timeout is still active or false if the machine should fail + */ + protected boolean checkComputationTimeout() { + if (eComputationTimeout > 0) { + return --eComputationTimeout > 0; + } + return false; + } + + // region ModularUI + + @Override + public int getGUIWidth() { + return 198; + } + + @Override + public int getGUIHeight() { + return 192; + } + + @Override + public void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(7, 109), getGUITextureSet().getItemSlot()); + } + + public boolean isPowerPassButtonEnabled() { + return true; + } + + public boolean isSafeVoidButtonEnabled() { + return true; + } + + public boolean isAllowedToWorkButtonEnabled() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(173, 74)); + } + + private static byte LEDCounter = 0; + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (doesBindPlayerInventory()) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(4, 4) + .setSize(190, 91)); + } else { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_NO_INVENTORY) + .setPos(4, 4) + .setSize(190, 171)); + } + final SlotWidget inventorySlot = new SlotWidget(new BaseSlot(inventoryHandler, 1) { + + @Override + public int getSlotStackLimit() { + return getInventoryStackLimit(); + } + }); + if (doesBindPlayerInventory()) { + builder + .widget( + inventorySlot.setBackground(getGUITextureSet().getItemSlot(), TecTechUITextures.OVERLAY_SLOT_MESH) + .setPos(173, 167)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_SMALL) + .setPos(173, 185) + .setSize(18, 6)); + } + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + drawTexts(screenElements, inventorySlot); + builder.widget(screenElements.setPos(7, 8)); + + Widget powerPassButton = createPowerPassButton(); + builder.widget(powerPassButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPass, val -> ePowerPass = val)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPassCover, val -> ePowerPassCover = val)); + Widget safeVoidButton = createSafeVoidButton(); + builder.widget(safeVoidButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> eSafeVoid, val -> eSafeVoid = val)); + Widget powerSwitchButton = createPowerSwitchButton(); + builder.widget(powerSwitchButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> { + if (val) getBaseMetaTileEntity().enableWorking(); + else getBaseMetaTileEntity().disableWorking(); + })); + + builder.widget(new DrawableWidget() { + + @Override + public void draw(float partialTicks) { + super.draw(partialTicks); + LEDCounter = (byte) ((1 + LEDCounter) % 6); + } + }.setDrawable(TecTechUITextures.PICTURE_PARAMETER_BLANK) + .setPos(5, doesBindPlayerInventory() ? 96 : 176) + .setSize(166, 12)); + for (int hatch = 0; hatch < 10; hatch++) { + for (int param = 0; param < 2; param++) { + int ledID = hatch + param * 10; + buildContext + .addSyncedWindow(LED_WINDOW_BASE_ID + ledID, (player) -> createLEDConfigurationWindow(ledID)); + addParameterLED(builder, hatch, param, true); + addParameterLED(builder, hatch, param, false); + } + } + + if (doesBindPlayerInventory()) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_MONITOR_MULTIMACHINE) + .setPos(173, 96) + .setSize(18, 18)); + for (int i = 0; i < 9; i++) { + final int index = i; + builder.widget(new DrawableWidget().setDrawable(() -> { + UITexture valid = TecTechUITextures.PICTURE_UNCERTAINTY_VALID[index]; + UITexture invalid = TecTechUITextures.PICTURE_UNCERTAINTY_INVALID[index]; + switch (eCertainMode) { + case 1: // ooo oxo ooo + if (index == 4) return eCertainStatus == 0 ? valid : invalid; + break; + case 2: // ooo xox ooo + if (index == 3) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 5) return (eCertainStatus & 2) == 0 ? valid : invalid; + break; + case 3: // oxo xox oxo + if (index == 1) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 3) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 5) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 7) return (eCertainStatus & 8) == 0 ? valid : invalid; + break; + case 4: // xox ooo xox + if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 6) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 8) return (eCertainStatus & 8) == 0 ? valid : invalid; + break; + case 5: // xox oxo xox + if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 4) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 6) return (eCertainStatus & 8) == 0 ? valid : invalid; + if (index == 8) return (eCertainStatus & 16) == 0 ? valid : invalid; + break; + } + return null; + }) + .setPos(174 + (index % 3) * 6, 97 + (index / 3) * 6) + .setSize(4, 4)); + } + builder.widget(new FakeSyncWidget.ByteSyncer(() -> eCertainMode, val -> eCertainMode = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> eCertainStatus, val -> eCertainStatus = val)); + } + } + + protected ButtonWidget createPowerPassButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isPowerPassButtonEnabled() || ePowerPassCover) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + ePowerPass = !ePowerPass; + if (!isAllowedToWorkButtonEnabled()) { // TRANSFORMER HACK + if (ePowerPass) { + getBaseMetaTileEntity().enableWorking(); + } else { + getBaseMetaTileEntity().disableWorking(); + } + } + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + if (!isPowerPassButtonEnabled() && !ePowerPassCover) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_DISABLED); + } else { + if (ePowerPass) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_OFF); + } + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 116 : 140) + .setSize(16, 16); + if (isPowerPassButtonEnabled()) { + button.addTooltip("Power Pass") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + return (ButtonWidget) button; + } + + protected ButtonWidget createSafeVoidButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isSafeVoidButtonEnabled()) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + eSafeVoid = !eSafeVoid; + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + if (!isSafeVoidButtonEnabled()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_DISABLED); + } else { + if (eSafeVoid) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_OFF); + } + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 132 : 156) + .setSize(16, 16); + if (isSafeVoidButtonEnabled()) { + button.addTooltip("Safe Void") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + return (ButtonWidget) button; + } + + protected ButtonWidget createPowerSwitchButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isAllowedToWorkButtonEnabled()) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (getBaseMetaTileEntity().isAllowedToWork()) { + getBaseMetaTileEntity().disableWorking(); + } else { + getBaseMetaTileEntity().enableWorking(); + } + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + if (!isAllowedToWorkButtonEnabled()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED); + } else { + if (getBaseMetaTileEntity().isAllowedToWork()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF); + } + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 148 : 172) + .setSize(16, 16); + if (isAllowedToWorkButtonEnabled()) { + button.addTooltip("Power Switch") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + return (ButtonWidget) button; + } + + private ModularWindow createLEDConfigurationWindow(int ledID) { + return ModularWindow.builder(100, 40) + .setBackground(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos( + (screenSize, mainWindow) -> new Pos2d( + (screenSize.width / 2 - mainWindow.getSize().width / 2) - 110, + (screenSize.height / 2 - mainWindow.getSize().height / 2))) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(85, 3)) + .widget( + new NumericWidget().setGetter(() -> parametrization.iParamsIn[ledID]) + .setSetter(val -> parametrization.iParamsIn[ledID] = val) + .setIntegerOnly(false) + .modifyNumberFormat(format -> format.setMaximumFractionDigits(8)) + .setTextColor(Color.LIGHT_BLUE.normal) + .setTextAlignment(Alignment.CenterLeft) + .setFocusOnGuiOpen(true) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) + .setPos(5, 20) + .setSize(90, 15)) + .widget( + new TextWidget((ledID % 10) + ":" + (ledID / 10) + ":I").setDefaultColor(Color.WHITE.normal) + .setTextAlignment(Alignment.Center) + .setPos(5, 5)) + .build(); + } + + private void addParameterLED(ModularWindow.Builder builder, int hatch, int param, boolean input) { + final int parameterIndex = hatch + param * 10; + final int posIndex = hatch * 2 + param; + ButtonWidget ledWidget = new ButtonWidget() { + + @Override + public void draw(float partialTicks) { + IDrawable texture = null; + final LedStatus status = input ? parametrization.eParamsInStatus[parameterIndex] + : parametrization.eParamsOutStatus[parameterIndex]; + switch (status) { + case STATUS_WTF: { + int c = LEDCounter; + if (c > 4) { + c = TecTech.RANDOM.nextInt(5); + } + switch (c) { + case 0: + texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex]; + break; + case 1: + texture = TecTechUITextures.PICTURE_PARAMETER_CYAN[posIndex]; + break; + case 2: + texture = TecTechUITextures.PICTURE_PARAMETER_GREEN[posIndex]; + break; + case 3: + texture = TecTechUITextures.PICTURE_PARAMETER_ORANGE[posIndex]; + break; + case 4: + texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex]; + break; + } + break; + } + case STATUS_WRONG: // fallthrough + if (LEDCounter < 2) { + texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex]; + break; + } else if (LEDCounter < 4) { + texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex]; + break; + } + case STATUS_OK: // ok + texture = TecTechUITextures.PICTURE_PARAMETER_GREEN[posIndex]; + break; + case STATUS_TOO_LOW: // too low blink + if (LEDCounter < 3) { + texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex]; + break; + } + case STATUS_LOW: // too low + texture = TecTechUITextures.PICTURE_PARAMETER_CYAN[posIndex]; + break; + case STATUS_TOO_HIGH: // too high blink + if (LEDCounter < 3) { + texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex]; + break; + } + case STATUS_HIGH: // too high + texture = TecTechUITextures.PICTURE_PARAMETER_ORANGE[posIndex]; + break; + case STATUS_NEUTRAL: + if (LEDCounter < 3) { + GL11.glColor4f(.85f, .9f, .95f, .5F); + } else { + GL11.glColor4f(.8f, .9f, 1f, .5F); + } + texture = TecTechUITextures.PICTURE_PARAMETER_GRAY; + break; + case STATUS_UNDEFINED: + if (LEDCounter < 3) { + GL11.glColor4f(.5f, .1f, .15f, .5F); + } else { + GL11.glColor4f(0f, .1f, .2f, .5F); + } + texture = TecTechUITextures.PICTURE_PARAMETER_GRAY; + break; + case STATUS_UNUSED: + default: + // no-op + break; + } + setBackground(texture); + super.draw(partialTicks); + GL11.glColor4f(1f, 1f, 1f, 1f); + } + }.setOnClick((clickData, widget) -> { + if (!widget.isClient() && input + && parametrization.eParamsInStatus[parameterIndex] != LedStatus.STATUS_UNUSED) { + // We don't use CloseAllButMain here in case MB implementation adds their own window + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + if (widget.getContext() + .isWindowOpen(LED_WINDOW_BASE_ID + i)) { + widget.getContext() + .closeWindow(LED_WINDOW_BASE_ID + i); + } + } + widget.getContext() + .openSyncedWindow(LED_WINDOW_BASE_ID + parameterIndex); + } + }); + builder.widget(ledWidget.dynamicTooltip(() -> { + if (input) { + return getFullLedDescriptionIn(hatch, param); + } else { + return getFullLedDescriptionOut(hatch, param); + } + }) + .setPos(12 + posIndex * 8, (doesBindPlayerInventory() ? 97 : 177) + (input ? 0 : 1) * 6) + .setSize(6, 4)); + if (input) { + builder + .widget( + new FakeSyncWidget.ByteSyncer( + () -> parametrization.eParamsInStatus[parameterIndex].getOrdinalByte(), + val -> parametrization.eParamsInStatus[parameterIndex] = LedStatus.getStatus(val)) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())) + .widget( + new FakeSyncWidget.DoubleSyncer( + () -> parametrization.iParamsIn[parameterIndex], + val -> parametrization.iParamsIn[parameterIndex] = val) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())); + } else { + builder + .widget( + new FakeSyncWidget.ByteSyncer( + () -> parametrization.eParamsOutStatus[parameterIndex].getOrdinalByte(), + val -> parametrization.eParamsOutStatus[parameterIndex] = LedStatus.getStatus(val)) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())) + .widget( + new FakeSyncWidget.DoubleSyncer( + () -> parametrization.iParamsOut[parameterIndex], + val -> parametrization.iParamsOut[parameterIndex] = val) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())); + } + } + + // endregion + + protected void turnOffMaintenance() { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + hasMaintenanceChecks = false; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/INameFunction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/INameFunction.java new file mode 100644 index 0000000000..11867c067a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/INameFunction.java @@ -0,0 +1,6 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +public interface INameFunction { + + String apply(T t, Parameters.IParameter iParameter); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java new file mode 100644 index 0000000000..37d5664d20 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java @@ -0,0 +1,6 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +public interface IStatusFunction { + + LedStatus apply(T t, Parameters.IParameter iParameter); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java new file mode 100644 index 0000000000..e99739b69e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java @@ -0,0 +1,64 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import java.util.function.Supplier; + +import net.minecraft.util.EnumChatFormatting; + +import com.github.technus.tectech.TecTech; + +public enum LedStatus { + + STATUS_UNUSED(() -> EnumChatFormatting.DARK_GRAY + "Unused", true), // + STATUS_TOO_LOW(() -> EnumChatFormatting.BLUE + "Too Low", false), // + STATUS_LOW(() -> EnumChatFormatting.AQUA + "Low", true), // + STATUS_WRONG(() -> EnumChatFormatting.DARK_PURPLE + "Wrong", false), // + STATUS_OK(() -> EnumChatFormatting.GREEN + "Valid", true), // + STATUS_TOO_HIGH(() -> EnumChatFormatting.RED + "Too High", false), // + STATUS_HIGH(() -> EnumChatFormatting.GOLD + "High", true), // + STATUS_UNDEFINED(() -> EnumChatFormatting.GRAY + "Unknown", false), + STATUS_NEUTRAL(() -> EnumChatFormatting.WHITE + "Neutral", true), + STATUS_WTF(() -> LedStatus.values()[TecTech.RANDOM.nextInt(9)].name.get(), false); + + public final Supplier name; + public final boolean isOk; + + LedStatus(Supplier name, boolean ok) { + this.name = name; + this.isOk = ok; + } + + public byte getOrdinalByte() { + return (byte) ordinal(); + } + + public static LedStatus getStatus(byte value) { + try { + return LedStatus.values()[value]; + } catch (Exception e) { + return STATUS_UNDEFINED; + } + } + + public static LedStatus[] makeArray(int count, LedStatus defaultValue) { + LedStatus[] statuses = new LedStatus[count]; + for (int i = 0; i < count; i++) { + statuses[i] = defaultValue; + } + return statuses; + } + + public static LedStatus fromLimitsInclusiveOuterBoundary(double value, double min, double low, double high, + double max, double... excludedNumbers) { + if (value < min) return STATUS_TOO_LOW; + if (value > max) return STATUS_TOO_HIGH; + + if (value < low) return STATUS_LOW; + if (value > high) return STATUS_HIGH; + for (double val : excludedNumbers) { + if (val == value) return STATUS_WRONG; + } + if (Double.isNaN(value)) return STATUS_WRONG; + return STATUS_OK; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/Parameters.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/Parameters.java new file mode 100644 index 0000000000..5b2c73b593 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/Parameters.java @@ -0,0 +1,327 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import java.util.ArrayList; + +/** + * Instantiate parameters as field in parametersInstantiation_EM(); + */ +public class Parameters { + + private static final IStatusFunction LED_STATUS_FUNCTION_DEFAULT = (b, p) -> LedStatus.STATUS_UNDEFINED; + private static final INameFunction NAME_FUNCTION_DEFAULT = (b, p) -> "Undefined"; + + final Group[] groups = new Group[10]; + + double[] iParamsIn = new double[20]; // number I from parametrizers + double[] iParamsOut = new double[20]; // number O to parametrizers + final ArrayList parameterInArrayList = new ArrayList<>(); + final ArrayList parameterOutArrayList = new ArrayList<>(); + + // package private for use in gui + LedStatus[] eParamsInStatus = LedStatus.makeArray(20, LedStatus.STATUS_UNUSED); // LED status for I + LedStatus[] eParamsOutStatus = LedStatus.makeArray(20, LedStatus.STATUS_UNUSED); // LED status for O + + double getIn(int hatchNo, int parameterId) { + return iParamsIn[hatchNo + 10 * parameterId]; + } + + double getOut(int hatchNo, int parameterId) { + return iParamsOut[hatchNo + 10 * parameterId]; + } + + LedStatus getStatusIn(int hatchNo, int parameterId) { + return eParamsInStatus[hatchNo + 10 * parameterId]; + } + + LedStatus getStatusOut(int hatchNo, int parameterId) { + return eParamsOutStatus[hatchNo + 10 * parameterId]; + } + + private final GT_MetaTileEntity_MultiblockBase_EM parent; + + Parameters(GT_MetaTileEntity_MultiblockBase_EM parent) { + this.parent = parent; + } + + public boolean trySetParameters(int hatch, double parameter0, double parameter1) { + Group p = groups[hatch]; + if (parent.mMaxProgresstime <= 0 || (p != null && p.updateWhileRunning)) { + iParamsIn[hatch] = parameter0; + iParamsIn[hatch + 10] = parameter1; + return true; + } + return false; + } + + @SuppressWarnings("unused") // Used in GTNH-Intergalactic, do not delete. + public boolean trySetParameters(int hatchNo, int parameterId, double parameter) { + Group p = groups[hatchNo]; + if (parent.mMaxProgresstime <= 0 || (p != null && p.updateWhileRunning)) { + iParamsIn[hatchNo + 10 * parameterId] = parameter; + return true; + } + return false; + } + + public void setToDefaults(int hatch, boolean defaultIn, boolean defaultOut) { + Group p = groups[hatch]; + if (p == null) { + if (defaultIn) { + iParamsIn[hatch] = 0; + iParamsIn[hatch + 10] = 0; + } + if (defaultOut) { + iParamsOut[hatch] = 0; + iParamsOut[hatch + 10] = 0; + } + } else { + p.setToDefaults(defaultIn, defaultOut); + } + } + + public void setToDefaults(boolean defaultIn, boolean defaultOut) { + for (int hatch = 0; hatch < 10; hatch++) { + setToDefaults(hatch, defaultIn, defaultOut); + } + } + + public Group getGroup(int hatchNo, boolean updateWhileRunning) { + return groups[hatchNo] != null ? groups[hatchNo] : new Group(hatchNo, updateWhileRunning); + } + + public Group getGroup(int hatchNo) { + return groups[hatchNo] != null ? groups[hatchNo] : new Group(hatchNo, false); + } + + public interface IParameter { + + double get(); + + double getDefault(); + + void updateStatus(); + + LedStatus getStatus(boolean update); + + int id(); + + int hatchId(); + + int parameterId(); + + String getBrief(); + } + + /** + * most likely used locally in parametersInstantiation_EM() + */ + public class Group { + + private final int hatchNo; + public final ParameterIn[] parameterIn = new ParameterIn[2]; + public final ParameterOut[] parameterOut = new ParameterOut[2]; + public boolean updateWhileRunning; + + private Group(int hatchNo, boolean updateWhileRunning) { + if (hatchNo < 0 || hatchNo >= 10) { + throw new IllegalArgumentException("Hatch id must be in 0 to 9 range"); + } + this.hatchNo = hatchNo; + this.updateWhileRunning = updateWhileRunning; + groups[hatchNo] = this; + } + + public ParameterIn makeInParameter(int paramID, double defaultValue, INameFunction name, + IStatusFunction status) { + return new ParameterIn(paramID, defaultValue, name, status); + } + + public ParameterOut makeOutParameter(int paramID, double defaultValue, INameFunction name, + IStatusFunction status) { + return new ParameterOut(paramID, defaultValue, name, status); + } + + public void setToDefaults(boolean defaultIn, boolean defaultOut) { + if (defaultIn) { + if (this.parameterIn[0] != null) { + this.parameterIn[0].setDefault(); + } else { + iParamsIn[hatchNo] = 0; + } + if (this.parameterIn[1] != null) { + this.parameterIn[1].setDefault(); + } else { + iParamsIn[hatchNo + 10] = 0; + } + } + if (defaultOut) { + if (this.parameterOut[0] != null) { + this.parameterOut[0].setDefault(); + } else { + iParamsOut[hatchNo] = 0; + } + if (this.parameterOut[1] != null) { + this.parameterOut[1].setDefault(); + } else { + iParamsOut[hatchNo + 10] = 0; + } + } + } + + /** + * Make a field out of this... + */ + public class ParameterOut implements IParameter { + + public final int id; + public final double defaultValue; + IStatusFunction status; + INameFunction name; + + private ParameterOut(int paramID, double defaultValue, INameFunction name, IStatusFunction status) { + this.name = name == null ? NAME_FUNCTION_DEFAULT : name; + if (paramID < 0 || paramID > 2) { + throw new IllegalArgumentException("Parameter id must be in 0 to 1 range"); + } + if (parameterOut[paramID] != null) { + throw new IllegalArgumentException("Parameter id already occupied"); + } + this.id = hatchNo + 10 * paramID; + this.defaultValue = defaultValue; + this.status = status == null ? LED_STATUS_FUNCTION_DEFAULT : status; + parameterOutArrayList.add(this); + parameterOut[paramID] = this; + } + + void setDefault() { + set(defaultValue); + } + + @Override + public double get() { + return iParamsOut[id]; + } + + @Override + public double getDefault() { + return defaultValue; + } + + public void set(double value) { + iParamsOut[id] = value; + } + + @SuppressWarnings("unchecked") + @Override + public void updateStatus() { + eParamsOutStatus[id] = status.apply(parent, this); + } + + @Override + public LedStatus getStatus(boolean update) { + if (update) { + updateStatus(); + } + return eParamsOutStatus[id]; + } + + @Override + public String getBrief() { + return name.apply(parent, this); + } + + @Override + public int id() { + return id; + } + + @Override + public int hatchId() { + return id % 10; + } + + @Override + public int parameterId() { + return id / 10; + } + } + + /** + * Make a field out of this... + */ + public class ParameterIn implements IParameter { + + public final int id; + public final double defaultValue; + IStatusFunction status; + INameFunction name; + + private ParameterIn(int paramID, double defaultValue, INameFunction name, IStatusFunction status) { + this.name = name == null ? NAME_FUNCTION_DEFAULT : name; + this.id = hatchNo + 10 * paramID; + if (paramID < 0 || paramID > 2) { + throw new IllegalArgumentException("Parameter id must be in 0 to 1 range"); + } + if (parameterIn[paramID] != null) { + throw new IllegalArgumentException("Parameter id already occupied"); + } + this.defaultValue = defaultValue; + this.status = status == null ? LED_STATUS_FUNCTION_DEFAULT : status; + parameterInArrayList.add(this); + parameterIn[paramID] = this; + } + + void setDefault() { + set(defaultValue); + } + + @Override + public double get() { + return iParamsIn[id]; + } + + void set(double value) { + iParamsIn[id] = value; + } + + @Override + public double getDefault() { + return defaultValue; + } + + @SuppressWarnings("unchecked") + @Override + public void updateStatus() { + eParamsInStatus[id] = status.apply(parent, this); + } + + @Override + public LedStatus getStatus(boolean update) { + if (update) { + updateStatus(); + } + return eParamsInStatus[id]; + } + + @Override + public String getBrief() { + return name.apply(parent, this); + } + + @Override + public int id() { + return id; + } + + @Override + public int hatchId() { + return id % 10; + } + + @Override + public int parameterId() { + return id / 10; + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/SoundLoop.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/SoundLoop.java new file mode 100644 index 0000000000..591f7d3be5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/SoundLoop.java @@ -0,0 +1,59 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.MovingSound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +@SideOnly(Side.CLIENT) +public class SoundLoop extends MovingSound { + + private final boolean whileActive; + private final boolean whileInactive; + private final int worldID; + private boolean fadeMe = false; + + public SoundLoop(ResourceLocation p_i45104_1_, IGregTechTileEntity base, boolean stopWhenActive, + boolean stopWhenInactive) { + super(p_i45104_1_); + this.whileActive = stopWhenActive; + this.whileInactive = stopWhenInactive; + xPosF = base.getXCoord(); + yPosF = base.getYCoord(); + zPosF = base.getZCoord(); + worldID = base.getWorld().provider.dimensionId; + repeat = true; + volume = 0.0625f; + } + + @Override + public void update() { + if (donePlaying) { + return; + } + if (fadeMe) { + volume -= 0.0625f; + if (volume <= 0) { + volume = 0; + donePlaying = true; + } + } else if (volume < 1) { + volume += 0.0625f; + } + World world = Minecraft.getMinecraft().thePlayer.worldObj; + donePlaying = world.provider.dimensionId != worldID + || !world.checkChunksExist((int) xPosF, (int) yPosF, (int) zPosF, (int) xPosF, (int) yPosF, (int) zPosF); + if (donePlaying) return; + TileEntity tile = world.getTileEntity((int) xPosF, (int) yPosF, (int) zPosF); + if (!(tile instanceof IGregTechTileEntity)) { + donePlaying = true; + return; + } + fadeMe |= ((IGregTechTileEntity) tile).isActive() ? whileActive : whileInactive; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java new file mode 100644 index 0000000000..6e5597516b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java @@ -0,0 +1,25 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base.render; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.common.render.GT_RenderedTexture; + +public class TT_RenderedExtendedFacingTexture extends GT_RenderedTexture { + + public TT_RenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha, boolean glow, + boolean stdOrient, boolean extFacing) { + super(aIcon, aRGBa, allowAlpha, glow, stdOrient, extFacing); + } + + public TT_RenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) { + this(aIcon, aRGBa, aAllowAlpha, false, false, true); + } + + public TT_RenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa) { + this(aIcon, aRGBa, true); + } + + public TT_RenderedExtendedFacingTexture(IIconContainer aIcon) { + this(aIcon, Dyes._NULL.mRGBa); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_BaseModule.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_BaseModule.java new file mode 100644 index 0000000000..004fc2b40a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_BaseModule.java @@ -0,0 +1,497 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules; + +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.GodforgeCasings; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.processInitialSettings; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +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.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GT_StructureUtility; + +public class GT_MetaTileEntity_EM_BaseModule extends GT_MetaTileEntity_MultiblockBase_EM { + + protected final int tier = getTier(); + protected boolean isConnected = false; + protected double overclockTimeFactor = 2d; + protected boolean isUpgrade83Unlocked = false; + protected boolean isMultiStepPlasmaCapable = false; + protected boolean isMagmatterCapable = false; + private boolean isVoltageConfigUnlocked = false; + protected UUID userUUID; + protected int machineHeat = 0; + protected int overclockHeat = 0; + protected int maximumParallel = 0; + protected int plasmaTier = 0; + protected float processingSpeedBonus = 0; + protected float energyDiscount = 0; + protected long processingVoltage = 2_000_000_000; + protected BigInteger powerTally = BigInteger.ZERO; + protected long recipeTally = 0; + private static Textures.BlockIcons.CustomIcon ScreenON; + private static Textures.BlockIcons.CustomIcon ScreenOFF; + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final int VOLTAGE_WINDOW_ID = 9; + private static final int TEXTURE_INDEX = 960; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + new String[][] { { " ", " BBB ", " BBBBB ", " BB~BB ", " BBBBB ", " BBB ", " " }, + { " CCC ", " CFFFC ", "CFFFFFC", "CFFFFFC", "CFFFFFC", " CFFFC ", " CCC " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " G ", " ", " ", " " } }) + .addElement('A', ofBlock(GregTech_API.sSolenoidCoilCasings, 9)) + .addElement( + 'B', + GT_StructureUtility.ofHatchAdderOptional( + GT_MetaTileEntity_EM_BaseModule::addClassicToMachineList, + TEXTURE_INDEX, + 1, + GodforgeCasings, + 0)) + .addElement('C', ofBlock(GodforgeCasings, 0)) + .addElement('D', ofBlock(GodforgeCasings, 1)) + .addElement('E', ofBlock(GodforgeCasings, 2)) + .addElement('F', ofBlock(GodforgeCasings, 3)) + .addElement('G', ofBlock(GodforgeCasings, 4)) + .build(); + + public GT_MetaTileEntity_EM_BaseModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_BaseModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_BaseModule(mName); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && isConnected) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aTick % 400 == 0) fixAllIssues(); + if (mEfficiency < 0) mEfficiency = 0; + } + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.blastFurnaceRecipes; + } + + @Override + public boolean drainEnergyInput(long EUtEffective, long Amperes) { + long EU_drain = EUtEffective * Amperes; + if (EU_drain == 0L) { + return true; + } else { + if (EU_drain > 0L) { + EU_drain = -EU_drain; + } + return addEUToGlobalEnergyMap(userUUID, EU_drain); + } + } + + public void connect() { + isConnected = true; + } + + public void disconnect() { + isConnected = false; + } + + public void setHeat(int heat) { + machineHeat = heat; + } + + public int getHeat() { + return machineHeat; + } + + public void setHeatForOC(int heat) { + overclockHeat = heat; + } + + public int getHeatForOC() { + return overclockHeat; + } + + public void setMaxParallel(int parallel) { + maximumParallel = parallel; + } + + public int getMaxParallel() { + return maximumParallel; + } + + public void setSpeedBonus(float bonus) { + processingSpeedBonus = bonus; + } + + public float getSpeedBonus() { + return processingSpeedBonus; + } + + public void setEnergyDiscount(float discount) { + energyDiscount = discount; + } + + public float getEnergyDiscount() { + return energyDiscount; + } + + public void setUpgrade83(boolean unlocked) { + isUpgrade83Unlocked = unlocked; + } + + public void setOverclockTimeFactor(double factor) { + overclockTimeFactor = factor; + } + + public double getOverclockTimeFactor() { + return overclockTimeFactor; + } + + public void setMultiStepPlasma(boolean isCapable) { + isMultiStepPlasmaCapable = isCapable; + } + + public void setProcessingVoltage(long Voltage) { + processingVoltage = Voltage; + } + + public long getProcessingVoltage() { + return processingVoltage; + } + + public void setMagmatterCapable(boolean isCapable) { + isMagmatterCapable = isCapable; + } + + public float getHeatEnergyDiscount() { + return isUpgrade83Unlocked ? 0.92f : 0.95f; + } + + public void setPlasmaTier(int tier) { + plasmaTier = tier; + } + + public int getPlasmaTier() { + return plasmaTier; + } + + public void setVoltageConfig(boolean unlocked) { + isVoltageConfigUnlocked = unlocked; + } + + public void setPowerTally(BigInteger amount) { + powerTally = amount; + } + + public BigInteger getPowerTally() { + return powerTally; + } + + public void addToPowerTally(BigInteger amount) { + powerTally = powerTally.add(amount); + } + + public void setRecipeTally(long amount) { + recipeTally = amount; + } + + public long getRecipeTally() { + return recipeTally; + } + + public void addToRecipeTally(long amount) { + recipeTally += amount; + } + + protected void fixAllIssues() { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } + + public int getTier() { + return tier; + } + + @Override + public long getMaxInputVoltage() { + return gregtech.api.enums.GT_Values.V[tier]; + } + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM(STRUCTURE_PIECE_MAIN, 3, 3, 0, stackSize, hintsOnly); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + fixAllIssues(); + return structureCheck_EM(STRUCTURE_PIECE_MAIN, 3, 3, 0); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide() && (aTick == 1)) { + userUUID = processInitialSettings(aBaseMetaTileEntity); + } + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(4, 4) + .setSize(190, 85)); + final SlotWidget inventorySlot = new SlotWidget(inventoryHandler, 1); + builder.widget( + inventorySlot.setPos(173, 167) + .setBackground(GT_UITextures.SLOT_DARK_GRAY)); + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + drawTexts(screenElements, inventorySlot); + builder.widget(screenElements); + + buildContext.addSyncedWindow(VOLTAGE_WINDOW_ID, this::createVoltageWindow); + + builder.widget( + TextWidget.dynamicText(this::connectionStatus) + .setDefaultColor(EnumChatFormatting.BLACK) + .setPos(75, 94) + .setSize(100, 10)); + + builder.widget(createPowerSwitchButton(builder)) + .widget(createVoidExcessButton(builder)) + .widget(createInputSeparationButton(builder)) + .widget(createBatchModeButton(builder)) + .widget(createLockToSingleRecipeButton(builder)) + .widget(createVoltageButton(builder)); + } + + protected Widget createVoltageButton(IWidgetBuilder builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isVoltageConfigUnlocked) { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(VOLTAGE_WINDOW_ID); + } + } + }) + .setPlayClickSound(isVoltageConfigUnlocked) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + if (isVoltageConfigUnlocked) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_DISABLED); + } + return ret.toArray(new IDrawable[0]); + }) + .addTooltip(translateToLocal("fog.button.voltageconfig.tooltip.01")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 129) + .setSize(16, 16) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> isVoltageConfigUnlocked, val -> isVoltageConfigUnlocked = val), + builder); + if (!isVoltageConfigUnlocked) { + button.addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.voltageconfig.tooltip.02")); + } + return button; + } + + protected ModularWindow createVoltageWindow(final EntityPlayer player) { + final int WIDTH = 158; + final int HEIGHT = 52; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add( + Alignment.BottomRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) + .add(WIDTH - 3, 0) + .subtract(0, 10))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.voltageinfo") + .setPos(3, 4) + .setSize(150, 20)) + .widget( + new NumericWidget().setSetter(val -> processingVoltage = (long) val) + .setGetter(() -> processingVoltage) + .setBounds(2_000_000_000, Long.MAX_VALUE) + .setDefaultValue(2_000_000_000) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(150, 18) + .setPos(4, 25) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) + .attachSyncer( + new FakeSyncWidget.LongSyncer(this::getProcessingVoltage, this::setProcessingVoltage), + builder)); + return builder.build(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_LOGO) + .setSize(18, 18) + .setPos(172, 67)); + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean willExplodeInRain() { + return false; + } + + private Text connectionStatus() { + String status = EnumChatFormatting.RED + + translateToLocal("gt.blockmachines.multimachine.FOG.modulestatus.false"); + if (isConnected) { + status = EnumChatFormatting.GREEN + translateToLocal("gt.blockmachines.multimachine.FOG.modulestatus.true"); + } + return new Text(translateToLocal("gt.blockmachines.multimachine.FOG.modulestatus") + " " + status); + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + NBT.setBoolean("isConnected", isConnected); + NBT.setBoolean("isVoltageConfigUnlocked", isVoltageConfigUnlocked); + NBT.setLong("processingVoltage", processingVoltage); + NBT.setLong("recipeTally", recipeTally); + NBT.setByteArray("powerTally", powerTally.toByteArray()); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(final NBTTagCompound NBT) { + isConnected = NBT.getBoolean("isConnected"); + isVoltageConfigUnlocked = NBT.getBoolean("isVoltageConfigUnlocked"); + processingVoltage = NBT.getLong("processingVoltage"); + recipeTally = NBT.getLong("recipeTally"); + powerTally = new BigInteger(NBT.getByteArray("powerTally")); + super.loadNBTData(NBT); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/GODFORGE_MODULE_ACTIVE"); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/SCREEN_OFF"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX), + new TT_RenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX) }; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_ExoticModule.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_ExoticModule.java new file mode 100644 index 0000000000..7e5c0d0b94 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_ExoticModule.java @@ -0,0 +1,529 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules; + +import static com.github.technus.tectech.loader.recipe.Godforge.exoticModuleMagmatterItemMap; +import static com.github.technus.tectech.loader.recipe.Godforge.exoticModulePlasmaFluidMap; +import static com.github.technus.tectech.loader.recipe.Godforge.exoticModulePlasmaItemMap; +import static com.github.technus.tectech.recipe.TecTechRecipeMaps.godforgeExoticMatterRecipes; +import static com.github.technus.tectech.util.GodforgeMath.getRandomIntInRange; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GT_RecipeBuilder.INGOTS; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.TierEU; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_EM_ExoticModule extends GT_MetaTileEntity_EM_BaseModule { + + private int numberOfFluids = 0; + private int numberOfItems = 0; + private long wirelessEUt = 0; + private long EUt = 0; + private long actualParallel = 0; + private boolean recipeInProgress = false; + private boolean magmatterMode = false; + private FluidStack[] randomizedFluidInput = new FluidStack[] {}; + private ItemStack[] randomizedItemInput = new ItemStack[] {}; + List inputPlasmas = new ArrayList<>(); + private GT_Recipe plasmaRecipe = null; + private static RecipeMap tempRecipeMap = RecipeMapBuilder.of("bye") + .maxIO(0, 0, 7, 2) + .disableRegisterNEI() + .build(); + private static final RecipeMap emptyRecipeMap = RecipeMapBuilder.of("hey") + .maxIO(0, 0, 7, 2) + .disableRegisterNEI() + .build(); + private static final int NUMBER_OF_INPUTS = 7; + + public GT_MetaTileEntity_EM_ExoticModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_ExoticModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_ExoticModule(mName); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected Stream findRecipeMatches(@Nullable RecipeMap map) { + if (!recipeInProgress) { + actualParallel = getMaxParallel(); + FluidStack outputFluid = MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000 * actualParallel); + tempRecipeMap = emptyRecipeMap; + if (magmatterMode) { + randomizedItemInput = getRandomItemInputs(exoticModuleMagmatterItemMap, 1); + numberOfItems = 1; + numberOfFluids = 2; + int timeAmount = getRandomIntInRange(1, 50); + int spaceAmount = getRandomIntInRange(51, 100); + randomizedFluidInput = new FluidStack[] { MaterialsUEVplus.Time.getMolten(timeAmount * 1000L), + MaterialsUEVplus.Space.getMolten(spaceAmount * 1000L) }; + inputPlasmas = new ArrayList<>( + Arrays.asList( + convertItemToPlasma(randomizedItemInput, (spaceAmount - timeAmount) * actualParallel))); + inputPlasmas.add(MaterialsUEVplus.Time.getMolten(timeAmount * actualParallel)); + inputPlasmas.add(MaterialsUEVplus.Space.getMolten(spaceAmount * actualParallel)); + outputFluid = MaterialsUEVplus.MagMatter.getMolten(144 * actualParallel); + } else { + numberOfFluids = getRandomIntInRange(0, NUMBER_OF_INPUTS); + numberOfItems = NUMBER_OF_INPUTS - numberOfFluids; + randomizedFluidInput = getRandomFluidInputs(exoticModulePlasmaFluidMap, numberOfFluids); + randomizedItemInput = getRandomItemInputs(exoticModulePlasmaItemMap, numberOfItems); + + if (numberOfFluids != 0) { + for (FluidStack fluidStack : randomizedFluidInput) { + fluidStack.amount = 1000 * getRandomIntInRange(1, 64); + } + } + + if (numberOfItems != 0) { + for (ItemStack itemStack : randomizedItemInput) { + itemStack.stackSize = getRandomIntInRange(1, 64); + } + } + + inputPlasmas = new ArrayList<>( + Arrays.asList(convertItemToPlasma(randomizedItemInput, actualParallel))); + inputPlasmas.addAll(Arrays.asList(convertFluidToPlasma(randomizedFluidInput, actualParallel))); + } + plasmaRecipe = new GT_Recipe( + false, + null, + null, + null, + null, + inputPlasmas.toArray(new FluidStack[0]), + new FluidStack[] { outputFluid }, + 10 * SECONDS * (int) actualParallel, + (int) TierEU.RECIPE_MAX, + 0); + + tempRecipeMap.add(plasmaRecipe); + } + return tempRecipeMap.getAllRecipes() + .parallelStream(); + } + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + if (!recipeInProgress) { + maxParallel = 1; + wirelessEUt = (long) recipe.mEUt * maxParallel; + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + tempRecipeMap = emptyRecipeMap; + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + + if (numberOfFluids != 0) { + for (FluidStack fluidStack : randomizedFluidInput) { + dumpFluid( + mOutputHatches, + new FluidStack( + fluidStack.getFluid(), + (int) (fluidStack.amount / 1000 * actualParallel)), + false); + } + } + + if (numberOfItems != 0) { + long multiplier = actualParallel; + if (magmatterMode) { + multiplier = 1; + } + for (ItemStack itemStack : randomizedItemInput) { + int stacksize = (int) (itemStack.stackSize * multiplier); + ItemStack tmpItem = itemStack.copy(); + // split itemStacks > 64 + while (stacksize >= 64) { + tmpItem.stackSize = 64; + addOutput(tmpItem); + stacksize -= 64; + } + tmpItem.stackSize = stacksize; + addOutput(tmpItem); + + } + } + + recipeInProgress = true; + } + if (new HashSet<>(Arrays.asList(inputFluids)).containsAll(inputPlasmas)) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + return SimpleCheckRecipeResult.ofFailure("waiting_for_inputs"); + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GT_Recipe recipe) { + wirelessEUt = (long) recipe.mEUt * maxParallel; + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + addToRecipeTally(calculatedParallels); + EUt = calculatedEut; + setCalculatedEut(0); + tempRecipeMap = emptyRecipeMap; + recipeInProgress = false; + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + } + + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public RecipeMap getRecipeMap() { + return godforgeExoticMatterRecipes; + } + + private FluidStack[] getRandomFluidInputs(HashMap fluidMap, int numberOfFluids) { + int cumulativeWeight = 0; + + List> fluidEntryList = new ArrayList<>(fluidMap.entrySet()); + + List cumulativeWeights = new ArrayList<>(); + for (Map.Entry entry : fluidEntryList) { + cumulativeWeight += entry.getValue(); + cumulativeWeights.add(cumulativeWeight); + } + + List pickedFluids = new ArrayList<>(); + for (int i = 0; i < numberOfFluids; i++) { + int randomWeight = getRandomIntInRange(1, cumulativeWeight); + // Find the corresponding FluidStack based on randomWeight + for (int j = 0; j < cumulativeWeights.size(); j++) { + if (randomWeight <= cumulativeWeights.get(j)) { + FluidStack pickedFluid = fluidEntryList.get(j) + .getKey(); + // prevent duplicates + if (pickedFluids.contains(pickedFluid)) { + i--; + break; + } + pickedFluids.add(pickedFluid); + break; + } + } + } + + return pickedFluids.toArray(new FluidStack[0]); + + } + + private ItemStack[] getRandomItemInputs(HashMap itemMap, int numberOfItems) { + int cumulativeWeight = 0; + + List> itemEntryList = new ArrayList<>(itemMap.entrySet()); + + List cumulativeWeights = new ArrayList<>(); + for (Map.Entry entry : itemEntryList) { + cumulativeWeight += entry.getValue(); + cumulativeWeights.add(cumulativeWeight); + } + + List pickedItems = new ArrayList<>(); + for (int i = 0; i < numberOfItems; i++) { + int randomWeight = getRandomIntInRange(1, cumulativeWeight); + // Find the corresponding ItemStack based on randomWeight + for (int j = 0; j < cumulativeWeights.size(); j++) { + if (randomWeight <= cumulativeWeights.get(j)) { + ItemStack pickedItem = itemEntryList.get(j) + .getKey(); + // prevent duplicates + if (pickedItems.contains(pickedItem)) { + i--; + break; + } + pickedItems.add(pickedItem); + break; + } + } + } + return pickedItems.toArray(new ItemStack[0]); + + } + + private FluidStack[] convertItemToPlasma(ItemStack[] items, long multiplier) { + List plasmas = new ArrayList<>(); + + for (ItemStack itemStack : items) { + String dict = OreDictionary.getOreName(OreDictionary.getOreIDs(itemStack)[0]); + // substring 8 because dustTiny is 8 characters long and there is no other possible oreDict + String strippedOreDict = dict.substring(8); + plasmas.add( + FluidRegistry.getFluidStack( + "plasma." + strippedOreDict.toLowerCase(), + (int) (INGOTS * multiplier * itemStack.stackSize))); + } + + return plasmas.toArray(new FluidStack[0]); + } + + private FluidStack[] convertFluidToPlasma(FluidStack[] fluids, long multiplier) { + List plasmas = new ArrayList<>(); + + for (FluidStack fluidStack : fluids) { + String[] fluidName = fluidStack.getUnlocalizedName() + .split("\\."); + plasmas.add( + FluidRegistry.getFluidStack( + "plasma." + fluidName[fluidName.length - 1], + (int) (multiplier * fluidStack.amount))); + } + + return plasmas.toArray(new FluidStack[0]); + } + + @Override + public boolean supportsSingleRecipeLocking() { + return false; + } + + @Override + public boolean supportsBatchMode() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + + NBT.setBoolean("recipeInProgress", recipeInProgress); + NBT.setBoolean("magmatterMode", magmatterMode); + + // Store damage values/stack sizes of input plasmas + NBTTagCompound fluidStackListNBTTag = new NBTTagCompound(); + fluidStackListNBTTag.setLong("numberOfPlasmas", inputPlasmas.size()); + + int indexFluids = 0; + for (FluidStack fluidStack : inputPlasmas) { + // Save fluid amount to NBT + fluidStackListNBTTag.setLong(indexFluids + "fluidAmount", fluidStack.amount); + + // Save FluidStack to NBT + NBT.setTag(indexFluids + "fluidStack", fluidStack.writeToNBT(new NBTTagCompound())); + + indexFluids++; + } + + NBT.setTag("inputPlasmas", fluidStackListNBTTag); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(final NBTTagCompound NBT) { + + recipeInProgress = NBT.getBoolean("recipeInProgress"); + magmatterMode = NBT.getBoolean("magmatterMode"); + + // Load damage values/fluid amounts of input plasmas and convert back to fluids + NBTTagCompound tempFluidTag = NBT.getCompoundTag("inputPlasmas"); + + // Iterate over all stored fluids + for (int indexFluids = 0; indexFluids < tempFluidTag.getLong("numberOfPlasmas"); indexFluids++) { + + // Load fluid amount from NBT + int fluidAmount = tempFluidTag.getInteger(indexFluids + "fluidAmount"); + + // Load FluidStack from NBT + FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(NBT.getCompoundTag(indexFluids + "fluidStack")); + + inputPlasmas.add(new FluidStack(fluidStack, fluidAmount)); + } + FluidStack outputFluid = MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000); + + if (magmatterMode) { + outputFluid = MaterialsUEVplus.MagMatter.getMolten(144); + } + + tempRecipeMap.add( + new GT_Recipe( + false, + null, + null, + null, + null, + inputPlasmas.toArray(new FluidStack[0]), + new FluidStack[] { outputFluid }, + 10 * SECONDS, + (int) TierEU.RECIPE_MAX, + 0)); + + super.loadNBTData(NBT); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder.widget(magmatterSwitch(builder)); + + } + + protected ButtonWidget magmatterSwitch(IWidgetBuilder builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isMagmatterCapable) { + magmatterMode = !magmatterMode; + } + }) + .setPlayClickSound(isMagmatterCapable) + .setBackground(() -> { + List ret = new ArrayList<>(); + if (isMagmatterModeOn()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + if (isMagmatterCapable) { + ret.add(GT_UITextures.OVERLAY_BUTTON_CHECKMARK); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_DISABLE); + } + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + if (isMagmatterCapable) { + ret.add(GT_UITextures.OVERLAY_BUTTON_CROSS); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_DISABLE); + } + } + if (!isMagmatterCapable) { + ret.add(GT_UITextures.OVERLAY_BUTTON_DISABLE); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isMagmatterModeOn, this::setMagmatterMode), builder) + .addTooltip(translateToLocal("fog.button.magmattermode.tooltip.01")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 91) + .setSize(16, 16) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> isMagmatterCapable, this::setMagmatterCapable), + builder); + if (!isMagmatterCapable) { + button.addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.magmattermode.tooltip.02")); + } + return (ButtonWidget) button; + } + + public boolean isMagmatterModeOn() { + return magmatterMode; + } + + private void setMagmatterMode(boolean enabled) { + magmatterMode = enabled; + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Exotic Matter Producer") + .addInfo("Controller block of the Quark Gluon Plasma Module") + .addInfo("Uses a Star to to turn Items into Quark Gluon Plasma") + .addSeparator() + .beginStructureBlock(1, 4, 2, false) + .addEnergyHatch("Any Infinite Spacetime Casing", 1) + .addMaintenanceHatch("Any Infinite Spacetime Casing", 1) + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + GT_Utility.formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_MoltenModule.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_MoltenModule.java new file mode 100644 index 0000000000..cfd0548f9e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_MoltenModule.java @@ -0,0 +1,227 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules; + +import static gregtech.api.util.GT_OreDictUnificator.getAssociation; +import static gregtech.api.util.GT_ParallelHelper.addFluidsLong; +import static gregtech.api.util.GT_ParallelHelper.addItemsLong; +import static gregtech.api.util.GT_RecipeBuilder.BUCKETS; +import static gregtech.api.util.GT_RecipeBuilder.INGOTS; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; + +import java.math.BigInteger; +import java.util.ArrayList; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.util.CommonValues; + +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_EM_MoltenModule extends GT_MetaTileEntity_EM_BaseModule { + + private long EUt = 0; + private int currentParallel = 0; + + public GT_MetaTileEntity_EM_MoltenModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_MoltenModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_MoltenModule(mName); + } + + long wirelessEUt = 0; + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + private FluidStack[] meltableItems; + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + + if (recipe.mSpecialValue > getHeat()) { + return CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + wirelessEUt = (long) recipe.mEUt * getMaxParallel(); + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + + meltableItems = new FluidStack[recipe.mOutputs.length]; + for (int i = 0; i < recipe.mOutputs.length; i++) { + ItemStack item = recipe.getOutput(i); + if (item == null) { + continue; + } + // if this is null it has to be a gt++ material + ItemData data = getAssociation(item); + Materials mat = data == null ? null : data.mMaterial.mMaterial; + if (mat != null) { + if (mat.mStandardMoltenFluid != null) { + meltableItems[i] = mat.getMolten(INGOTS); + } else if (mat.mFluid != null) { + meltableItems[i] = mat.getFluid(BUCKETS); + } + } else { + String dict = OreDictionary.getOreName(OreDictionary.getOreIDs(item)[0]); + // substring 8 because ingotHot is 8 characters long + String strippedOreDict = dict.substring(8); + meltableItems[i] = FluidRegistry + .getFluidStack("molten." + strippedOreDict.toLowerCase(), INGOTS); + } + } + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setRecipeHeat(recipe.mSpecialValue) + .setHeatOC(true) + .setHeatDiscount(true) + .setMachineHeat(getHeatForOC()) + .setHeatDiscountMultiplier(getHeatEnergyDiscount()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GT_Recipe recipe) { + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(calculatedEut * duration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + addToRecipeTally(calculatedParallels); + currentParallel = calculatedParallels; + EUt = calculatedEut; + setCalculatedEut(0); + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected GT_ParallelHelper createParallelHelper(@Nonnull GT_Recipe recipe) { + return super.createParallelHelper(recipe).setCustomItemOutputCalculation(currentParallel -> { + ArrayList outputItems = new ArrayList<>(); + for (int i = 0; i < recipe.mOutputs.length; i++) { + ItemStack item = recipe.getOutput(i); + if (item == null || meltableItems[i] != null) { + continue; + } + ItemStack itemToAdd = item.copy(); + addItemsLong(outputItems, itemToAdd, (long) item.stackSize * currentParallel); + } + return outputItems.toArray(new ItemStack[0]); + }) + .setCustomFluidOutputCalculation(currentParallel -> { + ArrayList fluids = new ArrayList<>(); + + for (int i = 0; i < recipe.mOutputs.length; i++) { + FluidStack fluid = meltableItems[i]; + if (fluid == null) { + continue; + } + FluidStack fluidToAdd = fluid.copy(); + long fluidAmount = (long) fluidToAdd.amount * recipe.mOutputs[i].stackSize + * currentParallel; + addFluidsLong(fluids, fluidToAdd, fluidAmount); + } + + for (int i = 0; i < recipe.mFluidOutputs.length; i++) { + FluidStack fluid = recipe.getFluidOutput(i); + if (fluid == null) { + continue; + } + FluidStack fluidToAdd = fluid.copy(); + addFluidsLong(fluids, fluidToAdd, (long) fluidToAdd.amount * currentParallel); + } + return fluids.toArray(new FluidStack[0]); + }); + } + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setMaxParallel(getMaxParallel()); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public String[] getInfoData() { + ArrayList str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + GT_Utility.formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(currentParallel)); + str.add(YELLOW + "Heat Capacity: " + RESET + formatNumbers(getHeat())); + str.add(YELLOW + "Effective Heat Capacity: " + RESET + formatNumbers(getHeatForOC())); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Blast Furnace") + .addInfo("Controller block of the Molten Module") + .addInfo("Uses a Star to to melt Metals") + .addSeparator() + .beginStructureBlock(1, 4, 2, false) + .addEnergyHatch("Any Infinite Spacetime Casing", 1) + .addMaintenanceHatch("Any Infinite Spacetime Casing", 1) + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_PlasmaModule.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_PlasmaModule.java new file mode 100644 index 0000000000..8143c6fea4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_PlasmaModule.java @@ -0,0 +1,226 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules; + +import static com.github.technus.tectech.recipe.TecTechRecipeMaps.godforgePlasmaRecipes; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Objects; + +import javax.annotation.Nonnull; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import gregtech.api.enums.SoundResource; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_EM_PlasmaModule extends GT_MetaTileEntity_EM_BaseModule { + + private long EUt = 0; + private int currentParallel = 0; + private boolean debug = true; + private int inputMaxParallel = 0; + + public GT_MetaTileEntity_EM_PlasmaModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_PlasmaModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_PlasmaModule(mName); + } + + long wirelessEUt = 0; + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + wirelessEUt = (long) recipe.mEUt * getMaxParallel(); + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + if (recipe.mSpecialValue > getPlasmaTier() + || Objects.equals(recipe.mSpecialItems.toString(), "true") && !isMultiStepPlasmaCapable) { + return SimpleCheckRecipeResult.ofFailure("missing_upgrades"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GT_Recipe recipe) { + wirelessEUt = (long) recipe.mEUt * maxParallel; + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + addToRecipeTally(calculatedParallels); + currentParallel = calculatedParallels; + EUt = calculatedEut; + setCalculatedEut(0); + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + } + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setMaxParallel(getMaxParallel()); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + if (debug) { + builder.widget(createTestButton(builder)) + .widget(createTestButton2()) + .widget(createTestButton3()); + } + } + + protected Widget createTestButton(IWidgetBuilder builder) { + return new ButtonWidget() + .setOnClick((clickData, widget) -> isMultiStepPlasmaCapable = !isMultiStepPlasmaCapable) + .setPlayClickSoundResource( + () -> isAllowedToWork() ? SoundResource.GUI_BUTTON_UP.resourceLocation + : SoundResource.GUI_BUTTON_DOWN.resourceLocation) + .setBackground(() -> { + if (isMultiStepPlasmaCapable) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, + GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; + } else { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, + GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; + } + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isAllowedToWork, val -> { + if (val) enableWorking(); + else disableWorking(); + }), builder) + .addTooltip("multi-step") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 100) + .setSize(16, 16); + } + + protected Widget createTestButton2() { + return new TextFieldWidget().setSetterInt(this::setPlasmaTier) + .setGetterInt(this::getPlasmaTier) + .setNumbers(0, 2) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setPos(3, 18) + .addTooltip("fusion tier") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setSize(16, 16) + .setPos(174, 80) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD); + } + + protected Widget createTestButton3() { + return new TextFieldWidget().setSetterInt(val -> inputMaxParallel = val) + .setGetterInt(() -> inputMaxParallel) + .setNumbers(0, Integer.MAX_VALUE) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setPos(3, 18) + .addTooltip("parallel") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setSize(70, 16) + .setPos(174, 60) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD); + } + + @Override + public RecipeMap getRecipeMap() { + return godforgePlasmaRecipes; + } + + @Override + public String[] getInfoData() { + ArrayList str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + GT_Utility.formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(currentParallel)); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Plasma Fabricator") + .addInfo("Controller block of the Plasma Module") + .addInfo("Uses a Star to to turn Metals into Plasma") + .addSeparator() + .beginStructureBlock(1, 4, 2, false) + .addEnergyHatch("Any Infinite Spacetime Casing", 1) + .addMaintenanceHatch("Any Infinite Spacetime Casing", 1) + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_SmeltingModule.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_SmeltingModule.java new file mode 100644 index 0000000000..ee77d7cc95 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/godforge_modules/GT_MetaTileEntity_EM_SmeltingModule.java @@ -0,0 +1,228 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules; + +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.nbt.NBTTagCompound; + +import org.jetbrains.annotations.NotNull; + +import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_EM_SmeltingModule extends GT_MetaTileEntity_EM_BaseModule { + + private long EUt = 0; + private long currentParallel = 0; + private boolean furnaceMode = false; + + public GT_MetaTileEntity_EM_SmeltingModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_SmeltingModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_SmeltingModule(mName); + } + + @Override + public RecipeMap getRecipeMap() { + return furnaceMode ? RecipeMaps.furnaceRecipes : RecipeMaps.blastFurnaceRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.blastFurnaceRecipes, RecipeMaps.furnaceRecipes); + } + + long wirelessEUt = 0; + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + + if (recipe.mSpecialValue > getHeat()) { + return CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + + wirelessEUt = (long) recipe.mEUt * getMaxParallel(); + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GT_Recipe recipe) { + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(calculatedEut * duration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + if (!furnaceMode) { + addToRecipeTally(calculatedParallels); + } + currentParallel = calculatedParallels; + EUt = calculatedEut; + setCalculatedEut(0); + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setRecipeHeat(recipe.mSpecialValue) + .setHeatOC(true) + .setHeatDiscount(true) + .setMachineHeat(getHeatForOC()) + .setHeatDiscountMultiplier(getHeatEnergyDiscount()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + } + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setMaxParallel(getMaxParallel()); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder.widget(furnaceSwitch(builder)); + + } + + protected ButtonWidget furnaceSwitch(IWidgetBuilder builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> furnaceMode = !furnaceMode) + .setPlayClickSound(true) + .setBackground(() -> { + List ret = new ArrayList<>(); + if (isFurnaceModeOn()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + ret.add(GT_UITextures.OVERLAY_BUTTON_CHECKMARK); + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + ret.add(GT_UITextures.OVERLAY_BUTTON_CROSS); + + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isFurnaceModeOn, this::setFurnaceMode), builder) + .addTooltip(translateToLocal("fog.button.furnacemode.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 91) + .setSize(16, 16); + return (ButtonWidget) button; + } + + private boolean isFurnaceModeOn() { + return furnaceMode; + } + + private void setFurnaceMode(boolean enabled) { + furnaceMode = enabled; + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + NBT.setBoolean("furnaceMode", furnaceMode); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(final NBTTagCompound NBT) { + furnaceMode = NBT.getBoolean("furnaceMode"); + super.loadNBTData(NBT); + } + + @Override + public String[] getInfoData() { + ArrayList str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + GT_Utility.formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(currentParallel)); + str.add(YELLOW + "Heat Capacity: " + RESET + formatNumbers(getHeat())); + str.add(YELLOW + "Effective Heat Capacity: " + RESET + formatNumbers(getHeatForOC())); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Blast Furnace, Furnace") + .addInfo("Controller block of the Smelting Module") + .addInfo("Uses a Star to Smelt Metals") + .addSeparator() + .beginStructureBlock(1, 4, 2, false) + .addEnergyHatch("Any Infinite Spacetime Casing", 1) + .addMaintenanceHatch("Any Infinite Spacetime Casing", 1) + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Data.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Data.java new file mode 100644 index 0000000000..6ba5dd753c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Data.java @@ -0,0 +1,52 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GT_MetaTileEntity_PipeBlock_Data extends GT_MetaTileEntity_Pipe_Data { + + public GT_MetaTileEntity_PipeBlock_Data(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_PipeBlock_Data(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_PipeBlock_Data(mName); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); + } + + @Override + public float getThickNess() { + return 1f; + } + + @Override + public float getExplosionResistance(ForgeDirection side) { + return 1000.0f; + } + + @Override + public String[] getDescription() { + return ArrayUtils.add( + super.getDescription(), + EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.desc.4")); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Energy.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Energy.java new file mode 100644 index 0000000000..469c5b786a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_PipeBlock_Energy.java @@ -0,0 +1,52 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GT_MetaTileEntity_PipeBlock_Energy extends GT_MetaTileEntity_Pipe_Energy { + + public GT_MetaTileEntity_PipeBlock_Energy(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_PipeBlock_Energy(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_PipeBlock_Energy(mName); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); + } + + @Override + public float getThickNess() { + return 1f; + } + + @Override + public float getExplosionResistance(ForgeDirection side) { + return 1000.0f; + } + + @Override + public String[] getDescription() { + return ArrayUtils.add( + super.getDescription(), + EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.desc.4")); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java new file mode 100644 index 0000000000..b9428fcc1c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java @@ -0,0 +1,316 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.pipe.IActivePipe; +import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GT_Mod; +import gregtech.api.enums.Dyes; +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.BaseMetaPipeEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.common.GT_Client; + +/** + * Created by Tec on 26.02.2017. + */ +public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConnectsToDataPipe, IActivePipe { + + private static Textures.BlockIcons.CustomIcon EMpipe; + private static Textures.BlockIcons.CustomIcon EMbar, EMbarActive; + public byte connectionCount = 0; + + private boolean active; + + public GT_MetaTileEntity_Pipe_Data(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + } + + public GT_MetaTileEntity_Pipe_Data(String aName) { + super(aName, 0); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Pipe_Data(mName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_DATA"); + EMbar = new Textures.BlockIcons.CustomIcon("iconsets/EM_BAR"); + EMbarActive = new Textures.BlockIcons.CustomIcon("iconsets/EM_BAR_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections, + int colorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { new GT_RenderedTexture(EMpipe), + new GT_RenderedTexture( + getActive() ? EMbarActive : EMbar, + Dyes.getModulation(colorIndex, MACHINE_METAL.getRGBA())) }; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void loadNBTData(NBTTagCompound nbtTagCompound) { + active = nbtTagCompound.getBoolean("eActive"); + } + + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setBoolean("eActive", active); + } + + @Override + public boolean renderInside(ForgeDirection side) { + return false; + } + + @Override + public byte getTileEntityBaseType() { + return 4; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.pipe.datastream.desc.0"), // Advanced + // data + // transmission + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.datastream.desc.1"), // Don't stare at the beam! + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.datastream.desc.2"), // Must be + // painted to + // work + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.datastream.desc.3") // Do not cross or + // split + }; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isClientSide()) { + NetworkDispatcher.INSTANCE.sendToServer(new PipeActivityMessage.PipeActivityQuery(this)); + } + onPostTick(aBaseMetaTileEntity, 31); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if ((aTick & 31) == 31) { + if (TecTech.RANDOM.nextInt(15) == 0) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + if (active) { + active = false; + } + mConnections = 0; + connectionCount = 0; + byte myColor = aBaseMetaTileEntity.getColorization(); + if (aBaseMetaTileEntity.getColorization() < 0) { + return; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final ForgeDirection oppositeSide = side.getOpposite(); + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); + if (tTileEntity instanceof IConnectsToDataPipe) { + byte tColor = ((IConnectsToDataPipe) tTileEntity).getColorization(); + if (tColor != myColor) { + continue; + } + if (((IConnectsToDataPipe) tTileEntity).canConnectData(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } + } else if (tTileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + if (meta instanceof IConnectsToDataPipe) { + byte tColor = ((IConnectsToDataPipe) meta).getColorization(); + if (tColor != myColor) { + continue; + } + if (((IConnectsToDataPipe) meta).canConnectData(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } + } + } + } + } + } else if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { + aBaseMetaTileEntity.issueTextureUpdate(); + } + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return true; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source) { + if (connectionCount != 2) { + return null; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if ((mConnections & 1 << side.ordinal()) == 0) { + continue; // if not connected continue + } + TileEntity next = getBaseMetaTileEntity().getTileEntityAtSide(side); + if (next instanceof IConnectsToDataPipe && next != source) { + if (((IConnectsToDataPipe) next).isDataInputFacing(side.getOpposite())) { + return (IConnectsToDataPipe) next; + } + } else if (next instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) next).getMetaTileEntity(); + if (meta instanceof IConnectsToDataPipe connecsToPipe && meta != source) { + if (meta instanceof GT_MetaTileEntity_Pipe_Data pipeData && pipeData.connectionCount == 2) { + pipeData.markUsed(); + return connecsToPipe; + } + if (connecsToPipe.isDataInputFacing(side.getOpposite())) { + return connecsToPipe; + } + } + } + } + return null; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + float tSpace = (1f - 0.375f) / 2; + float tSide0 = tSpace; + float tSide1 = 1f - tSpace; + float tSide2 = tSpace; + float tSide3 = 1f - tSpace; + float tSide4 = tSpace; + float tSide5 = 1f - tSpace; + + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.DOWN) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.UP) != 0) { + tSide2 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.NORTH) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.SOUTH) != 0) { + tSide0 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.WEST) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide3 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.EAST) != 0) { + tSide0 = tSide2 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + + byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; + if ((tConn & 1 << ForgeDirection.DOWN.ordinal()) != 0) { + tSide0 = 0f; + } + if ((tConn & 1 << ForgeDirection.UP.ordinal()) != 0) { + tSide1 = 1f; + } + if ((tConn & 1 << ForgeDirection.NORTH.ordinal()) != 0) { + tSide2 = 0f; + } + if ((tConn & 1 << ForgeDirection.SOUTH.ordinal()) != 0) { + tSide3 = 1f; + } + if ((tConn & 1 << ForgeDirection.WEST.ordinal()) != 0) { + tSide4 = 0f; + } + if ((tConn & 1 << ForgeDirection.EAST.ordinal()) != 0) { + tSide5 = 1f; + } + + return AxisAlignedBB + .getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + } + + @Override + public float getThickNess() { + if (GT_Mod.instance.isClientSide() && GT_Client.hideValue == 1) { + return 0.0625F; + } + return 0.375f; + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return true; + } + + @Override + public byte getColorization() { + return getBaseMetaTileEntity().getColorization(); + } + + @Override + public void markUsed() { + this.active = true; + } + + @Override + public void setActive(boolean state) { + if (state != active) { + active = state; + getBaseMetaTileEntity().issueTextureUpdate(); + } + } + + @Override + public boolean getActive() { + return active; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java new file mode 100644 index 0000000000..264bc77d4a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java @@ -0,0 +1,285 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.pipe.IActivePipe; +import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; +import com.github.technus.tectech.util.CommonValues; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GT_Mod; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.PowerLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.common.GT_Client; + +public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements IConnectsToEnergyTunnel, IActivePipe { + + static Textures.BlockIcons.CustomIcon EMcandy, EMCandyActive; + private static Textures.BlockIcons.CustomIcon EMpipe; + public byte connectionCount = 0; + + private boolean active; + + public GT_MetaTileEntity_Pipe_Energy(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + } + + public GT_MetaTileEntity_Pipe_Energy(String aName) { + super(aName, 0); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Pipe_Energy(mName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + EMcandy = new Textures.BlockIcons.CustomIcon("iconsets/EM_CANDY"); + EMCandyActive = new Textures.BlockIcons.CustomIcon("iconsets/EM_CANDY_ACTIVE"); + EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_LASER"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections, + int colorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { new GT_RenderedTexture(EMpipe), + new GT_RenderedTexture( + getActive() ? EMCandyActive : EMcandy, + Dyes.getModulation(colorIndex, MACHINE_METAL.getRGBA())) }; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void loadNBTData(NBTTagCompound nbtTagCompound) { + active = nbtTagCompound.getBoolean("eActive"); + } + + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setBoolean("eActive", active); + } + + @Override + public boolean renderInside(ForgeDirection side) { + return false; + } + + @Override + public byte getTileEntityBaseType() { + return 4; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.pipe.energystream.desc.0"), // Laser + // tunneling + // device. + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.energystream.desc.1"), // Bright Vacuum!!! + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.energystream.desc.2"), // Must be + // painted to + // work + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.energystream.desc.3") // Do not split + // or turn + }; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (getBaseMetaTileEntity().isClientSide()) { + NetworkDispatcher.INSTANCE.sendToServer(new PipeActivityMessage.PipeActivityQuery(this)); + } + onPostTick(aBaseMetaTileEntity, 31); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if ((aTick & 31) == 31) { + if (TecTech.RANDOM.nextInt(15) == 0) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + if (active) { + active = false; + } + mConnections = 0; + connectionCount = 0; + if (aBaseMetaTileEntity.getColorization() < 0) { + return; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final ForgeDirection oppositeSide = side.getOpposite(); + // if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(b0).alwaysLookConnected(b0, + // aBaseMetaTileEntity.getCoverIDAtSide(b0), aBaseMetaTileEntity.getCoverDataAtSide(b0), + // aBaseMetaTileEntity)) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); + if (tTileEntity instanceof IColoredTileEntity) { + // if (aBaseMetaTileEntity.getColorization() >= 0) { + byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if (tColor != aBaseMetaTileEntity.getColorization()) { + continue; + } + // } + } + if (tTileEntity instanceof PowerLogicHost) { + PowerLogic logic = ((PowerLogicHost) tTileEntity).getPowerLogic(oppositeSide); + if (logic != null && logic.canUseLaser()) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + continue; + } + } + if (tTileEntity instanceof IConnectsToEnergyTunnel + && ((IConnectsToEnergyTunnel) tTileEntity).canConnect(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } else if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IConnectsToEnergyTunnel) { + if (((IConnectsToEnergyTunnel) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()) + .canConnect(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } + } + } + } + + } else if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { + aBaseMetaTileEntity.issueTextureUpdate(); + } + } + + @Override + public void setActive(boolean state) { + if (state != active) { + active = state; + getBaseMetaTileEntity().issueTextureUpdate(); + } + } + + @Override + public boolean getActive() { + return active; + } + + @Override + public void markUsed() { + this.active = true; + } + + @Override + public boolean canConnect(ForgeDirection side) { + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + float tSpace = (1f - 0.5f) / 2; + float tSide0 = tSpace; + float tSide1 = 1f - tSpace; + float tSide2 = tSpace; + float tSide3 = 1f - tSpace; + float tSide4 = tSpace; + float tSide5 = 1f - tSpace; + + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.DOWN) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.UP) != 0) { + tSide2 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.NORTH) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.SOUTH) != 0) { + tSide0 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.WEST) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide3 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.EAST) != 0) { + tSide0 = tSide2 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + + byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; + if ((tConn & 1 << ForgeDirection.DOWN.ordinal()) != 0) { + tSide0 = 0f; + } + if ((tConn & 1 << ForgeDirection.UP.ordinal()) != 0) { + tSide1 = 1f; + } + if ((tConn & 1 << ForgeDirection.NORTH.ordinal()) != 0) { + tSide2 = 0f; + } + if ((tConn & 1 << ForgeDirection.SOUTH.ordinal()) != 0) { + tSide3 = 1f; + } + if ((tConn & 1 << ForgeDirection.WEST.ordinal()) != 0) { + tSide4 = 0f; + } + if ((tConn & 1 << ForgeDirection.EAST.ordinal()) != 0) { + tSide5 = 1f; + } + + return AxisAlignedBB + .getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + } + + @Override + public float getThickNess() { + if (GT_Mod.instance.isClientSide() && GT_Client.hideValue == 1) { + return 0.0625F; + } + return 0.5f; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java new file mode 100644 index 0000000000..f8ed346fa9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java @@ -0,0 +1,271 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_POWER_TT; +import static com.github.technus.tectech.util.CommonValues.VN; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; + +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.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +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; + +public class GT_MetaTileEntity_BuckConverter extends GT_MetaTileEntity_TieredMachineBlock + implements IAddUIWidgets, IAddGregtechLogo { + + private static GT_RenderedTexture BUCK, BUCK_ACTIVE; + public int EUT = 0, AMP = 0; + private static NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public GT_MetaTileEntity_BuckConverter(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.machine.tt.buck.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.machine.tt.buck.desc.1"), }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_BuckConverter(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TT_Utility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_BuckConverter(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + BUCK = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/BUCK")); + BUCK_ACTIVE = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/BUCK_ACTIVE")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { MACHINE_CASINGS_TT[mTier][colorIndex + 1], + side == facing ? (aActive ? BUCK_ACTIVE : BUCK) + : (side == facing.getOpposite() ? OVERLAYS_ENERGY_IN_POWER_TT[mTier] + : (aActive ? OVERLAYS_ENERGY_OUT_POWER_TT[mTier] : OVERLAYS_ENERGY_IN_POWER_TT[mTier])) }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("eEUT", EUT); + aNBT.setInteger("eAMP", AMP); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + EUT = aNBT.getInteger("eEUT"); + AMP = aNBT.getInteger("eAMP"); + getBaseMetaTileEntity().setActive((long) AMP * EUT >= 0); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return getBaseMetaTileEntity().isActive() && side != getBaseMetaTileEntity().getFrontFacing() + && side != getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long maxAmperesOut() { + return getBaseMetaTileEntity().isActive() ? Math.min(Math.abs(AMP), 64) : 0; + } + + @Override + public long maxEUInput() { + return CommonValues.V[mTier]; + } + + @Override + public long maxEUOutput() { + return getBaseMetaTileEntity().isActive() ? Math.min(Math.abs(EUT), maxEUInput()) : 0; + } + + @Override + public long maxEUStore() { + return CommonValues.V[mTier] << 4; + } + + @Override + public long getMinimumStoredEU() { + return CommonValues.V[mTier] << 2; + } + + @Override + public int getProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + .widget( + new TextWidget().setStringSupplier(() -> "EUT: " + numberFormat.format(EUT)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 8)) + .widget( + new TextWidget().setStringSupplier(() -> "TIER: " + VN[TT_Utility.getTier(Math.abs(EUT))]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 16)) + .widget( + new TextWidget().setStringSupplier(() -> "AMP: " + numberFormat.format(AMP)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 24)) + .widget( + new TextWidget().setStringSupplier(() -> "SUM: " + numberFormat.format((long) AMP * EUT)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 32)); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT -= val, 512, 64, 7, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT /= val, 512, 64, 7, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP -= val, 512, 64, 7, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP /= val, 512, 64, 7, 58); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT -= val, 16, 1, 25, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT /= val, 16, 2, 25, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP -= val, 16, 1, 25, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP /= val, 16, 2, 25, 58); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT += val, 16, 1, 133, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT *= val, 16, 2, 133, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP += val, 16, 1, 133, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP *= val, 16, 2, 133, 58); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT += val, 512, 64, 151, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT *= val, 512, 64, 151, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP += val, 512, 64, 151, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP *= val, 512, 64, 151, 58); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + setter.accept(clickData.shift ? changeNumberShift : changeNumber); + getBaseMetaTileEntity().setActive((long) AMP * EUT >= 0); + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java new file mode 100644 index 0000000000..9e2a5ced60 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java @@ -0,0 +1,246 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; + +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.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +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 gregtech.common.GT_Pollution; + +/** + * Created by Tec on 23.03.2017. + */ +public class GT_MetaTileEntity_DebugPollutor extends GT_MetaTileEntity_TieredMachineBlock + implements IAddUIWidgets, IAddGregtechLogo { + + private static GT_RenderedTexture POLLUTOR; + public int pollution = 0; + private static final NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public GT_MetaTileEntity_DebugPollutor(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.debug.tt.pollutor.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.pollutor.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.pollutor.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_DebugPollutor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TT_Utility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_DebugPollutor(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + POLLUTOR = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/POLLUTOR")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { MACHINE_CASINGS_TT[mTier][colorIndex + 1], + (side == facing) ? POLLUTOR : OVERLAYS_ENERGY_OUT_LASER_TT[mTier] }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("ePollution", pollution); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + pollution = aNBT.getInteger("ePollution"); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (pollution > 0) { + GT_Pollution.addPollution(aBaseMetaTileEntity, pollution); + } + } else if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (side != aBaseMetaTileEntity.getFrontFacing()) { + TecTech.proxy.em_particle(aBaseMetaTileEntity, side); + TecTech.proxy.pollutor_particle(aBaseMetaTileEntity, side); + } + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + .widget( + new TextWidget().setStringSupplier(() -> "Pollution: " + numberFormat.format(pollution)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 8)); + + addChangeNumberButton( + builder, + GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + val -> pollution -= val, + 512, + 64, + 7, + 4); + addChangeNumberButton( + builder, + GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + val -> pollution /= val, + 512, + 64, + 7, + 22); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> pollution -= val, 16, 1, 25, 4); + addChangeNumberButton( + builder, + GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, + val -> pollution /= val, + 16, + 2, + 25, + 22); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> pollution += val, 16, 1, 133, 4); + addChangeNumberButton( + builder, + GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, + val -> pollution *= val, + 16, + 2, + 133, + 22); + + addChangeNumberButton( + builder, + GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + val -> pollution += val, + 512, + 64, + 151, + 4); + addChangeNumberButton( + builder, + GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + val -> pollution *= val, + 512, + 64, + 151, + 22); + + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget( + new ButtonWidget() + .setOnClick((clickData, widget) -> setter.accept(clickData.shift ? changeNumberShift : changeNumber)) + .setBackground(GT_UITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java new file mode 100644 index 0000000000..342ca69864 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java @@ -0,0 +1,392 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_POWER_TT; +import static com.github.technus.tectech.util.CommonValues.TRANSFER_AT; +import static com.github.technus.tectech.util.CommonValues.VN; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; + +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.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Energy; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +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 gregtech.api.util.GT_Utility; + +/** + * Created by Tec on 23.03.2017. + */ +public class GT_MetaTileEntity_DebugPowerGenerator extends GT_MetaTileEntity_TieredMachineBlock + implements IConnectsToEnergyTunnel, IAddUIWidgets, IAddGregtechLogo { + + public static GT_RenderedTexture GENNY; + private boolean LASER = false; + public int EUT = 0, AMP = 0; + public boolean producing = true; + private static final NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public GT_MetaTileEntity_DebugPowerGenerator(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.debug.tt.genny.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.debug.tt.genny.desc.3"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.genny.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.genny.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_DebugPowerGenerator(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TT_Utility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_DebugPowerGenerator(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + LASER = !LASER; + GT_Utility.sendChatToPlayer( + aPlayer, + String.format(StatCollector.translateToLocal("tt.chat.debug.generator"), LASER ? "ON" : "OFF")); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + GENNY = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/GENNY")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { MACHINE_CASINGS_TT[mTier][colorIndex + 1], + side != facing + ? LASER ? (aActive ? OVERLAYS_ENERGY_OUT_LASER_TT[mTier] : OVERLAYS_ENERGY_IN_LASER_TT[mTier]) + : (aActive ? OVERLAYS_ENERGY_OUT_POWER_TT[mTier] : OVERLAYS_ENERGY_IN_POWER_TT[mTier]) + : GENNY }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("eEUT", EUT); + aNBT.setInteger("eAMP", AMP); + aNBT.setBoolean("eLaser", LASER); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + EUT = aNBT.getInteger("eEUT"); + AMP = aNBT.getInteger("eAMP"); + LASER = aNBT.getBoolean("eLaser"); + producing = (long) AMP * EUT >= 0; + getBaseMetaTileEntity().setActive(producing); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(producing); + if (!LASER) { + if (aBaseMetaTileEntity.isActive()) { + setEUVar(maxEUStore()); + } else { + setEUVar(0); + } + } else { + byte Tick = (byte) (aTick % 20); + if (aBaseMetaTileEntity.isActive() && TRANSFER_AT == Tick) { + setEUVar(maxEUStore()); + moveAround(aBaseMetaTileEntity); + } else if (TRANSFER_AT == Tick) { + setEUVar(0); + } + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetOutput() { + return !LASER; + } + + @Override + public boolean isEnetInput() { + return !LASER; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return !producing && side != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return producing && side != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public long maxAmperesIn() { + return producing ? 0 : Math.abs(AMP); + } + + @Override + public long maxAmperesOut() { + return producing ? Math.abs(AMP) : 0; + } + + @Override + public long maxEUInput() { + return producing ? 0 : Integer.MAX_VALUE; + } + + @Override + public long maxEUOutput() { + return producing ? Math.abs(EUT) : 0; + } + + @Override + public long maxEUStore() { + return LASER ? Math.abs((long) EUT * AMP * 24) : Math.abs((long) EUT * AMP) << 2; + } + + @Override + public long getMinimumStoredEU() { + return Math.abs((long) EUT * AMP); + } + + @Override + public int getProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + public int getEUT() { + return EUT; + } + + public void setEUT(int EUT) { + this.EUT = EUT; + } + + public int getAMP() { + return AMP; + } + + public void setAMP(int AMP) { + this.AMP = AMP; + } + + @Override + public boolean canConnect(ForgeDirection side) { + return LASER && side != getBaseMetaTileEntity().getFrontFacing(); + } + + private void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + for (final ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) { + if (face == aBaseMetaTileEntity.getFrontFacing()) continue; + final ForgeDirection opposite = face.getOpposite(); + for (short dist = 1; dist < 1000; dist++) { + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity + .getIGregTechTileEntityAtSideAndDistance(face, dist); + if (tGTTileEntity != null) { + IMetaTileEntity aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyTunnel + && opposite == tGTTileEntity.getFrontFacing()) { + if (maxEUOutput() > ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUInput()) { + aMetaTileEntity.doExplosion(maxEUOutput()); + } else { + long diff = Math.min( + AMP * 20L * maxEUOutput(), + Math.min( + ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUStore() + - aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU(), + aBaseMetaTileEntity.getStoredEU())); + ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).setEUVar( + aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU() + diff); + } + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy) { + if (((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).connectionCount < 2) {} else { + ((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).markUsed(); + } + } + } + } + } + } + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + + .widget( + new TextWidget().setStringSupplier(() -> "TIER: " + VN[TT_Utility.getTier(Math.abs(EUT))]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 22)) + + .widget( + new TextWidget().setStringSupplier(() -> "SUM: " + numberFormat.format((long) AMP * EUT)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 46)); + + addLabelledIntegerTextField(builder, "EUT: ", 24, this::getEUT, this::setEUT, 46, 8); + addLabelledIntegerTextField(builder, "AMP: ", 24, this::getAMP, this::setAMP, 46, 34); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT -= val, 512, 64, 7, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT /= val, 512, 64, 7, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP -= val, 512, 64, 7, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP /= val, 512, 64, 7, 58); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT -= val, 16, 1, 25, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT /= val, 16, 2, 25, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP -= val, 16, 1, 25, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP /= val, 16, 2, 25, 58); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT += val, 16, 1, 133, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT *= val, 16, 2, 133, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP += val, 16, 1, 133, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP *= val, 16, 2, 133, 58); + + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT += val, 512, 64, 151, 4); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT *= val, 512, 64, 151, 22); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP += val, 512, 64, 151, 40); + addChangeNumberButton(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP *= val, 512, 64, 151, 58); + } + + private void addLabelledIntegerTextField(ModularWindow.Builder builder, String label, int labelWidth, + IntSupplier getter, IntConsumer setter, int xPos, int yPos) { + builder.widget( + new TextWidget(label).setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(xPos, yPos)) + .widget( + new NumericWidget().setGetter(getter::getAsInt) + .setSetter(val -> setter.accept((int) val)) + .setTextColor(COLOR_TEXT_WHITE.get()) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(xPos + labelWidth, yPos - 1) + .setSize(56, 10)); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + setter.accept(clickData.shift ? changeNumberShift : changeNumber); + producing = (long) AMP * EUT >= 0; + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java new file mode 100644 index 0000000000..519ea19641 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java @@ -0,0 +1,300 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; + +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.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.structure.StructureUtility; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +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; + +/** + * Created by Tec on 23.03.2017. + */ +public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_TieredMachineBlock + implements IAddUIWidgets, IAddGregtechLogo { + + private static GT_RenderedTexture MARK; + public short[] numbers = new short[6]; + public boolean size = false; + public String[] result = new String[] { "Undefined" }; + + public GT_MetaTileEntity_DebugStructureWriter(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.debug.tt.writer.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.writer.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.writer.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_DebugStructureWriter(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TT_Utility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_DebugStructureWriter(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + MARK = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/MARK")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { MACHINE_CASINGS_TT[mTier][colorIndex + 1], + side != facing ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : MARK }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + for (int i = 0; i < numbers.length; i++) { + aNBT.setShort("eData" + i, numbers[i]); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + for (int i = 0; i < numbers.length; i++) { + numbers[i] = aNBT.getShort("eData" + i); + } + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + aBaseMetaTileEntity.disableWorking(); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + + String pseudoJavaCode = StructureUtility.getPseudoJavaCode( + aBaseMetaTileEntity.getWorld(), + ExtendedFacing.of(aBaseMetaTileEntity.getFrontFacing()), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + numbers[0], + numbers[1], + numbers[2], + te -> te.getClass() + .getCanonicalName(), + numbers[3], + numbers[4], + numbers[5], + false); + TecTech.LOGGER.info(pseudoJavaCode); + result = pseudoJavaCode.split("\\n"); + aBaseMetaTileEntity.disableWorking(); + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + IGregTechTileEntity aBaseMetaTileEntity = getBaseMetaTileEntity(); + + String pseudoJavaCode = StructureUtility.getPseudoJavaCode( + aBaseMetaTileEntity.getWorld(), + ExtendedFacing.of(aBaseMetaTileEntity.getFrontFacing()), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + numbers[0], + numbers[1], + numbers[2], + te -> te.getClass() + .getCanonicalName(), + numbers[3], + numbers[4], + numbers[5], + false); + TecTech.LOGGER.info(pseudoJavaCode); + result = pseudoJavaCode.split("\\n"); + aBaseMetaTileEntity.disableWorking(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return result; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + .widget( + new TextWidget().setStringSupplier(() -> size ? "Structure size" : "My position") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 8)) + .widget( + new TextWidget().setStringSupplier(() -> size ? "(Changing scan size)" : "(Moving origin)") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 16)) + .widget( + new TextWidget().setStringSupplier(() -> "A: " + numbers[size ? 3 : 0]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 24)) + .widget( + new TextWidget().setStringSupplier(() -> "B: " + numbers[size ? 4 : 1]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 32)) + .widget( + new TextWidget().setStringSupplier(() -> "C: " + numbers[size ? 5 : 2]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 40)); + + addChangeNumberButtons(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, -512, -64, 7); + addChangeNumberButtons(builder, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, -16, -1, 25); + addChangeNumberButtons(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, 16, 1, 133); + addChangeNumberButtons(builder, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, 512, 16, 151); + } + + private void addChangeNumberButtons(ModularWindow.Builder builder, IDrawable overlay, int addNumberShift, + int addNumber, int xPos) { + addChangeNumberButton( + builder, + overlay, + val -> numbers[size ? 3 : 0] += val, + addNumberShift, + addNumber, + xPos, + 4); + addChangeNumberButton( + builder, + overlay, + val -> numbers[size ? 4 : 1] += val, + addNumberShift, + addNumber, + xPos, + 22); + addChangeNumberButton( + builder, + overlay, + val -> numbers[size ? 5 : 2] += val, + addNumberShift, + addNumber, + xPos, + 40); + builder.widget( + new ButtonWidget().setOnClick((clickData, widget) -> { size = !size; }) + .setBackground(GT_UITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, 58)); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget( + new ButtonWidget() + .setOnClick( + (clickData, widget) -> { setter.accept(clickData.shift ? changeNumberShift : changeNumber); }) + .setBackground(GT_UITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java new file mode 100644 index 0000000000..8728a5d04f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java @@ -0,0 +1,239 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static com.github.technus.tectech.util.CommonValues.RECIPE_AT; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; + +/** + * Created by Tec on 23.03.2017. + */ +public class GT_MetaTileEntity_OwnerDetector extends GT_MetaTileEntity_TieredMachineBlock { + + private static GT_RenderedTexture OWNER_ONLINE, OWNER_OFFLINE; + private String uuid; + private boolean interdimensional = true; + + public GT_MetaTileEntity_OwnerDetector(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.machine.tt.ownerdetector.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.machine.tt.ownerdetector.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.machine.tt.ownerdetector.desc.2") }); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_OwnerDetector(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TT_Utility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_OwnerDetector(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + OWNER_ONLINE = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/OWNER_ONLINE")); + OWNER_OFFLINE = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/OWNER_OFFLINE")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { MACHINE_CASINGS_TT[mTier][colorIndex + 1], aActive ? OWNER_ONLINE : OWNER_OFFLINE }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setString("eUUID", uuid); + aNBT.setBoolean("eInterDim", interdimensional); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + uuid = aNBT.getString("eUUID"); + interdimensional = aNBT.getBoolean("eInterDim"); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isServerSide()) { + if (uuid == null || uuid.length() == 0) { + String name = aBaseMetaTileEntity.getOwnerName(); + if (!("Player".equals(name))) { + uuid = TecTech.proxy.getUUID(name); + } + } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == RECIPE_AT) { + boolean detected = TecTech.proxy.isOnlineUUID(uuid) || (uuid != null && uuid.length() > 0 + && TecTech.proxy.isOnlineName(aBaseMetaTileEntity.getOwnerName())); + aBaseMetaTileEntity.setActive(detected); + aBaseMetaTileEntity.setGenericRedstoneOutput(detected); + byte value = (byte) (detected ? 15 : 0); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + aBaseMetaTileEntity.setStrongOutputRedstoneSignal(side, value); + } + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + String clientLocale; + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + interdimensional ^= true; + GT_Utility.sendChatToPlayer( + aPlayer, + interdimensional ? translateToLocalFormatted("tt.keyphrase.Running_interdimensional_scan", clientLocale) + : translateToLocalFormatted("tt.keyphrase.Running_local_dimension_scan", clientLocale)); + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public long maxEUInput() { + return Integer.MAX_VALUE; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public int getProgresstime() { + return interdimensional ? 1 : 0; + } + + @Override + public int maxProgresstime() { + return 1; + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + return true; + } + + @Override + public boolean allowGeneralRedstoneOutput() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java new file mode 100644 index 0000000000..90114ea0f8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java @@ -0,0 +1,73 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_MULTI_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_MULTI_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_POWER_TT; +import static net.minecraft.util.StatCollector.translateToLocal; + +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Transformer; + +public class GT_MetaTileEntity_TT_Transformer extends GT_MetaTileEntity_Transformer { + + public GT_MetaTileEntity_TT_Transformer(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, ""); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_TT_Transformer(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + TT_Utility.setTier(aTier, this); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TT_Transformer(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + for (byte b = -1; b < 16; b++) { + rTextures[0][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_OUT_MULTI_TT[mTier] }; + rTextures[1][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_OUT_MULTI_TT[mTier] }; + rTextures[2][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_OUT_MULTI_TT[mTier] }; + rTextures[3][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_IN_POWER_TT[mTier + 1] }; + rTextures[4][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_IN_POWER_TT[mTier + 1] }; + rTextures[5][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_IN_POWER_TT[mTier + 1] }; + rTextures[6][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_IN_MULTI_TT[mTier] }; + rTextures[7][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_IN_MULTI_TT[mTier] }; + rTextures[8][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_IN_MULTI_TT[mTier] }; + rTextures[9][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_OUT_POWER_TT[mTier + 1] }; + rTextures[10][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_OUT_POWER_TT[mTier + 1] }; + rTextures[11][b + 1] = new ITexture[] { MACHINE_CASINGS_TT[mTier][b + 1], + OVERLAYS_ENERGY_OUT_POWER_TT[mTier + 1] }; + } + return rTextures; + } + + @Override + public String[] getDescription() { + return new String[] { + translateToLocal("gt.blockmachines.tt.transformer.tier." + (mTier > 9 ? "" : "0") + mTier + ".desc"), + CommonValues.TEC_MARK_GENERAL }; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java new file mode 100644 index 0000000000..e19ac1bf7d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -0,0 +1,404 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.generateTeslaNodeMap; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.powerTeslaNodeMap; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_MULTI_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_POWER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.TESLA_TRANSCEIVER_TOP_BA; +import static com.github.technus.tectech.util.CommonValues.V; +import static java.lang.Math.round; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.Arrays; +import java.util.HashSet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.spark.RendererMessage; +import com.github.technus.tectech.mechanics.spark.ThaumSpark; +import com.github.technus.tectech.mechanics.tesla.ITeslaConnectable; +import com.github.technus.tectech.mechanics.tesla.ITeslaConnectableSimple; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.google.common.collect.Multimap; +import com.google.common.collect.MultimapBuilder; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import eu.usrv.yamcore.auxiliary.PlayerChatHelper; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatteryBuffer; + +public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer implements ITeslaConnectable { + + // Interface fields + private final Multimap teslaNodeMap = MultimapBuilder.treeKeys() + .linkedListValues() + .build(); + private final HashSet sparkList = new HashSet<>(); + private int sparkCount = 10; + + private static final int transferRadiusMax = TecTech.configTecTech.TESLA_SINGLE_RANGE; // Default is 20 + private static final int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK; // Default is 1 + private static final float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE; // Default is + // 0.25F + private static final int transferRadiusMin = 4; // Minimum user configurable + private int transferRadius = transferRadiusMax; // Default transferRadius setting + + public boolean powerPassToggle = false; // Power Pass for public viewing + private static final int histSteps = 20; // Hysteresis Resolution + private int histSettingLow = 3; // Hysteresis Low Limit + private int histSettingHigh = 15; // Hysteresis High Limit + private static final int histLowLimit = 1; // How low can you configure it? + private static final int histHighLimit = 19; // How high can you configure it? + private float histLow = (float) histSettingLow / histSteps; // Power pass is disabled if power is under this + // fraction + private float histHigh = (float) histSettingHigh / histSteps; // Power pass is enabled if power is over this + // fraction + + private final long outputVoltage = V[mTier]; + private boolean overdriveToggle = false; + + private String clientLocale = "en_US"; + + public GT_MetaTileEntity_TeslaCoil(int aID, String aName, String aNameRegional, int aTier, int aSlotCount) { + super(aID, aName, aNameRegional, aTier, "", aSlotCount); + TT_Utility.setTier(aTier, this); + } + + public GT_MetaTileEntity_TeslaCoil(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, + int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + } + + @Override + public String[] getDescription() { + String[] jargon = new String[] { CommonValues.THETA_MOVEMENT, + translateToLocal("gt.blockmachines.machine.tt.tesla.desc.0"), // Your Tesla I/O machine of choice + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.machine.tt.tesla.desc.1") // Lightning + // stoves for the + // rich + }; + String[] sDesc = super.getDescription(); + sDesc = Arrays.copyOfRange(sDesc, 1, sDesc.length); // Removes first element from array + return ArrayUtils.addAll(jargon, sDesc); + } + + @Override + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (overdriveToggle) { + overdriveToggle = false; + PlayerChatHelper + .SendInfo(aPlayer, translateToLocalFormatted("tt.keyphrase.Overdrive_disengaged", clientLocale)); + } else { + overdriveToggle = true; + PlayerChatHelper + .SendInfo(aPlayer, translateToLocalFormatted("tt.keyphrase.Overdrive_engaged", clientLocale)); + } + return true; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + if (histSettingHigh < histHighLimit) { + histSettingHigh++; + } else { + histSettingHigh = histSettingLow + 1; + } + histHigh = (float) histSettingHigh / histSteps; + PlayerChatHelper.SendInfo( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Hysteresis_high_set_to", clientLocale) + " " + + round(histHigh * 100F) + + "%"); + } else { + if (histSettingLow > histLowLimit) { + histSettingLow--; + } else { + histSettingLow = histSettingHigh - 1; + } + histLow = (float) histSettingLow / histSteps; + PlayerChatHelper.SendInfo( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Hysteresis_low_set_to", clientLocale) + " " + + round(histLow * 100F) + + "%"); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + if (transferRadius > transferRadiusMin) { + transferRadius--; + } + } else { + if (transferRadius < transferRadiusMax) { + transferRadius++; + } + } + PlayerChatHelper.SendInfo( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Tesla_radius_set_to", clientLocale) + " " + transferRadius + "m"); + return false; + } + + // Cheeky skrub stuff to get machine to switch powerPass on soft mallet + @Override + public boolean hasAlternativeModeText() { + return true; + } + + @Override + public String getAlternativeModeText() { + // Hysteresis based ePowerPass Config + long energyMax = getStoredEnergy()[1]; + long energyStored = getStoredEnergy()[0]; + float energyFrac = (float) energyStored / energyMax; + + // ePowerPass hist toggle + if (energyFrac > histHigh) { + powerPassToggle = true; + } else if (energyFrac < histLow) { + powerPassToggle = false; + } else { + powerPassToggle = !powerPassToggle; + } + + // And after this cheeky-ness, toss the string XD + return powerPassToggle ? translateToLocalFormatted("tt.keyphrase.Sending_power", clientLocale) + "!" + : translateToLocalFormatted("tt.keyphrase.Receiving_power", clientLocale) + "!"; + } + + @Override + public boolean isFacingValid(ForgeDirection side) { + return side != ForgeDirection.UP; + } // Prevents output at the top side + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[3][17][]; + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = new ITexture[] { MACHINE_CASINGS_TT[this.mTier][i + 1] }; + rTextures[1][i + 1] = new ITexture[] { MACHINE_CASINGS_TT[this.mTier][i + 1], TESLA_TRANSCEIVER_TOP_BA }; + rTextures[2][i + 1] = new ITexture[] { MACHINE_CASINGS_TT[this.mTier][i + 1], + this.mInventory.length == 16 ? OVERLAYS_ENERGY_OUT_POWER_TT[this.mTier] + : (this.mInventory.length > 4 ? OVERLAYS_ENERGY_OUT_MULTI_TT[this.mTier] + : OVERLAYS_ENERGY_OUT_TT[this.mTier]) }; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return this.mTextures[side == facing ? 2 : side == ForgeDirection.UP ? 1 : 0][colorIndex + 1]; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TeslaCoil(mName, mTier, mDescriptionArray, mTextures, mInventory.length); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (!aBaseMetaTileEntity.isClientSide()) { + teslaSimpleNodeSetAdd(this); + generateTeslaNodeMap(this); + } + } + + @Override + public void onRemoval() { + super.onRemoval(); + if (!this.getBaseMetaTileEntity() + .isClientSide()) { + teslaSimpleNodeSetRemove(this); + } + } + + @Override + public void onUnload() { + if (!this.getBaseMetaTileEntity() + .isClientSide()) { + teslaSimpleNodeSetRemove(this); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + teslaSimpleNodeSetAdd(this); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isClientSide()) { + return; + } + + // Hysteresis based ePowerPass Config + long energyMax = getStoredEnergy()[1]; + long energyStored = getStoredEnergy()[0]; + float energyFrac = (float) energyStored / energyMax; + + // ePowerPass hist toggle + if (!powerPassToggle && energyFrac > histHigh) { + powerPassToggle = true; + } else if (powerPassToggle && energyFrac < histLow) { + powerPassToggle = false; + } + + // Send Power + powerTeslaNodeMap(this); + + // TODO Encapsulate the spark sender + sparkCount--; + if (sparkCount == 0) { + sparkCount = 10; + if (!sparkList.isEmpty()) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new RendererMessage.RendererData(sparkList), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + sparkList.clear(); + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isServerSide()) { + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } + return true; + } + + @Override + public byte getTeslaReceptionCapability() { + return 1; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 1; + } + + @Override + public Multimap getTeslaNodeMap() { + return teslaNodeMap; + } + + @Override + public HashSet getSparkList() { + return sparkList; + } + + @Override + public byte getTeslaTransmissionCapability() { + return 2; + } + + @Override + public int getTeslaTransmissionRange() { + return transferRadius; + } + + @Override + public boolean isOverdriveEnabled() { + return overdriveToggle; + } + + @Override + public int getTeslaEnergyLossPerBlock() { + return perBlockLoss; + } + + @Override + public float getTeslaOverdriveLossCoefficient() { + return overDriveLoss; + } + + @Override + public long getTeslaOutputVoltage() { + return outputVoltage; + } + + @Override + public long getTeslaOutputCurrent() { + return mBatteryCount; + } + + @Override + public boolean teslaDrainEnergy(long teslaVoltageDrained) { + if (getEUVar() < teslaVoltageDrained) { + return false; + } + + setEUVar(getEUVar() - teslaVoltageDrained); + return true; + } + + @Override + public boolean isTeslaReadyToReceive() { + return !this.powerPassToggle; + } + + @Override + public long getTeslaStoredEnergy() { + return getEUVar(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return new Vec3Impl( + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getYCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + } + + @Override + public Integer getTeslaDimension() { + return this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + return this.getBaseMetaTileEntity() + .injectEnergyUnits(ForgeDirection.UP, teslaVoltageInjected, 1L) > 0L; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java new file mode 100644 index 0000000000..97facf1046 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java @@ -0,0 +1,49 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import static com.github.technus.tectech.util.CommonValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import com.github.technus.tectech.util.CommonValues; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GT_MetaTileEntity_WetTransformer extends GT_MetaTileEntity_TT_Transformer { + + public GT_MetaTileEntity_WetTransformer(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_WetTransformer(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + translateToLocal("gt.blockmachines.wetransformer.tier." + (mTier > 9 ? "" : "0") + mTier + ".desc"), + "Accepts 16A and outputs 64A", CommonValues.TEC_MARK_GENERAL }; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier + 1]; + } + + @Override + public long maxEUStore() { + return 512L + V[mTier + 1] * 128L; + } + + @Override + public long maxAmperesOut() { + return getBaseMetaTileEntity().isAllowedToWork() ? 64 : 16; + } + + @Override + public long maxAmperesIn() { + return getBaseMetaTileEntity().isAllowedToWork() ? 16 : 64; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/multiTileEntity/GodForge.java b/src/main/java/com/github/technus/tectech/thing/multiTileEntity/GodForge.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java b/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java new file mode 100644 index 0000000000..ac24686d6a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java @@ -0,0 +1,143 @@ +package com.github.technus.tectech.thing.tileEntity; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import com.github.technus.tectech.Reference; + +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.core.IC2; +import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; +import ic2.core.init.MainConfig; +import ic2.core.util.ConfigUtil; + +/** + * Created by danie_000 on 30.09.2017. + */ +public class ReactorSimTileEntity extends TileEntityNuclearReactorElectric { + + private boolean hadRedstone = true; + + @Override + public void onLoaded() { + super.onLoaded(); + if (IC2.platform.isSimulating() && addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + // this.addedToEnergyNet = false; + } + } + + @Override + public void onUnloaded() { + addedToEnergyNet = false; + super.onUnloaded(); + } + + @Override + public String getInventoryName() { + return "Nuclear Reactor Simulator"; + } + + @Override + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return false; + } + + @Override + public double getOfferedEnergy() { + return 0; + } + + @Override + public double getReactorEUEnergyOutput() { + return getReactorEnergyOutput() * 5.0F + * ConfigUtil.getDouble(MainConfig.get(), "balance/energy/generator/nuclear"); + } + + @Override + protected void updateEntityServer() { + if (updateTicker++ % getTickRate() == 0) { + if (!worldObj.isRemote && worldObj.doChunksNearChunkExist(xCoord, yCoord, zCoord, 2)) { + if (hadRedstone && !receiveredstone()) { + hadRedstone = false; + } else if (!hadRedstone && receiveredstone()) { + doUpdates(); + hadRedstone = true; + } + markDirty(); + } + } + } + + @Override + public boolean calculateHeatEffects() { + if (heat >= 4000 && IC2.platform.isSimulating()) { + float power = (float) heat / (float) maxHeat; + if (power >= 1.0F) { + explode(); // ding + return true; + } else { + return false; + } + } + return false; + } + + // new method + private void doUpdates() { + heat = 0; + do { + dropAllUnfittingStuff(); + output = 0.0F; + maxHeat = 10000; + hem = 1.0F; + processChambers(); + } while (!calculateHeatEffects() && output > 0); + } + + @Override + public void explode() { + getWorld().playSoundEffect(xCoord, yCoord, zCoord, Reference.MODID + ":microwave_ding", 1, 1); + } + + @Override + public void addEmitHeat(int heat) {} + + @Override + public boolean isFluidCooled() { + return false; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } +} diff --git a/src/main/java/com/github/technus/tectech/util/CommonValues.java b/src/main/java/com/github/technus/tectech/util/CommonValues.java new file mode 100644 index 0000000000..8e4539a17a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/CommonValues.java @@ -0,0 +1,33 @@ +package com.github.technus.tectech.util; + +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.enums.GT_Values; + +/** + * Created by danie_000 on 11.01.2017. + */ +@SuppressWarnings("SpellCheckingInspection") +public final class CommonValues { + + public static final String TEC_MARK_SHORT = EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech"; + public static final String TEC_MARK_GENERAL = TEC_MARK_SHORT + EnumChatFormatting.BLUE + ": Interdimensional"; + public static final String TEC_MARK_EM = TEC_MARK_SHORT + EnumChatFormatting.BLUE + ": Elemental Matter"; + public static final String THETA_MOVEMENT = TEC_MARK_SHORT + EnumChatFormatting.BLUE + ": Theta Movement"; + public static final String COSMIC_MARK = TEC_MARK_SHORT + EnumChatFormatting.BLUE + ": Cosmic"; + public static final String GODFORGE_MARK = TEC_MARK_SHORT + EnumChatFormatting.BLUE + ": Project Godforge"; + + public static final byte MOVE_AT = 4; // move stuff around + public static final byte RECIPE_AT = 6; // move stuff around + // - in case some hatches are not in multiblock structure + public static final byte MULTI_CHECK_AT = 12; // multiblock checks its state + public static final byte TRANSFER_AT = 16; + + public static final String[] VN = GT_Values.VN; + public static final long[] V = GT_Values.V; + + public static final String[] EOH_TIER_FANCY_NAMES = { "Crude", "Primitive", "Stable", "Advanced", "Superb", + "Exotic", "Perfect", "Tipler", EnumChatFormatting.BOLD + "Gallifreyan" }; + + private CommonValues() {} +} diff --git a/src/main/java/com/github/technus/tectech/util/Converter.java b/src/main/java/com/github/technus/tectech/util/Converter.java new file mode 100644 index 0000000000..d0da11d405 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/Converter.java @@ -0,0 +1,41 @@ +package com.github.technus.tectech.util; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public final class Converter { + + private Converter() {} + + public static byte[] writeInts(int[] array) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(array.length * 4); + DataOutputStream dos = new DataOutputStream(bos); + for (int j : array) { + dos.writeInt(j); + } + + return bos.toByteArray(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public static int[] readInts(byte[] array) { + try { + ByteArrayInputStream bis = new ByteArrayInputStream(array); + DataInputStream dataInputStream = new DataInputStream(bis); + int size = array.length / Integer.BYTES; + int[] res = new int[size]; + for (int i = 0; i < size; i++) { + res[i] = dataInputStream.readInt(); + } + return res; + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/util/FluidStackLong.java b/src/main/java/com/github/technus/tectech/util/FluidStackLong.java new file mode 100644 index 0000000000..abd0134e85 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/FluidStackLong.java @@ -0,0 +1,29 @@ +package com.github.technus.tectech.util; + +import net.minecraftforge.fluids.FluidStack; + +public class FluidStackLong { + + public final FluidStack fluidStack; + public long amount; + + public FluidStackLong(FluidStack fluidStack, long amount) { + this.fluidStack = fluidStack; + this.amount = amount; + } + + // Copy constructor. + public FluidStackLong(FluidStackLong fluidStackLong) { + this.fluidStack = fluidStackLong.fluidStack; + this.amount = fluidStackLong.amount; + } + + public long getFluidAmount() { + return amount; + } + + public FluidStack getRegularFluidStack(FluidStackLong fluidStackLong, int amount) { + return new FluidStack(fluidStackLong.fluidStack, amount); + } + +} diff --git a/src/main/java/com/github/technus/tectech/util/GodforgeMath.java b/src/main/java/com/github/technus/tectech/util/GodforgeMath.java new file mode 100644 index 0000000000..7fda26a29c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/GodforgeMath.java @@ -0,0 +1,308 @@ +package com.github.technus.tectech.util; + +import java.math.BigInteger; + +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_ForgeOfGods; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_BaseModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_ExoticModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_MoltenModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_PlasmaModule; +import com.github.technus.tectech.thing.metaTileEntity.multi.godforge_modules.GT_MetaTileEntity_EM_SmeltingModule; + +public class GodforgeMath { + + public static int getRandomIntInRange(int min, int max) { + return (int) (Math.random() * (max - min)) + min; + } + + public static double calculateFuelConsumption(GT_MetaTileEntity_EM_ForgeOfGods godforge) { + double upgradeFactor = 1; + if (godforge.isUpgradeActive(2)) { + upgradeFactor = 0.8; + } + if (godforge.getFuelType() == 0) { + return Math + .max(godforge.getFuelFactor() * 300 * Math.pow(1.15, godforge.getFuelFactor()) * upgradeFactor, 1); + } + if (godforge.getFuelType() == 1) { + return Math.max(godforge.getFuelFactor() * 2 * Math.pow(1.08, godforge.getFuelFactor()) * upgradeFactor, 1); + } else return Math.max(godforge.getFuelFactor() / 25 * upgradeFactor, 1); + } + + public static int calculateStartupFuelConsumption(GT_MetaTileEntity_EM_ForgeOfGods godforge) { + return (int) Math.max(godforge.getFuelFactor() * 25 * Math.pow(1.2, godforge.getFuelFactor()), 1); + } + + public static int calculateMaxFuelFactor(GT_MetaTileEntity_EM_ForgeOfGods godforge) { + int fuelCap = 5; + if (godforge.isUpgradeActive(27)) { + fuelCap = Integer.MAX_VALUE; + } else { + if (godforge.isUpgradeActive(9)) { + fuelCap += godforge.getTotalActiveUpgrades(); + } + if (godforge.isUpgradeActive(3)) { + fuelCap *= 1.2; + } + } + return Math.max(fuelCap, 1); + } + + public static int calculateEffectiveFuelFactor(GT_MetaTileEntity_EM_ForgeOfGods godforge) { + int fuelFactor = godforge.getFuelFactor(); + if (fuelFactor <= 43) { + return fuelFactor; + } else { + return 43 + (int) Math.floor(Math.pow((fuelFactor - 43), 0.4)); + } + } + + public static void calculateMaxHeatForModules(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + double logBase = 1.5; + int baseHeat = 12601; + if (godforge.isUpgradeActive(12)) { + if (module instanceof GT_MetaTileEntity_EM_SmeltingModule) { + logBase = 1.12; + } else { + logBase = 1.18; + } + } + int recipeHeat = baseHeat + (int) (Math.log(godforge.getFuelFactor()) / Math.log(logBase) * 1000); + module.setHeatForOC(calculateOverclockHeat(module, godforge, recipeHeat)); + module.setHeat(recipeHeat); + } + + public static int calculateOverclockHeat(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge, Integer recipeHeat) { + int actualHeat; + double exponent; + if (godforge.isUpgradeActive(20)) { + if (module instanceof GT_MetaTileEntity_EM_SmeltingModule) { + exponent = 0.85; + } else { + exponent = 0.8; + } + if (recipeHeat > 30000) { + actualHeat = (int) Math.floor(30000 + Math.pow(recipeHeat - 30000, exponent)); + } else { + actualHeat = recipeHeat; + } + } else if (godforge.isUpgradeActive(17)) { + actualHeat = Math.min(recipeHeat, 30000); + } else { + actualHeat = Math.min(recipeHeat, 15000); + } + return actualHeat; + } + + public static void calculateSpeedBonusForModules(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + double speedBonus = 1; + + if (godforge.isUpgradeActive(1)) { + speedBonus = Math.pow(module.getHeat(), -0.01); + } + + if (godforge.isUpgradeActive(22)) { + if (module instanceof GT_MetaTileEntity_EM_PlasmaModule) { + speedBonus /= Math.pow(module.getMaxParallel(), 0.02); + } else { + speedBonus /= Math.pow(module.getMaxParallel(), 0.012); + } + } + + if (module instanceof GT_MetaTileEntity_EM_ExoticModule) { + if (godforge.isUpgradeActive(25)) { + speedBonus = Math.sqrt(speedBonus); + } else { + speedBonus = 1; + } + } + + module.setSpeedBonus((float) speedBonus); + } + + public static void calculateMaxParallelForModules(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + int baseParallel = 0; + float fuelFactorMultiplier = 1; + float heatMultiplier = 1; + float upgradeAmountMultiplier = 1; + int node53 = 1; + boolean isMoltenOrSmeltingWithUpgrade = false; + + if (module instanceof GT_MetaTileEntity_EM_SmeltingModule) { + baseParallel = 1024; + } + if (module instanceof GT_MetaTileEntity_EM_MoltenModule) { + baseParallel = 512; + } + if (module instanceof GT_MetaTileEntity_EM_PlasmaModule) { + baseParallel = 256; + } + if (module instanceof GT_MetaTileEntity_EM_ExoticModule) { + baseParallel = 36; + } + + if (module instanceof GT_MetaTileEntity_EM_MoltenModule + || (module instanceof GT_MetaTileEntity_EM_SmeltingModule && godforge.isUpgradeActive(16))) { + isMoltenOrSmeltingWithUpgrade = true; + } + + if (godforge.isUpgradeActive(10)) { + node53 = 2; + } + + if (godforge.isUpgradeActive(6)) { + if (godforge.isUpgradeActive(13)) { + if (isMoltenOrSmeltingWithUpgrade) { + fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f * 3; + } else { + fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f * 2; + } + } else { + fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f; + } + } + + if (godforge.isUpgradeActive(18)) { + if (isMoltenOrSmeltingWithUpgrade) { + heatMultiplier = 1 + module.getHeat() / 15000f; + } else { + heatMultiplier = 1 + module.getHeat() / 25000f; + } + } + + if (godforge.isUpgradeActive(21)) { + if (isMoltenOrSmeltingWithUpgrade) { + upgradeAmountMultiplier = 1 + godforge.getTotalActiveUpgrades() / 5f; + } else { + upgradeAmountMultiplier = 1 + godforge.getTotalActiveUpgrades() / 8f; + } + } + + int maxParallel = (int) (baseParallel * node53 + * fuelFactorMultiplier + * heatMultiplier + * upgradeAmountMultiplier); + + if (module instanceof GT_MetaTileEntity_EM_ExoticModule) { + if (godforge.isUpgradeActive(25)) { + maxParallel = (int) Math.max(9 * Math.floor(Math.sqrt(maxParallel) / 9), 36); + } else { + maxParallel = baseParallel; + } + } + + module.setMaxParallel(maxParallel); + } + + public static void calculateEnergyDiscountForModules(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + double fillRatioDiscount = 1; + double maxBatteryDiscount = 1; + + if (godforge.isUpgradeActive(8)) { + maxBatteryDiscount = 1 - (1 - Math.pow(1.001, -0.01 * godforge.getMaxBatteryCharge())) / 20; + } + + if (godforge.isUpgradeActive(19)) { + double fillRatioMinusZeroPointFive = (double) godforge.getBatteryCharge() / godforge.getMaxBatteryCharge() + - 0.5; + if (module instanceof GT_MetaTileEntity_EM_PlasmaModule) { + fillRatioDiscount = 1 - (Math.pow(fillRatioMinusZeroPointFive, 2) * (-0.6) + 0.15); + } else { + fillRatioDiscount = 1 - (Math.pow(fillRatioMinusZeroPointFive, 2) * (-0.6) + 0.15) * 2 / 3; + } + } + + if (module instanceof GT_MetaTileEntity_EM_ExoticModule) { + if (!godforge.isUpgradeActive(25)) { + fillRatioDiscount = 1; + maxBatteryDiscount = 1; + } else { + fillRatioDiscount = Math.sqrt(fillRatioDiscount); + maxBatteryDiscount = Math.sqrt(maxBatteryDiscount); + } + } + + module.setEnergyDiscount((float) (fillRatioDiscount * maxBatteryDiscount)); + } + + public static void calculateProcessingVoltageForModules(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + long voltage = Integer.MAX_VALUE; + + if (godforge.isUpgradeActive(4)) { + voltage += calculateEffectiveFuelFactor(godforge) * 100_000_000L; + } + + if (godforge.isUpgradeActive(23)) { + voltage *= Math.pow(4, godforge.getRingAmount()); + } + + module.setProcessingVoltage(voltage); + } + + public static void setMiscModuleParameters(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + int plasmaTier = 0; + double overclockTimeFactor = 2; + + if (godforge.isUpgradeActive(30)) { + plasmaTier = 2; + } else if (godforge.isUpgradeActive(24)) { + plasmaTier = 1; + } + + if (godforge.isUpgradeActive(14)) { + if (module instanceof GT_MetaTileEntity_EM_PlasmaModule) { + overclockTimeFactor = 2.3; + } else { + overclockTimeFactor = 2.15; + } + if (module instanceof GT_MetaTileEntity_EM_ExoticModule) { + if (godforge.isUpgradeActive(25)) { + overclockTimeFactor = 2 + Math.pow(overclockTimeFactor - 2, 2); + } else { + overclockTimeFactor = 2; + } + } + } + + module.setUpgrade83(godforge.isUpgradeActive(19)); + module.setMultiStepPlasma(godforge.isUpgradeActive(15)); + module.setPlasmaTier(plasmaTier); + module.setMagmatterCapable(godforge.isUpgradeActive(30)); + module.setVoltageConfig(godforge.isUpgradeActive(28)); + module.setOverclockTimeFactor(overclockTimeFactor); + } + + public static boolean allowModuleConnection(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + + if (module instanceof GT_MetaTileEntity_EM_MoltenModule && godforge.isUpgradeActive(5)) { + return true; + } + + if (module instanceof GT_MetaTileEntity_EM_PlasmaModule && godforge.isUpgradeActive(7)) { + return true; + } + + if (module instanceof GT_MetaTileEntity_EM_ExoticModule && godforge.isUpgradeActive(11)) { + return true; + } + + return module instanceof GT_MetaTileEntity_EM_SmeltingModule; + } + + public static void queryMilestoneStats(GT_MetaTileEntity_EM_BaseModule module, + GT_MetaTileEntity_EM_ForgeOfGods godforge) { + godforge.addTotalPowerConsumed(module.getPowerTally()); + module.setPowerTally(BigInteger.ZERO); + godforge.addTotalRecipesProcessed(module.getRecipeTally()); + module.setRecipeTally(0); + + } +} diff --git a/src/main/java/com/github/technus/tectech/util/ItemStackLong.java b/src/main/java/com/github/technus/tectech/util/ItemStackLong.java new file mode 100644 index 0000000000..94b5dcb88a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/ItemStackLong.java @@ -0,0 +1,28 @@ +package com.github.technus.tectech.util; + +import net.minecraft.item.ItemStack; + +public class ItemStackLong { + + public final ItemStack itemStack; + public long stackSize; + + public ItemStackLong(ItemStack itemStack, long stackSize) { + this.itemStack = itemStack; + this.stackSize = stackSize; + } + + // Copy constructor. + public ItemStackLong(ItemStackLong itemStackLong) { + this.itemStack = itemStackLong.itemStack; + this.stackSize = itemStackLong.stackSize; + } + + public long getStackSize() { + return stackSize; + } + + public long compareTo(ItemStackLong itemStackLong) { + return (stackSize - itemStackLong.stackSize); + } +} diff --git a/src/main/java/com/github/technus/tectech/util/TT_Utility.java b/src/main/java/com/github/technus/tectech/util/TT_Utility.java new file mode 100644 index 0000000000..0428c6cedf --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/TT_Utility.java @@ -0,0 +1,192 @@ +package com.github.technus.tectech.util; + +import java.lang.reflect.Field; +import java.math.BigInteger; +import java.util.Formatter; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; + +/** + * Created by Tec on 21.03.2017. + */ +public final class TT_Utility { + + private TT_Utility() {} + + private static final StringBuilder STRING_BUILDER = new StringBuilder(); + private static final Map FORMATTER_MAP = new HashMap<>(); + + private static Formatter getFormatter() { + STRING_BUILDER.setLength(0); + return FORMATTER_MAP.computeIfAbsent( + Locale.getDefault(Locale.Category.FORMAT), + locale -> new Formatter(STRING_BUILDER, locale)); + } + + public static String formatNumberExp(double value) { + return getFormatter().format("%+.5E", value) + .toString(); + } + + // Formats to standard form. + public static String toStandardForm(long number) { + if (number == 0) { + return "0"; + } + + int exponent = (int) Math.floor(Math.log10(Math.abs(number))); + double mantissa = number / Math.pow(10, exponent); + + // Round the mantissa to two decimal places + mantissa = Math.round(mantissa * 100.0) / 100.0; + + return mantissa + "*10^" + exponent; + } + + public static String toStandardForm(BigInteger number) { + BigInteger abs = number.abs(); + if (abs.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) < 0) { + return toStandardForm(number.longValue()); + } + String strNum = abs.toString(); + int exponent = strNum.length() - 1; + return (number.signum() == -1 ? "-" : "") + strNum.charAt(0) + "." + strNum.substring(1, 3) + "*10^" + exponent; + + } + + public static String toExponentForm(BigInteger number) { + BigInteger abs = number.abs(); + String strNum = abs.toString(); + int exponent = strNum.length() - 1; + return (number.signum() == -1 ? "-" : "") + strNum.charAt(0) + "." + strNum.substring(1, 3) + "e" + exponent; + + } + + public static int bitStringToInt(String bits) { + if (bits == null) { + return 0; + } + if (bits.length() > 32) { + throw new NumberFormatException("Too long!"); + } + return Integer.parseInt(bits, 2); + } + + public static int hexStringToInt(String hex) { + if (hex == null) { + return 0; + } + if (hex.length() > 8) { + throw new NumberFormatException("Too long!"); + } + return Integer.parseInt(hex, 16); + } + + public static double stringToDouble(String str) { + if (str == null) { + return 0; + } + return Double.parseDouble(str); + } + + public static String longBitsToShortString(long number) { + StringBuilder result = new StringBuilder(71); + + for (int i = 63; i >= 0; i--) { + long mask = 1L << i; + result.append((number & mask) != 0 ? ":" : "."); + + if (i % 8 == 0) { + result.append('|'); + } + } + result.replace(result.length() - 1, result.length(), ""); + + return result.toString(); + } + + public static float map(float x, float in_min, float in_max, float out_min, float out_max) { + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + } + + public static String getUniqueIdentifier(ItemStack is) { + return GameRegistry.findUniqueIdentifierFor(is.getItem()).modId + ':' + is.getUnlocalizedName(); + } + + public static byte getTier(long l) { + byte b = -1; + + do { + ++b; + if (b >= CommonValues.V.length) { + return b; + } + } while (l > CommonValues.V[b]); + + return b; + } + + public static void setTier(int tier, Object me) { + try { + Field field = GT_MetaTileEntity_TieredMachineBlock.class.getField("mTier"); + field.setAccessible(true); + field.set(me, (byte) tier); + } catch (Exception e) { + // e.printStackTrace(); + } + } + + @Deprecated + public static double receiveDouble(double previousValue, int startIndex, int index, int value) { + return Double.longBitsToDouble(receiveLong(Double.doubleToLongBits(previousValue), startIndex, index, value)); + } + + public static long receiveLong(long previousValue, int startIndex, int index, int value) { + value &= 0xFFFF; + switch (index - startIndex) { + case 0 -> { + previousValue &= 0xFFFF_FFFF_FFFF_0000L; + previousValue |= value; + } + case 1 -> { + previousValue &= 0xFFFF_FFFF_0000_FFFFL; + previousValue |= (long) value << 16; + } + case 2 -> { + previousValue &= 0xFFFF_0000_FFFF_FFFFL; + previousValue |= (long) value << 32; + } + case 3 -> { + previousValue &= 0x0000_FFFF_FFFF_FFFFL; + previousValue |= (long) value << 48; + } + } + return previousValue; + } + + @Deprecated + public static float receiveFloat(float previousValue, int startIndex, int index, int value) { + return Float.intBitsToFloat(receiveInteger(Float.floatToIntBits(previousValue), startIndex, index, value)); + } + + public static int receiveInteger(int previousValue, int startIndex, int index, int value) { + value &= 0xFFFF; + switch (index - startIndex) { + case 0 -> { + previousValue &= 0xFFFF_0000; + previousValue |= value; + } + case 1 -> { + previousValue &= 0x0000_FFFF; + previousValue |= value << 16; + } + } + return previousValue; + } +} -- cgit